SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
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(PTSTEP, KROOF_LAYER, PD_ROOF, PTC_ROOF, PHC_ROOF, PT_ROOF, 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 yomhook ,ONLY : lhook, dr_hook
52 USE parkind1 ,ONLY : jprb
53 !
54 USE modi_layer_e_budget_get_coef
55 !
56 IMPLICIT NONE
57 !
58 !
59 !* 0.1 Declarations of arguments
60 !
61 REAL , INTENT(IN) :: ptstep ! time step
62 INTEGER , INTENT(IN) :: kroof_layer ! number of roof layers
63 REAL, DIMENSION(:,:), INTENT(IN) :: pd_roof ! thickness of each layer
64 REAL, DIMENSION(:,:), INTENT(IN) :: ptc_roof ! thermal conductivity of each layer
65 REAL, DIMENSION(:,:), INTENT(IN) :: phc_roof ! heat capacity of each layer
66 REAL, DIMENSION(:,:), INTENT(IN) :: pt_roof ! temperature of each layer
67 REAL, DIMENSION(:), INTENT(OUT) :: ptdeep_a, ptdeep_b
68  ! Deep soil temperature (prescribed)
69 ! PTDEEP_A = Deep soil temperature
70 ! coefficient depending on flux
71 ! PTDEEP_B = Deep soil temperature (prescribed)
72 ! which models heating/cooling from
73 ! below the diurnal wave penetration
74 ! (surface temperature) depth. If it
75 ! is FLAGGED as undefined, then the zero
76 ! flux lower BC is applied.
77 ! Tdeep = PTDEEP_B + PTDEEP_A * PDEEP_FLUX
78 ! (with PDEEP_FLUX in W/m2)
79 !
80 !* 0.2 Local variables
81 !
82 REAL :: zimpl = 1.0 ! implicit coefficient
83 INTEGER :: jk ! loop counter
84 !
85 REAL, DIMENSION(SIZE(PTDEEP_A),KROOF_LAYER) :: 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),KROOF_LAYER) :: zw ! work array
92 REAL, DIMENSION(SIZE(PTDEEP_A),KROOF_LAYER) :: 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  CALL layer_e_budget_get_coef( pt_roof, ptstep, zimpl, phc_roof, ptc_roof, pd_roof, &
102  za, zb, zc, zy )
103 !
104 !-------------------------------------------------------------------------------
105 !
106 !* 2.0 Solving of the equation from bottom to top
107 ! ------------------------------------------
108 !
109 ! layer at bottom of roof
110 !
111 zdet(:) = zb(:,kroof_layer)
112 !
113 zt(:,kroof_layer) = zy(:,kroof_layer) / zdet(:)
114 !
115 ! internal layers & top layer (but without the external heat flux term)
116 !
117 DO jk=kroof_layer-1,1,-1
118  zw(:,jk) = za(:,jk+1)/zdet(:)
119  zdet(:) = zb(:,jk ) - zc(:,jk)*zw(:,jk)
120  zt(:,jk) = ( zy(:,jk) - zc(:,jk)*zt(:,jk+1) ) / zdet(:) ! + FLUX / ZDET
121  ! ! for layer 1
122  ! ! because the external
123  ! ! flux would be
124  ! ! included in the Y
125  ! ! term
126 END DO
127 !
128 ! Implicit coefficients for the heat flux
129 !
130 ptdeep_b = zt(:,1)
131 ptdeep_a = 1. / zdet(:)
132 !
133 !* The following lines are here if you want to test the explicit coupling
134 !PTDEEP_B = PT_ROOF(:,1)
135 !PTDEEP_A = 0.
136 !-------------------------------------------------------------------------------
137 IF (lhook) CALL dr_hook('ROOF_IMPL_COEF',1,zhook_handle)
138 !-------------------------------------------------------------------------------
139 !
140 END SUBROUTINE roof_impl_coef
subroutine roof_impl_coef(PTSTEP, KROOF_LAYER, PD_ROOF, PTC_ROOF, PHC_ROOF, PT_ROOF, PTDEEP_A, PTDEEP_B)
subroutine layer_e_budget_get_coef(PT, PTSTEP, PIMPL, PHC, PTC, PD, PA, PB, PC, PY)