100 subroutine mpr_sm(param, processMatrix, is_present, nHorizons, nTillHorizons, sand, clay, DbM, ID0, soilId0, LCover0, &
101 thetaS_till, thetaFC_till, thetaPW_till, thetaS, thetaFC, thetaPW, Ks, Db, KsVar_H0, KsVar_V0, SMs_FC0)
111 real(dp),
dimension(13),
intent(in) :: param
114 integer(i4),
dimension(:, :),
intent(in) :: processmatrix
118 integer(i4),
dimension(:),
intent(in) :: is_present
121 integer(i4),
dimension(:),
intent(in) :: nhorizons
124 integer(i4),
dimension(:),
intent(in) :: ntillhorizons
127 real(dp),
dimension(:, :),
intent(in) :: sand
130 real(dp),
dimension(:, :),
intent(in) :: clay
133 real(dp),
dimension(:, :),
intent(in) :: dbm
136 integer(i4),
dimension(:),
intent(in) :: id0
139 integer(i4),
dimension(:, :),
intent(in) :: soilid0
142 integer(i4),
dimension(:),
intent(in) :: lcover0
145 real(dp),
dimension(:, :, :),
intent(out) :: thetas_till
148 real(dp),
dimension(:, :, :),
intent(out) :: thetafc_till
151 real(dp),
dimension(:, :, :),
intent(out) :: thetapw_till
154 real(dp),
dimension(:, :),
intent(out) :: thetas
157 real(dp),
dimension(:, :),
intent(out) :: thetafc
160 real(dp),
dimension(:, :),
intent(out) :: thetapw
163 real(dp),
dimension(:, :, :),
intent(out) :: ks
166 real(dp),
dimension(:, :, :),
intent(out) :: db
169 real(dp),
dimension(:),
intent(out) :: ksvar_h0
172 real(dp),
dimension(:),
intent(out) :: ksvar_v0
176 real(dp),
dimension(:),
intent(out) :: sms_fc0
190 integer(i4) :: tmp_minsoilhorizon
200 real(dp) :: genu_mual_n
203 real(dp) :: genu_mual_alpha
205 real(dp) :: tmp_orgmattercontent_forest
207 real(dp) :: tmp_orgmattercontent_pervious
209 real(dp) :: tmp_orgmattercontent_impervious
212 real(dp),
dimension(:),
allocatable :: sms_tot0
215 integer(i4) :: max_lcover
218 real(dp),
dimension(:, :),
allocatable :: ks_non_till
222 select case (processmatrix(3, 1))
224 tmp_orgmattercontent_forest = param(3) + param(1)
226 tmp_orgmattercontent_forest = param(1)
229 tmp_orgmattercontent_impervious = param(2)
230 tmp_orgmattercontent_pervious = param(3)
235 tmp_minsoilhorizon = minval(ntillhorizons(:))
239 allocate(sms_tot0(
size(id0, 1)))
243 s =
size(is_present, 1)
246 allocate(ks_non_till(s, 1))
257 thetafc_till = 0.0_dp
258 thetapw_till = 0.0_dp
264 if(
allocated(ks_non_till)) ks_non_till = 0.0_dp
265 max_lcover = maxval(lcover0)
274 do i = 1,
size(is_present)
275 if (is_present(i) .lt. 1) cycle
276 horizon :
do j = 1, nhorizons(i)
278 call hydro_cond(ks_tmp, param(10 : 13), sand(i, j), clay(i, j))
282 if (j .le. ntillhorizons(i))
then
287 pom = tmp_orgmattercontent_forest
289 pom = tmp_orgmattercontent_impervious
291 pom = tmp_orgmattercontent_pervious
293 call error_message(
'Error mpr_sm: pOM used uninitialized.')
301 ks(i, j, l) = ks(i, j, l) * (dbm(i, j) / db(i, j, l))
303 call genuchten(thetas_till(i, j, l), genu_mual_n, genu_mual_alpha, &
304 param(4 : 9), sand(i, j), clay(i, j), db(i, j, l))
306 call field_cap(thetafc_till(i, j, l), ks(i, j, l), thetas_till(i, j, l), genu_mual_n)
308 call pwp(genu_mual_n, genu_mual_alpha, thetas_till(i, j, l), thetapw_till(i, j, l))
313 call genuchten(thetas(i, j - tmp_minsoilhorizon), genu_mual_n, genu_mual_alpha, &
314 param(4 : 9), sand(i, j), clay(i, j), dbm(i, j))
316 call field_cap(thetafc(i, j - tmp_minsoilhorizon), &
317 ks(i, j, 1), thetas(i, j - tmp_minsoilhorizon), genu_mual_n)
319 call pwp(genu_mual_n, genu_mual_alpha, thetas(i, j - tmp_minsoilhorizon), &
320 thetapw(i, j - tmp_minsoilhorizon))
328 cellloop :
do i = 1,
size(soilid0, 1)
330 do j = 1, nhorizons(s)
331 if (j .le. ntillhorizons(s))
then
333 ksvar_h0(i) = ksvar_h0(i) + thetas_till(s, j, lcover0(i)) * ks(s, j, lcover0(i))
334 ksvar_v0(i) = ksvar_v0(i) + thetas_till(s, j, lcover0(i)) / ks(s, j, lcover0(i))
335 sms_fc0(i) = sms_fc0(i) + thetafc_till(s, j, lcover0(i))
336 sms_tot0(i) = sms_tot0(i) + thetas_till(s, j, lcover0(i))
339 ksvar_h0(i) = ksvar_h0(i) + thetas(s, j - tmp_minsoilhorizon) * ks(s, j, 1)
340 ksvar_v0(i) = ksvar_v0(i) + thetas(s, j - tmp_minsoilhorizon) / ks(s, j, 1)
341 sms_fc0(i) = sms_fc0(i) + thetafc(s, j - tmp_minsoilhorizon)
342 sms_tot0(i) = sms_tot0(i) + thetas(s, j - tmp_minsoilhorizon)
352 sms_fc0(i) = (sms_tot0(i) - sms_fc0(i)) / sms_tot0(i)
355 ksvar_h0(i) = ksvar_h0(i) / sms_tot0(i) / param(13)
356 ksvar_v0(i) = sms_tot0(i) / ksvar_v0(i) / param(13)
363 do i = 1,
size(is_present)
364 if (is_present(i) .lt. 1) cycle
370 call hydro_cond(ks_tmp, param(10 : 13), sand(i, j), clay(i, j))
371 ks_non_till(i, j) = ks_tmp
378 pom = tmp_orgmattercontent_forest
380 pom = tmp_orgmattercontent_impervious
382 pom = tmp_orgmattercontent_pervious
384 call error_message(
'Error mpr_sm: pOM used is not initialized.')
392 ks_tmp = ks_tmp * (dbm(i, j) / db(i, j, l))
395 call genuchten(thetas_till(i, j, l), genu_mual_n, genu_mual_alpha, &
396 param(4 : 9), sand(i, j), clay(i, j), db(i, j, l))
398 call field_cap(thetafc_till(i, j, l), ks_tmp, thetas_till(i, j, l), genu_mual_n)
400 call pwp(genu_mual_n, genu_mual_alpha, thetas_till(i, j, l), thetapw_till(i, j, l))
406 ks_tmp = ks_non_till(i, j)
408 call genuchten(thetas(i, j), genu_mual_n, genu_mual_alpha, param(4 : 9), sand(i, j), clay(i, j), dbm(i, j))
410 call field_cap(thetafc(i, j), ks_tmp, thetas(i, j), genu_mual_n)
412 call pwp(genu_mual_n, genu_mual_alpha, thetas(i, j), thetapw(i, j))
418 do i = 1,
size(soilid0, 1)
419 do j = 1,
size(soilid0, 2)
421 if (j .le. ntillhorizons(1))
then
423 ksvar_h0(i) = ksvar_h0(i) + thetas_till(s, 1, lcover0(i)) * ks(s, 1, lcover0(i))
424 ksvar_v0(i) = ksvar_v0(i) + thetas_till(s, 1, lcover0(i)) / ks(s, 1, lcover0(i))
425 sms_fc0(i) = sms_fc0(i) + thetafc_till(s, 1, lcover0(i))
426 sms_tot0(i) = sms_tot0(i) + thetas_till(s, 1, lcover0(i))
429 ksvar_h0(i) = ksvar_h0(i) + thetas(s, 1) * ks_non_till(s, 1)
430 ksvar_v0(i) = ksvar_v0(i) + thetas(s, 1) / ks_non_till(s, 1)
431 sms_fc0(i) = sms_fc0(i) + thetafc(s, 1)
432 sms_tot0(i) = sms_tot0(i) + thetas(s, 1)
440 sms_fc0(i) = (sms_tot0(i) - sms_fc0(i)) / sms_tot0(i)
443 ksvar_h0(i) = ksvar_h0(i) / sms_tot0(i) / param(13)
444 ksvar_v0(i) = sms_tot0(i) / ksvar_v0(i) / param(13)
448 call error_message(
'***ERROR: iFlag_soilDB option given does not exist. Only 0 and 1 is taken at the moment.')
453 if(
allocated(ks_non_till))
deallocate(ks_non_till)