SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
e_budget_meb.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 e_budget_meb(HISBA,HCPSURF,PTSTEP, &
7  pps,pcg,pct,pcv,pwrvn,pwr, &
8  ptdeep_a,ptdeep_b,pd_g,psoilcondz,psoilhcapz, &
9  psnowdz,psnowcondz,psnowhcapz, &
10  pswnet_v,pswnet_g,pswnet_n,ptau_n, &
11  plwnet_v,plwnet_g,plwnet_n, &
12  plwnet_v_dtv,plwnet_v_dtg,plwnet_v_dtn, &
13  plwnet_g_dtv,plwnet_g_dtg,plwnet_g_dtn, &
14  plwnet_n_dtv,plwnet_n_dtg,plwnet_n_dtn, &
15  ppew_a_coef,ppew_b_coef,ppet_a_coef,ppeq_a_coef,ppet_b_coef,ppeq_b_coef, &
16  pthrma_ta,pthrmb_ta,pthrma_tc,pthrmb_tc, &
17  pthrma_tg,pthrmb_tg,pthrma_tv,pthrmb_tv,pthrma_tn,pthrmb_tn, &
18  pqsat_g,pqsat_v,pqsati_n, &
19  pff,pffrozen,ppsn,ppsna,ppsncv, &
20  pcheatv,pcheatg,pcheatn, &
21  pleg_delta,plegi_delta,phug,phugi,phvg,phvn,pfrozen1, &
22  pflxc_c_a,pflxc_g_c,pflxc_vg_c,pflxc_vn_c,pflxc_n_c,pflxc_n_a, &
23  pflxc_mom, &
24  ptg,ptv,ptn, &
25  pflxc_v_c,phvgs,phvns, &
26  pdqsat_g,pdqsat_v,pdqsati_n, &
27  ptc,pqc,pta_ic,pqa_ic,pustar2_ic,pvmod, &
28  pdeltat_g,pdeltat_v,pdeltat_n,pgrndflux,pcps,plvtt,plstt, &
29  phpsnow,pmeltadv,prestore,pdeep_flux, &
30  pdelheatv_sfc,pdelheatg_sfc,pdelheatg )
31 ! ##########################################################################
32 !
33 !!**** *E_BUDGET*
34 !!
35 !! PURPOSE
36 !! -------
37 !
38 ! Calculates the implicit simulataneous solution of multiple surface
39 ! energy budgets (understory vegetation-soil composite, vegetation canopy
40 ! and explicit snowpack) and sub-surface soil temperatures. Canopy
41 ! air space temperature and specific humidities are also diagnosed.
42 ! Fully implicit coupling with the atmosphere allowed.
43 ! Note that a 'test' snow temperature is computed herein which is just
44 ! use to compute the surface fluxes. These fluxes are then used within
45 ! the snow scheme as an upper boundary condition to compute the snow
46 ! temperatures. In theory, they should be very close, but this method is
47 ! done to ensure a high level of energy conservation.
48 !
49 !
50 !!** METHOD
51 !! ------
52 !
53 ! 1- compute coefficients for each energy budget
54 ! 2- solve the equations for snow, vegetation canopy and soil-understory
55 ! vegetation composite
56 ! 3- solve soil T profile
57 ! 4- diagnose canopy air space variables, and lowest level atmospheric
58 ! state variable values at t+dt
59 !
60 !! EXTERNAL
61 !! --------
62 !!
63 !! none
64 !!
65 !! IMPLICIT ARGUMENTS
66 !! ------------------
67 !!
68 !!
69 !!
70 !! REFERENCE
71 !! ---------
72 !!
73 !! Noilhan and Planton (1989)
74 !! Belair (1995)
75 !! * to be done * (2011)
76 !!
77 !! AUTHOR
78 !! ------
79 !!
80 !! A. Boone * CNRM-GAME, Meteo-France *
81 !! P. Samuelsson * SMHI *
82 !! S. Gollvik * SMHI *
83 !!
84 !! MODIFICATIONS
85 !! -------------
86 !! Original 22/01/11
87 !! 10/10/14 (A. Boone) Removed understory vegetation
88 !!
89 !-------------------------------------------------------------------------------
90 !
91 !* 0. DECLARATIONS
92 ! ------------
93 !
94 USE modd_csts, ONLY : xlvtt, xlstt, xtt, xcpd, xcpv, xcl, &
95  xday, xpi
96 USE modd_surf_atm, ONLY : lcpl_arp
97 USE modd_surf_par, ONLY : xundef
98 USE modd_snow_metamo, ONLY : xsnowdzmin
99 !
100 USE mode_thermos
101 USE mode_meb, ONLY : sfc_heatcap_veg
102 !
103 USE modi_tridiag_ground_rm_coefs
104 USE modi_tridiag_ground_rm_soln
105 !
106 USE yomhook ,ONLY : lhook, dr_hook
107 USE parkind1 ,ONLY : jprb
108 !
109 IMPLICIT NONE
110 !
111 !* 0.1 declarations of arguments
112 !
113  CHARACTER(LEN=*), INTENT(IN) :: hisba ! type of ISBA version:
114 ! ! '2-L' (default)
115 ! ! '3-L'
116 ! ! 'DIF'
117 !
118  CHARACTER(LEN=*), INTENT(IN) :: hcpsurf ! Specific heat
119 ! ! 'DRY' = dry Cp
120 ! ! 'HUM' = humid Cp fct of qc for MEB
121 !
122 REAL, INTENT(IN) :: ptstep
123 ! PTSTEP = timestep of the integration (s)
124 !
125 REAL, DIMENSION(:), INTENT(IN) :: pct, pcv, pwrvn, pwr, pcg
126 ! PCG = area-averaged soil heat capacity (m2 K J-1)
127 ! PCT = surface understory or composite thermal inertia (m2 K J-1)
128 ! PCV = vegetation canopy thermal inertia (m2 K J-1)
129 ! PWRVN = liquid water equivalent snow intercepted on the canopy (kg m-2)
130 ! PWR = liquid water intercepted on the canopy (kg m-2)
131 !
132 REAL, DIMENSION(:), INTENT(IN) :: ptdeep_a, ptdeep_b
133 ! PTDEEP_A = Deep soil temperature
134 ! coefficient depending on flux
135 ! PTDEEP_B = Deep soil temperature (prescribed)
136 ! which models heating/cooling from
137 ! below the diurnal wave penetration
138 ! (surface temperature) depth. If it
139 ! is FLAGGED as undefined, then the zero
140 ! flux lower BC is applied.
141 ! Tdeep = PTDEEP_B + PTDEEP_A * PDEEP_FLUX
142 ! (with PDEEP_FLUX in W/m2)
143 !
144 REAL, DIMENSION(:), INTENT(IN) :: pps
145 ! PPS = surface pressure (Pa)
146 !
147 REAL, DIMENSION(:,:), INTENT(IN) :: pd_g, psoilcondz, psoilhcapz
148 ! PD_G = soil layer depth (m)
149 ! PSOILCONDZ = soil thermal conductivity (W m-1 K-1)
150 ! PSOILHCAPZ = soil heat capacity (J m-3 K-1)
151 !
152 REAL, DIMENSION(:,:), INTENT(IN) :: psnowdz, psnowcondz, psnowhcapz
153 ! PSNOWDZ = snow layer thickness (m)
154 ! PSNOWCONDZ = snow thermal conductivity (W m-1 K-1)
155 ! PSNOWHCAPZ = snow heat capacity (J m-3 K-1)
156 !
157 REAL, DIMENSION(:), INTENT(IN) :: pswnet_v, pswnet_g, pswnet_n
158 ! PSWNET_G = Understory-ground net SW radiation explicit term (W m-2)
159 ! PSWNET_V = Vegetation canopy net SW radiation explicit term (W m-2)
160 ! PSWNET_N = Ground-based snow net SW radiation explicit term (W m-2)
161 !
162 REAL, DIMENSION(:,:), INTENT(IN) :: ptau_n
163 ! PTAU_N = shortwave radiation transmission through (at the base of)
164 ! each snow layer. Implicitly PTAU_N(0) = 1 (-)
165 ! It decreases with depth to zero somewhere in a deep snowpack,
166 ! but can be above 0 at snowpack base for shallow snow, then
167 ! it is presumed to go into the uppermost soil layer.
168 !
169 REAL, DIMENSION(:), INTENT(IN) :: plwnet_v, plwnet_g, plwnet_n
170 ! PLWNET_G = Understory-ground net LW radiation explicit term (W m-2)
171 ! PLWNET_V = Vegetation canopy net LW radiation explicit term (W m-2)
172 ! PLWNET_N = Ground-based snow net LW radiation explicit term (W m-2)
173 !
174 REAL, DIMENSION(:), INTENT(IN) :: plwnet_v_dtv, plwnet_v_dtg, plwnet_v_dtn
175 ! PLWNET_V_DTV, PLWNET_V_DTG, PLWNET_V_DTN = Vegetation canopy net LW radiation
176 ! derivatives w/r/t surface temperature(s) (W m-2 K-1)
177 !
178 REAL, DIMENSION(:), INTENT(IN) :: plwnet_g_dtv, plwnet_g_dtg, plwnet_g_dtn
179 ! PLWNET_G_DTV, PLWNET_G_DTG, PLWNET_G_DTN = Understory-ground net LW radiation
180 ! derivatives w/r/t surface temperature(s) (W m-2 K-1)
181 !
182 REAL, DIMENSION(:), INTENT(IN) :: plwnet_n_dtv, plwnet_n_dtg, plwnet_n_dtn
183 ! PLWNET_N_DTV, PLWNET_N_DTG, PLWNET_N_DTN = Ground-based snow net LW radiation
184 ! derivatives w/r/t surface temperature(s) (W m-2 K-1)
185 !
186 REAL, DIMENSION(:), INTENT(IN) :: pthrma_ta, pthrmb_ta, pthrma_tc, pthrmb_tc, &
187  pthrma_tg, pthrmb_tg, pthrma_tv, pthrmb_tv, pthrma_tn, pthrmb_tn
188 ! PTHRMA_TA (J kg-1 K-1)
189 ! PTHRMB_TA = linear transform coefficinets for atmospheric
190 ! thermal variable for lowest atmospheric level. (J kg-1)
191 ! Transform T to dry static energy or enthalpy.
192 ! PTHRMA_TC (J kg-1 K-1)
193 ! PTHRMB_TC = linear transform coefficinets for atmospheric
194 ! thermal variable for canopy air (J kg-1)
195 ! Transform T to dry static energy or enthalpy.
196 ! PTHRMA_TG,V,N (J kg-1 K-1)
197 ! PTHRMB_TG,V,N = linear transform coefficinets for atmospheric
198 ! thermal variable for surfaces (G, V, and N) (J kg-1)
199 ! Transform T to dry static energy or enthalpy.
200 !
201 REAL, DIMENSION(:), INTENT(IN) :: ppet_a_coef, ppeq_a_coef, ppet_b_coef, ppeq_b_coef, &
202  ppew_a_coef, ppew_b_coef
203 ! PPEW_A_COEF = wind atmospheric coupling coefficient
204 ! PPEW_B_COEF = wind atmospheric coupling coefficient
205 ! PPET_A_COEF = A-air temperature atmospheric coupling coefficient
206 ! PPET_B_COEF = B-air temperature atmospheric coupling coefficient
207 ! PPEQ_A_COEF = A-air specific humidity atmospheric coupling coefficient
208 ! PPEQ_B_COEF = B-air specific humidity atmospheric coupling coefficient
209 !
210 REAL, DIMENSION(:), INTENT(IN) :: pqsat_g, pqsat_v, pqsati_n
211 ! PQSAT_G = saturation specific humidity for understory surface (kg kg-1)
212 ! PQSAT_V = saturation specific humidity for the vegetation canopy (kg kg-1)
213 ! PQSATI_N = saturation specific humidity over ice for the snowpack (kg kg-1)
214 !
215 REAL, DIMENSION(:), INTENT(IN) :: pff, pffrozen, ppsn, ppsna, ppsncv
216 ! PFF = total flooded fraction (-)
217 ! PFFROZEN = total frozen flooded fraction (-)
218 ! PPSN = fraction of snow on ground and understory vegetation (-)
219 ! PPSNA = fraction of vegetation canopy buried by ground-based snowpack (-)
220 ! PPSNCV = fraction of vegetation canopy covered by intercepted snow (-)
221 !
222 REAL, DIMENSION(:), INTENT(IN) :: pleg_delta, plegi_delta, phug, phugi, phvg, phvn, pfrozen1
223 ! PHUG = relative humidity of the surface soil (-)
224 ! PHUGI = relative humidity of the frozen surface soil (-)
225 ! PHVG = Halstead coefficient of non-buried (snow) canopy vegetation (-)
226 ! PHVN = Halstead coefficient of paritally-buried (snow) canopy vegetation (-)
227 ! PLEG_DELTA = soil evaporation delta fn (-)
228 ! PLEGI_DELTA = soil sublimation delta fn (-)
229 ! PFROZEN1 = fraction of surface soil layer which is frozen (-)
230 !
231 REAL, DIMENSION(:), INTENT(IN) :: pflxc_c_a, pflxc_g_c, pflxc_vg_c, pflxc_vn_c, pflxc_n_c, pflxc_n_a, pflxc_mom
232 ! PFLXC_C_A = Flux form heat transfer coefficient: canopy air to atmosphere (kg m-2 s-1)
233 ! PFLXC_G_C = As above, but for : ground-understory to canopy air (kg m-2 s-1)
234 ! PFLXC_VG_C = As above, but for : non-snow buried canopy to canopy air (kg m-2 s-1)
235 ! PFLXC_VN_C = As above, but for : partially snow-buried canopy air to canopy
236 ! air (kg m-2 s-1)
237 ! PFLXC_N_C = As above, but for : ground-based snow to atmosphere (kg m-2 s-1)
238 ! PFLXC_N_A = As above, but for : ground-based snow to canopy air (kg m-2 s-1)
239 ! PFLXC_MOM = flux form drag transfer coefficient: canopy air to atmosphere (kg m-2 s-1)
240 !
241 REAL, DIMENSION(:,:), INTENT(INOUT):: ptn
242 ! PTN = Ground-based snow temperature profile (K)
243 !
244 REAL, DIMENSION(:), INTENT(INOUT):: ptv
245 ! PTV = Vegetation canopy temperature (K)
246 !
247 REAL, DIMENSION(:,:), INTENT(INOUT):: ptg
248 ! PTG = Soil temperature profile (K)
249 !
250 REAL, DIMENSION(:), INTENT(OUT) :: pcheatv, pcheatg, pcheatn
251 ! PCHEATV = Vegetation canopy *effective surface* heat capacity (J m-2 K-1)
252 ! PCHEATG = Understory-ground *effective surface* heat capacity (J m-2 K-1)
253 ! PCHEATN = Ground-based snow *effective surface* heat capacity (J m-2 K-1)
254 !
255 REAL, DIMENSION(:), INTENT(OUT) :: pdqsat_g, pdqsat_v, pdqsati_n
256 ! PQSAT_G = saturation specific humidity derivative for understory
257 ! surface (kg kg-1 K-1)
258 ! PQSAT_V = saturation specific humidity derivative for the vegetation
259 ! canopy (kg kg-1 K-1)
260 ! PQSATI_N = saturation specific humidity derivative over ice for the
261 ! ground-based snowpack (kg kg-1 K-1)
262 !
263 REAL, DIMENSION(:), INTENT(OUT) :: pflxc_v_c, phvgs, phvns
264 ! PFLXC_V_C = Flux form heat transfer coefficient: total canopy (partially
265 ! snow-buried and non-buried parts) to canopy air (kg m-2 s-1)
266 ! PHVGS = Dimensionless pseudo humidity factor for computing vapor
267 ! fluxes from the non-buried part of the canopy to the canopy air (-)
268 ! PHVNS = Dimensionless pseudo humidity factor for computing vapor
269 ! fluxes from the partly-buried part of the canopy to the canopy air (-)
270 !
271 REAL, DIMENSION(:), INTENT(OUT) :: ptc, pqc, pta_ic, pqa_ic, pustar2_ic, pvmod
272 ! PTC = Canopy air space temperature (K)
273 ! PQC = Canopy air space specific humidity (kg kg-1)
274 ! PTA_IC = Near-ground air temperature (K)
275 ! PQA_IC = Near-ground air specific humidity (kg kg-1)
276 ! PUSTAR2_IC = Surface friction velocity squared (m2 s-2)
277 ! (modified if implicit coupling with
278 ! atmosphere used)
279 ! PVMOD = lowest level wind speed (m s-1)
280 !
281 REAL, DIMENSION(:), INTENT(OUT) :: pdeltat_v, pdeltat_n, pdeltat_g
282 ! PDELTAT_V = Time change in vegetation canopy temperature (K)
283 ! PDELTAT_N = Time change in snowpack surface temperature (K)
284 ! PDELTAT_G = Time change in soil surface temperature (K)
285 !
286 REAL, DIMENSION(:), INTENT(OUT) :: pgrndflux
287 ! PGRNDFLUX = Flux between snowpack base and ground surface (W m-2)
288 !
289 REAL, DIMENSION(:), INTENT(OUT) :: pcps, plvtt, plstt
290 ! PCPS = specific heat capacity of the surface (J kg-1 K-1)
291 ! PLVTT= latent heat of vaporization (J kg-1)
292 ! PLSTT= latent heat of sublimation (J kg-1)
293 !
294 REAL, DIMENSION(:), INTENT(OUT) :: phpsnow, pmeltadv, prestore
295 ! PHPSNOW = Precipitation heating term for ground-based snowpack (W m-2)
296 ! PMELTADV= Heating resulting when meltwater enters soil at sub-freezing
297 ! temperatures (W m-2)
298 ! PRESTORE= flux between surface and sub-surface in soil (W m-2)
299 !
300 REAL, DIMENSION(:), INTENT(OUT) :: pdeep_flux ! Heat flux at bottom of ISBA (W/m2)
301 !
302 REAL, DIMENSION(:), INTENT(OUT) :: pdelheatv_sfc, pdelheatg_sfc, pdelheatg
303 ! PDELHEATV_SFC = change in heat storage of the vegetation canopy layer over the current time step (W m-2)
304 ! PDELHEATG_SFC = change in heat storage of the surface soil layer over the current time step (W m-2)
305 ! PDELHEATG = change in heat storage of the entire soil column over the current time step (W m-2)
306 !
307 !* 0.2 declarations of local variables
308 !
309 !
310 INTEGER :: jnsnow, jngrnd, jnpts, jj, jk, jl
311 !
312 REAL :: zhns
313 !
314 REAL, DIMENSION(SIZE(PTG,1),SIZE(PTG,2)) :: ztgo
315 !
316 REAL, DIMENSION(SIZE(PTN,1),SIZE(PTN,2)) :: ztno
317 !
318 REAL, DIMENSION(SIZE(PTG,1)) :: ztvo
319 !
320 REAL, DIMENSION(SIZE(PPS)) :: zhn, zhs, zhvs
321 !
322 REAL, DIMENSION(SIZE(PPS)) :: zpsnag, zwork, zfff, zgcond1
323 !
324 REAL, DIMENSION(SIZE(PPS)) :: zpet_a_coef_p, zpet_b_coef_p, zpet_c_coef_p
325 !
326 REAL, DIMENSION(SIZE(PPS)) :: zpeq_a_coef_p, zpeq_b_coef_p, zpeq_c_coef_p
327 !
328 REAL, DIMENSION(SIZE(PPS)) :: zcoefa_tc, zcoefb_tc, zcoefc_tc, zcoefd_tc, &
329  zcoefa_qc, zcoefb_qc, zcoefc_qc, zcoefd_qc
330 !
331 REAL, DIMENSION(SIZE(PPS)) :: zbeta_v, zalpha_v, zgamma_v, &
332  zbeta_g, zalpha_g, zgamma_g, &
333  zbeta_n, zalpha_n, zgamma_n, &
334  zbeta_p_v, zalpha_p_v, zbeta_p_n, zalpha_p_n
335 !
336 REAL, DIMENSION(SIZE(PPS)) :: zrnet_nn, zrnet_n_dtnn, zrnet_n_dtgn, zrnet_n_dtvn
337 !
338 REAL, DIMENSION(SIZE(PPS)) :: zvmod, zustar2, zpsna
339 !
340 REAL, DIMENSION(SIZE(PPS)) :: ztconda_delz_g, ztconda_delz_n, ztconda_delz_ng
341 !
342 REAL, DIMENSION(SIZE(PTG,1),SIZE(PTG,2)) :: zsoil_coef_a, zsoil_coef_b
343 !
344 REAL, DIMENSION(SIZE(PSNOWDZ,1),SIZE(PSNOWDZ,2)):: zsnow_coef_a, zsnow_coef_b, zsnowdz
345 !
346 REAL, DIMENSION(SIZE(PD_G,1),SIZE(PD_G,2)+SIZE(PSNOWDZ,2)) :: zd, zt, zhcapz, zcondz, &
347  zcoef_a, zcoef_b, zsource
348 !
349 REAL(KIND=JPRB) :: zhook_handle
350 !-------------------------------------------------------------------------------
351 !
352 REAL, PARAMETER :: zertol = 1.0e-6 ! -
353 REAL, PARAMETER :: zertol_flx_c = 1.0e-12 ! -
354 !
355 !-------------------------------------------------------------------------------
356 !
357 !* 0. Initialization:
358 ! ---------------
359 !
360 IF (lhook) CALL dr_hook('E_BUDGET_MEB',0,zhook_handle)
361 !
362 ztgo(:,:) = ptg(:,:)
363 ztno(:,:) = ptn(:,:)
364 ztvo(:) = ptv(:)
365 
366 ! To prevent possible numerical problems in the limit as psna==>1, we
367 ! limit the value for certain computations:
368 
369 zpsna(:) = min(1.0-zertol, ppsna(:))
370 
371 zsnowdz(:,:) = 0.0 ! local working variable
372 
373 jnsnow = SIZE(ptn,2)
374 jngrnd = SIZE(ptg,2)
375 jnpts = SIZE(ptg,1)
376 
377 ! sub-surface / surface coupling coefficients:
378 
379 zsoil_coef_a(:,:) = 0.0
380 zsoil_coef_b(:,:) = 0.0
381 zsnow_coef_a(:,:) = 0.0
382 zsnow_coef_b(:,:) = 0.0
383 
384 !-------------------------------------------------------------------------------
385 !
386 !* 1. Some variables/coefficients needed for coupling or solution
387 ! -----------------------------------------------------------
388 ! - Effective Surface heat capacities for each energy budget (J m-2 K-1)
389 !
390 pcheatg(:) = 1/pct(:) ! understory soil/floodplain
391 !
392 pcheatv(:) = sfc_heatcap_veg(pwrvn,pwr,pcv) ! vegetation canopy heat capacity
393 !
394 pcheatn(:) = psnowhcapz(:,1)*psnowdz(:,1) ! snow surface layer
395 !
396 ! - Specific humidity derivatives (kg kg-1 K-1)
397 !
398 pdqsat_g(:) = dqsat(ztgo(:,1), pps(:),pqsat_g(:) )
399 pdqsat_v(:) = dqsat(ztvo(:), pps(:),pqsat_v(:) )
400 pdqsati_n(:) = dqsati(ztno(:,1), pps(:),pqsati_n(:) )
401 !
402 ! - Precipitation heating term for snowpack:
403 ! Rainfall renders it's heat to the snow when it enters
404 ! the snowpack:
405 ! NOTE: for now set to zero because we'd need to remove this heat from
406 ! the atmosphere to conserve energy. This can be done, but should
407 ! be tested within an atmos model first probably...
408 ! ALSO, water should include canopy drip etc....but again, conservation
409 ! would need to be carefully accounted for. So for now within MEB,
410 ! set to 0. But code within MEB and ES can accept this term, so
411 ! if this process is added at some point, it would be here.
412 ! Also, it is treated explicitly...this might also have to be changed
413 ! to implicit depending how this term is expressed. That would require
414 ! modification to this routine and flux routine: but retain it here for possible
415 ! future implementation.
416 !
417 phpsnow(:) = 0.0 ! W m-2
418 !
419 ! Snowmeltwater advection which can heat uppermost soil layer if below freezing.
420 ! NOTE this term is currently OFF for MEB since it would mean keeping meltwater
421 ! flux from previous timestep (since snow called *after* energy budget). Also,
422 ! the heat would need to be removed from snowpack to conserve energy (and currently
423 ! not done) so we turn off for now (set to 0), but retain it here for possible
424 ! future implementation.
425 !
426 pmeltadv(:) = 0.0 ! W m-2
427 !
428 ! - Implicit wind speed at lowest atmospheric level for this patch:
429 !
430 zustar2(:) = (pflxc_mom(:)*ppew_b_coef(:))/ &
431  (1.0-pflxc_mom(:)*ppew_a_coef(:))
432 !
433 zvmod(:) = ppew_a_coef(:)*zustar2(:) + ppew_b_coef(:)
434 !
435 pvmod(:) = max(zvmod,0.)
436 !
437 WHERE (ppew_a_coef(:) /= 0.)
438  zustar2(:) = max(0., ( pvmod(:) - ppew_b_coef(:) ) / ppew_a_coef(:) )
439 END WHERE
440 !
441 pustar2_ic(:)= zustar2(:)
442 !
443 ! NOTE: put in new option HIMPLICIT_WIND=='OLD' or 'NEW' ?
444 !
445 zsource(:,:) = 0. ! heat Eq source term initialization: c dz dT/dt = d/dz(k dT/dz) + Source
446 !
447 IF(hisba == 'DIF')THEN
448 !
449 !* 2.a Compute sub-surface soil coupling coefficients: upward sweep
450 ! ------------------------------------------------------------
451 ! Upward sweep of the tridiagnal matrix using R&M method. Also compute
452 ! interfacial thermal conductivity to layer thickness ratio (W m-2 K-1)
453 ! These coefficients are used to compute the temperature profile implicitly.
454 !
455  CALL tridiag_ground_rm_coefs(ptstep,pd_g,ztgo,psoilhcapz,psoilcondz, &
456  zsource(:,1:jngrnd),ptdeep_a,ptdeep_b,ztconda_delz_g,zsoil_coef_a,zsoil_coef_b)
457 !
458 ! Here we repeat this for the snowpack: but note, this is just
459 ! to better estimate surface fluxes via the surface-sub surface heat
460 ! Flux term (we do not actually solve
461 ! the snow T profile here since fractional coverage not included).
462 ! We start from base of soil up through snow
463 ! to surface. This gives coefficients which are fully implicit
464 ! from the base of the soil to the snow surface, so numerically it is
465 ! quite robust. Note, this only corresponds to the snow-covered part of grid box,
466 ! so it is more accurate as the snow fraction approaches unity.
467 ! Starting from snowpack surface downward to base of ground:
468 !
469  zsnowdz(:,:) = max(xsnowdzmin, psnowdz(:,:))
470 !
471 
472  jl = 1
473  zd(:,jl) = zsnowdz(:,1)
474  zt(:,jl) = ztno(:,1)
475  zhcapz(:,jl) = psnowhcapz(:,1)
476  zcondz(:,jl) = psnowcondz(:,1)
477  zsource(:,jl) = 0. ! Included in energy budget
478  DO jk=2,jnsnow
479  jl = jl + 1
480  DO jj=1,jnpts
481  zd(jj,jl) = zsnowdz(jj,jk)
482  zt(jj,jl) = ztno(jj,jk)
483  zhcapz(jj,jl) = psnowhcapz(jj,jk)
484  zcondz(jj,jl) = psnowcondz(jj,jk)
485  zsource(jj,jl) = pswnet_n(jj)*(ptau_n(jj,jk-1)-ptau_n(jj,jk))
486  ENDDO
487  ENDDO
488  jl = jl + 1
489  zd(:,jl) = pd_g(:,1)
490  zt(:,jl) = ztgo(:,1)
491  zhcapz(:,jl) = pcheatg(:)/pd_g(:,1)
492  zcondz(:,jl) = psoilcondz(:,1)
493  zsource(:,jl) = pswnet_n(:)*ptau_n(:,jnsnow)
494  DO jk=2,jngrnd
495  jl = jl + 1
496  DO jj=1,jnpts
497  zd(jj,jl) = pd_g(jj,jk)
498  zt(jj,jl) = ztgo(jj,jk)
499  zhcapz(jj,jl) = psoilhcapz(jj,jk)
500  zcondz(jj,jl) = psoilcondz(jj,jk)
501  zsource(jj,jl) = 0.
502  ENDDO
503  ENDDO
504 !
505 ! Get coefficients from upward sweep (starting from soil base to snow surface):
506 !
507  CALL tridiag_ground_rm_coefs(ptstep,zd,zt,zhcapz,zcondz, &
508  zsource,ptdeep_a,ptdeep_b,ztconda_delz_n,zcoef_a,zcoef_b)
509 !
510  zsnow_coef_a(:,2) = zcoef_a(:,2)
511  zsnow_coef_b(:,2) = zcoef_b(:,2)
512 !
513  zgcond1(:) = psoilcondz(:,1) ! save uppermost soil thermal condcutivity
514 !
515 ELSE
516 !
517  zsoil_coef_a(:,2) = (ptstep/xday)/(1.0 + ptstep/xday)
518  zsoil_coef_b(:,2) = ztgo(:,2) /(1.0 + ptstep/xday)
519 
520  ztconda_delz_g(:) = (2*xpi/xday)/pct(:)
521 
522 ! - Soil thermal conductivity
523 ! is implicit in Force-Restore soil method, so it
524 ! must be backed-out of surface thermal coefficients
525 ! (Etchevers and Martin 1997):
526 
527  zgcond1(:) = (4*xpi/xday)/( pcg(:)*pcg(:)/(pd_g(:,1)*pct(:)) )
528 
529 
530  jl = 1
531  zd(:,jl) = zsnowdz(:,1)
532  zt(:,jl) = ztno(:,1)
533  zhcapz(:,jl) = psnowhcapz(:,1)
534  zcondz(:,jl) = psnowcondz(:,1)
535  zsource(:,jl) = 0. ! Included in energy budget
536  DO jk=2,jnsnow
537  jl = jl + 1
538  DO jj=1,jnpts
539  zd(jj,jl) = zsnowdz(jj,jk)
540  zt(jj,jl) = ztno(jj,jk)
541  zhcapz(jj,jl) = psnowhcapz(jj,jk)
542  zcondz(jj,jl) = psnowcondz(jj,jk)
543  zsource(jj,jl) = pswnet_n(jj)*(ptau_n(jj,jk-1)-ptau_n(jj,jk))
544  ENDDO
545  ENDDO
546  jl = jl + 1
547  zd(:,jl) = pd_g(:,1)
548  zt(:,jl) = ztgo(:,1)
549  zhcapz(:,jl) = 1/pct(:)
550  zcondz(:,jl) = zgcond1(:)
551  zsource(:,jl) = pswnet_n(:)*ptau_n(:,jnsnow)
552 
553 ! Get coefficients from upward sweep (starting from soil base to snow surface):
554 !
555  CALL tridiag_ground_rm_coefs(ptstep,zd(:,1:jl),zt(:,1:jl), &
556  zhcapz(:,1:jl),zcondz(:,1:jl),zsource(:,1:jl), &
557  ptdeep_a,ptdeep_b,ztconda_delz_n,zcoef_a(:,1:jl),zcoef_b(:,1:jl))
558 
559  zsnow_coef_a(:,2) = zcoef_a(:,2)
560  zsnow_coef_b(:,2) = zcoef_b(:,2)
561 !
562 ENDIF
563 !
564 ! Interfacial ground-snowbase thermal conductivity divided by interfacial dz:
565 !
566 ztconda_delz_ng(:) = 2/((zsnowdz(:,jnsnow)/psnowcondz(:,jnsnow))+(pd_g(:,1)/zgcond1(:) ))
567 !
568 !
569 !* 3. Pseudo humidity factors (-)
570 ! ---------------------------------------------------------
571 !
572 ! First, compute the average flux heat exchange coefficient for the canopy: (kg m-2 s-1)
573 ! Numerical: let get very small (fluxes can become essentially negligible), but not zero
574 !
575 pflxc_v_c(:) = pflxc_vg_c(:)*(1.-ppsn(:)) + pflxc_vn_c(:)*ppsn(:)*(1.-zpsna(:))
576 pflxc_v_c(:) = max(pflxc_v_c(:), zertol_flx_c)
577 
578 ! Understory vegetation and ground factors:
579 
580 zfff(:) = pff(:)*( 1.0 - pffrozen(:)*(1.0 - (xlstt/xlvtt)) )
581 
582 zhn(:) = (1.0-ppsn(:)-zfff(:))*( &
583  pleg_delta(:) *(1.0-pfrozen1(:)) &
584  + plegi_delta(:)* pfrozen1(:)*(xlstt/xlvtt) ) + zfff(:)
585 
586 zhs(:) = (1.0-ppsn(:)-zfff(:))*( &
587  phug(:) *pleg_delta(:) *(1.0-pfrozen1(:)) &
588  + phugi(:)*plegi_delta(:)* pfrozen1(:)*(xlstt/xlvtt) ) + zfff(:)
589 
590 ! adjust for local use in solution (since they are multiplied by 1-psn herein):
591 
592 zhn(:) = zhn(:)/max(1.0 - ppsn(:) , zertol)
593 
594 zhs(:) = zhs(:)/max(1.0 - ppsn(:) , zertol)
595 
596 ! Vegetation canopy factor:
597 
598 phvgs(:) = (1.-zpsna(:))*ppsn(:) *phvn(:)*(pflxc_vn_c(:)/pflxc_v_c(:)) + &
599  (1.-ppsn(:))*phvg(:)*(pflxc_vg_c(:)/pflxc_v_c(:))
600 
601 phvns(:) = (1.-zpsna(:))*ppsn(:) * (pflxc_vn_c(:)/pflxc_v_c(:)) + &
602  (1.-ppsn(:))* (pflxc_vg_c(:)/pflxc_v_c(:))
603 
604 ! - total canopy H factor (including intercepted snow)
605 
606 zhvs(:) = (1.-ppsncv(:))*phvgs(:) + ppsncv(:)*(xlstt/xlvtt)*phvns(:)
607 
608 ! Snow latent heating factor:
609 ! NOTE, for now we consider only snow sublimation
610 ! (not evaporation from snow liquid)
611 !
612 zhns = (xlstt/xlvtt)
613 !
614 !
615 !* 4. Transform atmospheric coupling coefficients for T and q
616 ! ---------------------------------------------------------
617 !
618 ! Transform coupling coefficients from flux form to scalar form for local
619 ! use in the energy budgets.
620 !
621 ! - first, to shorten computations a bit, define a snow fraction product
622 
623 zpsnag(:) = 1.0 - ppsn(:)*ppsna(:)
624 
625 ! T coefficients: where : TA = PET_B_COEF_P + PET_A_COEF_P*TC + PET_C_COEF_P*TN
626 
627 zwork(:) = pthrma_ta(:)*( 1.0 + ppet_a_coef(:)*( &
628  pflxc_c_a(:)*zpsnag(:) + pflxc_n_a(:)*ppsn(:)*ppsna(:)) )
629 zpet_a_coef_p(:) = ppet_a_coef(:)*pflxc_c_a(:)*zpsnag(:)*pthrma_tc(:) /zwork(:)
630 zpet_b_coef_p(:) = ( ppet_b_coef(:) - pthrmb_ta(:) + &
631  ppet_a_coef(:)*(pflxc_c_a(:)*zpsnag(:)*(pthrmb_tc(:)-pthrmb_ta(:)) + &
632  pflxc_n_a(:)*ppsn(:)*ppsna(:)*(pthrmb_tn(:)-pthrmb_ta(:)) ) ) /zwork(:)
633 zpet_c_coef_p(:) = ppet_a_coef(:)*pflxc_n_a(:)*ppsn(:)*ppsna(:)*pthrma_tn(:) /zwork(:)
634 
635 ! q coefficients:
636 
637 zwork(:) = 1.0 + ppeq_a_coef(:)*(pflxc_c_a(:)*zpsnag(:) + &
638  pflxc_n_a(:)*ppsn(:)*ppsna(:)*zhns)
639 zpeq_a_coef_p(:) = ppeq_a_coef(:)*pflxc_c_a(:)*zpsnag(:) /zwork(:)
640 zpeq_b_coef_p(:) = ppeq_b_coef(:) /zwork(:)
641 zpeq_c_coef_p(:) = ppeq_a_coef(:)*pflxc_n_a(:)*ppsn(:)*ppsna(:)*zhns/zwork(:)
642 
643 
644 !* 5. Compute canopy air coefficients (T and q)
645 ! ---------------------------------------------------------
646 
647 
648 ! - Canopy air T coefs, where : TC = COEFA_TC + COEFB_TC*TV + COEFC_TC*TG + COEFD_TC*TN
649 
650 zwork(:) = pflxc_c_a(:) *(pthrma_tc(:)-pthrma_ta(:)*zpet_a_coef_p(:))*zpsnag(:) &
651  + pflxc_v_c(:) *pthrma_tc(:) &
652  + pflxc_g_c(:) *pthrma_tc(:)*(1.0-ppsn(:)) &
653  + pflxc_n_c(:) *pthrma_tc(:)* ppsn(:) *(1.0-ppsna(:))
654 
655 zcoefa_tc(:) = (pflxc_c_a(:) * zpsnag(:) *(pthrma_ta(:)*zpet_b_coef_p(:)-pthrmb_tc(:)+pthrmb_ta(:)) &
656  + pflxc_v_c(:) * (pthrmb_tv(:)-pthrmb_tc(:)) &
657  + pflxc_g_c(:) * (pthrmb_tg(:)-pthrmb_tc(:))*(1.0-ppsn(:)) &
658  + pflxc_n_c(:) * (pthrmb_tn(:)-pthrmb_tc(:))* ppsn(:) *(1.0-ppsna(:)) &
659  )/zwork(:)
660 
661 zcoefb_tc(:) = pflxc_v_c(:)*pthrma_tv(:) /zwork(:)
662 
663 zcoefc_tc(:) = pflxc_g_c(:)*pthrma_tg(:)*(1.0-ppsn(:)) /zwork(:)
664 
665 zcoefd_tc(:) =(pflxc_n_c(:)*pthrma_tn(:)* ppsn(:)*(1.0-ppsna(:)) + &
666  pflxc_c_a(:) *pthrma_ta(:)*zpet_c_coef_p(:)*zpsnag(:) ) /zwork(:)
667 
668 !- Canopy air q coefs, where : QC = COEFA_QC + COEFB_QC*TV + COEFC_QC*TG + COEFD_QC*TN
669 
670 
671 zwork(:) = pflxc_c_a(:) *(1.-zpeq_a_coef_p(:))*zpsnag(:) &
672  + pflxc_v_c(:)* zhvs(:) &
673  + pflxc_g_c(:) *zhn(:) *(1.0-ppsn(:)) &
674  + pflxc_n_c(:) *zhns * ppsn(:) *(1.0-ppsna(:))
675 zwork(:) = max(zertol, zwork(:))
676 
677 zcoefa_qc(:) = ( pflxc_c_a(:) *zpeq_b_coef_p(:)*zpsnag(:) &
678  + pflxc_v_c(:) *zhvs(:)*(pqsat_v(:)-pdqsat_v(:)*ztvo(:) ) &
679  + pflxc_g_c(:) *zhs(:) *(pqsat_g(:)-pdqsat_g(:)*ztgo(:,1))*(1.0-ppsn(:)) &
680  + pflxc_n_c(:) *zhns *(pqsati_n(:)-pdqsati_n(:)*ztno(:,1))* &
681  ppsn(:)*(1.0-ppsna(:)) &
682  )/zwork(:)
683 
684 zcoefb_qc(:) = pflxc_v_c(:) *zhvs(:)*pdqsat_v(:) /zwork(:)
685 
686 zcoefc_qc(:) = pflxc_g_c(:) *zhs(:) *pdqsat_g(:)*(1.0-ppsn(:)) /zwork(:)
687 
688 zcoefd_qc(:) = pflxc_n_c(:) *zhns *pdqsati_n(:)* ppsn(:)*(1.0-ppsna(:))/zwork(:)
689 
690 !* 6. Surface Energy Budget(s) coefficients
691 ! -------------------------------------
692 ! Each of the 'N' energy budgets is linearized, so we have
693 ! 'N' linear equations and 'N' unknowns. Here we set up the coefficients.
694 ! For computations here, make snow radiative terms relative to snow surface:
695 
696 zwork(:) = 1/max(zertol, ppsn(:))
697 
698 zrnet_nn(:) = (pswnet_n(:) + plwnet_n(:))*zwork(:)
699 zrnet_n_dtnn(:) = plwnet_n_dtn(:) *zwork(:)
700 zrnet_n_dtgn(:) = plwnet_n_dtg(:) *zwork(:)
701 zrnet_n_dtvn(:) = plwnet_n_dtv(:) *zwork(:)
702 
703 
704 ! Tv coefs, where TV = BETA_V + ALPHA_V*TG + GAMMA_V*TN
705 
706 zwork(:) = (pcheatv(:)/ptstep) - plwnet_v_dtv(:) &
707  + pflxc_v_c(:)*(pthrma_tv(:) - pthrma_tc(:)*zcoefb_tc(:) &
708  + xlvtt*zhvs(:)*(pdqsat_v(:) - zcoefb_qc(:)) )
709 
710 zbeta_v(:) = ( (pcheatv(:)/ptstep)*ztvo(:) + plwnet_v(:) + pswnet_v(:) &
711  - plwnet_v_dtv(:)*ztvo(:) - plwnet_v_dtg(:)*ztgo(:,1) - plwnet_v_dtn(:)*ztno(:,1) &
712  - pflxc_v_c(:)*( pthrmb_tv(:)-pthrmb_tc(:)-pthrma_tc(:)*zcoefa_tc(:) &
713  + xlvtt*zhvs(:)*(pqsat_v(:) - pdqsat_v(:)*ztvo(:) &
714  - zcoefa_qc(:)) ) )/zwork(:)
715 
716 zalpha_v(:) = (plwnet_v_dtg(:) + pflxc_v_c(:)*(pthrma_tc(:)*zcoefc_tc(:) &
717  + xlvtt*zhvs(:)*zcoefc_qc(:) ) )/zwork(:)
718 
719 zgamma_v(:) = (plwnet_v_dtn(:) + pflxc_v_c(:)*(pthrma_tc(:)*zcoefd_tc(:) &
720  + xlvtt*zhvs(:)*zcoefd_qc(:) ) )/zwork(:)
721 
722 ! Tg coefs, where TG = BETA_G + ALPHA_G*TV + GAMMA_G*TN
723 
724 zwork(:) = (pcheatg(:)/ptstep) - plwnet_g_dtg(:) &
725  + (1.0-ppsn(:))*pflxc_g_c(:)*( (pthrma_tg(:) - pthrma_tc(:)*zcoefc_tc(:)) &
726  + xlvtt*(zhs(:)*pdqsat_g(:) - zhn(:)*zcoefc_qc(:)) ) &
727  + ztconda_delz_g(:)*(1.0-zsoil_coef_a(:,2)) &
728  + ppsn(:)*ztconda_delz_ng(:)
729 
730 zbeta_g(:) = ( (pcheatg(:)/ptstep)*ztgo(:,1) + plwnet_g(:) + pswnet_g(:) &
731  - plwnet_g_dtv(:)*ztvo(:) - plwnet_g_dtg(:)*ztgo(:,1) - plwnet_g_dtn(:)*ztno(:,1) &
732  - (1.0-ppsn(:))*pflxc_g_c(:)*( pthrmb_tg(:)-pthrmb_tc(:)-pthrma_tc(:)*zcoefa_tc(:) &
733  + xlvtt*(zhs(:)*(pqsat_g(:) - pdqsat_g(:)*ztgo(:,1)) &
734  - zhn(:)*zcoefa_qc(:)) ) &
735  + ztconda_delz_g(:)*zsoil_coef_b(:,2) &
736  + ppsn(:)*ztconda_delz_ng(:)*ztno(:,jnsnow) )/zwork(:)
737 
738 zalpha_g(:) = (plwnet_g_dtv(:) + pflxc_g_c(:)*(1.0-ppsn(:))*( pthrma_tc(:)*zcoefb_tc(:) &
739  + xlvtt*zhn(:)*zcoefb_qc(:) ) )/zwork(:)
740 
741 zgamma_g(:) = (plwnet_g_dtn(:) + pflxc_g_c(:)*(1.0-ppsn(:))*( pthrma_tc(:)*zcoefd_tc(:) &
742  + xlvtt*zhn(:)*zcoefd_qc(:) ) )/zwork(:)
743 
744 ! Tn coefs, where TN = BETA_N + ALPHA_N*TV + GAMMA_N*TG
745 
746 zwork(:) = (pcheatn(:)/ptstep) - zrnet_n_dtnn(:) &
747  + pflxc_n_c(:)*(1.-ppsna(:))*( pthrma_tn(:) - pthrma_tc(:)*zcoefd_tc(:) &
748  + (xlvtt*zhns)*(pdqsati_n(:) - zcoefd_qc(:)) ) &
749  + pflxc_n_a(:)* ppsna(:)*( &
750  pthrma_tn(:) - pthrma_ta(:)*(zpet_a_coef_p(:)*zcoefd_tc(:) + zpet_c_coef_p(:)) &
751  + (xlvtt*zhns)*(pdqsati_n(:)*(1.0-zpeq_c_coef_p(:)) - zpeq_a_coef_p(:)*zcoefd_qc(:)) ) &
752  + ztconda_delz_n(:)*(1.0-zsnow_coef_a(:,2))
753 
754 zbeta_n(:) = ( (pcheatn(:)/ptstep)*ztno(:,1) + zrnet_nn(:) + phpsnow(:) + pmeltadv(:) &
755  - zrnet_n_dtvn(:)*ztvo(:) - zrnet_n_dtgn(:)*ztgo(:,1) - zrnet_n_dtnn(:)*ztno(:,1) &
756  - pflxc_n_c(:)*(1.-ppsna(:))*( pthrmb_tn(:) - pthrmb_tc(:) - pthrma_tc(:)*zcoefa_tc(:) &
757  + (xlvtt*zhns)*(pqsati_n(:) - pdqsati_n(:)*ztno(:,1) &
758  - zcoefa_qc(:)) ) &
759  - pflxc_n_a(:)*ppsna(:)*( pthrmb_tc(:) - pthrmb_ta(:) - &
760  pthrma_ta(:)*(zpet_b_coef_p(:) + zcoefa_tc(:)*zpet_a_coef_p(:)) &
761  + (xlvtt*zhns)*((pqsati_n(:) - pdqsati_n(:)*ztno(:,1))*(1.0-zpeq_c_coef_p(:)) &
762  - zpeq_b_coef_p(:) - zpeq_a_coef_p(:)*zcoefa_qc(:)) ) &
763  + ztconda_delz_n(:)*zsnow_coef_b(:,2) )/zwork(:)
764 
765 zalpha_n(:) = ( zrnet_n_dtvn(:) + pflxc_n_c(:)*(1.-ppsna(:))*( pthrma_tc(:)*zcoefb_tc(:) &
766  + (xlvtt*zhns)*zcoefb_qc(:) ) &
767  + pflxc_n_a(:)* ppsna(:) *( pthrma_ta(:)*zcoefb_tc(:)*zpet_a_coef_p(:) &
768  + (xlvtt*zhns)*zcoefb_qc(:)*zpeq_a_coef_p(:) ) )/zwork(:)
769 
770 zgamma_n(:) = ( zrnet_n_dtgn(:) + pflxc_n_c(:)*(1.-ppsna(:))*( pthrma_tc(:)*zcoefc_tc(:) &
771  + (xlvtt*zhns)*zcoefc_qc(:)) &
772  + pflxc_n_a(:)* ppsna(:) *( pthrma_ta(:)*zcoefc_tc(:)*zpet_a_coef_p(:) &
773  + (xlvtt*zhns)*zcoefc_qc(:)*zpeq_a_coef_p(:) ) )/zwork(:)
774 
775 !* 7. Solve multiple energy budgets simultaneously (using an implicit time scheme)
776 ! ----------------------------------------------------------------------------
777 ! Also compute certain needed diagnostics, like the canopy air T and q, and T and q at
778 ! the lowest model level: They are used within the current patch to compute implicit or explicit
779 ! fluxes (depending upon the values of the atmospheric Implicit Coupling (IC) coefficients)
780 
781 
782 WHERE(ppsn(:) > 0.0)
783 
784  zwork(:) = 1.0 - zalpha_v(:)*zalpha_g(:)
785  zbeta_p_v(:) = (zbeta_v(:) + zalpha_v(:)*zbeta_g(:) )/zwork(:)
786  zalpha_p_v(:) = (zgamma_v(:) + zalpha_v(:)*zgamma_g(:))/zwork(:)
787 
788  zwork(:) = 1.0 - zgamma_g(:)*zgamma_n(:)
789  zbeta_p_n(:) = (zbeta_n(:) + zgamma_n(:)*zbeta_g(:) )/zwork(:)
790  zalpha_p_n(:) = (zalpha_n(:) + zgamma_n(:)*zalpha_g(:))/zwork(:)
791 
792  ptn(:,1) = (zbeta_p_n(:) + zalpha_p_n(:)*zbeta_p_v(:))/ &
793  (1.0 - zalpha_p_n(:)*zalpha_p_v(:) )
794 
795 ! Since the fluxes are passed to the snow scheme, we can simply limit Tn here
796 ! for flux computations (to make sure fluxes correspond to a snow sfc which
797 ! doesn't exceed it's physical limit, Tf). The new real snow Tn consistent with these fluxes
798 ! (and the T-profile within the snow) will be computed within the snow scheme.
799 
800  ptn(:,1) = min(xtt, ptn(:,1))
801 
802  ptv(:) = zbeta_p_v(:) + zalpha_p_v(:)*ptn(:,1)
803 
804  ptg(:,1) = zbeta_g(:) + zalpha_g(:)*ptv(:) + zgamma_g(:)*ptn(:,1)
805 
806  ptc(:) = zcoefa_tc(:) + zcoefb_tc(:)*ptv(:) + zcoefc_tc(:)*ptg(:,1) + zcoefd_tc(:)*ptn(:,1)
807 
808  pqc(:) = zcoefa_qc(:) + zcoefb_qc(:)*ptv(:) + zcoefc_qc(:)*ptg(:,1) + zcoefd_qc(:)*ptn(:,1)
809 
810 ! Lowest atmospheric level air temperature (for this patch):
811 
812  pta_ic(:) = zpet_b_coef_p(:) + zpet_a_coef_p(:) *ptc(:) + zpet_c_coef_p(:) *ptn(:,1)
813 
814 ! Lowest atmospheric level specific humidity (for this patch):
815 ! - First, compute the surface specific humidity of the snow:
816 
817  zwork(:) = zhns*( pqsati_n(:) + pdqsati_n(:)*(ptn(:,1) - ztno(:,1)) ) ! q_n+
818 
819  pqa_ic(:) = zpeq_b_coef_p(:) + zpeq_a_coef_p(:) *pqc(:) + zpeq_c_coef_p(:) *zwork(:)
820 
821 ! diagnostic snow thermal flux: surface to sub-surface thermal transfer
822 
823 ! ZRESTOREN(:) = PPSN(:)*ZTCONDA_DELZ_N(:)*(PTN(:,1)*(1.0-ZSNOW_COEF_A(:,2)) - ZSNOW_COEF_B(:,2))
824 
825 ELSEWHERE ! snow free canopy-understory case:
826 
827  ptg(:,1) = (zbeta_g(:) + zalpha_g(:)*zbeta_v(:))/ &
828  (1.0 - zalpha_g(:)*zalpha_v(:) )
829 
830  ptv(:) = zbeta_v(:) + zalpha_v(:)*ptg(:,1)
831 
832  ptc(:) = zcoefa_tc(:) + zcoefb_tc(:)*ptv(:) + zcoefc_tc(:)*ptg(:,1)
833 
834  pqc(:) = zcoefa_qc(:) + zcoefb_qc(:)*ptv(:) + zcoefc_qc(:)*ptg(:,1)
835 
836 ! Lowest atmospheric level air temperature (for this patch):
837 
838  pta_ic(:) = zpet_b_coef_p(:) + zpet_a_coef_p(:) *ptc(:)
839 
840 ! Lowest atmospheric level specific humidity (for this patch):
841 
842  pqa_ic(:) = zpeq_b_coef_p(:) + zpeq_a_coef_p(:) *pqc(:)
843 
844 ! arbitrary: (as no snow mass present)
845 
846  ptn(:,1) = xtt
847 
848 ! ZRESTOREN(:) = 0.0
849 
850 END WHERE
851 !
852 !
853 ! Compute test sub-surface snow temperatures: this improves time split estimate of
854 ! surface to sub-surface flux estimates. Note that the sub-surface
855 ! snow temperatures are "test" temperatures, with final "true" values
856 ! computed within the snow routine.
857 !
858 
859  CALL tridiag_ground_rm_soln(zt,zcoef_a,zcoef_b)
860 DO jk=2,jnsnow
861  WHERE(ppsn(:) > 0.0)
862  ptn(:,jk) = min(xtt,zt(:,jk))
863  ENDWHERE
864 ENDDO
865 !
866 !
867 !* 8. Solve soil temperature profile (implicitly coupled to surface energy budgets)
868 ! -----------------------------------------------------------------------------
869 ! The back-substitution of sub-surface soil T profile
870 ! (update all temperatures *below* the surface)
871 !
872 IF(hisba == 'DIF')THEN
873  CALL tridiag_ground_rm_soln(ptg,zsoil_coef_a,zsoil_coef_b)
874 ELSE
875  ptg(:,2) = zsoil_coef_b(:,2) + zsoil_coef_a(:,2)*ptg(:,1)
876 ENDIF
877 !
878 ! Diagnose (semi-implicit) flux across ground base:
879 ! (semi-implicit if T imposed, explicit if flux imposed)
880 !
881 WHERE(ptdeep_b(:) == xundef)
882  pdeep_flux(:) = 0.0
883 ELSEWHERE
884  zwork(:) = psoilcondz(:,jngrnd)*2/(pd_g(:,jngrnd)-pd_g(:,jngrnd-1)) ! (W/m2/K)
885  pdeep_flux(:) = zwork(:)*(ptdeep_b(:) - ptg(:,jngrnd))/ &
886  (1. - zwork(:)*ptdeep_a(:)) ! (W/m2)
887 END WHERE
888 !
889 !* 9. Temperature tendencies
890 ! ----------------------
891 !
892 ! Compute energy budget tendencies (for flux computations)
893 ! and sub-sfc soil tendencies (K) (for phase changes)
894 
895 pdeltat_g(:) = ptg(:,1) - ztgo(:,1)
896 pdeltat_v(:) = ptv(:) - ztvo(:)
897 pdeltat_n(:) = ptn(:,1) - ztno(:,1)
898 !
899 !
900 !* 10. Flux Diagnostics
901 ! ----------------
902 !
903 ! Locally implicit (with respect to the ground T) snow-ground heat flux (W m-2).
904 ! This is a first estimate, since the final fully implicit flux
905 ! is computed in the snow routine: any differences
906 ! between this flux estimate and the final one are
907 ! transferred to the soil as heating/cooling, thus
908 ! conserving energy.
909 !
910 pgrndflux(:) = ppsn(:)*ztconda_delz_ng(:)*( ptn(:,jnsnow) - ptg(:,1) )
911 !
912 !
913 !* 10. Energy Storage Diagnostics (W m-2)
914 ! ----------------------------------
915 !
916 pdelheatg_sfc(:) = pcheatg(:)*pdeltat_g(:)/ptstep
917 pdelheatv_sfc(:) = pcheatv(:)*pdeltat_v(:)/ptstep
918 !
919 IF(hisba == 'DIF')THEN
920 
921 ! Flux between surface and sub-surface (W m-2):
922 
923  prestore(:) = (ptg(:,1) - ptg(:,2))* 2/( ((pd_g(:,2)-pd_g(:,1))/psoilcondz(:,2)) + &
924  ( pd_g(:,1) /psoilcondz(:,1)) )
925 !
926 !
927 !* 10.a Energy Storage Diagnostics (W m-2): DIF
928 ! ---------------------------------------
929 !
930 ! These terms are used for computing energy budget diagnostics.
931 !
932 !
933  pdelheatg(:) = pdelheatg_sfc(:) ! initialize
934  DO jk=2,jngrnd
935  DO jj=1,jnpts
936  pdelheatg(jj) = pdelheatg(jj) + psoilhcapz(jj,jk)*(pd_g(jj,jk)-pd_g(jj,jk-1))* &
937  (ptg(jj,jk) - ztgo(jj,jk))/ptstep
938  ENDDO
939  ENDDO
940 !
941 ELSE
942 
943 !* 10.b Energy Storage Diagnostics (W m-2): Force Restore
944 ! -------------------------------------------------
945 !
946 ! Flux between surface and sub-surface (W m-2):
947 
948  prestore(:) = (2*xpi/xday)*(ptg(:,1) - ptg(:,2))/pct(:)
949 
950 ! These terms are used for computing energy budget diagnostics.
951 !
952  pdelheatg(:) = pdelheatg_sfc(:) + prestore(:)
953 !
954 ENDIF
955 
956 !
957 !* 11. Additional Diagnostics
958 ! ----------------------
959 !
960 ! Here compute the updated (time t+dt) effective reference level specific heat capacity:
961 ! (just a diagnostic here):
962 !
963 IF (hcpsurf=='DRY') THEN
964  pcps(:) = xcpd
965 ELSEIF(.NOT.lcpl_arp)THEN
966  pcps(:) = xcpd + ( xcpv - xcpd ) * pqc(:)
967 ENDIF
968 !
969 plvtt(:) = xlvtt
970 plstt(:) = xlvtt ! latent heat of sublimation already accounted for
971 !
972 !
973 IF (lhook) CALL dr_hook('E_BUDGET_MEB',1,zhook_handle)
974 !
975 END SUBROUTINE e_budget_meb
976 
977 
subroutine tridiag_ground_rm_soln(PSOLN, PA_COEF, PB_COEF)
subroutine e_budget_meb(HISBA, HCPSURF, PTSTEP, PPS, PCG, PCT, PCV, PWRVN, PWR, PTDEEP_A, PTDEEP_B, PD_G, PSOILCONDZ, PSOILHCAPZ, PSNOWDZ, PSNOWCONDZ, PSNOWHCAPZ, PSWNET_V, PSWNET_G, PSWNET_N, PTAU_N, PLWNET_V, PLWNET_G, PLWNET_N, PLWNET_V_DTV, PLWNET_V_DTG, PLWNET_V_DTN, PLWNET_G_DTV, PLWNET_G_DTG, PLWNET_G_DTN, PLWNET_N_DTV, PLWNET_N_DTG, PLWNET_N_DTN, PPEW_A_COEF, PPEW_B_COEF, PPET_A_COEF, PPEQ_A_COEF, PPET_B_COEF, PPEQ_B_COEF, PTHRMA_TA, PTHRMB_TA, PTHRMA_TC, PTHRMB_TC, PTHRMA_TG, PTHRMB_TG, PTHRMA_TV, PTHRMB_TV, PTHRMA_TN, PTHRMB_TN, PQSAT_G, PQSAT_V, PQSATI_N, PFF, PFFROZEN, PPSN, PPSNA, PPSNCV, PCHEATV, PCHEATG, PCHEATN, PLEG_DELTA, PLEGI_DELTA, PHUG, PHUGI, PHVG, PHVN, PFROZEN1, PFLXC_C_A, PFLXC_G_C, PFLXC_VG_C, PFLXC_VN_C, PFLXC_N_C, PFLXC_N_A, PFLXC_MOM, PTG, PTV, PTN, PFLXC_V_C, PHVGS, PHVNS, PDQSAT_G, PDQSAT_V, PDQSATI_N, PTC, PQC, PTA_IC, PQA_IC, PUSTAR2_IC, PVMOD, PDELTAT_G, PDELTAT_V, PDELTAT_N, PGRNDFLUX, PCPS, PLVTT, PLSTT, PHPSNOW, PMELTADV, PRESTORE, PDEEP_FLUX, PDELHEATV_SFC, PDELHEATG_SFC, PDELHEATG)
Definition: e_budget_meb.F90:6
subroutine tridiag_ground_rm_coefs(PTSTEP, PDEPTH, PTEMP, PHEATCAP, PCONDTRM, PSOURCE, PTDEEP_A, PTDEEP_B, PCONDA_DELZ, PA_COEF, PB_COEF)