021b0c624ae5317eb94f8478faa7a57479cd804c
[MNH-git_open_source-lfs.git] / src / SURFEX / write_diag_misc_tebn.F90
1 !SURFEX_LIC Copyright 1994-2014 Meteo-France 
2 !SURFEX_LIC This is part of the SURFEX software governed by the CeCILL-C  licence
3 !SURFEX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SURFEX_LIC for details. version 1.
5 !     #########
6       SUBROUTINE WRITE_DIAG_MISC_TEB_n(HPROGRAM,KTEB_PATCH)
7 !     #################################
8 !
9 !!****  *WRITE_DIAG_MISC_TEB* - writes the TEB diagnostic fields
10 !!
11 !!    PURPOSE
12 !!    -------
13 !!
14 !!
15 !!**  METHOD
16 !!    ------
17 !!
18 !!    REFERENCE
19 !!    ---------
20 !!
21 !!
22 !!    AUTHOR
23 !!    ------
24 !!      P. Le Moigne   *Meteo France*   
25 !!
26 !!    MODIFICATIONS
27 !!    -------------
28 !!      Original    10/2004
29 !-------------------------------------------------------------------------------
30 !
31 !*       0.    DECLARATIONS
32 !              ------------
33 USE MODI_INIT_IO_SURF_n
34 USE MODI_WRITE_SURF
35 USE MODI_END_IO_SURF_n
36 USE MODD_TEB_n,ONLY : XZ0_TOWN, NTEB_PATCH, CBEM, XROAD, LGREENROOF, LGARDEN, CWALL_OPT
37 USE MODD_DIAG_MISC_TEB_n,ONLY : LSURF_MISC_BUDGET,                               &
38                                   XQF_BLD,XFLX_BLD, XQF_TOWN, XDQS_TOWN,         &
39                                   XRN_ROAD, XH_ROAD, XLE_ROAD, XGFLUX_ROAD,      &
40                                   XRN_WALL_A, XH_WALL_A, XGFLUX_WALL_A,          &
41                                   XRN_WALL_B, XH_WALL_B, XGFLUX_WALL_B,          &
42                                   XRN_ROOF, XH_ROOF, XLE_ROOF, XGFLUX_ROOF,      &
43                                   XRN_GARDEN,XH_GARDEN,XLE_GARDEN,XGFLUX_GARDEN, &
44                                   XRN_BLT,XH_BLT,XLE_BLT,XGFLUX_BLT,             &
45                                   XABS_SW_ROOF ,XABS_SW_SNOW_ROOF,               &
46                                   XABS_LW_ROOF ,XABS_LW_SNOW_ROOF,               &
47                                   XABS_SW_ROAD ,XABS_SW_SNOW_ROAD,               &
48                                   XABS_LW_ROAD ,XABS_LW_SNOW_ROAD,               &
49                                   XABS_SW_WALL_A , XABS_LW_WALL_A,               &
50                                   XABS_SW_WALL_B , XABS_LW_WALL_B,               &
51                                   XABS_SW_GARDEN, XABS_LW_GARDEN,                &
52                                   XH_BLD_COOL, XT_BLD_COOL,                      &     
53                                   XH_BLD_HEAT, XLE_BLD_COOL, XLE_BLD_HEAT,       &
54                                   XH_WASTE, XLE_WASTE, XHVAC_COOL,               &
55                                   XHVAC_HEAT, XCAP_SYS, XM_SYS, XCOP,            &
56                                   XQ_SYS, XT_SYS, XTR_SW_WIN, XFAN_POWER,        &
57                                   XABS_SW_WIN, XABS_LW_WIN, XEMIT_LW_FAC,        &
58                                   XEMIT_LW_GRND, XT_RAD_IND, XREF_SW_GRND,       &
59                                   XREF_SW_FAC, XHU_BLD,                          &
60                                   XRN_STRLROOF,XH_STRLROOF,XLE_STRLROOF,         &
61                                   XGFLUX_STRLROOF,                               &
62                                   XRN_GREENROOF,XH_GREENROOF,XLE_GREENROOF,      &
63                                   XGFLUX_GREENROOF,                              &
64                                   XABS_SW_GREENROOF, XABS_LW_GREENROOF,          &  
65                                   XG_GREENROOF_ROOF,                             &
66                                   XRUNOFF_GREENROOF, XDRAIN_GREENROOF
67 !
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 !
77  CHARACTER(LEN=6),  INTENT(IN)  :: HPROGRAM   ! program calling
78 INTEGER,           INTENT(IN)  :: KTEB_PATCH ! patch number being written
79 !
80 !*       0.2   Declarations of local variables
81 !              -------------------------------
82 !
83 INTEGER           :: IRESP          ! IRESP  : return-code if a problem appears
84  CHARACTER(LEN=3)  :: YPATCH         ! Prefix for current patch
85  CHARACTER(LEN=12) :: YRECFM         ! Name of the article to be read
86  CHARACTER(LEN=100):: YCOMMENT       ! Comment string
87 REAL(KIND=JPRB) :: ZHOOK_HANDLE
88 !
89 !-------------------------------------------------------------------------------
90 !
91 !         Initialisation for IO
92 !
93 IF (LHOOK) CALL DR_HOOK('WRITE_DIAG_MISC_TEB_N',0,ZHOOK_HANDLE)
94  CALL INIT_IO_SURF_n(HPROGRAM,'TOWN  ','TEB   ','WRITE')
95 !
96 YPATCH = '   '
97 IF (NTEB_PATCH>1) WRITE(YPATCH,FMT='(A,I1,A)') 'T',KTEB_PATCH,'_'
98 !-------------------------------------------------------------------------------
99 !
100 IF (LSURF_MISC_BUDGET) THEN
101 !
102 !*       Miscellaneous fields :
103 !        ----------------------
104 !
105 YRECFM='D_RD'
106 YCOMMENT='Road fraction'
107  CALL WRITE_SURF(HPROGRAM,YRECFM,XROAD(:),IRESP,HCOMMENT=YCOMMENT)
108 !
109 YRECFM='Z0_TOWN'
110 YRECFM=ADJUSTL(YPATCH//YRECFM)
111 YCOMMENT='town roughness length'
112 !
113  CALL WRITE_SURF(HPROGRAM,YRECFM,XZ0_TOWN(:),IRESP,HCOMMENT=YCOMMENT)
114 !
115 YRECFM='XQF_BLD'
116 YRECFM=ADJUSTL(YPATCH//YRECFM)
117 YCOMMENT='domestic heating'//' (W/m2)'
118 !
119  CALL WRITE_SURF(HPROGRAM,YRECFM,XQF_BLD(:),IRESP,HCOMMENT=YCOMMENT)
120 !
121 YRECFM='XQF_TOWN'
122 YRECFM=ADJUSTL(YPATCH//YRECFM)
123 YCOMMENT='total anthropogenic heat'//' (W/m2)'
124 !
125  CALL WRITE_SURF(HPROGRAM,YRECFM,XQF_TOWN(:),IRESP,HCOMMENT=YCOMMENT)
126 !
127 YRECFM='XDQS_TOWN'
128 YRECFM=ADJUSTL(YPATCH//YRECFM)
129 YCOMMENT='heat storage inside building'//' (W/m2)'
130 !
131  CALL WRITE_SURF(HPROGRAM,YRECFM,XDQS_TOWN(:),IRESP,HCOMMENT=YCOMMENT)
132 !
133 YRECFM='RN_RD'
134 YRECFM=ADJUSTL(YPATCH//YRECFM)
135 YCOMMENT=' net radiation at road'//' (W/m2)'
136 !
137  CALL WRITE_SURF(HPROGRAM,YRECFM,XRN_ROAD(:),IRESP,HCOMMENT=YCOMMENT)
138 !
139 YRECFM='H_RD'
140 YRECFM=ADJUSTL(YPATCH//YRECFM)
141 YCOMMENT='road sensible heat flux'//' (W/m2)'
142 !
143  CALL WRITE_SURF(HPROGRAM,YRECFM,XH_ROAD(:),IRESP,HCOMMENT=YCOMMENT)
144 !
145 YRECFM='LE_RD'
146 YRECFM=ADJUSTL(YPATCH//YRECFM)
147 YCOMMENT='road latent heat flux'//' (W/m2)'
148 !
149  CALL WRITE_SURF(HPROGRAM,YRECFM,XLE_ROAD(:),IRESP,HCOMMENT=YCOMMENT)
150 !
151 YRECFM='GFLUX_RD'
152 YRECFM=ADJUSTL(YPATCH//YRECFM)
153 YCOMMENT='net road conduction flux'//' (W/m2)'
154 !
155  CALL WRITE_SURF(HPROGRAM,YRECFM,XGFLUX_ROAD(:),IRESP,HCOMMENT=YCOMMENT)
156 !
157 IF (CWALL_OPT=='UNIF') THEN
158   !
159   YRECFM='RN_WL'
160   YRECFM=ADJUSTL(YPATCH//YRECFM)
161   YCOMMENT='net radiation for wall '//YRECFM//' (W/m2)'
162   !
163   CALL WRITE_SURF(HPROGRAM,YRECFM,XRN_WALL_A(:),IRESP,HCOMMENT=YCOMMENT)
164   !
165   YRECFM='H_WL'
166   YRECFM=ADJUSTL(YPATCH//YRECFM)
167   YCOMMENT='wall sensible heat flux'//YRECFM//' (W/m2)'
168   !
169   CALL WRITE_SURF(HPROGRAM,YRECFM,XH_WALL_A(:),IRESP,HCOMMENT=YCOMMENT)
170   !
171   YRECFM='GFLUX_WL'
172   YRECFM=ADJUSTL(YPATCH//YRECFM)
173   YCOMMENT='net wall conduction flux'//YRECFM//' (W/m2)'
174   !
175   CALL WRITE_SURF(HPROGRAM,YRECFM,XGFLUX_WALL_A(:),IRESP,HCOMMENT=YCOMMENT)
176   !
177 ELSE
178   !
179   YRECFM='RN_WLA'
180   YRECFM=ADJUSTL(YPATCH//YRECFM)
181   YCOMMENT='net radiation for wall A'//YRECFM//' (W/m2)'
182   !
183   CALL WRITE_SURF(HPROGRAM,YRECFM,XRN_WALL_A(:),IRESP,HCOMMENT=YCOMMENT)
184   !
185   YRECFM='H_WLA'
186   YRECFM=ADJUSTL(YPATCH//YRECFM)
187   YCOMMENT='wall A sensible heat flux'//YRECFM//' (W/m2)'
188   !
189   CALL WRITE_SURF(HPROGRAM,YRECFM,XH_WALL_A(:),IRESP,HCOMMENT=YCOMMENT)
190   !
191   YRECFM='GFLUX_WLA'
192   YRECFM=ADJUSTL(YPATCH//YRECFM)
193   YCOMMENT='net wall A conduction flux'//YRECFM//' (W/m2)'
194   !
195   CALL WRITE_SURF(HPROGRAM,YRECFM,XGFLUX_WALL_A(:),IRESP,HCOMMENT=YCOMMENT)
196   !
197   YRECFM='RN_WLB'
198   YRECFM=ADJUSTL(YPATCH//YRECFM)
199   YCOMMENT='net radiation for wall B'//YRECFM//' (W/m2)'
200   !
201   CALL WRITE_SURF(HPROGRAM,YRECFM,XRN_WALL_B(:),IRESP,HCOMMENT=YCOMMENT)
202   !
203   YRECFM='H_WLB'
204   YRECFM=ADJUSTL(YPATCH//YRECFM)
205   YCOMMENT='wall B sensible heat flux'//YRECFM//' (W/m2)'
206   !
207   CALL WRITE_SURF(HPROGRAM,YRECFM,XH_WALL_B(:),IRESP,HCOMMENT=YCOMMENT)
208   !
209   YRECFM='GFLUX_WLB'
210   YRECFM=ADJUSTL(YPATCH//YRECFM)
211   YCOMMENT='net wall B conduction flux'//YRECFM//' (W/m2)'
212   !
213   CALL WRITE_SURF(HPROGRAM,YRECFM,XGFLUX_WALL_B(:),IRESP,HCOMMENT=YCOMMENT)
214   !
215 ENDIF
216 !
217 YRECFM='RN_RF'
218 YRECFM=ADJUSTL(YPATCH//YRECFM)
219 YCOMMENT='net radiation for roof'//YRECFM//' (W/m2)'
220 !
221  CALL WRITE_SURF(HPROGRAM,YRECFM,XRN_ROOF(:),IRESP,HCOMMENT=YCOMMENT)
222 !
223 YRECFM='H_RF'
224 YRECFM=ADJUSTL(YPATCH//YRECFM)
225 YCOMMENT='roof sensible heat flux'//YRECFM//' (W/m2)'
226 !
227  CALL WRITE_SURF(HPROGRAM,YRECFM,XH_ROOF(:),IRESP,HCOMMENT=YCOMMENT)
228 !
229 YRECFM='LE_RF'
230 YRECFM=ADJUSTL(YPATCH//YRECFM)
231 YCOMMENT='roof latent heat flux'//YRECFM//' (W/m2)'
232 !
233  CALL WRITE_SURF(HPROGRAM,YRECFM,XLE_ROOF(:),IRESP,HCOMMENT=YCOMMENT)
234 !
235 YRECFM='GFLUX_RF'
236 YRECFM=ADJUSTL(YPATCH//YRECFM)
237 YCOMMENT='net roof conduction flux'//YRECFM//' (W/m2)'
238 !
239  CALL WRITE_SURF(HPROGRAM,YRECFM,XGFLUX_ROOF(:),IRESP,HCOMMENT=YCOMMENT)
240 !
241 IF (LGARDEN) THEN
242   !
243   YRECFM='RN_GD'
244   YRECFM=ADJUSTL(YPATCH//YRECFM)
245   YCOMMENT='net radiation for GARDEN areas'//YRECFM//' (W/m2)'
246   !
247   CALL WRITE_SURF(HPROGRAM,YRECFM,XRN_GARDEN(:),IRESP,HCOMMENT=YCOMMENT)
248   !
249   YRECFM='H_GD'
250   YRECFM=ADJUSTL(YPATCH//YRECFM)
251   YCOMMENT='GARDEN area sensible heat flux'//YRECFM//' (W/m2)'
252   !
253   CALL WRITE_SURF(HPROGRAM,YRECFM,XH_GARDEN(:),IRESP,HCOMMENT=YCOMMENT)
254   !
255   YRECFM='LE_GD'
256   YRECFM=ADJUSTL(YPATCH//YRECFM)
257   YCOMMENT='GARDEN area latent heat flux'//YRECFM//' (W/m2)'
258   !
259   CALL WRITE_SURF(HPROGRAM,YRECFM,XLE_GARDEN(:),IRESP,HCOMMENT=YCOMMENT)
260   !
261   YRECFM='GFLUX_GD'
262   YRECFM=ADJUSTL(YPATCH//YRECFM)
263   YCOMMENT='net GARDEN area conduction flux'//YRECFM//' (W/m2)'
264   !
265   CALL WRITE_SURF(HPROGRAM,YRECFM,XGFLUX_GARDEN(:),IRESP,HCOMMENT=YCOMMENT)
266   !
267 ENDIF
268 !
269 YRECFM='RN_BLT'
270 YRECFM=ADJUSTL(YPATCH//YRECFM)
271 YCOMMENT='net radiation for built surfaces'//YRECFM//' (W/m2)'
272 !
273  CALL WRITE_SURF(HPROGRAM,YRECFM,XRN_BLT(:),IRESP,HCOMMENT=YCOMMENT)
274 !
275 YRECFM='H_BLT'
276 YRECFM=ADJUSTL(YPATCH//YRECFM)
277 YCOMMENT='built surface sensible heat flux'//YRECFM//' (W/m2)'
278 !
279  CALL WRITE_SURF(HPROGRAM,YRECFM,XH_BLT(:),IRESP,HCOMMENT=YCOMMENT)
280 !
281 YRECFM='LE_BLT'
282 YRECFM=ADJUSTL(YPATCH//YRECFM)
283 YCOMMENT='built surface latent heat flux'//YRECFM//' (W/m2)'
284 !
285  CALL WRITE_SURF(HPROGRAM,YRECFM,XLE_BLT(:),IRESP,HCOMMENT=YCOMMENT)
286 !
287 YRECFM='GFLUX_BLT'
288 YRECFM=ADJUSTL(YPATCH//YRECFM)
289 YCOMMENT='built surface conduction flux'//YRECFM//' (W/m2)'
290 !
291  CALL WRITE_SURF(HPROGRAM,YRECFM,XGFLUX_BLT(:),IRESP,HCOMMENT=YCOMMENT)
292 !
293 !
294 YRECFM='SWA_RF'
295 YRECFM=ADJUSTL(YPATCH//YRECFM)
296 YCOMMENT='Sdown absorbed by roofs'//' (W/m2)'
297 !
298  CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_SW_ROOF(:),IRESP,HCOMMENT=YCOMMENT)
299 !
300 YRECFM='SWA_SN_RF'
301 YRECFM=ADJUSTL(YPATCH//YRECFM)
302 YCOMMENT='Sdown absorbed by snow on roofs'//' (W/m2)'
303 !
304  CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_SW_SNOW_ROOF(:),IRESP,HCOMMENT=YCOMMENT)
305 !
306 YRECFM='LWA_RF'
307 YRECFM=ADJUSTL(YPATCH//YRECFM)
308 YCOMMENT='Ldown absorbed by roofs'//' (W/m2)'
309 !
310  CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_LW_ROOF(:),IRESP,HCOMMENT=YCOMMENT)
311 !
312 YRECFM='LWA_SN_RF'
313 YRECFM=ADJUSTL(YPATCH//YRECFM)
314 YCOMMENT='Ldown absorbed by snow on roofs'//' (W/m2)'
315 !
316  CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_LW_SNOW_ROOF(:),IRESP,HCOMMENT=YCOMMENT)
317 !
318 YRECFM='SWA_RD'
319 YRECFM=ADJUSTL(YPATCH//YRECFM)
320 YCOMMENT='Sdown absorbed by roads'//' (W/m2)'
321 !
322  CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_SW_ROAD(:),IRESP,HCOMMENT=YCOMMENT)
323 !
324 YRECFM='SWA_SN_RD'
325 YRECFM=ADJUSTL(YPATCH//YRECFM)
326 YCOMMENT='Sdown absorbed by snow on roads'//' (W/m2)'
327 !
328  CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_SW_SNOW_ROAD(:),IRESP,HCOMMENT=YCOMMENT)
329 !
330 YRECFM='LWA_RD'
331 YRECFM=ADJUSTL(YPATCH//YRECFM)
332 YCOMMENT='Ldown absorbed by roads'//' (W/m2)'
333 !
334  CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_LW_ROAD(:),IRESP,HCOMMENT=YCOMMENT)
335 !
336 YRECFM='LWA_SN_RD'
337 YRECFM=ADJUSTL(YPATCH//YRECFM)
338 YCOMMENT='Ldown absorbed by snow on roads'//' (W/m2)'
339 !
340  CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_LW_SNOW_ROAD(:),IRESP,HCOMMENT=YCOMMENT)
341 !
342 IF (CWALL_OPT=='UNIF') THEN
343   !
344   YRECFM='SWA_WL'
345   YRECFM=ADJUSTL(YPATCH//YRECFM)
346   YCOMMENT='Sdown absorbed by wall'//' (W/m2)'
347   !
348   CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_SW_WALL_A(:),IRESP,HCOMMENT=YCOMMENT)
349   !
350   YRECFM='LWA_WL'
351   YRECFM=ADJUSTL(YPATCH//YRECFM)
352   YCOMMENT='Ldown absorbed by wall '//' (W/m2)'
353   !
354   CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_LW_WALL_A(:),IRESP,HCOMMENT=YCOMMENT)
355   !
356 ELSE
357   !
358   YRECFM='SWA_WLA'
359   YRECFM=ADJUSTL(YPATCH//YRECFM)
360   YCOMMENT='Sdown absorbed by wall A'//' (W/m2)'
361   !
362   CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_SW_WALL_A(:),IRESP,HCOMMENT=YCOMMENT)
363   !
364   YRECFM='LWA_WLA'
365   YRECFM=ADJUSTL(YPATCH//YRECFM)
366   YCOMMENT='Ldown absorbed by wall A'//' (W/m2)'
367   !
368   CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_LW_WALL_A(:),IRESP,HCOMMENT=YCOMMENT)
369   !
370   YRECFM='SWA_WLB'
371   YRECFM=ADJUSTL(YPATCH//YRECFM)
372   YCOMMENT='Sdown absorbed by wall B'//' (W/m2)'
373   !
374   CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_SW_WALL_B(:),IRESP,HCOMMENT=YCOMMENT)
375   !
376   YRECFM='LWA_WLB'
377   YRECFM=ADJUSTL(YPATCH//YRECFM)
378   YCOMMENT='Ldown absorbed by wall B'//' (W/m2)'
379   !
380   CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_LW_WALL_B(:),IRESP,HCOMMENT=YCOMMENT)
381   !
382 ENDIF
383 !
384 IF (LGARDEN) THEN
385   !
386   YRECFM='SWA_GD'
387   YRECFM=ADJUSTL(YPATCH//YRECFM)
388   YCOMMENT='Sdown absorbed by GARDEN areas'//' (W/m2)'
389   !
390   CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_SW_GARDEN(:),IRESP,HCOMMENT=YCOMMENT)
391   !
392   YRECFM='LWA_GD'
393   YRECFM=ADJUSTL(YPATCH//YRECFM)
394   YCOMMENT='Ldown absorbed by GARDEN areas'//' (W/m2)'
395   !
396   CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_LW_GARDEN(:),IRESP,HCOMMENT=YCOMMENT)
397   !
398 ENDIF
399 !
400 YRECFM='REF_SW_GO'
401 YRECFM=ADJUSTL(YPATCH//YRECFM)
402 YCOMMENT='Total solar rad reflected by ground '//' (W/m2)'
403  CALL WRITE_SURF(HPROGRAM,YRECFM,XREF_SW_GRND(:),IRESP,HCOMMENT=YCOMMENT)
404 !
405 YRECFM='LWE_GO'
406 YRECFM=ADJUSTL(YPATCH//YRECFM)
407 YCOMMENT='LW emitted by ground'//' (W/m2)'
408  CALL WRITE_SURF(HPROGRAM,YRECFM,XEMIT_LW_GRND(:),IRESP,HCOMMENT=YCOMMENT)
409 !
410 YRECFM='REF_SW_FA'
411 YRECFM=ADJUSTL(YPATCH//YRECFM)
412 YCOMMENT='Total solar rad reflected by facade '//' (W/m2)'
413  CALL WRITE_SURF(HPROGRAM,YRECFM,XREF_SW_FAC(:),IRESP,HCOMMENT=YCOMMENT)
414 !
415 YRECFM='LWE_FA'
416 YRECFM=ADJUSTL(YPATCH//YRECFM)
417 YCOMMENT='LW emitted by facade'//' (W/m2)'
418  CALL WRITE_SURF(HPROGRAM,YRECFM,XEMIT_LW_FAC(:),IRESP,HCOMMENT=YCOMMENT)
419 !
420 !
421   IF (CBEM=='BEM') THEN
422     !
423     YRECFM='XFLX_BLD'
424     YRECFM=ADJUSTL(YPATCH//YRECFM)
425     YCOMMENT='heat flux from bld'//' (W/m2)'
426     CALL WRITE_SURF(HPROGRAM,YRECFM,XFLX_BLD(:),IRESP,HCOMMENT=YCOMMENT)
427     !
428     YRECFM='H_BLD_CL'
429     YRECFM=ADJUSTL(YPATCH//YRECFM)
430     YCOMMENT='sensible cooling demand'//' (W/m2)'
431     CALL WRITE_SURF(HPROGRAM,YRECFM,XH_BLD_COOL(:),IRESP,HCOMMENT=YCOMMENT)
432     !
433     YRECFM='T_BLD_CL'
434     YRECFM=ADJUSTL(YPATCH//YRECFM)
435     YCOMMENT='Total cooling demand'//' (W/m2)'
436     CALL WRITE_SURF(HPROGRAM,YRECFM,XT_BLD_COOL(:),IRESP,HCOMMENT=YCOMMENT)
437     !  
438     YRECFM='H_BLD_HT'
439     YRECFM=ADJUSTL(YPATCH//YRECFM)
440     YCOMMENT='sensible heating demand'//' (W/m2)'
441     CALL WRITE_SURF(HPROGRAM,YRECFM,XH_BLD_HEAT(:),IRESP,HCOMMENT=YCOMMENT)
442     !
443     YRECFM='LE_BLD_CL'
444     YRECFM=ADJUSTL(YPATCH//YRECFM)
445     YCOMMENT='latent cooling demand'//' (W/m2)'
446     CALL WRITE_SURF(HPROGRAM,YRECFM,XLE_BLD_COOL(:),IRESP,HCOMMENT=YCOMMENT)
447     !
448     YRECFM='LE_BLD_HT'
449     YRECFM=ADJUSTL(YPATCH//YRECFM)
450     YCOMMENT='latent heating demand'//' (W/m2)'
451     CALL WRITE_SURF(HPROGRAM,YRECFM,XLE_BLD_HEAT(:),IRESP,HCOMMENT=YCOMMENT)
452     !
453     YRECFM='H_WASTE'
454     YRECFM=ADJUSTL(YPATCH//YRECFM)
455     YCOMMENT='sensible waste heat from HVAC'//' (W/m2)'
456     CALL WRITE_SURF(HPROGRAM,YRECFM,XH_WASTE(:),IRESP,HCOMMENT=YCOMMENT)
457     !
458     YRECFM='LE_WASTE'
459     YRECFM=ADJUSTL(YPATCH//YRECFM)
460     YCOMMENT='latent waste heat from HVAC'//' (W/m2)'
461     CALL WRITE_SURF(HPROGRAM,YRECFM,XLE_WASTE(:),IRESP,HCOMMENT=YCOMMENT)  
462     !
463     YRECFM='HVAC_CL'
464     YRECFM=ADJUSTL(YPATCH//YRECFM)
465     YCOMMENT='cooling energy consumption'//' (W/m2)'
466     CALL WRITE_SURF(HPROGRAM,YRECFM,XHVAC_COOL(:),IRESP,HCOMMENT=YCOMMENT)
467     !
468     YRECFM='HVAC_HT'
469     YRECFM=ADJUSTL(YPATCH//YRECFM)
470     YCOMMENT='heating energy consumption'//' (W/m2)'
471     CALL WRITE_SURF(HPROGRAM,YRECFM,XHVAC_HEAT(:),IRESP,HCOMMENT=YCOMMENT)
472     !
473     YRECFM='CAP_SYS'
474     YRECFM=ADJUSTL(YPATCH//YRECFM)
475     YCOMMENT='Actual capacity of the cooling system'//' (W m-2(bld))'
476     CALL WRITE_SURF(HPROGRAM,YRECFM,XCAP_SYS(:),IRESP,HCOMMENT=YCOMMENT)
477     !
478     YRECFM='M_SYS'
479     YRECFM=ADJUSTL(YPATCH//YRECFM)
480     YCOMMENT='Actual HVAC mass flow rate'//' (kg s-1 m-2(bld))'
481     CALL WRITE_SURF(HPROGRAM,YRECFM,XM_SYS(:),IRESP,HCOMMENT=YCOMMENT)
482     !
483     YRECFM='COP'
484     YRECFM=ADJUSTL(YPATCH//YRECFM)
485     YCOMMENT='Actual COP of the cooling system'//' ()'
486     CALL WRITE_SURF(HPROGRAM,YRECFM,XCOP(:),IRESP,HCOMMENT=YCOMMENT)  
487     !
488     YRECFM='Q_SYS'
489     YRECFM=ADJUSTL(YPATCH//YRECFM)
490     YCOMMENT='Supply air specific humidity'//' (kg kg-1)'
491     CALL WRITE_SURF(HPROGRAM,YRECFM,XQ_SYS(:),IRESP,HCOMMENT=YCOMMENT)
492     !
493     YRECFM='T_SYS'
494     YRECFM=ADJUSTL(YPATCH//YRECFM)
495     YCOMMENT='Supply air temperature'//' (K)'
496     CALL WRITE_SURF(HPROGRAM,YRECFM,XT_SYS(:),IRESP,HCOMMENT=YCOMMENT)  
497     !
498     YRECFM='TR_SW_WIN'
499     YRECFM=ADJUSTL(YPATCH//YRECFM)
500     YCOMMENT='Solar radiation transmitted through windows'//' (W m-2(bld))'
501     CALL WRITE_SURF(HPROGRAM,YRECFM,XTR_SW_WIN(:),IRESP,HCOMMENT=YCOMMENT)
502     !
503     YRECFM='FAN_POWER'
504     YRECFM=ADJUSTL(YPATCH//YRECFM)
505     YCOMMENT='HVAC fan power'//' (W m-2(bld))'
506     CALL WRITE_SURF(HPROGRAM,YRECFM,XFAN_POWER(:),IRESP,HCOMMENT=YCOMMENT)  
507     !
508     YRECFM='T_RAD_IND'
509     YRECFM=ADJUSTL(YPATCH//YRECFM)
510     YCOMMENT='Indoor mean radiant temperature'//' (K)'
511     CALL WRITE_SURF(HPROGRAM,YRECFM,XT_RAD_IND(:),IRESP,HCOMMENT=YCOMMENT)
512     !
513     YRECFM='HU_BLD'
514     YRECFM=ADJUSTL(YPATCH//YRECFM)
515     YCOMMENT='Indoor relative humidity'//' (-)'
516     CALL WRITE_SURF(HPROGRAM,YRECFM,XHU_BLD(:),IRESP,HCOMMENT=YCOMMENT)
517     !
518     YRECFM='SWA_WIN'
519     YRECFM=ADJUSTL(YPATCH//YRECFM)
520     YCOMMENT='Sdown absorbed by windows'//' (W/m2)'
521     CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_SW_WIN(:),IRESP,HCOMMENT=YCOMMENT)
522     !
523     YRECFM='LWA_WIN'
524     YRECFM=ADJUSTL(YPATCH//YRECFM)
525     YCOMMENT='Ldown absorbed by windows'//' (W/m2)'
526     CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_LW_WIN(:),IRESP,HCOMMENT=YCOMMENT)    
527     !
528   ENDIF
529   !
530   IF (LGREENROOF) THEN
531   !
532     YRECFM='RN_GR'
533     YRECFM=ADJUSTL(YPATCH//YRECFM)
534     YCOMMENT='net radiation for GREENROOFs'//' (W/m2)'
535     CALL WRITE_SURF(HPROGRAM,YRECFM,XRN_GREENROOF(:),IRESP,HCOMMENT=YCOMMENT)
536     !
537     YRECFM='H_GR'
538     YRECFM=ADJUSTL(YPATCH//YRECFM)
539     YCOMMENT='sensible heat flux for GREENROOFs'//' (W/m2)'
540     CALL WRITE_SURF(HPROGRAM,YRECFM,XH_GREENROOF(:),IRESP,HCOMMENT=YCOMMENT)
541     !
542     YRECFM='LE_GR'
543     YRECFM=ADJUSTL(YPATCH//YRECFM)
544     YCOMMENT='latent heat flux for GREENROOFs'//' (W/m2)'
545     CALL WRITE_SURF(HPROGRAM,YRECFM,XLE_GREENROOF(:),IRESP,HCOMMENT=YCOMMENT)
546     !
547     YRECFM='GFLUX_GR'
548     YRECFM=ADJUSTL(YPATCH//YRECFM)
549     YCOMMENT='net conduction flux for GREENROOFs'//' (W/m2)'
550     CALL WRITE_SURF(HPROGRAM,YRECFM,XGFLUX_GREENROOF(:),IRESP,HCOMMENT=YCOMMENT)
551     !
552     YRECFM='SWA_GR'
553     YRECFM=ADJUSTL(YPATCH//YRECFM)
554     YCOMMENT='Sdown absorbed by GREENROOFs'//' (W/m2)'
555     CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_SW_GREENROOF(:),IRESP,HCOMMENT=YCOMMENT)
556     !
557     YRECFM='LWA_GR'
558     YRECFM=ADJUSTL(YPATCH//YRECFM)
559     YCOMMENT='Ldown absorbed by GREENROOFs'//' (W/m2)'
560     CALL WRITE_SURF(HPROGRAM,YRECFM,XABS_LW_GREENROOF(:),IRESP,HCOMMENT=YCOMMENT)
561     !
562     YRECFM='G_GR_ROOF'
563     YRECFM=ADJUSTL(YPATCH//YRECFM)
564     YCOMMENT='heat flux between GREENROOF and ROOF'//' (W/m2)'
565     CALL WRITE_SURF(HPROGRAM,YRECFM,XG_GREENROOF_ROOF(:),IRESP,HCOMMENT=YCOMMENT)
566     !
567     YRECFM='RUNOFF_GR'
568     YRECFM=ADJUSTL(YPATCH//YRECFM)
569     YCOMMENT='GREENROOF soil surface runoff'//' (kg/m2/s)'
570     CALL WRITE_SURF(HPROGRAM,YRECFM,XRUNOFF_GREENROOF(:),IRESP,HCOMMENT=YCOMMENT)
571     !
572     YRECFM='DRAIN_GR'
573     YRECFM=ADJUSTL(YPATCH//YRECFM)
574     YCOMMENT='GREENROOF total vertical drainage'//' (kg/m2/s)'
575     CALL WRITE_SURF(HPROGRAM,YRECFM,XDRAIN_GREENROOF(:),IRESP,HCOMMENT=YCOMMENT)
576   !
577   ENDIF
578   !
579 END IF
580 !
581 !*       5.    Cumulated Energy fluxes 
582 !
583 !
584 !-------------------------------------------------------------------------------
585 !
586 !         End of IO
587 !
588  CALL END_IO_SURF_n(HPROGRAM)
589 IF (LHOOK) CALL DR_HOOK('WRITE_DIAG_MISC_TEB_N',1,ZHOOK_HANDLE)
590 !
591 END SUBROUTINE WRITE_DIAG_MISC_TEB_n