SURFEX v8.1
General documentation of Surfex
hydro_soildif.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! #########
6  SUBROUTINE hydro_soildif(IO, KK, PK, PEK, PTSTEP, PPG, PLETR, PLEG, PEVAPCOR, &
7  PF2WGHT, PPS, PQSAT, PQSATI, PDRAIN, PHORTON, KMAX_LAYER, PQSB)
8 ! ##########################################################################
9 !
10 !
11 !!**** *HYDRO_SOILDIF*
12 !
13 !! PURPOSE
14 !! -------
15 ! This subroutine solves the 1-D (z) mass conservation equation
16 ! (mixed-form Richard's equation: tendency in terms of volumetric
17 ! water content, gradient in terms of matric potential)
18 ! for liquid water (using Darcy's Law for the vertical flux)
19 ! together with the Clapp and Hornberger (1978) simplification to
20 ! the Brooks and Corey (1966) empirical model for relating matric
21 ! potential and hydraulic conductivity to soil water content.
22 ! Any set of parameters can be used (eg. Clapp and Hornberger 1978;
23 ! Cosby et al. 1984; etc.) Modifications to the equations is also
24 ! made for the Van Genucten model/relationships. The equations
25 ! also incorporate vapor transfer for dry soils. The soil porosity
26 ! is modified in the presence of soil ice. Soil ice content
27 ! is also updated herein due to changes resulting from sublimation.
28 ! The layer averaged set of equations are time differenced
29 ! using an implicit time scheme.
30 ! The equations/model *assume* a heterogeneous soil texture profile,
31 ! however, if the soil properties are homogeneous, the equations
32 ! collapse into the standard homogeneous approach (i.e. give the
33 ! same results as). The eqs are solved rapidly by taking advantage of the
34 ! fact that the matrix is tridiagonal.
35 ! Note that the exponential profile of hydraulic conductivity with soil
36 ! depth is applied to interfacial conductivity (or interblock)
37 !
38 !
39 !!** METHOD
40 !! ------
41 !
42 ! Direct calculation
43 !
44 !! EXTERNAL
45 !! --------
46 !
47 ! None
48 !!
49 !! IMPLICIT ARGUMENTS
50 !! ------------------
51 !!
52 !! USE MODD_CST
53 !! USE MODI_TRIDIAG_GROUND
54 !!
55 !! REFERENCE
56 !! ---------
57 !!
58 !! Boone (2000)
59 !! Boone et al. (2000)
60 !!
61 !! AUTHOR
62 !! ------
63 !! A. Boone * Meteo-France *
64 !!
65 !! MODIFICATIONS
66 !! -------------
67 !! Original 16/02/00 Boone
68 !! Modif 04/2010 B.Decharme: geometric mean for interfacial conductivity
69 !! Brook and Corey
70 !! Modif 08/2011 B.Decharme: Optimization using global loops
71 !! 10/12 B.Decharme: EVAPCOR snow correction in DIF
72 !! 04/13 B.Decharme: Subsurface runoff if SGH (DIF option only)
73 !! 07/2013 B.Decharme: Surface / Water table depth coupling
74 !! 01/2016 B.Decharme: Bug : if no surface runoff (HRUNOFF=WSAT) then no Horton
75 !-------------------------------------------------------------------------------
76 !
77 !* 0. DECLARATIONS
78 ! ------------
79 !
82 !
83 USE modd_surf_par, ONLY : xundef, nundef
84 USE modd_csts, ONLY : xrholw
85 USE modd_isba_par, ONLY : xwgmin
86 !
88 !
89 USE yomhook ,ONLY : lhook, dr_hook
90 USE parkind1 ,ONLY : jprb
91 !
92 IMPLICIT NONE
93 !
94 TYPE(isba_options_t), INTENT(INOUT) :: IO
95 TYPE(isba_k_t), INTENT(INOUT) :: KK
96 TYPE(isba_p_t), INTENT(INOUT) :: PK
97 TYPE(isba_pe_t), INTENT(INOUT) :: PEK
98 !
99 REAL, INTENT(IN) :: PTSTEP ! Model time step (s)
100 !
101 REAL, DIMENSION(:), INTENT(IN) :: PPS, PPG, PLETR, PLEG, PEVAPCOR
102 ! PPS = surface pressure (Pa)
103 ! PPG = throughfall rate:
104 ! rate at which water reaches the surface
105 ! of the soil (from snowmelt, rain, canopy
106 ! drip, etc...) (m/s)
107 ! PLETR = transpiration rate (m/s)
108 ! PLEG = bare-soil evaporation rate (m/s)
109 ! PEVAPCOR = correction for any excess evaporation
110 ! from snow as it completely ablates (m/s)
111 !
112 REAL, DIMENSION(:,:), INTENT(IN) :: PQSAT,PQSATI
113 ! specific humidity at saturation
114 !
115 REAL, DIMENSION(:,:), INTENT(IN) :: PF2WGHT
116 ! PF2WGHT = root-zone transpiration weights (-)
117 !
118 INTEGER, INTENT(IN) :: KMAX_LAYER
119 ! KMAX_LAYER = Max number of soil moisture layers (DIF option)
120 !
121 REAL, DIMENSION(:), INTENT(OUT) :: PDRAIN, PHORTON
122 ! PDRAIN = drainage (flux out of model base) (kg m-2 s-1)
123 !
124 REAL, DIMENSION(:), INTENT(OUT) :: PQSB !Lateral subsurface flow [kg/m²/s]
125 !
126 !
127 !* 0.2 declarations of local variables
128 !
129 INTEGER :: JJ, JL ! loop control
130 !
131 INTEGER :: INJ, INL, IDEPTH ! Number of point and grid layers
132 !
133 REAL, DIMENSION(SIZE(PK%XDZG,1)) :: ZINFILTC, ZEXCESS, ZDGN, ZWGTOT, ZPSIWTD, ZWTD
134 ! ZEXCESS = working variable: excess soil water
135 ! which is used as a constraint
136 ! ZDGN = Depth of the last node (m)
137 ! and the water table (m s-1)
138 ! ZWGTOT = total soil moisture for ZINFNEG computation
139 ! ZPSIWTD = matric potential at saturation for water table depth coupling
140 ! ZWTD = water table depth positive below soil surface (m)
141 !
142 REAL, DIMENSION(SIZE(PK%XDZG,1),SIZE(PK%XDZG,2)) :: ZWFLUX, ZDFLUXDT1, ZDFLUXDT2, ZWFLUXN
143 ! ZWFLUX = vertical soil water flux (+ up) (m s-1)
144 ! ZDFLUXDT = total vertical flux derrivative
145 ! ZDFLUXDT1 = vertical flux derrivative: dF_j/dw_j
146 ! ZDFLUXDT2 = vertical flux derrivative: dF_j/dw_j+1
147 ! ZWFLUXN = vertical soil water flux at end of time
148 
149 REAL, DIMENSION(SIZE(PK%XDZG,1),SIZE(PK%XDZG,2)) :: ZPSI, ZK, ZNU, ZWSAT, ZHEAD, &
150  ZVAPCOND, ZFRZ, ZKI, ZCAPACITY, ZINFNEG
151 ! ZNU = interfacial total conductivity (m s-1)
152 ! at level z_j
153 ! ZK = hydraulic conductivity (m s-1)
154 ! ZHEAD = matric potential gradient (-)
155 ! ZWSAT = ice modified soil porosity (m3 m-3)
156 ! ZFRZ = diffusion coefficient for freezing (-)
157 ! ZVAPCOND = vapor conductivity (m s-1)
158 ! ZKI = interfacial hydraulic conductivity (m s-1) at level z_j
159 ! ZCAPACITY = simple volumetric water holding capacity estimate for
160 ! wetting front penetration (-)
161 ! ZINFNEG = Negative infiltration (m s-1)
162 !
163 REAL, DIMENSION(SIZE(PK%XDZG,1),SIZE(PK%XDZG,2)) :: ZAMTRX, ZBMTRX, ZCMTRX, ZFRC, ZSOL, &
164  ZTOPQS
165 ! ZAMTRX = leftmost diagonal element of tri-diagonal
166 ! coefficient matrix
167 ! ZBMTRX = center diagonal element (vector)
168 ! ZCMTRX = rightmost diagonal element (vector)
169 ! ZFRC = forcing function (vector)
170 ! ZSOL = solution vector
171 !
172 REAL, DIMENSION(SIZE(PK%XDZG,1),SIZE(PK%XDZG,2)) :: ZINFLAYER
173 !
174 REAL, PARAMETER :: ZWGHT = 0.5 ! time scheme weight for calculating flux.
175 ! varies from 0 (explicit time scheme)
176 ! to 1 (backward difference implicit)
177 ! Default is 1/2 (Crank-Nicholson)
178 !
179 REAL, PARAMETER :: ZEICE = 6.0 ! Ice vertical diffusion impedence factor
180 !
181 REAL :: ZLOG10, ZS, ZLOG, ZWDRAIN
182 !
183 REAL :: ZDKDT1, ZDKDT2, ZDHEADDT1, ZDHEADDT2
184 ! ZDKDT1 = hydraulic conductivity derrivative w/r/t upper layer water content
185 ! ZDKDT2 = "" lower layer water content
186 ! ZDHEADDT1 = matric potential gradient derrivative w/r/t upper layer water content
187 ! ZDHEADDT2 = "" lower layer water content
188 !
189 REAL(KIND=JPRB) :: ZHOOK_HANDLE
190 !
191 !-------------------------------------------------------------------------------
192 !
193 ! 0. Initialization:
194 ! ---------------
195 !
196 IF (lhook) CALL dr_hook('HYDRO_SOILDIF',0,zhook_handle)
197 !
198 inj = SIZE(pk%XDZG,1)
199 inl = kmax_layer
200 !
201 zlog10 = log(10.0)
202 !
203 pdrain(:) = 0.0
204 pqsb(:) = 0.0
205 phorton(:) = 0.0
206 zinfiltc(:) = 0.0
207 zexcess(:) = 0.0
208 !
209 zdgn(:) = xundef
210 zpsiwtd(:) = xundef
211 zwtd(:) = xundef
212 !
213 zinfneg(:,:) = 0.0
214 zinflayer(:,:) = 0.0
215 zfrc(:,:) = 0.0
216 zfrz(:,:) = 0.0
217 !
218 zwsat(:,:) = xundef
219 zcapacity(:,:) = xundef
220 zpsi(:,:) = xundef
221 zk(:,:) = xundef
222 zvapcond(:,:) = xundef
223 zki(:,:) = xundef
224 zsol(:,:) = xundef
225 znu(:,:) = xundef
226 zhead(:,:) = xundef
227 zwflux(:,:) = xundef
228 zwfluxn(:,:) = xundef
229 zdfluxdt1(:,:) = xundef
230 zdfluxdt2(:,:) = xundef
231 zamtrx(:,:) = xundef
232 zbmtrx(:,:) = xundef
233 zcmtrx(:,:) = xundef
234 !
235 ! Modification/addition of frozen soil parameters
236 ! -----------------------------------------------
237 !
238 DO jl=1,inl
239  DO jj=1,inj
240 !
241  idepth=pk%NWG_LAYER(jj)
242  IF(jl<=idepth)THEN
243 !
244 ! Modify soil porosity as ice assumed to become part
245 ! of solid soil matrix (with respect to liquid flow):
246  zwsat(jj,jl) = max(xwgmin, kk%XWSAT(jj,jl)-pek%XWGI(jj,jl))
247 !
248 ! Factor from (Johnsson and Lundin 1991), except here it is normalized so that it
249 ! goes to zero in the limit as all available pore space is filled up with ice.
250 ! For now, a simple constant is used for all soils. Further modifications
251 ! will be made as research warrents.
252 ! Old : 10.**(-ZEICE*(PEK%XWGI(JJ,JL)/(PEK%XWGI(JJ,JL)+PEK%XWG(JJ,JL))))
253  zfrz(jj,jl) = exp(zlog10*(-zeice*(pek%XWGI(jj,jl)/(pek%XWGI(jj,jl)+pek%XWG(jj,jl)))))
254 !
255  ENDIF
256 !
257  ENDDO
258 ENDDO
259 !
260 ! Lateral sub-surface flow (m s-1) if Topmodel
261 ! --------------------------------------------
262 !
263 IF(io%CRUNOFF=='SGH')THEN
264  ztopqs(:,:)=zfrz(:,:)*pk%XTOPQS(:,:)
265 ELSE
266  ztopqs(:,:)=0.0
267 ENDIF
268 !
269 ! 1. Infiltration at "t"
270 ! -------------------
271 !
272 ! Surface flux term (m s-1): Infiltration (and surface runoff)
273 ! Surface fluxes are limited a Green-Ampt approximation from Abramopoulos et al
274 ! (1988) and Entekhabi and Eagleson (1989).
275 ! Note : when Horton option is used, infiltration already calculated in hydro_sgh
276 !
277 !Surface cumulative infiltration (m)
278 zinfiltc(:) = max(0.0,ppg(:))*ptstep
279 
280 !
281 ! 2. Initialise soil moisture profile according to infiltration terms at "t"
282 ! ----------------------------------------------------------------------
283 !
284 DO jl=1,inl
285  DO jj=1,inj
286  idepth=pk%NWG_LAYER(jj)
287  IF(jl<=idepth)THEN
288 ! Simple volumetric water holding capacity estimate for wetting front penetration
289  zcapacity(jj,jl) = max(0.0,zwsat(jj,jl)-pek%XWG(jj,jl))*pk%XDZG(jj,jl)
290 ! Infiltration terms (m) :
291  zinflayer(jj,jl) = min(zinfiltc(jj),zcapacity(jj,jl))
292 ! Soil moisture (m3/m3) :
293  pek%XWG(jj,jl) = pek%XWG(jj,jl)+zinflayer(jj,jl)/pk%XDZG(jj,jl)
294 ! Put remainding infiltration into the next layer (m)
295  zinfiltc(jj) = zinfiltc(jj) - zinflayer(jj,jl)
296  ENDIF
297  ENDDO
298 ENDDO
299 !
300 ! 3. Compute Fast(temporal)-response runoff and Possible negative infiltration
301 ! -------------------------------------------------------------------------
302 !
303 !Possible negative infiltration (m s-1)
304 zwgtot(:)=0.0
305 DO jl=1,inl
306  DO jj=1,inj
307  idepth=pk%NWG_LAYER(jj)
308  IF(jl<idepth)THEN
309  zinfneg(jj,jl) = (min(0.0,ppg(jj))-pevapcor(jj))*pk%XDZG(jj,jl)*pek%XWG(jj,jl)
310  zwgtot(jj ) = zwgtot(jj)+pk%XDZG(jj,jl)*pek%XWG(jj,jl)
311  ENDIF
312  ENDDO
313 ENDDO
314 DO jl=1,inl
315  DO jj=1,inj
316  zinfneg(jj,jl) = zinfneg(jj,jl)/zwgtot(jj)
317  ENDDO
318 ENDDO
319 !
320 !Fast(temporal)-response runoff (surface excess) (kg m2 s-1):
321 !special case : if infiltration > total soil capacity
322 phorton(:)=(phorton(:)+zinfiltc(:)/ptstep)*xrholw
323 !
324 !
325 ! 4. Initialise matric potential and hydraulic conductivity at "t"
326 ! -------------------------------------------------------------
327 !
328 DO jl=1,inl
329  DO jj=1,inj
330  idepth=pk%NWG_LAYER(jj)
331  IF(jl<=idepth)THEN
332 ! Matric potential (m) :
333 ! psi=mpotsat*(w/wsat)**(-bcoef)
334  zs = min(1.0,pek%XWG(jj,jl)/zwsat(jj,jl))
335  zlog = kk%XBCOEF(jj,jl)*log(zs)
336  zpsi(jj,jl) = kk%XMPOTSAT(jj,jl)*exp(-zlog)
337 ! Hydraulic conductivity from matric potential (m s-1):
338 ! k=frz*condsat*(psi/mpotsat)**(-2-3/bcoef)
339  zlog = -zlog*(2.0+3.0/kk%XBCOEF(jj,jl))
340  zk(jj,jl) = zfrz(jj,jl)*pk%XCONDSAT(jj,jl)*exp(-zlog)
341  ENDIF
342  ENDDO
343 ENDDO
344 !
345 ! Prepare water table depth coupling
346 ! ----------------------------------
347 !
348 DO jj=1,inj
349  idepth=pk%NWG_LAYER(jj)
350 ! Depth of the last node
351  zdgn(jj) = 0.5*(pk%XDG(jj,idepth)+pk%XDG(jj,idepth-1))
352  zpsiwtd(jj) = zpsi(jj,idepth)
353  IF(kk%XWTD(jj)/=xundef)THEN
354 ! Water table depth
355  zwtd(jj) = max(pk%XDG(jj,idepth),-kk%XWTD(jj))
356 ! Modify matric potential at saturation for water table coupling
357  zs = min(1.0,zwsat(jj,idepth)/kk%XWSAT(jj,idepth))
358  zlog = kk%XBCOEF(jj,idepth)*log(zs)
359  zpsiwtd(jj) = kk%XMPOTSAT(jj,idepth)*exp(-zlog)
360  ENDIF
361 ENDDO
362 !
363 ! 5. Vapor diffusion conductivity (m s-1)
364 ! ------------------------------------
365 !
366 zvapcond(:,:) = vapcondcf(pek%XTG, pps, pek%XWG, pek%XWGI, zpsi,&
367  kk%XWSAT, kk%XWFC, pqsat, pqsati, pk%NWG_LAYER, inl)
368 zvapcond(:,:) = zfrz(:,:)*zvapcond(:,:)
369 !
370 ! 6. Linearized water flux: values at "t"
371 ! ------------------------------------
372 ! calculate flux at the beginning of the time step:
373 !
374 DO jl=1,inl
375  DO jj=1,inj
376 !
377  idepth=pk%NWG_LAYER(jj)
378  IF(jl<idepth)THEN
379 !
380 ! Total interfacial conductivity (m s-1) And Potential gradient (dimensionless):
381  zki(jj,jl) = sqrt(zk(jj,jl)*zk(jj,jl+1))
382  znu(jj,jl) = zki(jj,jl) + sqrt(zvapcond(jj,jl)*zvapcond(jj,jl+1))
383  zhead(jj,jl) = (zpsi(jj,jl)-zpsi(jj,jl+1))/pk%XDZDIF(jj,jl)
384 !
385 ! Total Sub-surface soil water fluxes (m s-1): (+ up, - down) using Darcy's
386 ! Law with an added linear drainage term:
387  zwflux(jj,jl) = -znu(jj,jl) * zhead(jj,jl) - zki(jj,jl)
388 !
389  ELSEIF(jl==idepth)THEN !Last layers
390 !
391 ! Total interfacial conductivity (m s-1) And Potential gradient (dimensionless):
392  zki(jj,idepth) = zk(jj,idepth)
393  znu(jj,idepth) = zk(jj,idepth) * kk%XFWTD(jj)
394  zhead(jj,idepth) = (zpsi(jj,idepth)-zpsiwtd(jj))/(zwtd(jj)-zdgn(jj))
395 !
396 ! Total Sub-surface soil water fluxes (m s-1): (+ up, - down) using Darcy's
397 ! Law with an added linear drainage term:
398  zwflux(jj,idepth) = -znu(jj,idepth) * zhead(jj,idepth) - zki(jj,idepth)
399 !
400  ENDIF
401 !
402  ENDDO
403 ENDDO
404 !
405 !
406 ! 7. Linearized water flux: values at "t+dt"
407 ! ---------------------------------------
408 ! Flux Derrivative terms, see A. Boone thesis (Annexe E).
409 !
410 DO jl=1,inl
411  DO jj=1,inj
412  idepth=pk%NWG_LAYER(jj)
413  IF(jl<idepth)THEN
414  zdheaddt1 = -kk%XBCOEF(jj,jl )*zpsi(jj,jl )/(pek%XWG(jj,jl )*pk%XDZDIF(jj,jl))
415  zdheaddt2 = -kk%XBCOEF(jj,jl+1)*zpsi(jj,jl+1)/(pek%XWG(jj,jl+1)*pk%XDZDIF(jj,jl))
416  zdkdt1 = (2.*kk%XBCOEF(jj,jl )+3.)*zki(jj,jl)/(2.0*pek%XWG(jj,jl ))
417  zdkdt2 = (2.*kk%XBCOEF(jj,jl+1)+3.)*zki(jj,jl)/(2.0*pek%XWG(jj,jl+1))
418 ! Total Flux derrivative terms:
419  zdfluxdt1(jj,jl) = -zdkdt1*zhead(jj,jl) - znu(jj,jl)*zdheaddt1 - zdkdt1
420  zdfluxdt2(jj,jl) = -zdkdt2*zhead(jj,jl) + znu(jj,jl)*zdheaddt2 - zdkdt2
421  ELSEIF(jl==idepth)THEN !Last layers
422  zdheaddt1 = -kk%XBCOEF(jj,idepth)*zpsi(jj,idepth)/(pek%XWG (jj,idepth)*(zwtd(jj)-zdgn(jj))) &
423  +kk%XBCOEF(jj,idepth)*zpsiwtd(jj )/(zwsat(jj,idepth) *(zwtd(jj)-zdgn(jj)))
424  zdheaddt2 = 0.0
425  zdkdt1 = (2.*kk%XBCOEF(jj,idepth)+3.)*zk(jj,idepth)/pek%XWG(jj,idepth)
426  zdkdt2 = 0.0
427 ! Total Flux derrivative terms:
428  zdfluxdt1(jj,idepth) = -zdkdt1*zhead(jj,idepth)*kk%XFWTD(jj) - znu(jj,idepth)*zdheaddt1 - zdkdt1
429  zdfluxdt2(jj,idepth) = -zdkdt2*zhead(jj,idepth)*kk%XFWTD(jj) + znu(jj,idepth)*zdheaddt2 - zdkdt2
430  ENDIF
431  ENDDO
432 ENDDO
433 !
434 ! 8. Jacobian Matrix coefficients and Forcing function
435 ! -------------------------------------------------
436 !
437 !surface layer:
438 zfrc(:,1) = zwflux(:,1) - pleg(:) - pf2wght(:,1)*pletr(:) + zinfneg(:,1) - ztopqs(:,1)
439 zamtrx(:,1) = 0.0
440 zbmtrx(:,1) = (pk%XDZG(:,1)/ptstep) - zwght*zdfluxdt1(:,1)
441 zcmtrx(:,1) = -zwght*zdfluxdt2(:,1)
442 !
443 !Other sub-surface layers:
444 DO jl=2,inl
445  DO jj=1,inj
446  idepth=pk%NWG_LAYER(jj)
447  IF(jl<=idepth)THEN
448  zfrc(jj,jl) = zwflux(jj,jl) - zwflux(jj,jl-1) - pf2wght(jj,jl)*pletr(jj) + zinfneg(jj,jl) - ztopqs(jj,jl)
449  zamtrx(jj,jl) = zwght*zdfluxdt1(jj,jl-1)
450  zbmtrx(jj,jl) = (pk%XDZG(jj,jl)/ptstep) - zwght*(zdfluxdt1(jj,jl)-zdfluxdt2(jj,jl-1))
451  zcmtrx(jj,jl) = -zwght*zdfluxdt2(jj,jl)
452  ENDIF
453  ENDDO
454 ENDDO
455 !
456 !Solve Matrix Equation: tridiagonal system: solve for soil
457 !water (volumetric water content) tendencies:
458 !
459  CALL tridiag_dif(zamtrx,zbmtrx,zcmtrx,zfrc,pk%NWG_LAYER(:),inl,zsol)
460 !
461 ! 9. Final calculations and diagnostics:
462 ! -----------------------------------
463 !
464 !
465 DO jl=1,inl
466  DO jj=1,inj
467 !
468  idepth=pk%NWG_LAYER(jj)
469  IF(jl<idepth)THEN
470 !
471 ! Update liquid water content (m3 m-3):
472  pek%XWG(jj,jl) = pek%XWG(jj,jl) + zsol(jj,jl)
473 !
474 ! Supersaturated drainage (kg m-2 s-1):
475  zexcess(jj) = max(0.0, pek%XWG(jj,jl) - zwsat(jj,jl))
476  pek%XWG(jj,jl ) = min(pek%XWG(jj,jl),zwsat(jj,jl))
477  pek%XWG(jj,jl+1) = pek%XWG(jj,jl+1) + zexcess(jj)*(pk%XDZG(jj,jl)/pk%XDZG(jj,jl+1))
478 !
479 ! final fluxes (at end of time step) (m s-1):
480  zwfluxn(jj,jl) = zwflux(jj,jl) + zdfluxdt1(jj,jl)*zsol(jj,jl) + zdfluxdt2(jj,jl)*zsol(jj,jl+1)
481 !
482 ! Total topmodel subsurface flow
483  pqsb(jj) = pqsb(jj) + ztopqs(jj,jl)*xrholw
484 !
485  ELSEIF(jl==idepth)THEN
486 !
487 ! Update liquid water content (m3 m-3):
488  pek%XWG(jj,idepth) = pek%XWG(jj,idepth) + zsol(jj,idepth)
489 !
490 ! Supersaturated drainage (kg m-2 s-1):
491  zexcess(jj) = max(0.0, pek%XWG(jj,idepth) - zwsat(jj,idepth))
492  pek%XWG(jj,idepth) = min(pek%XWG(jj,idepth),zwsat(jj,idepth))
493  pdrain(jj) = pdrain(jj) + zexcess(jj)*pk%XDZG(jj,idepth)*xrholw/ptstep
494 !
495 ! final fluxes (at end of time step) (m s-1):
496  zwfluxn(jj,idepth) = zwflux(jj,idepth) + zdfluxdt1(jj,idepth)*zsol(jj,idepth)
497 !
498 ! Drainage or baseflow out of bottom of model (slow time response) (kg m-2 s-1):
499 ! Final fluxes (if needed) over the time step (kg m-2 s-1)
500 ! would be calculated as (for water budget checks) as F = [ wgt*F(t+dt) + (1.-wgt)*F(t) ]*XRHOLW
501  pdrain(jj) = pdrain(jj)-(zwght*zwfluxn(jj,idepth)+(1.-zwght)*zwflux(jj,idepth))*xrholw
502 !
503 ! Total topmodel subsurface flow
504  pqsb(jj) = pqsb(jj) + ztopqs(jj,idepth)*xrholw
505 !
506  ENDIF
507 !
508  ENDDO
509 ENDDO
510 !
511 ! Possible correction/Constraint application:
512 !
513 DO jl=1,inl
514  DO jj=1,inj
515  idepth=pk%NWG_LAYER(jj)
516  IF(jl<idepth)THEN
517 ! if the soil water happens to fall below the minimum, then
518 ! extract needed water from the layer below: this should
519 ! generally be non-existant: but added to ensure conservation
520 ! even for the most extreme events.
521  zexcess(jj) = max(0., xwgmin - pek%XWG(jj,jl))
522  pek%XWG(jj,jl) = pek%XWG(jj,jl) + zexcess(jj)
523  pek%XWG(jj,jl+1) = pek%XWG(jj,jl+1) - zexcess(jj)*pk%XDZG(jj,jl)/pk%XDZG(jj,jl+1)
524  ELSEIF(jl==idepth.AND.pek%XWG(jj,idepth)<xwgmin)THEN
525 ! NOTE, negative moisture can arise for *completely* dry/dessicated soils
526 ! owing to the above check because vertical fluxes
527 ! can be *very* small but nonzero. Here correct owing to
528 ! small numerical drainage.
529  pdrain(jj) = pdrain(jj) + min(0.0,pek%XWG(jj,idepth)-xwgmin)*pk%XDZG(jj,idepth)*xrholw/ptstep
530  pek%XWG(jj,idepth) = xwgmin
531  ENDIF
532  ENDDO
533 ENDDO
534 !
535 IF (lhook) CALL dr_hook('HYDRO_SOILDIF',1,zhook_handle)
536 !
537 END SUBROUTINE hydro_soildif
538 
539 
540 
541 
542 
543 
subroutine hydro_soildif(IO, KK, PK, PEK, PTSTEP, PPG, PLETR, PLEG
real, parameter xundef
integer, parameter jprb
Definition: parkind1.F90:32
integer, parameter nundef
logical lhook
Definition: yomhook.F90:15
real, save xrholw
Definition: modd_csts.F90:64