SURFEX v8.1
General documentation of Surfex
budget_coupl_rout.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 ! ##########################
7  SUBROUTINE budget_coupl_rout (DE, DEC, DC, DMI, IO, NP, NPE, U, KNI, KFORC_STEP)
8 ! ##########################
9 !
10 !!
11 !! PURPOSE
12 !! -------
13 !
14 !
15 !!** METHOD
16 !! ------
17 !
18 !! EXTERNAL
19 !! --------
20 !!
21 !! none
22 !!
23 !! IMPLICIT ARGUMENTS
24 !! ------------------
25 !!
26 !! REFERENCE
27 !! ---------
28 !!
29 !! AUTHOR
30 !! ------
31 !!
32 !! L. Bouilloud & B. Vincendon * Meteo-France *
33 !!
34 !! MODIFICATIONS
35 !! -------------
36 !!
37 !! Original 03/2008
38 !! 03/2014: Modif BV : add more variables
39 !-------------------------------------------------------------------------------
40 !
41 !* 0. DECLARATIONS
42 ! ------------
43 !
44 USE modd_diag_n, ONLY : diag_t
48 USE modd_isba_n, ONLY : isba_np_t, isba_npe_t
49 USE modd_surf_atm_n, ONLY : surf_atm_t
50 !
51 USE modd_budget_coupl_rout ! contains all useful variables XB_*
52 !
55 
56 !
57 USE modd_surf_par
58 USE modd_csts, ONLY : xrholw
59 !
60 USE modd_forc_atm, ONLY : xsnow ,&! snow precipitation (kg/m2/s)
61  xrain ! liquid precipitation (kg/m2/s)
62 !
65 USE modi_avg_patch_wg
66 USE modi_dg_dfto3l
67 !USE MODI_WRITE_DISCHARGE_FILE_PRTEST
68 !
69 USE yomhook ,ONLY : lhook, dr_hook
70 USE parkind1 ,ONLY : jprb
71 !
72 IMPLICIT NONE
73 !
74 !* 0.1 declarations of arguments
75 !
76 TYPE(diag_t), INTENT(INOUT) :: DC
77 TYPE(diag_evap_isba_t), INTENT(INOUT) :: DE
78 TYPE(diag_evap_isba_t), INTENT(INOUT) :: DEC
79 TYPE(diag_misc_isba_t), INTENT(INOUT) :: DMI
80 TYPE(isba_options_t), INTENT(INOUT) :: IO
81 TYPE(isba_np_t), INTENT(INOUT) :: NP
82 TYPE(isba_npe_t), INTENt(INOUT) :: NPE
83 TYPE(surf_atm_t), INTENT(INOUT) :: U
84 !
85 INTEGER, INTENT(IN) :: KNI ! expected physical size of full surface array
86 INTEGER, INTENT(IN) :: KFORC_STEP ! time step
87 !
88 !* 0.2 declarations of local variables
89 REAL, DIMENSION(U%NSIZE_NATURE) :: ZINTER
90 REAL :: ZFACT0, ZFACT1, ZFACT2
91 INTEGER :: JMESH,JCAT
92 REAL, DIMENSION(U%NSIZE_NATURE,3) :: ZWG_3L,ZWGI_3L,ZDG_3L
93 REAL, DIMENSION(KNI) :: ZB_DWGTOT,ZB_DWGITOT,ZB_DSWETOT,ZB_DWR,ZB_WATBUD
94 !
95 REAL(KIND=JPRB) :: ZHOOK_HANDLE
96 !-------------------------------------------------------------------------------
97 IF (lhook) CALL dr_hook('BUDGET_COUPL_ROUT',0,zhook_handle)
98 !
99 !* 1. Budget computation:
100 ! ---------------
101 IF (io%CISBA=='DIF') THEN
102  CALL dg_dfto3l(io, np, zdg_3l)
103  zwg_3l(:,2)=dmi%XFRD2_TWG(:)
104  zwg_3l(:,3)=dmi%XFRD3_TWG(:)
105  zwgi_3l(:,2)=dmi%XFRD2_TWGI(:)
106  zwgi_3l(:,3)=dmi%XFRD3_TWGI(:)
107 
108 ELSEIF (io%CISBA=='3-L') THEN
109  CALL avg_patch_wg(io, np, npe, zwg_3l, zwgi_3l, zdg_3l)
110 ENDIF
111 !
112 CALL UNPACK_SAME_RANK(U%NR_NATURE,DE%XRAINFALL(:), XB_RAIN)
113 CALL UNPACK_SAME_RANK(U%NR_NATURE,DE%XSNOWFALL(:), XB_SNOW)
114 !
115 CALL UNPACK_SAME_RANK(U%NR_NATURE,DE%XDWR, ZB_DWR)
116 CALL UNPACK_SAME_RANK(U%NR_NATURE,DC%XEVAP, XB_EVAP)
117 !
118 CALL UNPACK_SAME_RANK(U%NR_NATURE,DEC%XRUNOFF,XB_RUNOFF_ISBA)
119 CALL UNPACK_SAME_RANK(U%NR_NATURE,DEC%XHORT,XB_HORTON)
120 CALL UNPACK_SAME_RANK(U%NR_NATURE,DE%XWATBUD, ZB_WATBUD)
122 CALL UNPACK_SAME_RANK(U%NR_NATURE,DEC%XDRAIN, XB_DRAIN)
123 !
124 CALL UNPACK_SAME_RANK(U%NR_NATURE,ZWG_3L(:,2) ,XB_WG2)
125 CALL UNPACK_SAME_RANK(U%NR_NATURE,ZWG_3L(:,3) ,XB_WG3)
126 WHERE ( xb_wg2/=xundef .AND. xb_dg2/=xundef .AND. xb_wg3/=xundef .AND. xb_dg3/=xundef )
127  xb_wgtot(:) = xb_wg2(:)*xb_dg2(:) + xb_wg3(:)*(xb_dg3(:)-xb_dg2(:)) !m3/m2
128 ELSEWHERE
129  xb_wgtot(:) = xundef
130 ENDWHERE
131 !
132 CALL UNPACK_SAME_RANK(U%NR_NATURE,ZWGI_3L(:,2) ,XB_WGI2)
133 CALL UNPACK_SAME_RANK(U%NR_NATURE,ZWGI_3L(:,3) ,XB_WGI3)
134 WHERE ( xb_wgi2/=xundef .AND. xb_dg2/=xundef .AND. xb_wgi3/=xundef .AND. xb_dg3/=xundef )
135  xb_wgitot(:) = xb_wgi2(:)*xb_dg2(:) + xb_wgi3(:)*(xb_dg3(:)-xb_dg2(:)) !m3/m2
136 ELSEWHERE
137  xb_wgitot(:) = xundef
138 ENDWHERE
139 !
140 CALL UNPACK_SAME_RANK(NP%AL(1)%NR_P,NPE%AL(1)%TSNOW%WSNOW(:,1),ZINTER)
141 CALL UNPACK_SAME_RANK(U%NR_NATURE,ZINTER,XB_SWE1)
142 !
143 CALL UNPACK_SAME_RANK(NP%AL(1)%NR_P,NPE%AL(1)%TSNOW%WSNOW(:,2),ZINTER)
144 CALL UNPACK_SAME_RANK(U%NR_NATURE,ZINTER,XB_SWE2)
145 !
146 CALL UNPACK_SAME_RANK(NP%AL(1)%NR_P,NPE%AL(1)%TSNOW%WSNOW(:,3),ZINTER)
147 CALL UNPACK_SAME_RANK(U%NR_NATURE,ZINTER,XB_SWE3)
148 !
149 xb_swetot(:) = xb_swe1(:)+xb_swe2(:)+xb_swe3(:)
150 !
151 DO jcat=1,nncat
152  xb_qtot(jcat) = sum(xqtot(jcat,1:kforc_step))
153  xb_qrun(jcat) = sum(xqb_run(jcat,1:kforc_step))
154  xb_qdr(jcat) = sum(xqb_dr(jcat,1:kforc_step))
155 ENDDO
156 !
157 DO jcat=1,nncat
158  !
159  DO jmesh=1,kni
160  !
161  IF ( xb_dg2(jmesh)/=xundef ) THEN
162 !! Water going in the system
163  zfact0 = xb_abv_bymesh(jmesh,jcat) * xb_mesh_size(jmesh)
164  zfact1 = zfact0 / xrholw
165  zfact2 = nnb_topd * zfact1
166  !ZFACT2 = XTOPD_STEP * ZFACT1
167  !
168 !! variable =1 : Rain
169  xb_var_bv(kforc_step,jcat,1) = xb_var_bv(kforc_step,jcat,1) + xb_rain(jmesh) * zfact2
170 !! variable =2 : Snow
171  xb_var_bv(kforc_step,jcat,2) = xb_var_bv(kforc_step,jcat,2) + xb_snow(jmesh) * zfact2
172 !! Water going out of the system
173 !! variable =3 : Incerception
174  xb_var_bv(kforc_step,jcat,3) = xb_var_bv(kforc_step,jcat,3) + zb_dwr(jmesh) * zfact2
175 !! variable =4 : Evaporation
176  xb_var_bv(kforc_step,jcat,4) = xb_var_bv(kforc_step,jcat,4) + (xb_evap(jmesh)-xb_evapm(jmesh)) * zfact1
177 !! variable =5 : Runoff
178  xb_var_bv(kforc_step,jcat,5) = xb_var_bv(kforc_step,jcat,5) + (xb_runoff_topd(jmesh)-xb_runoff_topdm(jmesh)) * zfact1
179 !! variable =6 : Drainage
180  xb_var_bv(kforc_step,jcat,6) = xb_var_bv(kforc_step,jcat,6) + (xb_drain(jmesh)-xb_drainm(jmesh)) * zfact1
181 !! variable =7 : Variation of liquid water stocked in the ground
182  xb_var_bv(kforc_step,jcat,7) = xb_var_bv(kforc_step,jcat,7) + (xb_wgtot(jmesh)-xb_wgtotm(jmesh)) * zfact0
183 !! variable =8 : Variation of solid water stocked in the ground
184  xb_var_bv(kforc_step,jcat,8) = xb_var_bv(kforc_step,jcat,8) + (xb_wgitot(jmesh)-xb_wgitotm(jmesh)) * zfact0
185 !! variable =9 : Variation of melting snow
186  xb_var_bv(kforc_step,jcat,9) = xb_var_bv(kforc_step,jcat,9) + (xb_swetot(jmesh)-xb_swetotm(jmesh)) * zfact0
187 !! variable =11 : Hortonian Runoff
188  xb_var_bv(kforc_step,jcat,11) = xb_var_bv(kforc_step,jcat,11) + (xb_horton(jmesh)-xb_hortonm(jmesh)) * zfact1
189 !! variable =12 : ISBA water budget
190  xb_var_bv(kforc_step,jcat,12) = xb_var_bv(kforc_step,jcat,12) + zb_watbud(jmesh) * zfact2
191 
192  !! bilan hors BV en m3
193  zfact0 = (1.-xb_abv_bymesh(jmesh,jcat)) * xb_mesh_size(jmesh)
194  zfact1 = zfact0 / xrholw
195  zfact2 = nnb_topd * zfact1
196 ! ZFACT2 = XTOPD_STEP * ZFACT1
197  !
198  xb_var_nobv(kforc_step,jcat,1) = xb_var_nobv(kforc_step,jcat,1) + xb_rain(jmesh) * zfact2
199  xb_var_nobv(kforc_step,jcat,2) = xb_var_nobv(kforc_step,jcat,2) + xb_snow(jmesh) * zfact2
200  xb_var_nobv(kforc_step,jcat,3) = xb_var_nobv(kforc_step,jcat,3) + zb_dwr(jmesh) * zfact2
201  xb_var_nobv(kforc_step,jcat,4) = xb_var_nobv(kforc_step,jcat,4) + (xb_evap(jmesh)-xb_evapm(jmesh)) * zfact1
202  xb_var_nobv(kforc_step,jcat,5) = xb_var_nobv(kforc_step,jcat,5) + (xb_runoff_isba(jmesh)-xb_runoff_isbam(jmesh)) * zfact1
203  xb_var_nobv(kforc_step,jcat,6) = xb_var_nobv(kforc_step,jcat,6) + (xb_drain(jmesh)-xb_drainm(jmesh)) * zfact1
204  xb_var_nobv(kforc_step,jcat,7) = xb_var_nobv(kforc_step,jcat,7) + (xb_wgtot(jmesh)-xb_wgtotm(jmesh)) * zfact0
205  xb_var_nobv(kforc_step,jcat,8) = xb_var_nobv(kforc_step,jcat,8) + (xb_wgitot(jmesh)-xb_wgitotm(jmesh)) * zfact0
206  xb_var_nobv(kforc_step,jcat,9) = xb_var_nobv(kforc_step,jcat,9) + (xb_swetot(jmesh)-xb_swetotm(jmesh)) * zfact0
207  xb_var_nobv(kforc_step,jcat,11) = xb_var_nobv(kforc_step,jcat,11) + (xb_horton(jmesh)-xb_hortonm(jmesh)) * zfact1
208  xb_var_nobv(kforc_step,jcat,12) = xb_var_nobv(kforc_step,jcat,12) + zb_watbud(jmesh) * zfact2
209  !
210  ENDIF
211  !
212  ENDDO
213  !
214  xb_var_bv(kforc_step,jcat,10) = sum(xb_var_bv(kforc_step,jcat,1:2)) - sum(xb_var_bv(kforc_step,jcat,3:9))
215  !
216  xb_var_nobv(kforc_step,jcat,10) = sum(xb_var_nobv(kforc_step,jcat,1:2)) - sum(xb_var_nobv(kforc_step,jcat,3:9))
217  !
218  xb_var_q(kforc_step,jcat,1) = (xb_qtot(jcat)-xb_qtotm(jcat)) * xtopd_step
219  xb_var_q(kforc_step,jcat,2) = (xb_qrun(jcat)-xb_qrunm(jcat)) * xtopd_step
220  xb_var_q(kforc_step,jcat,3) = (xb_qdr(jcat)- xb_qdrm(jcat)) * xtopd_step
221  xb_var_q(kforc_step,jcat,4) = sum(xrun_torout(jcat,:)) * xtopd_step
222  xb_var_q(kforc_step,jcat,5) = sum(xdr_torout(jcat,:)) * xtopd_step
223  !
224 ENDDO
225 !
226 !bilan tot isba (m3)
227 DO jmesh=1,kni
228  !
229  IF (xb_dg2(jmesh)/=xundef) THEN
230  !
231  zfact0 = xb_mesh_size(jmesh)
232  zfact1 = zfact0 / xrholw
233  zfact2 = nnb_topd * zfact1
234 ! ZFACT2 = XTOPD_STEP * ZFACT1
235  !
236 !! Water going in the system
237 !! variable =1 : Rain
238  xb_var_tot(kforc_step,1) = xb_var_tot(kforc_step,1) + xb_rain(jmesh) * zfact2
239 !! variable =2 : Snow
240  xb_var_tot(kforc_step,2) = xb_var_tot(kforc_step,2) + xb_snow(jmesh) * zfact2
241 !! Water going out of the system
242 !! variable =3 : Incerception
243  xb_var_tot(kforc_step,3) = xb_var_tot(kforc_step,3) + zb_dwr(jmesh) * zfact2
244 !! variable =4 : Evaporation
245  xb_var_tot(kforc_step,4) = xb_var_tot(kforc_step,4) + (xb_evap(jmesh)-xb_evapm(jmesh)) * zfact1
246 !! variable =5 : Runoff
247  xb_var_tot(kforc_step,5) = xb_var_tot(kforc_step,5) + (xb_runoff_isba(jmesh)-xb_runoff_isbam(jmesh)) * zfact1
248 !! variable =6 : Drainage
249  xb_var_tot(kforc_step,6) = xb_var_tot(kforc_step,6) + (xb_drain(jmesh)-xb_drainm(jmesh)) * zfact1
250 !! variable =7 : Variation of liquid water stocked in the ground
251  xb_var_tot(kforc_step,7) = xb_var_tot(kforc_step,7) + (xb_wgtot(jmesh)-xb_wgtotm(jmesh)) * zfact0
252 !! variable =8 : Variation of solid water stocked in the ground
253  xb_var_tot(kforc_step,8) = xb_var_tot(kforc_step,8) + (xb_wgitot(jmesh)-xb_wgitotm(jmesh)) * zfact0
254 !! variable =9 : Variation of melting snow
255  xb_var_tot(kforc_step,9) = xb_var_tot(kforc_step,9) + (xb_swetot(jmesh)-xb_swetotm(jmesh)) * zfact0
256 !! variable =11: Hortonian runoff
257  xb_var_tot(kforc_step,11) = xb_var_tot(kforc_step,11) + (xb_horton(jmesh)-xb_hortonm(jmesh)) * zfact1
258 !! variable =12 : ISBA water budget
259  xb_var_tot(kforc_step,12) = xb_var_tot(kforc_step,12) + zb_watbud(jmesh) * zfact2
260  !
261  ENDIF
262  !
263 ENDDO !JMESH
264 !
265 xb_var_tot(kforc_step,10) = sum(xb_var_tot(kforc_step,1:2)) - sum(xb_var_tot(kforc_step,3:9))
266 !
267 !
268 xb_wrm(:) = xb_wr(:)
269 xb_evapm(:) = xb_evap(:)
270 !
273 xb_hortonm(:) = xb_horton(:)
274 xb_drainm(:) = xb_drain(:)
275 !
276 xb_wg2m(:) = xb_wg2(:)
277 xb_wg3m(:) = xb_wg3(:)
278 xb_wgtotm(:) = xb_wgtot(:)
279 xb_wgi2m(:) = xb_wgi2(:)
280 xb_wgi3m(:) = xb_wgi3(:)
281 xb_wgitotm(:) = xb_wgitot(:)
282 xb_swe1m(:) = xb_swe1(:)
283 xb_swe2m(:) = xb_swe2(:)
284 xb_swe3m(:) = xb_swe3(:)
285 xb_swetotm(:) = xb_swetot(:)
286 !
287 xb_qtotm(:) = xb_qtot(:)
288 xb_qrunm(:) = xb_qrun(:)
289 xb_qdrm(:) = xb_qdr(:)
290 !
291 IF (lhook) CALL dr_hook('BUDGET_COUPL_ROUT',1,zhook_handle)
292 !
293 END SUBROUTINE budget_coupl_rout
real, dimension(:), allocatable xb_dg2
real, dimension(:), allocatable xb_wg2
real, dimension(:,:), allocatable xb_var_tot
real, dimension(:), allocatable xb_runoff_topd
real, dimension(:), allocatable xb_qtotm
real, dimension(:), allocatable xb_qdrm
real, dimension(:), allocatable xb_wg3m
real, dimension(:), allocatable xb_evapm
real, dimension(:), allocatable xb_mesh_size
real, dimension(:), allocatable xb_snow
real, dimension(:,:), allocatable xqb_dr
real, dimension(:,:), allocatable xqb_run
real, dimension(:), allocatable xb_wrm
real, dimension(:), allocatable xsnow
real, dimension(:,:,:), allocatable xb_var_nobv
subroutine budget_coupl_rout(DE, DEC, DC, DMI, IO, NP, NPE, U, KN
real, dimension(:), allocatable xrunoff_top
real, dimension(:), allocatable xb_evap
real, dimension(:), allocatable xb_runoff_topdm
real, dimension(:), allocatable xb_swe3m
real, dimension(:), allocatable xb_swe2m
real, parameter xundef
real, dimension(:,:), allocatable xb_abv_bymesh
real, dimension(:), allocatable xb_swe1m
real, dimension(:,:,:), allocatable xb_var_bv
real, dimension(:), allocatable xb_drainm
integer, parameter jprb
Definition: parkind1.F90:32
real, dimension(:), allocatable xb_wgtot
subroutine dg_dfto3l(IO, NP, PDG)
Definition: dg_dfto3l.F90:8
real, dimension(:), allocatable xb_swe1
real, dimension(:,:,:), allocatable xb_var_q
real, dimension(:), allocatable xb_wgi3
real, dimension(:), allocatable xb_wgi3m
real, dimension(:), allocatable xb_runoff_isba
real, dimension(:), allocatable xb_wgitot
intent(out) overrides sub arrays one Sort by the least significant key first sum(iindex(1:n))
real, dimension(:), allocatable xb_swe3
real, dimension(:), allocatable xb_qrun
logical lhook
Definition: yomhook.F90:15
real, dimension(:), allocatable xb_wg3
real, dimension(:,:), allocatable xdr_torout
real, dimension(:), allocatable xb_dg3
real, dimension(:), allocatable xb_qrunm
real, dimension(:), allocatable xb_rain
real, dimension(:), allocatable xb_qdr
real, dimension(:), allocatable xb_wg2m
real, dimension(:), allocatable xb_drain
real, dimension(:), allocatable xb_swetot
real, save xrholw
Definition: modd_csts.F90:64
real, dimension(:), allocatable xb_wgitotm
real, dimension(:), allocatable xb_wr
real, dimension(:), allocatable xatop
real, dimension(:), allocatable xb_wgtotm
real, dimension(:), allocatable xb_hortonm
real, dimension(:), allocatable xb_qtot
real, dimension(:), allocatable xb_wgi2
real, dimension(:), allocatable xb_wgi2m
subroutine avg_patch_wg(IO, NP, NPE, PWG, PWGI, PDG)
Definition: avg_patch_wg.F90:8
real, dimension(:,:), allocatable xrun_torout
real, dimension(:), allocatable xb_swe2
real, dimension(:), allocatable xb_runoff_isbam
real, dimension(:), allocatable xb_horton
real, dimension(:,:), allocatable xqtot