d9bc17f0c5af276e2a64bcc0f5fa026b60fe7ab3
[MNH-git_open_source-lfs.git] / src / SURFEX / read_pgd_teb_parn.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 READ_PGD_TEB_PAR_n(HPROGRAM,KNI,HDIRIN)
7 !     ################################################
8 !
9 !!****  *READ_PGD_TEB_PAR_n* - reads ISBA physiographic fields
10 !!                        
11 !!
12 !!    PURPOSE
13 !!    -------
14 !!
15 !!**  METHOD
16 !!    ------
17 !!
18 !!    EXTERNAL
19 !!    --------
20 !!
21 !!
22 !!    IMPLICIT ARGUMENTS
23 !!    ------------------
24 !!
25 !!    REFERENCE
26 !!    ---------
27 !!
28 !!
29 !!    AUTHOR
30 !!    ------
31 !!      V. Masson   *Meteo France*      
32 !!
33 !!    MODIFICATIONS
34 !!    -------------
35 !!      Original    05/2005
36 !-------------------------------------------------------------------------------
37 !
38 !*       0.    DECLARATIONS
39 !              ------------
40 !
41 USE MODD_TEB_GRID_n, ONLY :   NDIM
42 USE MODD_TEB_n,      ONLY :   LECOCLIMAP, LGARDEN, CBEM
43 USE MODD_DATA_TEB_n, ONLY :   NPAR_ROOF_LAYER, NPAR_WALL_LAYER, NPAR_ROAD_LAYER, &
44                               NPAR_BLDTYPE, NPAR_USETYPE,                        &
45                               NPAR_BLDCODE, NPAR_BLD_AGE,                        &
46                               XPAR_Z0_TOWN, XPAR_BLD,                            &
47                               XPAR_GARDEN, XPAR_ROAD_DIR, XPAR_GREENROOF,        &
48                               XPAR_ALB_ROOF,                                     &
49                               XPAR_EMIS_ROOF, XPAR_HC_ROOF, XPAR_TC_ROOF,        &
50                               XPAR_D_ROOF, XPAR_ALB_ROAD, XPAR_EMIS_ROAD,        &
51                               XPAR_HC_ROAD, XPAR_TC_ROAD, XPAR_D_ROAD,           &
52                               XPAR_ALB_WALL, XPAR_EMIS_WALL, XPAR_HC_WALL,       &
53                               XPAR_TC_WALL, XPAR_D_WALL, XPAR_BLD_HEIGHT,        &
54                               XPAR_WALL_O_HOR,                                   &
55                               XPAR_H_TRAFFIC, XPAR_LE_TRAFFIC,                   &
56                               XPAR_H_INDUSTRY, XPAR_LE_INDUSTRY,                 &
57                               LDATA_Z0_TOWN, LDATA_BLD, LDATA_ALB_ROOF,          &
58                               LDATA_EMIS_ROOF, LDATA_HC_ROOF, LDATA_TC_ROOF,     &
59                               LDATA_D_ROOF, LDATA_ALB_ROAD, LDATA_EMIS_ROAD,     &
60                               LDATA_HC_ROAD, LDATA_TC_ROAD, LDATA_D_ROAD,        &
61                               LDATA_ALB_WALL, LDATA_EMIS_WALL, LDATA_HC_WALL,    &
62                               LDATA_TC_WALL, LDATA_D_WALL, LDATA_BLD_HEIGHT,     &
63                               LDATA_WALL_O_HOR,                                  &
64                               LDATA_H_TRAFFIC, LDATA_LE_TRAFFIC,                 &
65                               LDATA_H_INDUSTRY, LDATA_LE_INDUSTRY ,              &
66                               LDATA_GARDEN, LDATA_BLDTYPE, LDATA_GREENROOF,      &
67                               LDATA_ROAD_DIR, LDATA_USETYPE, LDATA_BLD_AGE,      &
68                               LDATA_ROUGH_ROOF, LDATA_ROUGH_WALL,                &
69                               XPAR_ROUGH_WALL, XPAR_ROUGH_ROOF
70
71 USE MODD_DATA_BEM_n, ONLY :   NPAR_FLOOR_LAYER,                                  &
72                               XPAR_TCOOL_TARGET, XPAR_THEAT_TARGET,              &
73                               XPAR_HC_FLOOR, XPAR_TC_FLOOR, XPAR_D_FLOOR,        & 
74                               XPAR_F_WASTE_CAN, XPAR_SHADE, XPAR_NATVENT,        &
75                               XPAR_EFF_HEAT, XPAR_QIN, XPAR_QIN_FRAD,            &
76                               XPAR_SHGC, XPAR_U_WIN, XPAR_GR,                    &
77                               XPAR_FLOOR_HEIGHT, XPAR_INF, XPAR_QIN_FLAT,        &
78                               XPAR_HR_TARGET, XPAR_V_VENT, XPAR_CAP_SYS_HEAT,    &
79                               XPAR_CAP_SYS_RAT, XPAR_T_ADP, XPAR_M_SYS_RAT,      &
80                               XPAR_COP_RAT, XPAR_T_SIZE_MAX, XPAR_T_SIZE_MIN,    &
81                               XPAR_F_WATER_COND, XPAR_SHGC_SH,                   &
82                               LDATA_HC_FLOOR, LDATA_TC_FLOOR, LDATA_D_FLOOR,     &
83                               LDATA_TCOOL_TARGET, LDATA_THEAT_TARGET,            &
84                               LDATA_F_WASTE_CAN, LDATA_SHADE, LDATA_NATVENT,     &
85                               LDATA_EFF_HEAT, LDATA_QIN, LDATA_QIN_FRAD,         &
86                               LDATA_SHGC, LDATA_U_WIN, LDATA_GR,                 &
87                               LDATA_FLOOR_HEIGHT, LDATA_INF, LDATA_QIN_FLAT,     &
88                               LDATA_HR_TARGET, LDATA_V_VENT, LDATA_CAP_SYS_HEAT, &
89                               LDATA_CAP_SYS_RAT, LDATA_T_ADP, LDATA_M_SYS_RAT,   &
90                               LDATA_COP_RAT, LDATA_T_SIZE_MAX, LDATA_T_SIZE_MIN, &
91                               LDATA_F_WATER_COND, LDATA_SHGC_SH
92 !
93 USE MODI_READ_SURF
94 USE MODI_READ_BLD_DESCRIPTION
95 USE MODI_GET_LUOUT
96 USE MODI_BLDCODE
97 USE MODI_ABOR1_SFX
98 !
99 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
100 USE PARKIND1  ,ONLY : JPRB
101 !
102 IMPLICIT NONE
103 !
104 !*       0.1   Declarations of arguments
105 !              -------------------------
106 !
107  CHARACTER(LEN=6),  INTENT(IN)  :: HPROGRAM ! program calling
108 INTEGER,           INTENT(IN)  :: KNI      ! size of the new domain
109  CHARACTER(LEN=1),  INTENT(IN)  :: HDIRIN
110 !
111 !*       0.2   Declarations of local variables
112 !              -------------------------------
113 !
114 INTEGER           :: ILUOUT         ! output listing logical unit
115 INTEGER           :: IRESP          ! IRESP  : return-code if a problem appears
116  CHARACTER(LEN=12) :: YRECFM         ! Name of the article to be read
117 INTEGER           :: JLAYER         ! loop index
118 !
119 INTEGER           :: IVERSION       ! surface version
120 INTEGER           :: IBUGFIX        ! surface bugfix version
121 REAL, DIMENSION(NDIM) :: ZWORK      ! work array
122 REAL(KIND=JPRB) :: ZHOOK_HANDLE
123 !
124 !-------------------------------------------------------------------------------
125 IF (LHOOK) CALL DR_HOOK('READ_PGD_TEB_PAR_N',0,ZHOOK_HANDLE)
126 !
127  CALL GET_LUOUT(HPROGRAM,ILUOUT)
128 !
129 YRECFM='VERSION'
130  CALL READ_SURF(HPROGRAM,YRECFM,IVERSION,IRESP)
131 YRECFM='BUG'
132  CALL READ_SURF(HPROGRAM,YRECFM,IBUGFIX,IRESP)
133 !
134 IF (IVERSION<7 .AND. .NOT.LECOCLIMAP) THEN
135   !
136   LDATA_BLDTYPE     = .FALSE.
137   LDATA_BLD_AGE     = .FALSE.
138   LDATA_USETYPE     = .FALSE.
139   LDATA_Z0_TOWN     = .TRUE.
140   LDATA_BLD         = .TRUE.
141   LDATA_GARDEN      = .TRUE.
142   LDATA_GREENROOF   = .TRUE.
143   LDATA_ROAD_DIR    = .FALSE.
144   LDATA_ALB_ROOF    = .TRUE.
145   LDATA_EMIS_ROOF   = .TRUE.
146   LDATA_HC_ROOF     = .TRUE.
147   LDATA_TC_ROOF     = .TRUE.
148   LDATA_D_ROOF      = .TRUE.
149   LDATA_ALB_ROAD    = .TRUE.
150   LDATA_EMIS_ROAD   = .TRUE.
151   LDATA_HC_ROAD     = .TRUE.
152   LDATA_TC_ROAD     = .TRUE.
153   LDATA_D_ROAD      = .TRUE.
154   LDATA_ALB_WALL    = .TRUE.
155   LDATA_EMIS_WALL   = .TRUE.
156   LDATA_HC_WALL     = .TRUE.
157   LDATA_TC_WALL     = .TRUE.
158   LDATA_D_WALL      = .TRUE.
159   LDATA_BLD_HEIGHT  = .TRUE.
160   LDATA_WALL_O_HOR  = .TRUE.
161   LDATA_H_TRAFFIC   = .TRUE.
162   LDATA_LE_TRAFFIC  = .TRUE.
163   LDATA_H_INDUSTRY  = .TRUE.
164   LDATA_LE_INDUSTRY = .TRUE.
165   LDATA_ROUGH_ROOF  = .FALSE.
166   LDATA_ROUGH_WALL  = .FALSE.
167   !
168 ELSEIF (IVERSION>=7) THEN
169   !
170   IF (IVERSION>7 .OR. IBUGFIX>=3) THEN
171     YRECFM='L_BLDTYPE'
172     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_BLDTYPE,IRESP)
173     YRECFM='L_BLD_AGE'
174     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_BLD_AGE,IRESP)
175     YRECFM='L_USETYPE'
176     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_USETYPE,IRESP)
177     IF (LDATA_BLDTYPE .OR. LDATA_BLD_AGE .OR. LDATA_USETYPE) CALL READ_BLD_DESCRIPTION(HPROGRAM)
178   ENDIF
179   YRECFM='L_Z0_TOWN'
180   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_Z0_TOWN,IRESP)
181   YRECFM='L_BLD'
182   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_BLD,IRESP)
183   IF (IVERSION>=6) THEN
184     YRECFM='L_GARDEN'
185     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_GARDEN,IRESP)
186   ENDIF
187   IF (IVERSION==7 .AND. IBUGFIX<=2) THEN
188     LDATA_ROAD_DIR = .FALSE.
189     LDATA_GREENROOF= .FALSE.
190   ELSE
191     YRECFM='L_ROAD_DIR'
192     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ROAD_DIR,IRESP)
193     YRECFM='L_GREENROOF'
194     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_GREENROOF,IRESP)
195   END IF
196   YRECFM='L_ALB_ROOF'
197   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ALB_ROOF,IRESP)
198   YRECFM='L_EMIS_ROOF'
199   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_EMIS_ROOF,IRESP)
200   YRECFM='L_HC_ROOF'
201   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_HC_ROOF,IRESP)
202   YRECFM='L_TC_ROOF'
203   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_TC_ROOF,IRESP)
204   YRECFM='L_D_ROOF'
205   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_D_ROOF,IRESP)
206   YRECFM='L_ALB_ROAD'
207   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ALB_ROAD,IRESP)
208   YRECFM='L_EMIS_ROAD'
209   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_EMIS_ROAD,IRESP)
210   YRECFM='L_HC_ROAD'
211   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_HC_ROAD,IRESP)
212   YRECFM='L_TC_ROAD'
213   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_TC_ROAD,IRESP)
214   YRECFM='L_D_ROAD'
215   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_D_ROAD,IRESP)
216   YRECFM='L_ALB_WALL'
217   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ALB_WALL,IRESP)
218   YRECFM='L_EMIS_WALL'
219   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_EMIS_WALL,IRESP)
220   YRECFM='L_HC_WALL'
221   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_HC_WALL,IRESP)
222   YRECFM='L_TC_WALL'
223   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_TC_WALL,IRESP)
224   YRECFM='L_D_WALL'
225   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_D_WALL,IRESP)
226   YRECFM='L_BLD_HEIGHT'
227   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_BLD_HEIGHT,IRESP)
228   YRECFM='L_WALL_O_HOR'
229   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_WALL_O_HOR,IRESP)
230   YRECFM='L_H_TRAF'
231   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_H_TRAFFIC,IRESP)
232   YRECFM='L_LE_TRAF'
233   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_LE_TRAFFIC,IRESP)
234   YRECFM='L_H_IND'
235   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_H_INDUSTRY,IRESP)
236   YRECFM='L_LE_IND'
237   CALL READ_SURF(HPROGRAM,YRECFM,LDATA_LE_INDUSTRY,IRESP)
238   IF (IVERSION>7 .OR. IBUGFIX>=3) THEN
239     YRECFM='L_ROUGH_ROOF'
240     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ROUGH_ROOF,IRESP)
241     YRECFM='L_ROUGH_WALL'
242     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ROUGH_WALL,IRESP)
243   ENDIF
244   !
245   IF (CBEM=='BEM') THEN
246     YRECFM='L_HC_FLOOR'
247     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_HC_FLOOR,IRESP)
248     YRECFM='L_TC_FLOOR'
249     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_TC_FLOOR,IRESP)
250     YRECFM='L_D_FLOOR'
251     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_D_FLOOR,IRESP)            
252     YRECFM='L_TCOOL_TARG'
253     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_TCOOL_TARGET,IRESP)
254     YRECFM='L_THEAT_TARG'
255     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_THEAT_TARGET,IRESP)
256     YRECFM='L_F_WAST_CAN'
257     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_F_WASTE_CAN,IRESP)
258     YRECFM='L_EFF_HEAT'
259     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_EFF_HEAT,IRESP)
260     YRECFM='L_QIN'
261     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_QIN,IRESP)
262     YRECFM='L_QIN_FRAD'
263     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_QIN_FRAD,IRESP)
264     YRECFM='L_SHGC'
265     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_SHGC,IRESP)
266     YRECFM='L_U_WIN'
267     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_U_WIN,IRESP)
268     YRECFM='L_GR'
269     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_GR,IRESP)
270     YRECFM='L_SHGC_SH'
271     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_SHGC_SH,IRESP)    
272     YRECFM='L_FLOOR_HEIG'
273     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_FLOOR_HEIGHT,IRESP)
274     YRECFM='L_INF'
275     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_INF,IRESP)
276     YRECFM='L_FWAT_COND'
277     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_F_WATER_COND,IRESP)
278     YRECFM='L_SHADE'
279     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_SHADE,IRESP) 
280     YRECFM='L_NATVENT'
281     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_NATVENT,IRESP)     
282     YRECFM='L_V_VENT'
283     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_V_VENT,IRESP)    
284     YRECFM='L_QIN_FLAT'
285     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_QIN_FLAT,IRESP)
286     YRECFM='L_HR_TARGET'
287     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_HR_TARGET,IRESP)
288     YRECFM='L_CAP_SYS_HE'
289     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_CAP_SYS_HEAT,IRESP)
290     YRECFM='L_CAP_SYS_RA'
291     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_CAP_SYS_RAT,IRESP)
292     YRECFM='L_T_ADP'
293     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_T_ADP,IRESP)
294     YRECFM='L_M_SYS_RAT'
295     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_M_SYS_RAT,IRESP)
296     YRECFM='L_COP_RAT'
297     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_COP_RAT,IRESP)
298     YRECFM='L_T_SIZE_MAX'
299     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_T_SIZE_MAX,IRESP)
300     YRECFM='L_T_SIZE_MIN'
301     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_T_SIZE_MIN,IRESP)
302   ENDIF
303   !
304 ENDIF
305 !
306 !* read number of layers if thermal properties are specified
307 !
308 IF (LDATA_HC_ROOF) THEN
309   YRECFM='PAR_RF_LAYER'
310   IF (IVERSION<7 .OR. (IVERSION==7 .AND. IBUGFIX<=2)) YRECFM='ROOF_LAYER'
311   CALL READ_SURF(HPROGRAM,YRECFM,NPAR_ROOF_LAYER,IRESP)
312 END IF
313 !
314 IF (LDATA_HC_ROAD) THEN
315   YRECFM='PAR_RD_LAYER'
316   IF (IVERSION<7 .OR. (IVERSION==7 .AND. IBUGFIX<=2)) YRECFM='ROAD_LAYER'
317   CALL READ_SURF(HPROGRAM,YRECFM,NPAR_ROAD_LAYER,IRESP)
318 END IF
319 !
320 IF (LDATA_HC_WALL) THEN
321   YRECFM='PAR_WL_LAYER'
322   IF (IVERSION<7 .OR. (IVERSION==7 .AND. IBUGFIX<=2)) YRECFM='WALL_LAYER'
323   CALL READ_SURF(HPROGRAM,YRECFM,NPAR_WALL_LAYER,IRESP)
324 END IF
325 !
326 IF (LDATA_HC_FLOOR) THEN
327   YRECFM='PAR_FL_LAYER'
328   IF (IVERSION<7 .OR. (IVERSION==7 .AND. IBUGFIX<=2)) YRECFM='FLOOR_LAYER'
329   CALL READ_SURF(HPROGRAM,YRECFM,NPAR_FLOOR_LAYER,IRESP)
330 END IF
331 !
332 !* read specified fields
333 !
334 IF (LDATA_BLDTYPE .AND. .NOT. LDATA_BLDTYPE) THEN
335   CALL ABOR1_SFX('FATAL ERROR: Building type is prescribed but not the building age')
336 END IF
337 !
338 IF (LDATA_BLDTYPE) THEN
339   ALLOCATE(NPAR_BLDTYPE     (NDIM))    
340   YRECFM='D_BLDTYPE'
341   CALL READ_FIELD(YRECFM,ZWORK,HDIRIN)
342   NPAR_BLDTYPE(:) = NINT(ZWORK)
343 ENDIF
344 !
345 IF (LDATA_BLD_AGE) THEN
346   ALLOCATE(NPAR_BLD_AGE     (NDIM))    
347   YRECFM='D_BLD_AGE'
348   CALL READ_FIELD(YRECFM,ZWORK,HDIRIN)
349   NPAR_BLD_AGE(:) = NINT(ZWORK)
350 ENDIF
351 !
352 IF (LDATA_BLDTYPE .AND. LDATA_BLDTYPE) THEN
353   ALLOCATE(NPAR_BLDCODE(NDIM))
354   NPAR_BLDCODE=BLDCODE(NPAR_BLDTYPE,NPAR_BLD_AGE)
355 END IF
356 !
357 IF (LDATA_USETYPE) THEN
358   ALLOCATE(NPAR_USETYPE     (NDIM))    
359   YRECFM='D_USETYPE'
360   CALL READ_FIELD(YRECFM,ZWORK,HDIRIN)
361   NPAR_USETYPE(:) = NINT(ZWORK)
362 ENDIF
363 !
364 IF (LDATA_Z0_TOWN) THEN
365   ALLOCATE(XPAR_Z0_TOWN     (NDIM))
366   YRECFM='D_Z0_TOWN'
367   CALL READ_FIELD(YRECFM,XPAR_Z0_TOWN,HDIRIN)
368 ENDIF
369 !
370 IF (LDATA_BLD) THEN
371   ALLOCATE(XPAR_BLD         (NDIM))
372   YRECFM='D_BLD'
373   CALL READ_FIELD(YRECFM,XPAR_BLD,HDIRIN)
374 ENDIF
375 !
376 IF (IVERSION>=6) THEN
377   IF (LDATA_GARDEN) THEN
378     ALLOCATE(XPAR_GARDEN      (NDIM))
379     YRECFM='D_GARDEN'
380     CALL READ_FIELD(YRECFM,XPAR_GARDEN,HDIRIN)
381   ENDIF
382 !
383 ENDIF
384 !
385 IF (LDATA_GREENROOF) THEN
386   ALLOCATE(XPAR_GREENROOF    (NDIM))
387   YRECFM='D_GREENROOF'
388   CALL READ_FIELD(YRECFM,XPAR_GREENROOF,HDIRIN)
389 ENDIF
390 !
391 IF (LDATA_ROAD_DIR) THEN
392   ALLOCATE(XPAR_ROAD_DIR    (NDIM))
393   YRECFM='D_ROAD_DIR'
394   CALL READ_FIELD(YRECFM,XPAR_ROAD_DIR,HDIRIN)
395 ENDIF
396 !
397 IF (LDATA_ALB_ROOF) THEN
398   ALLOCATE(XPAR_ALB_ROOF    (NDIM))        
399   YRECFM='D_ALB_ROOF'
400   CALL READ_FIELD(YRECFM,XPAR_ALB_ROOF,HDIRIN)
401 ENDIF
402 !
403 IF (LDATA_EMIS_ROOF) THEN
404   ALLOCATE(XPAR_EMIS_ROOF   (NDIM))        
405   YRECFM='D_EMI_ROOF'
406   CALL READ_FIELD(YRECFM,XPAR_EMIS_ROOF,HDIRIN)
407 ENDIF
408 !
409 IF (LDATA_HC_ROOF) THEN
410   ALLOCATE(XPAR_HC_ROOF     (NDIM,NPAR_ROOF_LAYER))
411   DO JLAYER=1,NPAR_ROOF_LAYER
412     WRITE(YRECFM,FMT='(A9,I1.1)') 'D_HC_ROOF',JLAYER
413     CALL READ_FIELD(YRECFM,XPAR_HC_ROOF(:,JLAYER),HDIRIN)
414   END DO
415 ENDIF
416 !
417 IF (LDATA_TC_ROOF) THEN
418   ALLOCATE(XPAR_TC_ROOF     (NDIM,NPAR_ROOF_LAYER))
419   DO JLAYER=1,NPAR_ROOF_LAYER
420     WRITE(YRECFM,FMT='(A9,I1.1)') 'D_TC_ROOF',JLAYER
421     CALL READ_FIELD(YRECFM,XPAR_TC_ROOF(:,JLAYER),HDIRIN)
422   END DO
423 ENDIF
424 !
425 IF (LDATA_D_ROOF) THEN
426   ALLOCATE(XPAR_D_ROOF      (NDIM,NPAR_ROOF_LAYER))
427   DO JLAYER=1,NPAR_ROOF_LAYER
428     WRITE(YRECFM,FMT='(A8,I1.1)') 'D_D_ROOF',JLAYER
429     CALL READ_FIELD(YRECFM,XPAR_D_ROOF(:,JLAYER),HDIRIN)
430   END DO
431 ENDIF
432 !
433 IF (LDATA_ALB_ROAD) THEN
434   ALLOCATE(XPAR_ALB_ROAD    (NDIM))
435   YRECFM='D_ALB_ROAD'
436   CALL READ_FIELD(YRECFM,XPAR_ALB_ROAD,HDIRIN)
437 ENDIF
438 !
439 IF (LDATA_EMIS_ROAD) THEN
440   ALLOCATE(XPAR_EMIS_ROAD   (NDIM))
441   YRECFM='D_EMI_ROAD'
442   CALL READ_FIELD(YRECFM,XPAR_EMIS_ROAD,HDIRIN)
443 ENDIF
444 !
445 IF (LDATA_HC_ROAD) THEN
446   ALLOCATE(XPAR_HC_ROAD     (NDIM,NPAR_ROAD_LAYER))
447   DO JLAYER=1,NPAR_ROAD_LAYER
448     WRITE(YRECFM,FMT='(A9,I1.1)') 'D_HC_ROAD',JLAYER
449     CALL READ_FIELD(YRECFM,XPAR_HC_ROAD(:,JLAYER),HDIRIN)
450   END DO
451 ENDIF
452 !
453 IF (LDATA_TC_ROAD) THEN
454   ALLOCATE(XPAR_TC_ROAD     (NDIM,NPAR_ROAD_LAYER))
455   DO JLAYER=1,NPAR_ROAD_LAYER
456     WRITE(YRECFM,FMT='(A9,I1.1)') 'D_TC_ROAD',JLAYER
457     CALL READ_FIELD(YRECFM,XPAR_TC_ROAD(:,JLAYER),HDIRIN)
458   END DO
459 ENDIF
460 !
461 IF (LDATA_D_ROAD) THEN
462   ALLOCATE(XPAR_D_ROAD      (NDIM,NPAR_ROAD_LAYER))
463   DO JLAYER=1,NPAR_ROAD_LAYER
464     WRITE(YRECFM,FMT='(A8,I1.1)') 'D_D_ROAD',JLAYER
465     CALL READ_FIELD(YRECFM,XPAR_D_ROAD(:,JLAYER),HDIRIN)
466   END DO
467 ENDIF
468 !
469 IF (LDATA_ALB_WALL) THEN
470   ALLOCATE(XPAR_ALB_WALL    (NDIM))
471   YRECFM='D_ALB_WALL'
472   CALL READ_FIELD(YRECFM,XPAR_ALB_WALL,HDIRIN)
473 ENDIF
474 !
475 IF (LDATA_EMIS_WALL) THEN
476   ALLOCATE(XPAR_EMIS_WALL   (NDIM))
477   YRECFM='D_EMI_WALL'
478   CALL READ_FIELD(YRECFM,XPAR_EMIS_WALL,HDIRIN)
479 ENDIF
480 !
481 IF (LDATA_HC_WALL) THEN
482   ALLOCATE(XPAR_HC_WALL     (NDIM,NPAR_WALL_LAYER))
483   DO JLAYER=1,NPAR_WALL_LAYER
484     WRITE(YRECFM,FMT='(A9,I1.1)') 'D_HC_WALL',JLAYER
485     CALL READ_FIELD(YRECFM,XPAR_HC_WALL(:,JLAYER),HDIRIN)
486   END DO
487 ENDIF
488 !
489 IF (LDATA_TC_WALL) THEN
490   ALLOCATE(XPAR_TC_WALL     (NDIM,NPAR_WALL_LAYER))
491   DO JLAYER=1,NPAR_WALL_LAYER
492     WRITE(YRECFM,FMT='(A9,I1.1)') 'D_TC_WALL',JLAYER
493     CALL READ_FIELD(YRECFM,XPAR_TC_WALL(:,JLAYER),HDIRIN)
494   END DO
495 ENDIF
496 !
497 IF (LDATA_D_WALL) THEN
498   ALLOCATE(XPAR_D_WALL      (NDIM,NPAR_WALL_LAYER))
499   DO JLAYER=1,NPAR_WALL_LAYER
500     WRITE(YRECFM,FMT='(A8,I1.1)') 'D_D_WALL',JLAYER
501     CALL READ_FIELD(YRECFM,XPAR_D_WALL(:,JLAYER),HDIRIN)
502   END DO
503 ENDIF
504 !
505 IF (LDATA_BLD_HEIGHT) THEN
506   ALLOCATE(XPAR_BLD_HEIGHT  (NDIM))
507   YRECFM='D_BLD_HEIG'
508   CALL READ_FIELD(YRECFM,XPAR_BLD_HEIGHT,HDIRIN)
509 ENDIF
510 !
511 IF (LDATA_WALL_O_HOR) THEN
512   ALLOCATE(XPAR_WALL_O_HOR  (NDIM))
513   YRECFM='D_WALL_O_H'
514   CALL READ_FIELD(YRECFM,XPAR_WALL_O_HOR,HDIRIN)
515 ENDIF
516 !
517 IF (LDATA_H_TRAFFIC) THEN
518   ALLOCATE(XPAR_H_TRAFFIC   (NDIM))
519   YRECFM='D_H_TRAF'
520   CALL READ_FIELD(YRECFM,XPAR_H_TRAFFIC,HDIRIN)
521 ENDIF
522 !
523 IF (LDATA_LE_TRAFFIC) THEN
524   ALLOCATE(XPAR_LE_TRAFFIC  (NDIM))
525   YRECFM='D_LE_TRAF'
526   CALL READ_FIELD(YRECFM,XPAR_LE_TRAFFIC,HDIRIN)
527 ENDIF
528 !
529 IF (LDATA_H_INDUSTRY) THEN
530   ALLOCATE(XPAR_H_INDUSTRY  (NDIM))
531   YRECFM='D_H_IND'
532   CALL READ_FIELD(YRECFM,XPAR_H_INDUSTRY,HDIRIN)
533 ENDIF
534 !
535 IF (LDATA_LE_INDUSTRY) THEN
536   ALLOCATE(XPAR_LE_INDUSTRY (NDIM))
537   YRECFM='D_LE_IND'
538   CALL READ_FIELD(YRECFM,XPAR_LE_INDUSTRY,HDIRIN)
539 ENDIF
540 !
541 IF (LDATA_ROUGH_ROOF) THEN
542   ALLOCATE(XPAR_ROUGH_ROOF (NDIM))
543   YRECFM='D_ROUGH_ROOF'
544   CALL READ_FIELD(YRECFM,XPAR_ROUGH_ROOF,HDIRIN)
545 ENDIF
546 !
547 IF (LDATA_ROUGH_WALL) THEN
548   ALLOCATE(XPAR_ROUGH_WALL (NDIM))
549   YRECFM='D_ROUGH_WALL'
550   CALL READ_FIELD(YRECFM,XPAR_ROUGH_WALL,HDIRIN)
551 ENDIF
552 !
553 IF (CBEM=='BEM') THEN
554   !
555
556   IF (LDATA_HC_FLOOR) THEN
557     ALLOCATE(XPAR_HC_FLOOR    (NDIM,NPAR_FLOOR_LAYER))
558     DO JLAYER=1,NPAR_FLOOR_LAYER
559       WRITE(YRECFM,FMT='(A10,I1.1)') 'D_HC_FLOOR',JLAYER
560       CALL READ_FIELD(YRECFM,XPAR_HC_FLOOR(:,JLAYER),HDIRIN)
561     END DO
562   ENDIF
563   !
564   IF (LDATA_TC_FLOOR) THEN
565     ALLOCATE(XPAR_TC_FLOOR    (NDIM,NPAR_FLOOR_LAYER))
566     DO JLAYER=1,NPAR_FLOOR_LAYER
567       WRITE(YRECFM,FMT='(A10,I1.1)') 'D_TC_FLOOR',JLAYER
568       CALL READ_FIELD(YRECFM,XPAR_TC_FLOOR(:,JLAYER),HDIRIN)
569     END DO
570   ENDIF
571   !
572   IF (LDATA_D_FLOOR) THEN
573     ALLOCATE(XPAR_D_FLOOR     (NDIM,NPAR_FLOOR_LAYER))
574     DO JLAYER=1,NPAR_FLOOR_LAYER
575       WRITE(YRECFM,FMT='(A9,I1.1)') 'D_D_FLOOR',JLAYER
576       CALL READ_FIELD(YRECFM,XPAR_D_FLOOR(:,JLAYER),HDIRIN)
577     END DO
578   ENDIF
579   !
580   IF (LDATA_TCOOL_TARGET) THEN
581     ALLOCATE(XPAR_TCOOL_TARGET  (NDIM))
582     YRECFM='D_TCOOL_TARG'
583     CALL READ_FIELD(YRECFM,XPAR_TCOOL_TARGET,HDIRIN)
584   ENDIF
585   !
586   IF (LDATA_THEAT_TARGET) THEN
587     ALLOCATE(XPAR_THEAT_TARGET  (NDIM))
588     YRECFM='D_THEAT_TARG'
589     CALL READ_FIELD(YRECFM,XPAR_THEAT_TARGET,HDIRIN)
590   ENDIF
591   !
592   IF (LDATA_F_WASTE_CAN) THEN
593     ALLOCATE(XPAR_F_WASTE_CAN   (NDIM))
594     YRECFM='D_F_WAST_CAN'
595     CALL READ_FIELD(YRECFM,XPAR_F_WASTE_CAN,HDIRIN)
596   ENDIF
597   !
598   IF (LDATA_EFF_HEAT) THEN
599     ALLOCATE(XPAR_EFF_HEAT      (NDIM))
600     YRECFM='D_EFF_HEAT'
601     CALL READ_FIELD(YRECFM,XPAR_EFF_HEAT,HDIRIN)
602   ENDIF
603   !
604   IF (LDATA_QIN) THEN
605     ALLOCATE(XPAR_QIN           (NDIM))
606     YRECFM='D_QIN'
607     CALL READ_FIELD(YRECFM,XPAR_QIN,HDIRIN)
608   ENDIF
609   !
610   IF (LDATA_QIN_FRAD) THEN
611     ALLOCATE(XPAR_QIN_FRAD      (NDIM))
612     YRECFM='D_QIN_FRAD'
613     CALL READ_FIELD(YRECFM,XPAR_QIN_FRAD,HDIRIN)
614   ENDIF
615   !
616   IF (LDATA_SHGC) THEN
617     ALLOCATE(XPAR_SHGC          (NDIM))
618     YRECFM='D_SHGC'
619     CALL READ_FIELD(YRECFM,XPAR_SHGC,HDIRIN)
620   ENDIF
621   !
622   IF (LDATA_U_WIN) THEN
623     ALLOCATE(XPAR_U_WIN         (NDIM))
624     YRECFM='D_U_WIN'
625     CALL READ_FIELD(YRECFM,XPAR_U_WIN,HDIRIN)
626   ENDIF
627   !
628   IF (LDATA_GR) THEN
629     ALLOCATE(XPAR_GR            (NDIM))
630     YRECFM='D_GR'
631     CALL READ_FIELD(YRECFM,XPAR_GR,HDIRIN)
632   ENDIF
633   !
634   IF (LDATA_SHGC_SH) THEN
635     ALLOCATE(XPAR_SHGC_SH       (NDIM))
636     YRECFM='D_SHGC_SH'
637     CALL READ_FIELD(YRECFM,XPAR_SHGC_SH,HDIRIN)
638   ENDIF
639   !
640   IF (LDATA_FLOOR_HEIGHT) THEN
641     ALLOCATE(XPAR_FLOOR_HEIGHT  (NDIM))
642     YRECFM='D_FLOOR_HEIG'
643     CALL READ_FIELD(YRECFM,XPAR_FLOOR_HEIGHT,HDIRIN)
644   ENDIF
645   !
646   IF (LDATA_INF) THEN
647     ALLOCATE(XPAR_INF           (NDIM))
648     YRECFM='D_INF'
649     CALL READ_FIELD(YRECFM,XPAR_INF,HDIRIN)
650   ENDIF
651   !
652   IF (LDATA_F_WATER_COND) THEN
653      ALLOCATE(XPAR_F_WATER_COND (NDIM))
654     YRECFM='D_FWAT_COND'
655     CALL READ_FIELD(YRECFM,XPAR_F_WATER_COND,HDIRIN)
656   ENDIF
657   !
658   IF (LDATA_SHADE) THEN
659     ALLOCATE(XPAR_SHADE        (NDIM))
660     YRECFM='D_SHADE'
661     CALL READ_FIELD(YRECFM,XPAR_SHADE,HDIRIN)
662     XPAR_SHADE=FLOAT(NINT(XPAR_SHADE))
663   ENDIF
664   !
665   IF (LDATA_NATVENT) THEN
666     ALLOCATE(XPAR_NATVENT      (NDIM))
667     YRECFM='D_NATVENT'
668     CALL READ_FIELD(YRECFM,XPAR_NATVENT,HDIRIN)
669     XPAR_NATVENT=FLOAT(NINT(XPAR_NATVENT))
670   ENDIF
671   !  
672   IF (LDATA_QIN_FLAT) THEN
673     ALLOCATE(XPAR_QIN_FLAT     (NDIM))
674     YRECFM='D_QIN_FLAT'
675     CALL READ_FIELD(YRECFM,XPAR_QIN_FLAT,HDIRIN)
676   ENDIF
677   !
678   IF (LDATA_HR_TARGET) THEN
679     ALLOCATE(XPAR_HR_TARGET    (NDIM))
680     YRECFM='D_HR_TARGET'
681     CALL READ_FIELD(YRECFM,XPAR_HR_TARGET,HDIRIN)
682   ENDIF
683   !
684   IF (LDATA_V_VENT) THEN
685     ALLOCATE(XPAR_V_VENT       (NDIM))
686     YRECFM='D_V_VENT'
687     CALL READ_FIELD(YRECFM,XPAR_V_VENT,HDIRIN)
688   ENDIF
689   !
690   IF (LDATA_CAP_SYS_HEAT) THEN
691     ALLOCATE(XPAR_CAP_SYS_HEAT (NDIM))
692     YRECFM='D_CAP_SYS_HE'
693     CALL READ_FIELD(YRECFM,XPAR_CAP_SYS_HEAT,HDIRIN)
694   ENDIF
695   !
696   IF (LDATA_CAP_SYS_RAT) THEN
697     ALLOCATE(XPAR_CAP_SYS_RAT  (NDIM))
698     YRECFM='D_CAP_SYS_RA'
699     CALL READ_FIELD(YRECFM,XPAR_CAP_SYS_RAT,HDIRIN)
700   ENDIF
701   !
702   IF (LDATA_T_ADP) THEN
703     ALLOCATE(XPAR_T_ADP        (NDIM))
704     YRECFM='D_T_ADP'
705     CALL READ_FIELD(YRECFM,XPAR_T_ADP,HDIRIN)
706   ENDIF
707   !
708   IF (LDATA_M_SYS_RAT) THEN
709     ALLOCATE(XPAR_M_SYS_RAT    (NDIM))
710     YRECFM='D_M_SYS_RAT'
711     CALL READ_FIELD(YRECFM,XPAR_M_SYS_RAT,HDIRIN)
712   ENDIF
713   !
714   IF (LDATA_COP_RAT) THEN
715     ALLOCATE(XPAR_COP_RAT      (NDIM))
716     YRECFM='D_COP_RAT'
717     CALL READ_FIELD(YRECFM,XPAR_COP_RAT,HDIRIN)
718   ENDIF
719   !
720   IF (LDATA_T_SIZE_MAX) THEN
721     ALLOCATE(XPAR_T_SIZE_MAX   (NDIM))
722     YRECFM='D_T_SIZE_MAX'
723     CALL READ_FIELD(YRECFM,XPAR_T_SIZE_MAX,HDIRIN)
724   ENDIF
725   !
726   IF (LDATA_T_SIZE_MIN) THEN
727     ALLOCATE(XPAR_T_SIZE_MIN   (NDIM))
728     YRECFM='D_T_SIZE_MIN'
729     CALL READ_FIELD(YRECFM,XPAR_T_SIZE_MIN,HDIRIN)
730   ENDIF
731   !
732 ENDIF
733 !
734 IF (LHOOK) CALL DR_HOOK('READ_PGD_TEB_PAR_N',1,ZHOOK_HANDLE)
735 !
736 !-------------------------------------------------------------------------------
737 CONTAINS
738 !-------------------------------------------------------------------------------
739 !
740 SUBROUTINE READ_FIELD(HRECFM,PFIELD,YDIR)
741 !
742 USE MODI_HOR_INTERPOL
743 !
744 IMPLICIT NONE
745 !
746  CHARACTER(LEN=*),     INTENT(IN)  :: HRECFM ! name of record in the file
747 REAL, DIMENSION(NDIM), INTENT(OUT) :: PFIELD
748  CHARACTER(LEN=1),     INTENT(IN)  :: YDIR
749 !
750 REAL, DIMENSION(KNI)              :: ZF
751 REAL, DIMENSION(:,:), POINTER     :: ZIN
752 REAL, DIMENSION(NDIM,1)           :: ZOUT
753 REAL(KIND=JPRB) :: ZHOOK_HANDLE
754 !
755 IF (LHOOK) CALL DR_HOOK('READ_PGD_TEB_PAR_N:READ_FIELD',0,ZHOOK_HANDLE)
756 !
757 IF (YDIR=='A') THEN
758   !
759   CALL READ_SURF(HPROGRAM,HRECFM,ZF,IRESP,HDIR='A')
760   ALLOCATE(ZIN(KNI,1))
761   ZIN(:,1) = ZF(:)
762   CALL HOR_INTERPOL(ILUOUT,ZIN,ZOUT)
763   DEALLOCATE(ZIN)
764   PFIELD(:) = ZOUT(:,1)
765   !
766 ELSE
767   CALL READ_SURF(HPROGRAM,HRECFM,PFIELD,IRESP)
768 ENDIF
769 !
770 IF (LHOOK) CALL DR_HOOK('READ_PGD_TEB_PAR_N:READ_FIELD',1,ZHOOK_HANDLE)
771 !
772 END SUBROUTINE READ_FIELD
773 !_______________________________
774 !
775 END SUBROUTINE READ_PGD_TEB_PAR_n