SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
prep_ver_snow.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 prep_ver_snow(TPSNOW,PZS_LS,PZS,PTG_LS,PTG,KDEEP_SOIL)
7 ! ###########################################
8 !
9 !
10 !!**** *PREP_VER_SNOW* - change in snow variables due to altitude change
11 !!
12 !! PURPOSE
13 !! -------
14 !
15 !!** METHOD
16 !! ------
17 !!
18 !! REFERENCE
19 !! ---------
20 !!
21 !!
22 !! AUTHOR
23 !! ------
24 !! V. Masson
25 !!
26 !! MODIFICATIONS
27 !! -------------
28 !! Original 01/2004
29 !! 02/2014 E. Martin, vertical correction applied to snow cover and not by layers
30 !! 09/2014 B. Decharme, Bug : Coherence between snow layer and depth
31 !!------------------------------------------------------------------
32 !
33 
35 USE modd_csts, ONLY : xtt
36 USE modd_prep, ONLY : xt_clim_grad
37 USE modd_prep_snow, ONLY : xwsnow_clim_grad
38 USE modd_surf_par, ONLY : xundef
39 !
42 USE modi_mkflag_snow
43 !
44 USE mode_snow3l
45 !
46 USE yomhook ,ONLY : lhook, dr_hook
47 USE parkind1 ,ONLY : jprb
48 !
49 IMPLICIT NONE
50 !
51 !* 0.1 declarations of arguments
52 !
53 TYPE(surf_snow), INTENT(INOUT) :: tpsnow ! snow mantel characteristics
54 REAL, DIMENSION(:), INTENT(IN) :: pzs_ls ! initial orography
55 REAL, DIMENSION(:), INTENT(IN) :: pzs ! final orography
56 REAL, DIMENSION(:,:,:),INTENT(IN),OPTIONAL:: ptg_ls ! soil temperature on initial orography
57 REAL, DIMENSION(:,:,:),INTENT(IN),OPTIONAL:: ptg ! soil temperature on final orography
58 INTEGER, INTENT(IN),OPTIONAL:: kdeep_soil ! index of deep soil temperature
59 !
60 !* 0.2 declarations of local variables
61 !
62 REAL, DIMENSION(:,:,:), ALLOCATABLE :: zwsnow_ls ! snow reservoir on initial orography
63 REAL, DIMENSION(:,:,:), ALLOCATABLE :: ztsnow_ls ! snow temperature on initial orography
64 REAL, DIMENSION(:,:,:), ALLOCATABLE :: zwsnow ! snow content on final orography
65 REAL, DIMENSION(:,:,:), ALLOCATABLE :: ztsnow ! snow temperature on final orography
66 REAL, DIMENSION(:,:,:), ALLOCATABLE :: zwsnow2 ! snow content on final orography
67 REAL, DIMENSION(:,:,:), ALLOCATABLE :: ztsnow2 ! snow temperature on final orography
68 REAL, DIMENSION(:,:,:), ALLOCATABLE :: zwliq ! snow liquid water content
69 REAL, DIMENSION(:,:), ALLOCATABLE :: zzsfreeze ! altitude where deep soil freezes
70 REAL, DIMENSION(:,:), ALLOCATABLE :: zdtot ! snow depth
71 REAL, DIMENSION(:,:,:), ALLOCATABLE :: zdzsn ! snow layer thickness
72 !
73 INTEGER :: ipatch ! number of patches
74 INTEGER :: jpatch ! loop counter on patches
75 INTEGER :: jlayer ! loop counter on snow layers
76 !
77 REAL(KIND=JPRB) :: zhook_handle
78 !
79 !-------------------------------------------------------------------------------------
80 !
81 IF (lhook) CALL dr_hook('PREP_VER_SNOW',0,zhook_handle)
82 ipatch = SIZE(tpsnow%WSNOW,3)
83 !
84 !* 1. Snow reservoir on initial orography
85 ! -----------------------------------
86 !
87 ALLOCATE(zwsnow_ls(SIZE(tpsnow%WSNOW,1),SIZE(tpsnow%WSNOW,2),ipatch))
88 zwsnow_ls(:,:,:) = tpsnow%WSNOW(:,:,:)
89 !
90 !-------------------------------------------------------------------------------------
91 !
92 !* 2. temperature of snow on initial orography
93 ! ----------------------------------------
94 !
95 ALLOCATE(ztsnow_ls(SIZE(tpsnow%WSNOW,1),SIZE(tpsnow%WSNOW,2),ipatch))
96 SELECT CASE(tpsnow%SCHEME)
97  CASE ('D95','EBA')
98  IF (present(ptg_ls)) THEN
99  DO jpatch=1,ipatch
100  ztsnow_ls(:,1,jpatch) = min(ptg_ls(:,1,jpatch),xtt)
101  END DO
102  ELSE
103  ztsnow_ls = xundef
104  END IF
105  CASE ('1-L')
106  ztsnow_ls(:,:,:) = tpsnow%T(:,:,:)
107  CASE ('3-L','CRO')
108  CALL snow_heat_to_t_wliq(tpsnow%HEAT(:,:,:),tpsnow%RHO(:,:,:),ztsnow_ls(:,:,:))
109 END SELECT
110 !
111 !-------------------------------------------------------------------------------------
112 !
113 !* 3. vertical shift of temperature
114 ! -----------------------------
115 !
116 ALLOCATE(ztsnow(SIZE(tpsnow%WSNOW,1),SIZE(tpsnow%WSNOW,2),ipatch))
117 DO jpatch=1,ipatch
118  DO jlayer=1,tpsnow%NLAYER
119  ztsnow(:,jlayer,jpatch) = ztsnow_ls(:,jlayer,jpatch) + xt_clim_grad * (pzs(:) - pzs_ls(:))
120  END DO
121 END DO
122 !
123 !-------------------------------------------------------------------------------------
124 !
125 !* 4. vertical shift of snow content where snow already exists
126 ! ------------------------------
127 !
128 !* use of climatological snow content gradient
129 !
130 ALLOCATE(zwsnow(SIZE(tpsnow%WSNOW,1),SIZE(tpsnow%WSNOW,2),ipatch))
131 !
132 zwsnow(:,:,:) = zwsnow_ls(:,:,:)
133 !
134 IF (present(ptg)) THEN
135  DO jpatch=1,ipatch
136  DO jlayer=1,tpsnow%NLAYER
137  WHERE(zwsnow_ls(:,jlayer,jpatch)>0..AND.((ptg(:,kdeep_soil,jpatch)-xtt >= 2.).OR.(pzs(:) > pzs_ls(:))))
138  zwsnow(:,jlayer,jpatch) = zwsnow_ls(:,jlayer,jpatch) + &
139  &( xwsnow_clim_grad * (pzs(:) - pzs_ls(:))/tpsnow%NLAYER)
140  zwsnow(:,jlayer,jpatch) = max(zwsnow(:,jlayer,jpatch),0.)
141  END WHERE
142  END DO
143  END DO
144 ELSE
145  DO jpatch=1,ipatch
146  DO jlayer=1,tpsnow%NLAYER
147  WHERE(zwsnow_ls(:,jlayer,jpatch)>0.)
148  zwsnow(:,jlayer,jpatch) = zwsnow_ls(:,jlayer,jpatch) + &
149  &( xwsnow_clim_grad * (pzs(:) - pzs_ls(:))/tpsnow%NLAYER)
150  zwsnow(:,jlayer,jpatch) = max(zwsnow(:,jlayer,jpatch),0.)
151  END WHERE
152  END DO
153  END DO
154 ENDIF
155 !
156 WHERE(tpsnow%WSNOW(:,:,:)/=xundef) tpsnow%WSNOW = zwsnow
157 !
158 !-------------------------------------------------------------------------------------
159 !
160 ! 5. Where snow did not exist on initial orography
161 ! ---------------------------------------------
162 !
163 !* in this case, new snow can appear only if orography differences in larger
164 ! than 1000m, and starts at an altitude where the deep soil temperature becomes negative
165 !
166 !* the same climatological gradient is used, but the value zero for the snow
167 ! content is defined as the altitude where deep soil freezes.
168 !
169 !* 5.1 Altitude where deep soil freezes (only if soil temperatures are provided)
170 ! --------------------------------
171 !
172 IF (present(ptg)) THEN
173  ALLOCATE(zzsfreeze(SIZE(tpsnow%WSNOW,1),ipatch))
174  DO jpatch=1,ipatch
175  zzsfreeze(:,jpatch) = pzs &
176  + (xtt - ptg(:,kdeep_soil,jpatch)) / xt_clim_grad
177  END DO
178 !
179 !* 5.2 Amount and Temperature of new snow (only if soil temperatures are provided)
180 ! ----------------------------------
181 !
182 !* Snow temperature is then defined as the deep soil temperature at the final
183 ! altitude.
184 !
185  ALLOCATE(zwsnow2(SIZE(tpsnow%WSNOW,1),tpsnow%NLAYER,ipatch))
186  ALLOCATE(ztsnow2(SIZE(tpsnow%WSNOW,1),tpsnow%NLAYER,ipatch))
187  DO jpatch=1,ipatch
188  DO jlayer=1,tpsnow%NLAYER
189  zwsnow2(:,jlayer,jpatch) = xwsnow_clim_grad *&
190  & (pzs(:) - zzsfreeze(:,jpatch))/tpsnow%NLAYER
191  zwsnow2(:,jlayer,jpatch) = max(zwsnow2(:,jlayer,jpatch),0.)
192  ztsnow2(:,jlayer,jpatch) = ptg(:,kdeep_soil,jpatch)
193  END DO
194  END DO
195 !
196 !* 5.3 Apply maximum between this value and the shifted one
197 ! ----------------------------------------------------
198 !
199  DO jpatch=1,ipatch
200  DO jlayer=1,tpsnow%NLAYER
201  WHERE(tpsnow%WSNOW(:,jlayer,jpatch)/=xundef .AND. zwsnow_ls(:,jlayer,jpatch)==0. &
202  .AND. (pzs(:)-pzs_ls(:))>1000. )
203  tpsnow%WSNOW(:,jlayer,jpatch) = zwsnow2(:,jlayer,jpatch)
204  ztsnow(:,jlayer,jpatch) = ztsnow2(:,jlayer,jpatch)
205  END WHERE
206  END DO
207  END DO
208 
209  DEALLOCATE(zzsfreeze)
210  DEALLOCATE(zwsnow2 )
211  DEALLOCATE(ztsnow2 )
212 END IF
213 !
214 !-------------------------------------------------------------------------------------
215 !
216 !* 6.1 Coherence between temperature and snow content
217 ! ----------------------------------------------
218 !
219 SELECT CASE(tpsnow%SCHEME)
220  CASE('1-L')
221  !* snow temperature cannot be larger than 0 C
222  tpsnow%T (:,:,:) = min( ztsnow(:,:,:), xtt )
223  CASE('3-L','CRO')
224  ALLOCATE(zwliq(SIZE(tpsnow%WSNOW,1),SIZE(tpsnow%WSNOW,2),ipatch))
225  CALL snow_t_wliq_to_heat(tpsnow%HEAT,tpsnow%RHO,ztsnow)
226  CALL snow_heat_to_t_wliq(tpsnow%HEAT,tpsnow%RHO,ztsnow,zwliq)
227  CALL snow_t_wliq_to_heat(tpsnow%HEAT,tpsnow%RHO,ztsnow,zwliq)
228  DEALLOCATE(zwliq)
229 END SELECT
230 !
231 !* 6.2 Coherence between snow layer and depth
232 ! --------------------------------------
233 !
234 SELECT CASE(tpsnow%SCHEME)
235  CASE('3-L','CRO')
236  ALLOCATE(zdtot(SIZE(tpsnow%WSNOW,1),ipatch))
237  ALLOCATE(zdzsn(SIZE(tpsnow%WSNOW,1),SIZE(tpsnow%WSNOW,2),ipatch))
238  zdtot(:,:)=0.0
239  DO jlayer=1,tpsnow%NLAYER
240  WHERE(tpsnow%WSNOW(:,jlayer,:)/=xundef.AND.tpsnow%RHO(:,jlayer,:)/=xundef)
241  zdtot(:,:)=zdtot(:,:)+tpsnow%WSNOW(:,jlayer,:)/tpsnow%RHO(:,jlayer,:)
242  ENDWHERE
243  END DO
244  DO jpatch=1,ipatch
245  CALL snow3lgrid(zdzsn(:,:,jpatch),zdtot(:,jpatch))
246  DO jlayer=1,tpsnow%NLAYER
247  WHERE(tpsnow%RHO(:,jlayer,jpatch)/=xundef.AND.zdtot(:,jpatch)>0.)
248  tpsnow%WSNOW(:,jlayer,jpatch) = tpsnow%RHO(:,jlayer,jpatch) * zdzsn(:,jlayer,jpatch)
249  ELSEWHERE(tpsnow%RHO(:,jlayer,jpatch)==xundef.OR.zdtot(:,jpatch)==0.0)
250  tpsnow%WSNOW(:,jlayer,jpatch) = 0.0
251  ELSEWHERE
252  tpsnow%WSNOW(:,jlayer,jpatch) = xundef
253  END WHERE
254  END DO
255  END DO
256  DEALLOCATE(zdtot)
257  DEALLOCATE(zdzsn)
258 END SELECT
259 !
260 !-------------------------------------------------------------------------------------
261 !
262 !* 7. Masking where there is no snow
263 ! ------------------------------
264 !
265  CALL mkflag_snow(tpsnow)
266 !
267 !-------------------------------------------------------------------------------------
268 DEALLOCATE(zwsnow_ls)
269 DEALLOCATE(ztsnow_ls)
270 DEALLOCATE(zwsnow )
271 DEALLOCATE(ztsnow )
272 IF (lhook) CALL dr_hook('PREP_VER_SNOW',1,zhook_handle)
273 !-------------------------------------------------------------------------------------
274 !
275 END SUBROUTINE prep_ver_snow
subroutine prep_ver_snow(TPSNOW, PZS_LS, PZS, PTG_LS, PTG, KDEEP_SOIL)
subroutine mkflag_snow(TPSNOW)
Definition: mkflag_snow.F90:6