SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
thermal_layers_conf.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 thermal_layers_conf(HTYPE,PHC,PTC,PD,PHC_OUT,PTC_OUT,PD_OUT)
7 ! ######################################################################
8 !
9 !!**** *THERMAL_LAYERS_CONF*
10 !!
11 !! PURPOSE
12 !! -------
13 ! Adjust the thermal characteristics of the layers in road, wall, roof or
14 ! floor depending on the number of layers that the user wants to use during
15 ! the simulations.
16 ! Initial data are prescribed depending on user preference.
17 ! They have to be averaged on the layers use in the simulation
18 !
19 !!
20 !!** METHOD
21 !! ------
22 !!
23 !! EXTERNAL
24 !! --------
25 !!
26 !! IMPLICIT ARGUMENTS
27 !! ------------------
28 !!
29 !! REFERENCE
30 !! ---------
31 !!
32 !! AUTHOR
33 !! ------
34 !! V. Masson *Meteo France*
35 !!
36 !! MODIFICATIONS
37 !! -------------
38 !! Original 05/2012
39 !-------------------------------------------------------------------------------
40 !
41 !* 0. DECLARATIONS
42 ! ------------
43 !
44 USE modd_surf_par, ONLY : xundef
45 USE modi_tebgrid
46 !
47 IMPLICIT NONE
48 !
49 !* 0.1 Declarations of arguments
50 ! -------------------------
51 !
52  CHARACTER(LEN=5), INTENT(IN) :: htype ! type of surface
53 REAL, DIMENSION(:,:), INTENT(IN) :: phc ! input Heat Capacity
54 REAL, DIMENSION(:,:), INTENT(IN) :: ptc ! input Thermal conductivity
55 REAL, DIMENSION(:,:), INTENT(IN) :: pd ! input Layer Thickness
56 REAL, DIMENSION(:,:), INTENT(OUT) :: phc_out ! output Heat Capacity
57 REAL, DIMENSION(:,:), INTENT(OUT) :: ptc_out ! output Thermal conductivity
58 REAL, DIMENSION(:,:), INTENT(OUT) :: pd_out ! output Layer Thickness
59 !
60 !* 0.2 Declarations of local variables
61 !
62 REAL, DIMENSION(SIZE(PHC,1)) :: zd_tot ! Total depth
63 REAL, DIMENSION(SIZE(PHC,1)) :: zd_half ! Depth of the half of the total surface
64 ! ! (excluding central layer in case
65 ! ! of odd number of layers)
66 REAL, DIMENSION(SIZE(PHC,1)) :: zd_mid ! Thickness of the layer in the middle
67 ! ! in case of odd number of layers
68 REAL, DIMENSION(SIZE(PHC,1),0:SIZE(PHC ,2))::zd_in ! Depth from the surface
69 ! ! to the layer bottom
70 REAL, DIMENSION(SIZE(PHC,1),0:SIZE(PHC_OUT,2))::zd_out ! Depth from the surface
71 ! ! to the layer bottom
72 REAL, DIMENSION(SIZE(PHC,1),SIZE(PHC,2)) :: zw ! 1/TC
73 REAL, DIMENSION(SIZE(PHC,1),SIZE(PHC_OUT,2)) :: zw_out ! 1/TC
74 INTEGER :: iin ! Number of layer in input data
75 INTEGER :: iout ! Number of layer in output fields
76 INTEGER :: jin ! Loop counter on input layers
77 INTEGER :: jout ! Loop counter on output layers
78 !
79 REAL, PARAMETER :: zd_g1 = 0.001 ! uppermost soil layer
80 ! ! thickness/depth ( m)
81 ! ! Can not be too thin as
82 ! ! then definition of soil
83 ! ! properties (i.e. phyiscal
84 ! ! representation of) and
85 ! ! accuarcy of
86 ! ! numerical solution come
87 ! ! into question. If it is too
88 ! ! thick, then resolution of
89 ! ! diurnal cycle not as valid.
90 !-------------------------------------------------------------------------------
91 !
92 iin = SIZE(phc,2)
93 iout= SIZE(phc_out,2)
94 !
95 !-------------------------------------------------------------------------------
96 !
97 !* Depths for the computational grid
98 !
99 !* total depth:
100 !
101 !
102 zd_in(:,0) = 0.
103 DO jin=1,iin
104  zd_in(:,jin) = zd_in(:,jin-1) + pd(:,jin)
105 END DO
106 zd_tot(:) = zd_in(:,iin)
107 !
108 !* surface like road or floor (thin grid at the surface, coarse at the bottom)
109 !
110 IF (htype=='ROAD ' .OR. htype=='FLOOR') THEN
111  zd_out(:,0) = 0.
112  CALL tebgrid(zd_tot,zd_out(:,1:),zd_g1)
113  pd_out(:,1) = zd_out(:,1)
114  DO jout=2,iout
115  pd_out(:,jout) = zd_out(:,jout) - zd_out(:,jout-1) ! Depths => Thickness of layer
116  END DO
117 ELSE
118 !
119 !* surface like roof or wall (thin grid on both sides, coarse in the middle)
120 !
121  IF (mod(iout,2)==0) THEN ! even number of output layers
122  zd_half(:) = zd_tot(:) / 2.
123  ELSE ! odd number of output layers
124  zd_mid(:) = 2. * zd_tot(:) / iout ! middle layer is arbitrarily fixed
125  IF (iout==3) zd_mid=max(zd_mid,zd_tot-2.*zd_g1) ! to impose layers equal
126  ! to ZD_G1 on both sides
127  zd_half(:) = (zd_tot(:)-zd_mid(:)) / 2.
128  pd_out(:,iout/2+1) = zd_mid(:)
129  END IF
130  zd_out(:,0) = 0.
131  CALL tebgrid(zd_half,zd_out(:,1:iout/2),zd_g1)
132  pd_out(:,1) = zd_out(:,1)
133  DO jout=2,iout/2
134  pd_out(:,jout) = zd_out(:,jout) - zd_out(:,jout-1) ! Depths => Thickness of layer
135  END DO
136  DO jout=1,iout/2
137  pd_out(:,iout+1-jout) = pd_out(:,jout)
138  END DO
139  !* recomputes Depths for further averagings
140  DO jout=2,iout
141  zd_out(:,jout) = zd_out(:,jout-1) + pd_out(:,jout)
142  END DO
143 
144 END IF
145 !
146 DO jout=1,iout
147  WHERE (pd(:,1)==xundef) pd_out(:,jout) = xundef
148 END DO
149 !-------------------------------------------------------------------------------
150 !
151 !* Averaging of the Heat Capacity and the Thermal conductivity
152 !
153 zw=1./ptc(:,:)
154  CALL av_thermal_data(phc,zw,phc_out,zw_out)
155 ptc_out=xundef
156 WHERE (zw_out/=xundef) ptc_out=1./zw_out
157 !
158 !-------------------------------------------------------------------------------
159  CONTAINS
160 !-------------------------------------------------------------------------------
161 SUBROUTINE av_thermal_data(PF1,PF2,PF1_OUT,PF2_OUT)
162 REAL, DIMENSION(:,:), INTENT(IN) :: pf1
163 REAL, DIMENSION(:,:), INTENT(IN) :: pf2
164 REAL, DIMENSION(:,:), INTENT(OUT) :: pf1_out
165 REAL, DIMENSION(:,:), INTENT(OUT) :: pf2_out
166 !
167 REAL :: zf1! ponderated field
168 REAL :: zf2! ponderated field
169 REAL :: zs ! sum of weights
170 REAL :: zc ! coefficient of ponderation
171 REAL :: zd_lim ! limit of previous layer that has been treated
172 !
173 INTEGER :: jl ! loop counter on spatial points
174 REAL :: zeps=1.e-6
175 !
176 DO jl=1,SIZE(pf1,1)
177  IF (pd(jl,1)==xundef) THEN
178  pf1_out(jl,:) = xundef
179  pf2_out(jl,:) = xundef
180  cycle
181  END IF
182  !
183  zf1 = 0.
184  zf2 = 0.
185  zs = 0.
186  jin = 1
187  jout= 1
188  zd_lim = 0.
189  DO
190  IF (jout>iout) EXIT
191  !
192  IF (zd_in(jl,jin)< zd_out(jl,jout)-zeps) THEN
193 ! ZC = ZD_IN(JL,JIN) - MAX(ZD_IN(JL,JIN-1),ZD_OUT(JL,JOUT-1))
194  zc = zd_in(jl,jin) - zd_lim
195  zf1 = zf1 + zc * pf1(jl,jin)
196  zf2 = zf2 + zc * pf2(jl,jin)
197  zs = zs + zc
198  zd_lim = zd_in(jl,jin)
199  !
200  jin=jin+1
201  ELSE
202 ! ZC = ZD_OUT(JL,JOUT) - MAX(ZD_IN(JL,JIN-1),ZD_OUT(JL,JOUT-1))
203  zc = zd_out(jl,jout) - zd_lim
204  zf1 = zf1 + zc * pf1(jl,jin)
205  zf2 = zf2 + zc * pf2(jl,jin)
206  zs = zs + zc
207  pf1_out(jl,jout) = zf1/zs
208  pf2_out(jl,jout) = zf2/zs
209  zd_lim = zd_out(jl,jout)
210  !
211  jout = jout+1
212  zf1 = 0.
213  zf2 = 0.
214  zs = 0.
215  END IF
216  END DO
217 END DO
218 !
219 END SUBROUTINE
220 !
221 END SUBROUTINE thermal_layers_conf
subroutine av_thermal_data(PF1, PF2, PF1_OUT, PF2_OUT)
subroutine thermal_layers_conf(HTYPE, PHC, PTC, PD, PHC_OUT, PTC_OUT, PD_OUT)
subroutine tebgrid(PSOILDEPTH, PD_G, PD_G1)
Definition: tebgrid.F90:6