SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
dif_layer.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 dif_layer(KLU, KGROUND_LAYER, KPATCH, KSIZE_NATURE_P, &
7  ppatch, pdg, pdroot, pdg2, prootfrac, &
8  kwg_layer, pdzg, pdzdif, psoilwght, &
9  prunoffd, klayer_hort, klayer_dun )
10 !#############################################################
11 !
12 !!**** *DIF_LAYER_n* - routine to initialize dif numbers of layers
13 !!
14 !! PURPOSE
15 !! -------
16 !!
17 !!** METHOD
18 !! ------
19 !!
20 !! EXTERNAL
21 !! --------
22 !!
23 !!
24 !! IMPLICIT ARGUMENTS
25 !! ------------------
26 !!
27 !! REFERENCE
28 !! ---------
29 !!
30 !!
31 !! AUTHOR
32 !! ------
33 !! S. Faroux
34 !!
35 !! MODIFICATIONS
36 !! -------------
37 !! Original 02/2012!!
38 !-------------------------------------------------------------------------------
39 !
40 !* 0. DECLARATIONS
41 ! ------------
42 !
43 USE modd_surf_par, ONLY : xundef, nundef
44 USE modd_sgh_par, ONLY : xhort_depth
45 !
46 USE modi_abor1_sfx
47 !
48 USE yomhook ,ONLY : lhook, dr_hook
49 USE parkind1 ,ONLY : jprb
50 !
51 IMPLICIT NONE
52 !
53 !* 0.1 Declarations of arguments
54 ! -------------------------
55 !
56 INTEGER, INTENT(IN) :: klu
57 INTEGER, INTENT(IN) :: kground_layer
58 INTEGER, INTENT(IN) :: kpatch
59 INTEGER, DIMENSION(:), INTENT(IN) :: ksize_nature_p
60 REAL, DIMENSION(:,:), INTENT(IN) :: ppatch
61 REAL, DIMENSION(:,:,:), INTENT(IN) :: pdg
62 REAL, DIMENSION(:,:), INTENT(IN) :: pdroot
63 REAL, DIMENSION(:,:), INTENT(IN) :: pdg2
64 REAL, DIMENSION(:,:,:), INTENT(IN) :: prootfrac
65 INTEGER, DIMENSION(:,:),INTENT(IN) :: kwg_layer
66 REAL, DIMENSION(:,:,:), INTENT(OUT) :: pdzg
67 REAL, DIMENSION(:,:,:), INTENT(OUT) :: pdzdif
68 REAL, DIMENSION(:,:,:), INTENT(OUT) :: psoilwght
69 REAL, DIMENSION(:,:), INTENT(OUT) :: prunoffd
70 INTEGER, INTENT(OUT) :: klayer_hort
71 INTEGER, INTENT(OUT) :: klayer_dun
72 !
73 !* 0.2 Declarations of local variables
74 ! -------------------------------
75 !
76 REAL, DIMENSION(KLU) :: zwork
77 INTEGER, DIMENSION(KLU,KPATCH) :: iwork
78 INTEGER :: jlayer, jpatch, jilu, idepth
79 !
80 REAL(KIND=JPRB) :: zhook_handle
81 !
82 !-------------------------------------------------------------------------------
83 !
84 ! Initialisation for IO
85 !
86 IF (lhook) CALL dr_hook('DIF_LAYER',0,zhook_handle)
87 !
88 DO jlayer = 1, kground_layer
89  IF (any((prootfrac(:,jlayer,:)<0. .OR. prootfrac(:,jlayer,:)>1.) .AND. ppatch(:,:).NE.0.)) &
90  CALL abor1_sfx('DIF_LAYER: WITH CISBA=DIF ROOTFRAC MUST BE DEFINED')
91 ENDDO
92 !
93 pdzg(:,:,:) = xundef
94 pdzdif(:,:,:) = xundef
95 psoilwght(:,:,:) = 0.0
96 !
97 DO jpatch=1,kpatch
98 !
99  IF (ksize_nature_p(jpatch) == 0 ) cycle
100 !
101 !* soil layers thicknesses
102  pdzg(:,1,jpatch) = pdg(:,1,jpatch)
103  DO jlayer=2,kground_layer
104  DO jilu=1,klu
105  pdzg(jilu,jlayer,jpatch) = pdg(jilu,jlayer,jpatch) - pdg(jilu,jlayer-1,jpatch)
106  ENDDO
107  ENDDO
108 !
109 !* distance between consecuative layer mid-points
110  DO jlayer=1,kground_layer
111  DO jilu=1,klu
112  IF(jlayer<kground_layer)THEN
113  pdzdif(jilu,jlayer,jpatch)=0.5*(pdzg(jilu,jlayer,jpatch)+pdzg(jilu,jlayer+1,jpatch))
114  ELSE
115  pdzdif(jilu,jlayer,jpatch)=0.5*pdzg(jilu,jlayer,jpatch)
116  ENDIF
117  ENDDO
118  ENDDO
119 !
120 ENDDO
121 !
122 ! Horton runoff parameter
123 !
124 iwork(:,:) = kwg_layer(:,:)
125 !
126 DO jpatch=1,kpatch
127 !
128  IF( ksize_nature_p(jpatch) == 0 ) cycle
129 !
130  DO jilu=1,klu
131  idepth = kwg_layer(jilu,jpatch)
132  IF (idepth==nundef) idepth = kground_layer
133  DO jlayer=1,idepth-1
134  IF(pdg(jilu,jlayer,jpatch)<xhort_depth) iwork(jilu,jpatch)=jlayer+1
135  ENDDO
136  ENDDO
137 !
138 END DO
139 !
140 klayer_hort=maxval(iwork(:,:),iwork(:,:)/=nundef)
141 !
142 ! Dunne runoff parameter
143 !
144 iwork(:,:)=kwg_layer(:,:)
145 !
146 DO jpatch=1,kpatch
147 !
148  IF (ksize_nature_p(jpatch) == 0 ) cycle
149 !
150  DO jilu=1,klu
151  IF(ppatch(jilu,jpatch)>0.0)THEN
152  idepth = kwg_layer(jilu,jpatch)
153  IF(pdroot(jilu,jpatch)>0.0.AND.pdroot(jilu,jpatch)/=xundef)THEN
154  prunoffd(jilu,jpatch) = pdg(jilu,1,jpatch)
155  DO jlayer=1,idepth-1
156  IF(prootfrac(jilu,jlayer,jpatch)<0.90)THEN
157  prunoffd(jilu,jpatch) = pdg(jilu,jlayer+1,jpatch)
158  ENDIF
159  ENDDO
160  ELSE
161  prunoffd(jilu,jpatch) = min(0.6,pdg2(jilu,jpatch))
162  ENDIF
163  ENDIF
164  ENDDO
165 !
166  zwork(:) = 0.0
167  DO jlayer=1,kground_layer
168  DO jilu=1,klu
169  IF(ppatch(jilu,jpatch)>0.0)THEN
170  idepth=kwg_layer(jilu,jpatch)
171  IF(jlayer<=idepth)THEN
172  zwork(jilu ) = zwork(jilu) + pdzg(jilu,jlayer,jpatch)
173  psoilwght(jilu,jlayer,jpatch) = min(pdzg(jilu,jlayer,jpatch), &
174  max(0.0,prunoffd(jilu,jpatch)-zwork(jilu)+pdzg(jilu,jlayer,jpatch)))
175  ENDIF
176  IF(pdg(jilu,jlayer,jpatch)<prunoffd(jilu,jpatch))THEN
177  iwork(jilu,jpatch)=jlayer+1
178  ENDIF
179  ENDIF
180  ENDDO
181  ENDDO
182 !
183 END DO
184 !
185 klayer_dun=maxval(iwork(:,:),iwork(:,:)/=nundef)
186 !
187 IF (lhook) CALL dr_hook('DIF_LAYER',1,zhook_handle)
188 !
189 END SUBROUTINE dif_layer
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine dif_layer(KLU, KGROUND_LAYER, KPATCH, KSIZE_NATURE_P, PPATCH, PDG, PDROOT, PDG2, PROOTFRAC, KWG_LAYER, PDZG, PDZDIF, PSOILWGHT, PRUNOFFD, KLAYER_HORT, KLAYER_DUN)
Definition: dif_layer.F90:6