Juan 8/12/2016: add management of LEN_HREC in MNH & SURFEX
[MNH-git_open_source-lfs.git] / src / SURFEX / read_pgd_isba_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_ISBA_PAR_n(HPROGRAM,KSIZE,OLAND_USE,HDIR)
7 !     ################################################
8 !
9 !!****  *READ_PGD_ISBA_PAR_n* - reads ISBA physiographic fields                     
10 !!
11 !!    PURPOSE
12 !!    -------
13 !!
14 !!**  METHOD
15 !!    ------
16 !!
17 !!    EXTERNAL
18 !!    --------
19 !!
20 !!
21 !!    IMPLICIT ARGUMENTS
22 !!    ------------------
23 !!
24 !!    REFERENCE
25 !!    ---------
26 !!
27 !!
28 !!    AUTHOR
29 !!    ------
30 !!      V. Masson   *Meteo France*      
31 !!
32 !!    MODIFICATIONS
33 !!    -------------
34 !!      Original    01/2003 
35 !!      P. Le Moigne 12/2004 : add type of photosynthesis 
36 !!      M.Moge    01/2016  using READ_SURF_FIELD2D/3D for 2D/3D surfex fields reads
37 !-------------------------------------------------------------------------------
38 !
39 !*       0.    DECLARATIONS
40 !              ------------
41 !
42 USE MODD_DATA_COVER_PAR, ONLY : NVEGTYPE
43 USE MODD_PREP,           ONLY : LINTERP
44 !
45 USE MODD_ISBA_GRID_n,    ONLY : NDIM
46 USE MODD_ISBA_n,         ONLY : LECOCLIMAP, NGROUND_LAYER
47 USE MODD_DATA_ISBA_n,    ONLY : NTIME, XPAR_VEG, XPAR_LAI,XPAR_RSMIN,XPAR_GAMMA,XPAR_WRMAX_CF, &
48                                 XPAR_RGL,XPAR_CV,XPAR_DG,XPAR_Z0,XPAR_Z0_O_Z0H,         &
49                                 XPAR_ALBNIR_VEG,XPAR_ALBVIS_VEG, XPAR_ALBUV_VEG,          &
50                                 XPAR_ALBNIR_SOIL,XPAR_ALBVIS_SOIL, XPAR_ALBUV_SOIL,       &
51                                 XPAR_EMIS, XPAR_DICE,                                      &
52                                 XPAR_VEGTYPE,XPAR_ROOTFRAC,                                &
53                                 XPAR_GMES,XPAR_BSLAI,XPAR_LAIMIN,XPAR_SEFOLD,XPAR_GC,   &
54                                 XPAR_DMAX, XPAR_F2I, LPAR_STRESS, XPAR_H_TREE,XPAR_RE25,&
55                                 XPAR_CE_NITRO,XPAR_CF_NITRO,XPAR_CNA_NITRO, &
56                                 XPAR_GROUND_DEPTH, XPAR_ROOT_DEPTH,               &
57                                 XPAR_ROOT_EXTINCTION, XPAR_ROOT_LIN,              &
58                                 LPAR_STRESS, XPAR_IRRIG, XPAR_WATSUP, &
59                                 LDATA_VEGTYPE, LDATA_LAI, LDATA_H_TREE, LDATA_DG, LDATA_ROOTFRAC,&  
60                                 LDATA_VEG, LDATA_Z0, LDATA_EMIS, LDATA_DICE, &
61                                 LDATA_RSMIN, LDATA_GAMMA, LDATA_WRMAX_CF, LDATA_RGL, &
62                                 LDATA_CV, LDATA_Z0_O_Z0H, &
63                                 LDATA_ALBNIR_VEG, LDATA_ALBVIS_VEG, LDATA_ALBUV_VEG, &
64                                 LDATA_ALBVIS_SOIL, LDATA_ALBNIR_SOIL, LDATA_ALBUV_SOIL, &
65                                 LDATA_GMES, LDATA_BSLAI, LDATA_SEFOLD, LDATA_GC, LDATA_DMAX, &
66                                 LDATA_RE25, LDATA_LAIMIN, LDATA_F2I, &
67                                 LDATA_CE_NITRO,LDATA_CF_NITRO, LDATA_CNA_NITRO,&
68                                 LDATA_STRESS, LDATA_IRRIG, LDATA_WATSUP  ,&
69                                 LDATA_GROUND_DEPTH, LDATA_ROOT_DEPTH,             &
70                                 LDATA_ROOT_EXTINCTION, LDATA_ROOT_LIN, LDATA_MIXPAR
71 !
72 USE MODI_GET_LUOUT
73 USE MODI_READ_SURF
74 USE MODI_READ_SURF_FIELD2D
75 USE MODI_HOR_INTERPOL
76 USE MODI_READ_SURF_ISBA_PAR_n
77 !
78 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
79 USE PARKIND1  ,ONLY : JPRB
80 !
81 IMPLICIT NONE
82 !
83 !*       0.1   Declarations of arguments
84 !              -------------------------
85 !
86  CHARACTER(LEN=6),  INTENT(IN)  :: HPROGRAM ! program calling
87 INTEGER,           INTENT(IN)  :: KSIZE
88 LOGICAL,           INTENT(IN)  :: OLAND_USE ! 
89  CHARACTER(LEN=1),OPTIONAL,INTENT(IN)  :: HDIR       ! type of field :
90 !                                                   ! 'H' : field with
91 !                                                   !       horizontal spatial dim.
92 !                                                   ! '-' : no horizontal dim.
93 !
94 !*       0.2   Declarations of local variables
95 !              -------------------------------
96 !
97 REAL, DIMENSION(KSIZE,NVEGTYPE) :: ZFIELD
98 REAL,    DIMENSION(:,:), ALLOCATABLE :: ZWORK
99 INTEGER           :: ILUOUT
100 INTEGER           :: ITIME
101 INTEGER           :: IRESP          ! IRESP  : return-code if a problem appears
102  CHARACTER(LEN=LEN_HREC) :: YRECFM         ! Name of the article to be read
103  CHARACTER(LEN=LEN_HREC) :: YRECFM2
104  CHARACTER(LEN=100):: YCOMMENT       ! Comment string
105  CHARACTER(LEN=1)  :: YDIR
106 INTEGER           :: JTIME          ! loop index
107 INTEGER           :: JLAYER         ! loop index
108 INTEGER           :: JPATCH         ! loop index
109 INTEGER           :: IVERSION       ! surface version
110 INTEGER           :: IBUGFIX
111 REAL(KIND=JPRB) :: ZHOOK_HANDLE
112 !
113 !
114 !-------------------------------------------------------------------------------
115 !
116 IF (LHOOK) CALL DR_HOOK('READ_PGD_ISBA_PAR_N',0,ZHOOK_HANDLE)
117 !
118  CALL GET_LUOUT(HPROGRAM,ILUOUT)
119 !
120 YDIR = 'H'
121 IF (PRESENT(HDIR)) YDIR = HDIR
122 !
123 YRECFM='VERSION'
124  CALL READ_SURF(HPROGRAM,YRECFM,IVERSION,IRESP)
125 WRITE(ILUOUT,*) 'read version ',IVERSION
126 !
127 YRECFM='BUG'
128  CALL READ_SURF(HPROGRAM,YRECFM,IBUGFIX,IRESP)
129 !
130 LDATA_MIXPAR = .FALSE. 
131 !
132 IF (IVERSION<7 .AND. .NOT.LECOCLIMAP) THEN
133   !
134   LDATA_VEGTYPE=.TRUE.
135   LDATA_VEG=.TRUE.
136   LDATA_LAI=.TRUE.
137   LDATA_Z0=.TRUE.
138   LDATA_EMIS=.TRUE.
139   LDATA_RSMIN=.TRUE.
140   LDATA_GAMMA=.TRUE.
141   LDATA_WRMAX_CF=.TRUE.
142   LDATA_RGL=.TRUE.
143   LDATA_CV=.TRUE.
144   LDATA_Z0_O_Z0H=.TRUE.
145   LDATA_DG=.TRUE.
146   LDATA_ROOTFRAC=.TRUE.
147   !
148   LDATA_DICE=.FALSE.
149   LDATA_GROUND_DEPTH=.FALSE.
150   LDATA_ROOT_DEPTH=.FALSE.
151   LDATA_ROOT_LIN=.FALSE.
152   LDATA_ROOT_EXTINCTION=.FALSE.  
153   !
154   LDATA_ALBNIR_VEG=.TRUE.
155   LDATA_ALBVIS_VEG=.TRUE.
156   LDATA_ALBUV_VEG=.TRUE.
157   LDATA_ALBNIR_SOIL=.TRUE.
158   LDATA_ALBVIS_SOIL=.TRUE.
159   LDATA_ALBUV_SOIL=.TRUE.
160   LDATA_GMES=.TRUE.
161   LDATA_BSLAI=.TRUE.
162   LDATA_LAIMIN=.TRUE.
163   LDATA_SEFOLD=.TRUE.
164   LDATA_GC=.TRUE.
165   LDATA_DMAX=.TRUE.
166   LDATA_F2I=.TRUE.
167   LDATA_STRESS=.TRUE.
168   LDATA_H_TREE=.TRUE.
169   LDATA_RE25=.TRUE.
170   LDATA_CE_NITRO=.TRUE.
171   LDATA_CF_NITRO=.TRUE.
172   LDATA_CNA_NITRO=.TRUE.
173   !
174   LDATA_IRRIG=.FALSE.
175   LDATA_WATSUP=.FALSE.
176   !
177 ENDIF
178 !
179 IF (.NOT.OLAND_USE) THEN
180   !
181   IF (IVERSION>=7) THEN
182     !
183     YRECFM='L_VEGTYPE'
184     YCOMMENT=YRECFM
185     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_VEGTYPE,IRESP,HCOMMENT=YCOMMENT)
186     IF (LDATA_VEGTYPE) LDATA_MIXPAR = .TRUE.
187     !
188     YRECFM='L_VEG'
189     YCOMMENT=YRECFM
190     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_VEG,IRESP,HCOMMENT=YCOMMENT)
191     IF (LDATA_VEG) LDATA_MIXPAR = .TRUE.
192     YRECFM='L_LAI'
193     YCOMMENT=YRECFM
194     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_LAI,IRESP,HCOMMENT=YCOMMENT)
195     IF (LDATA_LAI) LDATA_MIXPAR = .TRUE.
196     YRECFM='L_Z0'
197     YCOMMENT=YRECFM
198     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_Z0,IRESP,HCOMMENT=YCOMMENT)
199     IF (LDATA_Z0) LDATA_MIXPAR = .TRUE.
200     YRECFM='L_EMIS'
201     YCOMMENT=YRECFM
202     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_EMIS,IRESP,HCOMMENT=YCOMMENT)
203     IF (LDATA_EMIS) LDATA_MIXPAR = .TRUE.
204     !
205     YRECFM='L_RSMIN'
206     YCOMMENT=YRECFM
207     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_RSMIN,IRESP,HCOMMENT=YCOMMENT)
208     IF (LDATA_RSMIN) LDATA_MIXPAR = .TRUE.
209     YRECFM='L_GAMMA'
210     YCOMMENT=YRECFM
211     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_GAMMA,IRESP,HCOMMENT=YCOMMENT)
212     IF (LDATA_GAMMA) LDATA_MIXPAR = .TRUE.
213     YRECFM='L_WRMAX_CF'
214     YCOMMENT=YRECFM
215     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_WRMAX_CF,IRESP,HCOMMENT=YCOMMENT)
216     IF (LDATA_WRMAX_CF) LDATA_MIXPAR = .TRUE.
217     YRECFM='L_RGL'
218     YCOMMENT=YRECFM
219     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_RGL,IRESP,HCOMMENT=YCOMMENT)
220     IF (LDATA_RGL) LDATA_MIXPAR = .TRUE.
221     YRECFM='L_CV'
222     YCOMMENT=YRECFM
223     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_CV,IRESP,HCOMMENT=YCOMMENT)
224     IF (LDATA_CV) LDATA_MIXPAR = .TRUE.
225     YRECFM='L_Z0_O_Z0H'
226     YCOMMENT=YRECFM
227     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_Z0_O_Z0H,IRESP,HCOMMENT=YCOMMENT)
228     IF (LDATA_Z0_O_Z0H) LDATA_MIXPAR = .TRUE.
229     YRECFM='L_DG'
230     YCOMMENT=YRECFM
231     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_DG,IRESP,HCOMMENT=YCOMMENT)
232     IF (LDATA_DG) LDATA_MIXPAR = .TRUE.
233     YRECFM='L_ROOTFRAC'
234     YCOMMENT=YRECFM
235     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ROOTFRAC,IRESP,HCOMMENT=YCOMMENT)
236     IF (LDATA_ROOTFRAC) LDATA_MIXPAR = .TRUE.
237     YRECFM='L_DICE'
238     YCOMMENT=YRECFM
239     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_DICE,IRESP,HCOMMENT=YCOMMENT)
240     IF (LDATA_DICE) LDATA_MIXPAR = .TRUE.
241     !
242     IF (IBUGFIX>=2) THEN
243       YRECFM2='L_GROUND_DEPTH'
244       IF (IBUGFIX>=3) YRECFM2='L_GROUND_DPT'
245       YCOMMENT=YRECFM
246       CALL READ_SURF(HPROGRAM,YRECFM2,LDATA_GROUND_DEPTH,IRESP,HCOMMENT=YCOMMENT)
247       IF (LDATA_GROUND_DEPTH) LDATA_MIXPAR = .TRUE.
248       YRECFM='L_ROOT_DEPTH'
249       YCOMMENT=YRECFM
250       CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ROOT_DEPTH,IRESP,HCOMMENT=YCOMMENT)
251       IF (LDATA_ROOT_DEPTH) LDATA_MIXPAR = .TRUE.
252       YRECFM='L_ROOT_EXT'
253       YCOMMENT=YRECFM
254       CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ROOT_EXTINCTION,IRESP,HCOMMENT=YCOMMENT)
255       IF (LDATA_ROOT_EXTINCTION) LDATA_MIXPAR = .TRUE.
256       YRECFM='L_ROOT_LIN'
257       YCOMMENT=YRECFM
258       CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ROOT_LIN,IRESP,HCOMMENT=YCOMMENT)
259       IF (LDATA_ROOT_LIN) LDATA_MIXPAR = .TRUE.
260     ELSE
261       LDATA_GROUND_DEPTH = .FALSE.
262       LDATA_ROOT_DEPTH   = .FALSE.
263       LDATA_ROOT_EXTINCTION = .FALSE.
264       LDATA_ROOT_LIN = .FALSE.
265     ENDIF
266     !
267     YRECFM='L_ALBNIR_VEG'
268     YCOMMENT=YRECFM
269     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ALBNIR_VEG,IRESP,HCOMMENT=YCOMMENT)
270     IF (LDATA_ALBNIR_VEG) LDATA_MIXPAR = .TRUE.
271     YRECFM='L_ALBVIS_VEG'
272     YCOMMENT=YRECFM
273     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ALBVIS_VEG,IRESP,HCOMMENT=YCOMMENT)
274     IF (LDATA_ALBVIS_VEG) LDATA_MIXPAR = .TRUE.
275     YRECFM='L_ALBUV_VEG'
276     YCOMMENT=YRECFM
277     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ALBUV_VEG,IRESP,HCOMMENT=YCOMMENT)
278     IF (LDATA_ALBUV_VEG) LDATA_MIXPAR = .TRUE.
279     YRECFM='L_ALBNIR_SOI'
280     YCOMMENT=YRECFM
281     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ALBNIR_SOIL,IRESP,HCOMMENT=YCOMMENT)
282     IF (LDATA_ALBNIR_SOIL) LDATA_MIXPAR = .TRUE.
283     YRECFM='L_ALBVIS_SOI'
284     YCOMMENT=YRECFM
285     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ALBVIS_SOIL,IRESP,HCOMMENT=YCOMMENT)
286     IF (LDATA_ALBVIS_SOIL) LDATA_MIXPAR = .TRUE.
287     YRECFM='L_ALBUV_SOI'
288     YCOMMENT=YRECFM
289     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_ALBUV_SOIL,IRESP,HCOMMENT=YCOMMENT)
290     IF (LDATA_ALBUV_SOIL) LDATA_MIXPAR = .TRUE.
291     YRECFM='L_GMES'
292     YCOMMENT=YRECFM
293     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_GMES,IRESP,HCOMMENT=YCOMMENT)
294     IF (LDATA_GMES) LDATA_MIXPAR = .TRUE.
295     YRECFM='L_BSLAI'
296     YCOMMENT=YRECFM
297     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_BSLAI,IRESP,HCOMMENT=YCOMMENT)
298     IF (LDATA_BSLAI) LDATA_MIXPAR = .TRUE.
299     YRECFM='L_LAIMIN'
300     YCOMMENT=YRECFM
301     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_LAIMIN,IRESP,HCOMMENT=YCOMMENT)
302     IF (LDATA_LAIMIN) LDATA_MIXPAR = .TRUE.
303     YRECFM='L_SEFOLD'
304     YCOMMENT=YRECFM
305     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_SEFOLD,IRESP,HCOMMENT=YCOMMENT)
306     IF (LDATA_SEFOLD) LDATA_MIXPAR = .TRUE.
307     YRECFM='L_GC'
308     YCOMMENT=YRECFM
309     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_GC,IRESP,HCOMMENT=YCOMMENT)
310     IF (LDATA_GC) LDATA_MIXPAR = .TRUE.
311     YRECFM='L_DMAX'
312     YCOMMENT=YRECFM
313     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_DMAX,IRESP,HCOMMENT=YCOMMENT)
314     IF (LDATA_DMAX) LDATA_MIXPAR = .TRUE.
315     YRECFM='L_F2I'
316     YCOMMENT=YRECFM
317     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_F2I,IRESP,HCOMMENT=YCOMMENT)
318     IF (LDATA_F2I) LDATA_MIXPAR = .TRUE.
319     YRECFM='L_STRESS'
320     YCOMMENT=YRECFM
321     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_STRESS,IRESP,HCOMMENT=YCOMMENT)
322     IF (LDATA_STRESS) LDATA_MIXPAR = .TRUE.
323     YRECFM='L_H_TREE'
324     YCOMMENT=YRECFM
325     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_H_TREE,IRESP,HCOMMENT=YCOMMENT)
326     IF (LDATA_H_TREE) LDATA_MIXPAR = .TRUE.
327     YRECFM='L_RE25'
328     YCOMMENT=YRECFM
329     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_RE25,IRESP,HCOMMENT=YCOMMENT)
330     IF (LDATA_RE25) LDATA_MIXPAR = .TRUE.
331     YRECFM='L_CE_NITRO'
332     YCOMMENT=YRECFM
333     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_CE_NITRO,IRESP,HCOMMENT=YCOMMENT)
334     IF (LDATA_CE_NITRO) LDATA_MIXPAR = .TRUE.
335     YRECFM='L_CF_NITRO'
336     YCOMMENT=YRECFM
337     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_CF_NITRO,IRESP,HCOMMENT=YCOMMENT)
338     IF (LDATA_CF_NITRO) LDATA_MIXPAR = .TRUE.
339     YRECFM='L_CNA_NITRO'
340     YCOMMENT=YRECFM
341     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_CNA_NITRO,IRESP,HCOMMENT=YCOMMENT)
342     IF (LDATA_CNA_NITRO) LDATA_MIXPAR = .TRUE.
343     YRECFM='L_IRRIG'
344     YCOMMENT=YRECFM
345     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_IRRIG,IRESP,HCOMMENT=YCOMMENT)
346     IF (LDATA_IRRIG) LDATA_MIXPAR = .TRUE.
347     YRECFM='L_WATSUP'
348     YCOMMENT=YRECFM
349     CALL READ_SURF(HPROGRAM,YRECFM,LDATA_WATSUP,IRESP,HCOMMENT=YCOMMENT)
350     IF (LDATA_WATSUP) LDATA_MIXPAR = .TRUE.
351     !
352   ENDIF
353   !
354   IF (ALLOCATED(LINTERP)) LINTERP(:) = .TRUE.
355   !
356   IF (LDATA_VEGTYPE) THEN
357     YRECFM='D_VEGTYPE'
358     CALL READ_SURF_FIELD2D(HPROGRAM,ZFIELD(:,:),YRECFM,HCOMMENT=YCOMMENT,HDIR=YDIR)
359     ALLOCATE(XPAR_VEGTYPE   (NDIM,NVEGTYPE))
360     IF (NDIM/=KSIZE) THEN
361       CALL HOR_INTERPOL(ILUOUT,ZFIELD,XPAR_VEGTYPE)
362     ELSE
363       XPAR_VEGTYPE(:,:) = ZFIELD(:,:)
364     ENDIF
365   ENDIF
366 !
367   IF (LDATA_LAI .OR. LDATA_VEG .OR. LDATA_Z0 .OR. LDATA_EMIS) THEN
368     YRECFM='NDATA_TIME'
369     CALL READ_SURF(HPROGRAM,YRECFM,NTIME,IRESP,HCOMMENT=YCOMMENT)
370     ITIME = NTIME
371   ELSE
372     NTIME = 1
373   ENDIF
374 !  
375   IF (LDATA_VEG) THEN
376     ALLOCATE(XPAR_VEG(NDIM,NTIME,NVEGTYPE))           
377     DO JTIME=1,ITIME
378       WRITE(YRECFM,FMT='(A7,I2.2)') 'D_VEG_T',JTIME
379       CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_VEG(:,JTIME,:),IRESP,IVERSION,&
380                                 HCOMMENT=YCOMMENT,HDIR=YDIR)       
381     END DO
382   ENDIF
383 !
384   IF (LDATA_LAI) THEN
385     ALLOCATE(XPAR_LAI(NDIM,NTIME,NVEGTYPE))
386     DO JTIME=1,ITIME
387       WRITE(YRECFM,FMT='(A7,I2.2)') 'D_LAI_T',JTIME
388       CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_LAI(:,JTIME,:),IRESP,IVERSION,&
389                                 HCOMMENT=YCOMMENT,HDIR=YDIR)
390     END DO
391   ENDIF
392 !
393   IF (LDATA_Z0) THEN
394     ALLOCATE(XPAR_Z0        (NDIM,NTIME,NVEGTYPE))
395     DO JTIME=1,ITIME
396       WRITE(YRECFM,FMT='(A6,I2.2)') 'D_Z0_T',JTIME
397       CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_Z0(:,JTIME,:),IRESP,IVERSION,&
398                                 HCOMMENT=YCOMMENT,HDIR=YDIR)
399     END DO
400   ENDIF
401 !
402   IF (LDATA_EMIS) THEN
403     ALLOCATE(XPAR_EMIS      (NDIM,NTIME,NVEGTYPE))
404     DO JTIME=1,ITIME
405       WRITE(YRECFM,FMT='(A8,I2.2)') 'D_EMIS_T',JTIME
406       CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_EMIS(:,JTIME,:),IRESP,IVERSION,&
407                                 HCOMMENT=YCOMMENT,HDIR=YDIR)
408     END DO
409   ENDIF
410 !
411   IF (LDATA_RSMIN) THEN
412     ALLOCATE(XPAR_RSMIN     (NDIM,NVEGTYPE))
413     YRECFM='D_RSMIN'
414     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_RSMIN(:,:),IRESP,IVERSION,&
415                               HCOMMENT=YCOMMENT,HDIR=YDIR)
416   ENDIF
417 !
418   IF (LDATA_GAMMA) THEN
419     ALLOCATE(XPAR_GAMMA     (NDIM,NVEGTYPE))
420     YRECFM='D_GAMMA'
421     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_GAMMA(:,:),IRESP,IVERSION,&
422                               HCOMMENT=YCOMMENT,HDIR=YDIR)
423   ENDIF
424 !
425   IF (LDATA_WRMAX_CF) THEN
426     ALLOCATE(XPAR_WRMAX_CF  (NDIM,NVEGTYPE))
427     YRECFM='D_WRMAX_CF'
428     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_WRMAX_CF(:,:),IRESP,IVERSION,&
429                               HCOMMENT=YCOMMENT,HDIR=YDIR)
430   ENDIF
431 !
432   IF (LDATA_RGL) THEN
433     ALLOCATE(XPAR_RGL       (NDIM,NVEGTYPE))
434     YRECFM='D_RGL'
435     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_RGL(:,:),IRESP,IVERSION,&
436                               HCOMMENT=YCOMMENT,HDIR=YDIR)
437   ENDIF
438 !
439   IF (LDATA_CV) THEN
440     ALLOCATE(XPAR_CV        (NDIM,NVEGTYPE))
441     YRECFM='D_CV'
442     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_CV(:,:),IRESP,IVERSION,&
443                               HCOMMENT=YCOMMENT,HDIR=YDIR)
444   ENDIF
445 !
446   IF (LDATA_Z0_O_Z0H) THEN
447     ALLOCATE(XPAR_Z0_O_Z0H  (NDIM,NVEGTYPE))
448     YRECFM='D_Z0_O_Z0H'
449     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_Z0_O_Z0H(:,:),IRESP,IVERSION,&
450                               HCOMMENT=YCOMMENT,HDIR=YDIR)
451   ENDIF
452 !
453   IF (LDATA_DG) THEN
454     ALLOCATE(XPAR_DG        (NDIM,NGROUND_LAYER,NVEGTYPE))
455     ALLOCATE(ZWORK(SIZE(XPAR_DG,1),SIZE(XPAR_DG,3)))
456     DO JLAYER=1,SIZE(XPAR_DG,2)
457       IF (JLAYER<10)  WRITE(YRECFM,FMT='(A4,I1.1)') 'D_DG',JLAYER
458       IF (JLAYER>=10) WRITE(YRECFM,FMT='(A4,I2.2)') 'D_DG',JLAYER
459       CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,ZWORK,IRESP,IVERSION,&
460                                 HCOMMENT=YCOMMENT,HDIR=YDIR)
461       DO JPATCH=1,SIZE(XPAR_DG,3)
462         XPAR_DG(:,JLAYER,JPATCH) = ZWORK(:,JPATCH)
463       END DO
464     END DO
465     DEALLOCATE(ZWORK)
466   ENDIF
467 !
468   IF (LDATA_ROOTFRAC) THEN
469     ALLOCATE(XPAR_ROOTFRAC  (NDIM,NGROUND_LAYER,NVEGTYPE))
470     ALLOCATE(ZWORK(SIZE(XPAR_ROOTFRAC,1),SIZE(XPAR_ROOTFRAC,3)))
471     DO JLAYER=1,SIZE(XPAR_ROOTFRAC,2)
472       IF (JLAYER<10)  WRITE(YRECFM,FMT='(A10,I1.1)') 'D_ROOTFRAC',JLAYER
473       IF (JLAYER>=10) WRITE(YRECFM,FMT='(A10,I2.2)') 'D_ROOTFRAC',JLAYER
474         CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,ZWORK,IRESP,IVERSION,&
475                                   HCOMMENT=YCOMMENT,HDIR=YDIR)
476       DO JPATCH=1,SIZE(XPAR_ROOTFRAC,3)
477         XPAR_ROOTFRAC(:,JLAYER,JPATCH) = ZWORK(:,JPATCH)
478       END DO
479     END DO
480     DEALLOCATE(ZWORK)
481   ENDIF
482 !
483   IF (LDATA_DICE) THEN
484     ALLOCATE(XPAR_DICE      (NDIM,NVEGTYPE))
485     YRECFM='D_DICE'
486     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_DICE(:,:),IRESP,IVERSION,&
487                               HCOMMENT=YCOMMENT,HDIR=YDIR)
488   ENDIF
489 !
490   IF (LDATA_GROUND_DEPTH) THEN
491     ALLOCATE(XPAR_GROUND_DEPTH(NDIM,NVEGTYPE))
492     YRECFM2='D_GROUND_DEPTH'
493     IF (IVERSION>7 .OR. IVERSION==7 .AND. IBUGFIX>=3) YRECFM2='D_GROUND_DPT'
494     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM2,ILUOUT,KSIZE,XPAR_GROUND_DEPTH(:,:),IRESP,IVERSION,&
495                               HCOMMENT=YCOMMENT,HDIR=YDIR)
496   ENDIF
497 !
498   IF (LDATA_ROOT_DEPTH) THEN
499     ALLOCATE(XPAR_ROOT_DEPTH(NDIM,NVEGTYPE))
500     YRECFM='D_ROOT_DEPTH'
501     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_ROOT_DEPTH(:,:),IRESP,IVERSION,&
502                               HCOMMENT=YCOMMENT,HDIR=YDIR)
503   ENDIF
504 !
505   IF (LDATA_ROOT_EXTINCTION) THEN
506     ALLOCATE(XPAR_ROOT_EXTINCTION(NDIM,NVEGTYPE))
507     YRECFM='D_ROOT_EXT'
508     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_ROOT_EXTINCTION(:,:),IRESP,IVERSION,&
509                               HCOMMENT=YCOMMENT,HDIR=YDIR)
510   ENDIF
511 !
512   IF (LDATA_ROOT_LIN) THEN
513     ALLOCATE(XPAR_ROOT_LIN(NDIM,NVEGTYPE))
514     YRECFM='D_ROOT_LIN'
515     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_ROOT_LIN(:,:),IRESP,IVERSION,&
516                               HCOMMENT=YCOMMENT,HDIR=YDIR)
517   ENDIF
518 !
519   IF (LDATA_ALBNIR_VEG) THEN
520     ALLOCATE(XPAR_ALBNIR_VEG(NDIM,NVEGTYPE))
521     YRECFM='D_ALBNIR_VEG'
522     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_ALBNIR_VEG(:,:),IRESP,IVERSION,&
523                               HCOMMENT=YCOMMENT,HDIR=YDIR)
524   ENDIF
525 !
526   IF (LDATA_ALBVIS_VEG) THEN
527     ALLOCATE(XPAR_ALBVIS_VEG(NDIM,NVEGTYPE))
528     YRECFM='D_ALBVIS_VEG'
529     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_ALBVIS_VEG(:,:),IRESP,IVERSION,&
530                               HCOMMENT=YCOMMENT,HDIR=YDIR)
531   ENDIF
532 !
533   IF (LDATA_ALBUV_VEG) THEN
534     ALLOCATE(XPAR_ALBUV_VEG (NDIM,NVEGTYPE))
535     YRECFM='D_ALBUV_VEG'
536     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_ALBUV_VEG(:,:),IRESP,IVERSION,&
537                               HCOMMENT=YCOMMENT,HDIR=YDIR)
538   ENDIF
539 !
540   IF (LDATA_ALBNIR_SOIL) THEN
541     ALLOCATE(XPAR_ALBNIR_SOIL(NDIM,NVEGTYPE))
542     YRECFM='D_ALBNIR_SOI'
543     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_ALBNIR_SOIL(:,:),IRESP,IVERSION,&
544                               HCOMMENT=YCOMMENT,HDIR=YDIR)
545   ENDIF
546 !
547   IF (LDATA_ALBVIS_SOIL) THEN
548     ALLOCATE(XPAR_ALBVIS_SOIL(NDIM,NVEGTYPE))
549     YRECFM='D_ALBVIS_SOI'
550     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_ALBVIS_SOIL(:,:),IRESP,IVERSION,&
551                               HCOMMENT=YCOMMENT,HDIR=YDIR)
552   ENDIF
553 !
554   IF (LDATA_ALBUV_SOIL) THEN
555     ALLOCATE(XPAR_ALBUV_SOIL (NDIM,NVEGTYPE))
556     YRECFM='D_ALBUV_SOI'
557     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_ALBUV_SOIL(:,:),IRESP,IVERSION,&
558                               HCOMMENT=YCOMMENT,HDIR=YDIR)
559   ENDIF
560 !
561   IF (LDATA_GMES) THEN
562     ALLOCATE(XPAR_GMES      (NDIM,NVEGTYPE))
563     YRECFM='D_GMES'
564     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_GMES(:,:),IRESP,IVERSION,&
565                               HCOMMENT=YCOMMENT,HDIR=YDIR)
566   ENDIF
567 !
568   IF (LDATA_BSLAI) THEN
569     ALLOCATE(XPAR_BSLAI     (NDIM,NVEGTYPE))
570     YRECFM='D_BSLAI'
571     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_BSLAI(:,:),IRESP,IVERSION,&
572                               HCOMMENT=YCOMMENT,HDIR=YDIR)
573   ENDIF
574 !
575   IF (LDATA_LAIMIN) THEN
576     ALLOCATE(XPAR_LAIMIN    (NDIM,NVEGTYPE))
577     YRECFM='D_LAIMIN'
578     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_LAIMIN(:,:),IRESP,IVERSION,&
579                               HCOMMENT=YCOMMENT,HDIR=YDIR)
580   ENDIF
581 !
582   IF (LDATA_SEFOLD) THEN
583     ALLOCATE(XPAR_SEFOLD    (NDIM,NVEGTYPE))
584     YRECFM='D_SEFOLD'
585     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_SEFOLD(:,:),IRESP,IVERSION,&
586                               HCOMMENT=YCOMMENT,HDIR=YDIR)
587   ENDIF
588 !
589   IF (LDATA_GC) THEN
590     ALLOCATE(XPAR_GC        (NDIM,NVEGTYPE))
591     YRECFM='D_GC'
592     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_GC(:,:),IRESP,IVERSION,&
593                               HCOMMENT=YCOMMENT,HDIR=YDIR)
594   ENDIF
595 !
596   IF (LDATA_DMAX) THEN
597     ALLOCATE(XPAR_DMAX      (NDIM,NVEGTYPE))
598     YRECFM='D_DMAX'
599     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_DMAX(:,:),IRESP,IVERSION,&
600                               HCOMMENT=YCOMMENT,HDIR=YDIR)
601   ENDIF
602 !
603   IF (LDATA_F2I) THEN
604     ALLOCATE(XPAR_F2I       (NDIM,NVEGTYPE))
605     YRECFM='D_F2I'
606     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_F2I(:,:),IRESP,IVERSION,&
607                               HCOMMENT=YCOMMENT,HDIR=YDIR)
608   ENDIF
609 !
610   IF (LDATA_STRESS) THEN
611     ALLOCATE(LPAR_STRESS   (NDIM,NVEGTYPE))
612     ALLOCATE(ZWORK(SIZE(LPAR_STRESS,1),SIZE(LPAR_STRESS,2)))
613     YRECFM='D_STRESS'
614     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,ZWORK(:,:),IRESP,IVERSION,&
615                               HCOMMENT=YCOMMENT,HDIR=YDIR)
616     LPAR_STRESS = .FALSE.
617     WHERE(ZWORK==1.) LPAR_STRESS = .TRUE.
618     DEALLOCATE(ZWORK)
619   ENDIF
620 !
621   IF (LDATA_H_TREE) THEN
622     ALLOCATE(XPAR_H_TREE    (NDIM,NVEGTYPE))
623     YRECFM='D_H_TREE'
624     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_H_TREE(:,:),IRESP,IVERSION,&
625                               HCOMMENT=YCOMMENT,HDIR=YDIR)
626   ENDIF
627 !
628   IF (LDATA_RE25) THEN
629     ALLOCATE(XPAR_RE25      (NDIM,NVEGTYPE))
630     YRECFM='D_RE25'
631     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_RE25(:,:),IRESP,IVERSION,&
632                               HCOMMENT=YCOMMENT,HDIR=YDIR)
633   ENDIF
634 !
635   IF (LDATA_CE_NITRO) THEN
636     ALLOCATE(XPAR_CE_NITRO  (NDIM,NVEGTYPE))
637     YRECFM='D_CE_NITRO'
638     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_CE_NITRO(:,:),IRESP,IVERSION,&
639                               HCOMMENT=YCOMMENT,HDIR=YDIR)
640   ENDIF
641 !
642   IF (LDATA_CF_NITRO) THEN
643     ALLOCATE(XPAR_CF_NITRO  (NDIM,NVEGTYPE))
644     YRECFM='D_CF_NITRO'
645     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_CF_NITRO(:,:),IRESP,IVERSION,&
646                               HCOMMENT=YCOMMENT,HDIR=YDIR)
647   ENDIF
648 !
649   IF (LDATA_CNA_NITRO) THEN
650     ALLOCATE(XPAR_CNA_NITRO (NDIM,NVEGTYPE))
651     YRECFM='D_CNA_NITRO'
652     CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_CNA_NITRO(:,:),IRESP,IVERSION,&
653                               HCOMMENT=YCOMMENT,HDIR=YDIR)
654   ENDIF
655 !
656   IF (LDATA_IRRIG) THEN
657     ALLOCATE(XPAR_IRRIG     (NDIM,NTIME,NVEGTYPE))
658     DO JTIME=1,ITIME
659       WRITE(YRECFM,FMT='(A9,I2.2)') 'D_IRRIG_T',JTIME
660         CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_IRRIG(:,JTIME,:),IRESP,IVERSION,&
661                                   HCOMMENT=YCOMMENT,HDIR=YDIR)
662     END DO
663   ENDIF
664 !
665   IF (LDATA_WATSUP) THEN
666     ALLOCATE(XPAR_WATSUP     (NDIM,NTIME,NVEGTYPE))
667     DO JTIME=1,ITIME
668       WRITE(YRECFM,FMT='(A10,I2.2)') 'D_WATSUP_T',JTIME
669         CALL READ_SURF_ISBA_PAR_n(HPROGRAM,YRECFM,ILUOUT,KSIZE,XPAR_WATSUP(:,JTIME,:),IRESP,IVERSION,&
670                                   HCOMMENT=YCOMMENT,HDIR=YDIR)
671     END DO
672   ENDIF
673 !
674 ENDIF
675 !
676 IF (LHOOK) CALL DR_HOOK('READ_PGD_ISBA_PAR_N',1,ZHOOK_HANDLE)
677 !
678 !-------------------------------------------------------------------------------
679 !
680 END SUBROUTINE READ_PGD_ISBA_PAR_n