SURFEX v8.1
General documentation of Surfex
roof_impl_coef.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 roof_impl_coef(T, PTSTEP, PTDEEP_A, PTDEEP_B)
7 ! ###############################################
8 !
9 !!
10 !! PURPOSE
11 !! -------
12 !
13 ! Computes the corfficients for implicitation of upper
14 ! roof layer with what is above
15 !
16 !
17 !!** METHOD
18 ! ------
19 !
20 ! One computes a guess assuming a zero flux condition at the base
21 ! of the roof. One solves the half part of the tridiagonal matrix
22 ! fromm bottom to top.
23 !
24 !! The classical tridiagonal algorithm is used to invert the
25 !! implicit operator (from bottom to top only). Its matrix is given by:
26 !!
27 !! ( b(1) c(1) 0 0 0 0 0 0 )
28 !! ( a(2) b(2) c(2) 0 ... 0 0 0 0 )
29 !! ( 0 a(3) b(3) c(3) 0 0 0 0 )
30 !! .......................................................................
31 !! ( 0 ... 0 a(k) b(k) c(k) 0 ... 0 0 )
32 !! .......................................................................
33 !! ( 0 0 0 0 0 ... a(n-1) b(n-1) c(n-1))
34 !! ( 0 0 0 0 0 ... 0 a(n) b(n) )
35 !!
36 !!
37 !! AUTHOR
38 !! ------
39 !!
40 !! V. Masson * Meteo-France *
41 !!
42 !! MODIFICATIONS
43 !! -------------
44 !! Original 01/2013
45 !!
46 !-------------------------------------------------------------------------------
47 !
48 !* 0. DECLARATIONS
49 ! ------------
50 !
51 USE modd_teb_n, ONLY : teb_t
52 !
53 USE yomhook ,ONLY : lhook, dr_hook
54 USE parkind1 ,ONLY : jprb
55 !
56 USE modi_layer_e_budget_get_coef
57 !
58 IMPLICIT NONE
59 !
60 !
61 !* 0.1 Declarations of arguments
62 !
63 TYPE(teb_t), INTENT(INOUT) :: T
64 !
65 REAL , INTENT(IN) :: PTSTEP ! time step
66 REAL, DIMENSION(:), INTENT(OUT) :: PTDEEP_A, PTDEEP_B
67  ! Deep soil temperature (prescribed)
68 ! PTDEEP_A = Deep soil temperature
69 ! coefficient depending on flux
70 ! PTDEEP_B = Deep soil temperature (prescribed)
71 ! which models heating/cooling from
72 ! below the diurnal wave penetration
73 ! (surface temperature) depth. If it
74 ! is FLAGGED as undefined, then the zero
75 ! flux lower BC is applied.
76 ! Tdeep = PTDEEP_B + PTDEEP_A * PDEEP_FLUX
77 ! (with PDEEP_FLUX in W/m2)
78 !
79 !* 0.2 Local variables
80 !
81 REAL :: ZIMPL = 1.0 ! implicit coefficient
82 INTEGER :: JK ! loop counter
83 INTEGER :: ILAYER
84 !
85 REAL, DIMENSION(SIZE(PTDEEP_A),SIZE(T%XT_ROOF,2)) :: ZA,& ! lower diag.
86  ZB,& ! main diag.
87  ZC,& ! upper diag.
88  ZY ! r.h.s.
89 
90 REAL, DIMENSION(SIZE(PTDEEP_A)) :: ZDET ! work array
91 REAL, DIMENSION(SIZE(PTDEEP_A),SIZE(T%XT_ROOF,2)) :: ZW ! work array
92 REAL, DIMENSION(SIZE(PTDEEP_A),SIZE(T%XT_ROOF,2)) :: ZT ! guess of T
93 !
94 REAL(KIND=JPRB) :: ZHOOK_HANDLE
95 !-------------------------------------------------------------------------------
96 IF (lhook) CALL dr_hook('ROOF_IMPL_COEF',0,zhook_handle)
97 !
98 !* 1.0 Coefficients of the tridioagonal matrix for heat conduction eq.
99 ! ---------------------------------------------------------------
100 !
101 ilayer = SIZE(t%XT_ROOF,2)
102 !
103  CALL layer_e_budget_get_coef(t%XT_ROOF, ptstep, zimpl, t%XHC_ROOF, t%XTC_ROOF, t%XD_ROOF, &
104  za, zb, zc, zy )
105 !
106 !-------------------------------------------------------------------------------
107 !
108 !* 2.0 Solving of the equation from bottom to top
109 ! ------------------------------------------
110 !
111 ! layer at bottom of roof
112 !
113 zdet(:) = zb(:,ilayer)
114 !
115 zt(:,ilayer) = zy(:,ilayer) / zdet(:)
116 !
117 ! internal layers & top layer (but without the external heat flux term)
118 !
119 DO jk=ilayer-1,1,-1
120  zw(:,jk) = za(:,jk+1)/zdet(:)
121  zdet(:) = zb(:,jk ) - zc(:,jk)*zw(:,jk)
122  zt(:,jk) = ( zy(:,jk) - zc(:,jk)*zt(:,jk+1) ) / zdet(:) ! + FLUX / ZDET
123  ! ! for layer 1
124  ! ! because the external
125  ! ! flux would be
126  ! ! included in the Y
127  ! ! term
128 END DO
129 !
130 ! Implicit coefficients for the heat flux
131 !
132 ptdeep_b = zt(:,1)
133 ptdeep_a = 1. / zdet(:)
134 !
135 !* The following lines are here if you want to test the explicit coupling
136 !PTDEEP_B = T%XT_ROOF(:,1)
137 !PTDEEP_A = 0.
138 !-------------------------------------------------------------------------------
139 IF (lhook) CALL dr_hook('ROOF_IMPL_COEF',1,zhook_handle)
140 !-------------------------------------------------------------------------------
141 !
142 END SUBROUTINE roof_impl_coef
integer, parameter jprb
Definition: parkind1.F90:32
subroutine roof_impl_coef(T, PTSTEP, PTDEEP_A, PTDEEP_B)
logical lhook
Definition: yomhook.F90:15
subroutine layer_e_budget_get_coef(PT, PTSTEP, PIMPL, PHC, PTC, PD, PA, PB, PC, PY)