SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
soilgrid.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 soilgrid(PSOILGRID, PSOILDEPTH, PDG, KWG_LAYER )
7 
8 ! ##########################################################################
9 !
10 !!**** *SOILGRID*
11 !!
12 !! PURPOSE
13 !! -------
14 !
15 ! Calculates the soil grid configuration using a reference grid
16 ! Also compute the root fraction
17 !
18 !
19 !!** METHOD
20 !! ------
21 !
22 ! Direct calculation
23 !
24 !! EXTERNAL
25 !! --------
26 !
27 ! None
28 !!
29 !! IMPLICIT ARGUMENTS
30 !! ------------------
31 !!
32 !! REFERENCE
33 !! ---------
34 !!
35 !! Noilhan and Planton (1989)
36 !! Belair (1995)
37 !! Boone (2000)
38 !! Boone et al. (2000)
39 !! Habets et al. (2003)
40 !! Decharme et al. (2011)
41 !!
42 !! AUTHOR
43 !! ------
44 !! A. Boone * Meteo-France *
45 !! new version :
46 !! B. Decharme * Meteo-France *
47 !!
48 !! MODIFICATIONS
49 !! -------------
50 !! Original 12/04/03
51 !! new version :10/08/2011
52 !! modif : 09/2012 soildepth can reach 12m (permafrost)
53 !! bug coef algo
54 !-------------------------------------------------------------------------------
55 !
56 !* 0. DECLARATIONS
57 ! ------------
58 !
59 USE modd_surf_par, ONLY : xundef, nundef
60 USE modd_isba_par, ONLY : noptimlayer, xoptimgrid
61 !
62 USE modi_abor1_sfx
63 !
64 USE yomhook ,ONLY : lhook, dr_hook
65 USE parkind1 ,ONLY : jprb
66 !
67 IMPLICIT NONE
68 !
69 !* 0.1 declarations of arguments
70 !
71 REAL, DIMENSION(:), INTENT(IN) :: psoilgrid ! reference soil grid (m)
72 REAL, DIMENSION(:,:), INTENT(IN) :: psoildepth ! total soil depth (m)
73 REAL, DIMENSION(:,:,:), INTENT(OUT) :: pdg ! depth of base of soil layers (m)
74 INTEGER, DIMENSION(:,:), INTENT(OUT) :: kwg_layer ! last layers for soil moisture
75 !
76 !* 0.2 declarations of local variables
77 !
78 REAL,DIMENSION(SIZE(PDG,1),SIZE(PDG,3)) :: zref
79 !
80 REAL :: zwork
81 !
82 INTEGER :: ini,inl,ipatch
83 INTEGER :: jj,jl,jpatch
84 !
85 LOGICAL :: loptimgrid
86 !
87 REAL(KIND=JPRB) :: zhook_handle
88 !-------------------------------------------------------------------------------
89 ! 0. Initialization
90 ! --------------
91 !
92 IF (lhook) CALL dr_hook('SOILGRID',0,zhook_handle)
93 !
94 ini = SIZE(pdg,1)
95 inl = SIZE(pdg,2)
96 ipatch = SIZE(pdg,3)
97 !
98 kwg_layer(:,:) = 0
99 zref(:,:) = xundef
100 !
101 !-------------------------------------------------------------------------------
102 !
103 !* 1. Grid configuration
104 ! ------------------
105 !
106 !* 1.1 Check consistency
107 ! -----------------
108 !
109 loptimgrid=.false.
110 IF(inl==noptimlayer) THEN
111  IF( all(psoilgrid(1:inl)==xoptimgrid(1:noptimlayer)) ) loptimgrid=.true.
112 ENDIF
113 !
114 !* 1.2 Assign soil layer depths if ECOCLIMAP
115 ! -------------------------------------
116 !
117 IF(loptimgrid)THEN
118  !
119  !Optimized ECOCLIMAP soil grid
120  CALL optimsoilgrid
121  !
122 ELSE
123  !
124  WHERE(psoildepth(:,:)/=xundef)
125  pdg(:,1,:)=min(0.01,psoilgrid(1))
126  ELSEWHERE
127  pdg(:,1,:)=xundef
128  ENDWHERE
129  !
130  DO jpatch=1,ipatch
131  DO jj=1,ini
132  !
133  IF( psoildepth(jj,jpatch)==xundef )THEN
134  !
135  pdg(jj,:,jpatch) = xundef
136  kwg_layer(jj, jpatch) = nundef
137  !
138  ELSE
139  !
140  DO jl=2,inl
141  !
142  pdg(jj,jl,jpatch) = psoilgrid(jl)
143  !
144  IF ( psoilgrid(jl)-psoilgrid(jl-1)<=0.3 ) THEN
145  zwork = abs(psoilgrid(jl)-psoildepth(jj,jpatch))
146  IF(zwork<=zref(jj,jpatch))THEN
147  kwg_layer(jj,jpatch) = jl
148  zref(jj,jpatch) = zwork
149  ENDIF
150  ELSEIF(psoildepth(jj,jpatch)>=(psoilgrid(jl)*0.3+psoilgrid(jl-1)*0.7))THEN
151  kwg_layer(jj,jpatch) = jl
152  ENDIF
153  ENDDO
154  !
155  ENDIF
156  ENDDO
157  ENDDO
158  !
159 ENDIF
160 !
161 IF(any(kwg_layer(:,:)==0))THEN
162  CALL abor1_sfx('SOILGRID: WITH CISBA=DIF NWG_LAYER MUST BE DEFINED FOR EACH POINT')
163 ENDIF
164 !
165 IF (lhook) CALL dr_hook('SOILGRID',1,zhook_handle)
166 !
167 !-------------------------------------------------------------------------------
168  CONTAINS
169 !-------------------------------------------------------------------------------
170 !
171 SUBROUTINE optimsoilgrid
172 !
173 USE modd_reprod_oper, ONLY : cdgdif
174 !
175 IMPLICIT NONE
176 !
177 ! declarations of local variables
178 !
179 INTEGER, PARAMETER :: ndlim = 13
180 !
181 REAL, DIMENSION(NDLIM), PARAMETER :: zdlim = &
182  (/1.25,1.50,1.75,2.00,2.25,2.50,2.75,3.00,3.50,4.00,4.50,5.00,5.50/)
183 !
184 REAL,DIMENSION(SIZE(PDG,1),SIZE(PDG,3)) :: zdg_water
185 !
186 LOGICAL :: lwork
187 REAL(KIND=JPRB) :: zhook_handle
188 !
189 !-------------------------------------------------------------------------------
190 ! init
191 !
192 IF (lhook) CALL dr_hook('SOILGRID:OPTIMSOILGRID',0,zhook_handle)
193 !
194 zdg_water(:,:) = xundef
195 !
196 !-------------------------------------------------------------------------------
197 !a. Arranged depth
198 !
199 IF(cdgdif=='ROOT')THEN
200 !
201  DO jpatch=1,ipatch
202  DO jj=1,ini
203  IF(psoildepth(jj,jpatch)<=1.1)THEN
204  zdg_water(jj,jpatch)=min(1.0,psoildepth(jj,jpatch))
205  ELSEIF(psoildepth(jj,jpatch)>1.1.AND.psoildepth(jj,jpatch)<=1.25)THEN
206  zdg_water(jj,jpatch)=1.25
207  ELSEIF(psoildepth(jj,jpatch)>5.50.AND.psoildepth(jj,jpatch)<=8.00)THEN
208  zdg_water(jj,jpatch)=8.00
209  ELSEIF(psoildepth(jj,jpatch)>8.00.AND.psoildepth(jj,jpatch)<xundef)THEN
210  zdg_water(jj,jpatch)=12.00 ! Permafrost case
211  ELSE
212  DO jl=1,ndlim-1
213  IF(psoildepth(jj,jpatch)>zdlim(jl).AND.psoildepth(jj,jpatch)<=zdlim(jl+1))THEN
214  zdg_water(jj,jpatch)=merge(zdlim(jl),zdlim(jl+1),psoildepth(jj,jpatch)<(0.8*zdlim(jl)+0.2*zdlim(jl+1)))
215  ENDIF
216  ENDDO
217  ENDIF
218  ENDDO
219  ENDDO
220 !
221 ELSE
222 !
223  DO jpatch=1,ipatch
224  DO jj=1,ini
225  IF(psoildepth(jj,jpatch)<1.25)THEN
226  zdg_water(jj,jpatch)=min(1.0,psoildepth(jj,jpatch))
227  ELSEIF(psoildepth(jj,jpatch)>=5.50.AND.psoildepth(jj,jpatch)<6.50)THEN
228  zdg_water(jj,jpatch)=5.50
229  ELSEIF(psoildepth(jj,jpatch)>=6.50.AND.psoildepth(jj,jpatch)<10.50)THEN
230  zdg_water(jj,jpatch)=8.00
231  ELSEIF(psoildepth(jj,jpatch)>=10.50.AND.psoildepth(jj,jpatch)<xundef)THEN
232  zdg_water(jj,jpatch)=12.00 ! Permafrost case
233  ELSE
234  DO jl=1,ndlim-1
235  IF(psoildepth(jj,jpatch)>=zdlim(jl).AND.psoildepth(jj,jpatch)<zdlim(jl+1))THEN
236  zdg_water(jj,jpatch)=merge(zdlim(jl),zdlim(jl+1),psoildepth(jj,jpatch)<(0.4*zdlim(jl)+0.6*zdlim(jl+1)))
237  ENDIF
238  ENDDO
239  ENDIF
240  ENDDO
241  ENDDO
242 !
243 ENDIF
244 !
245 !-------------------------------------------------------------------------------
246 !b. General cases
247 !
248 DO jpatch=1,ipatch
249  DO jj=1,ini
250  !
251  IF(psoildepth(jj,jpatch)==xundef)THEN
252  !
253  pdg(jj,:,jpatch) = xundef
254  kwg_layer(jj, jpatch) = nundef
255  !
256  ELSE
257  !
258  pdg(jj,:,jpatch) = psoilgrid(:)
259  !
260  lwork=(zdg_water(jj,jpatch)<=1.0.OR.&
261  zdg_water(jj,jpatch)==1.5.OR.&
262  zdg_water(jj,jpatch)==2.0.OR.&
263  zdg_water(jj,jpatch)==3.0.OR.&
264  zdg_water(jj,jpatch)==5.0.OR.&
265  zdg_water(jj,jpatch)==8.0.OR.&
266  zdg_water(jj,jpatch)==12.0 )
267  !
268  IF (lwork) THEN
269  DO jl=2,inl
270  zwork = abs(psoilgrid(jl)-zdg_water(jj,jpatch))
271  IF(zwork<=zref(jj,jpatch))THEN
272  kwg_layer(jj,jpatch)=jl
273  zref(jj,jpatch)=zwork
274  ENDIF
275  ENDDO
276  ENDIF
277  !
278  ENDIF
279  !
280  ENDDO
281 ENDDO
282 !
283 !-------------------------------------------------------------------------------
284 !c. Particular cases
285 !
286 WHERE (zdg_water(:,:)==1.25)
287  kwg_layer(:,:) = 9
288  pdg(:,9,:) = zdg_water(:,:)
289 ELSEWHERE (zdg_water(:,:)==1.75 .OR. zdg_water(:,:)==2.25)
290  kwg_layer(:,:) = 10
291  pdg(:,10,:) = zdg_water(:,:)
292  WHERE (zdg_water(:,:)==1.75) pdg(:,9,:) = 1.25
293 ELSEWHERE (zdg_water(:,:)==2.50 .OR. zdg_water(:,:)==2.75 .OR. zdg_water(:,:)==3.50)
294  kwg_layer(:,:) = 11
295  pdg(:,11,:) = zdg_water(:,:)
296 ELSEWHERE (zdg_water(:,:)==4.00 .OR. zdg_water(:,:)==4.50 .OR. zdg_water(:,:)==5.50)
297  kwg_layer(:,:) = 12
298  pdg(:,12,:) = zdg_water(:,:)
299 ENDWHERE
300 !
301 IF (lhook) CALL dr_hook('SOILGRID:OPTIMSOILGRID',1,zhook_handle)
302 !
303 END SUBROUTINE optimsoilgrid
304 !
305 !-------------------------------------------------------------------------------
306 END SUBROUTINE soilgrid
subroutine soilgrid(PSOILGRID, PSOILDEPTH, PDG, KWG_LAYER)
Definition: soilgrid.F90:6
subroutine optimsoilgrid
Definition: soilgrid.F90:171
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6