Juan 8/12/2016: add management of LEN_HREC in MNH & SURFEX
[MNH-git_open_source-lfs.git] / src / SURFEX / writesurf_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 WRITESURF_PGD_ISBA_PAR_n(HPROGRAM)
7 !     ################################################
8 !
9 !!****  *WRITESURF_PGD_ISBA_PAR_n* - writes 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    01/2003 
36 !!      P. Le Moigne 12/2004 : add type of photosynthesis 
37 !!      M.Moge    01/2016  using WRITE_SURF_FIELD2D/3D for 2D/3D surfex fields writes
38 !-------------------------------------------------------------------------------
39 !
40 !*       0.    DECLARATIONS
41 !              ------------
42 !
43 USE MODD_DATA_ISBA_n,    ONLY : NTIME, XPAR_VEG, XPAR_LAI,XPAR_RSMIN,XPAR_GAMMA,XPAR_WRMAX_CF, &
44                                 XPAR_RGL,XPAR_CV,XPAR_DG,XPAR_Z0,XPAR_Z0_O_Z0H,         &
45                                 XPAR_ALBNIR_VEG,XPAR_ALBVIS_VEG, XPAR_ALBUV_VEG,          &
46                                 XPAR_ALBNIR_SOIL,XPAR_ALBVIS_SOIL, XPAR_ALBUV_SOIL,       &
47                                 XPAR_EMIS, XPAR_DICE,                                     &
48                                 XPAR_VEGTYPE,XPAR_ROOTFRAC,                                &
49                                 XPAR_GMES,XPAR_BSLAI,XPAR_LAIMIN,XPAR_SEFOLD,XPAR_GC,   &
50                                 XPAR_DMAX, XPAR_F2I, LDATA_STRESS, XPAR_H_TREE,XPAR_RE25,&
51                                 XPAR_CE_NITRO,XPAR_CF_NITRO,XPAR_CNA_NITRO, &
52                                 XPAR_GROUND_DEPTH, XPAR_ROOT_DEPTH,               &
53                                 XPAR_ROOT_EXTINCTION, XPAR_ROOT_LIN,              &
54                                 LPAR_STRESS, XPAR_IRRIG, XPAR_WATSUP, &
55                                 LDATA_VEGTYPE, LDATA_LAI, LDATA_H_TREE, LDATA_DG, LDATA_ROOTFRAC,&  
56                                 LDATA_VEG, LDATA_Z0, LDATA_EMIS, LDATA_DICE, &
57                                 LDATA_RSMIN, LDATA_GAMMA, LDATA_WRMAX_CF, LDATA_RGL, &
58                                 LDATA_CV, LDATA_Z0_O_Z0H, &
59                                 LDATA_ALBNIR_VEG, LDATA_ALBVIS_VEG, LDATA_ALBUV_VEG, &
60                                 LDATA_ALBVIS_SOIL, LDATA_ALBNIR_SOIL, LDATA_ALBUV_SOIL, &
61                                 LDATA_GMES, LDATA_BSLAI, LDATA_SEFOLD, LDATA_GC, LDATA_DMAX, &
62                                 LDATA_RE25, LDATA_LAIMIN, LDATA_F2I, &
63                                 LDATA_CE_NITRO,LDATA_CF_NITRO, LDATA_CNA_NITRO,&
64                                 LDATA_STRESS, LDATA_IRRIG, LDATA_WATSUP,             &   
65                                 LDATA_GROUND_DEPTH, LDATA_ROOT_DEPTH,             &
66                                 LDATA_ROOT_EXTINCTION, LDATA_ROOT_LIN
67   
68 !
69 USE MODI_WRITE_SURF
70 USE MODI_WRITE_SURF_FIELD2D
71 !
72 !
73 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
74 USE PARKIND1  ,ONLY : JPRB
75 !
76 IMPLICIT NONE
77 !
78 !*       0.1   Declarations of arguments
79 !              -------------------------
80 !
81  CHARACTER(LEN=6),  INTENT(IN)  :: HPROGRAM ! program calling
82 !
83 !*       0.2   Declarations of local variables
84 !              -------------------------------
85 !
86 INTEGER           :: IRESP          ! IRESP  : return-code if a problem appears
87  CHARACTER(LEN=LEN_HREC) :: YRECFM         ! Name of the article to be read
88  CHARACTER(LEN=100):: YCOMMENT       ! Comment string
89  CHARACTER(LEN=100):: YCOMMENTUNIT   ! Comment string : unit of the datas in the field to write
90 INTEGER           :: JTIME          ! loop index
91 INTEGER           :: JLAYER         ! loop index
92 INTEGER           :: JPATCH         ! loop index
93 REAL,    DIMENSION(:,:), ALLOCATABLE :: ZWORK
94 REAL(KIND=JPRB) :: ZHOOK_HANDLE
95 !
96 !-------------------------------------------------------------------------------
97 !
98 IF (LHOOK) CALL DR_HOOK('WRITESURF_PGD_ISBA_PAR_N',0,ZHOOK_HANDLE)
99 YRECFM='L_VEGTYPE'
100 YCOMMENT=YRECFM
101  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_VEGTYPE,IRESP,HCOMMENT=YCOMMENT)
102 IF (LDATA_VEGTYPE) THEN
103   YRECFM='D_VEGTYPE'
104   YCOMMENT='X_Y_DATA_VEGTYPE'
105   YCOMMENTUNIT='-'
106   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_VEGTYPE(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
107 ENDIF
108 !
109 IF (LDATA_LAI .OR. LDATA_VEG .OR. LDATA_Z0 .OR. LDATA_EMIS) THEN
110   YRECFM='NDATA_TIME'
111   YCOMMENT='(-)'
112   CALL WRITE_SURF(HPROGRAM,YRECFM,NTIME,IRESP,HCOMMENT=YCOMMENT)
113 ENDIF
114 !
115 YRECFM='L_VEG'
116 YCOMMENT=YRECFM
117  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_VEG,IRESP,HCOMMENT=YCOMMENT)
118 IF (LDATA_VEG) THEN
119   DO JTIME=1,NTIME
120     WRITE(YRECFM,FMT='(A7,I2.2)') 'D_VEG_T',JTIME
121     YCOMMENT='X_Y_D_VEG'
122     YCOMMENTUNIT='-'
123     CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_VEG(:,JTIME,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
124   END DO
125 ENDIF
126 !
127 YRECFM='L_LAI'
128 YCOMMENT=YRECFM
129  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_LAI,IRESP,HCOMMENT=YCOMMENT)
130 IF (LDATA_LAI) THEN
131   DO JTIME=1,NTIME
132     WRITE(YRECFM,FMT='(A7,I2.2)') 'D_LAI_T',JTIME
133     YCOMMENT='X_Y_D_LAI'
134     YCOMMENTUNIT='-'
135     CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_LAI(:,JTIME,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
136   END DO
137 ENDIF
138 !
139 YRECFM='L_Z0'
140 YCOMMENT=YRECFM
141  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_Z0,IRESP,HCOMMENT=YCOMMENT)
142 IF (LDATA_Z0) THEN
143   DO JTIME=1,NTIME
144     WRITE(YRECFM,FMT='(A6,I2.2)') 'D_Z0_T',JTIME
145     YCOMMENT='X_Y_D_Z0'
146     YCOMMENTUNIT='-'
147     CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_Z0(:,JTIME,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
148   END DO
149 ENDIF
150 !
151 YRECFM='L_EMIS'
152 YCOMMENT=YRECFM
153  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_EMIS,IRESP,HCOMMENT=YCOMMENT)
154 IF (LDATA_EMIS) THEN
155   DO JTIME=1,NTIME
156     WRITE(YRECFM,FMT='(A8,I2.2)') 'D_EMIS_T',JTIME
157     YCOMMENT='X_Y_D_EMIS'
158     YCOMMENTUNIT='-'
159     CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_EMIS(:,JTIME,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
160   END DO
161 ENDIF
162 !
163 YRECFM='L_RSMIN'
164 YCOMMENT=YRECFM
165  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_RSMIN,IRESP,HCOMMENT=YCOMMENT)
166 IF (LDATA_RSMIN) THEN
167   YRECFM='D_RSMIN'
168   YCOMMENT='X_Y_D_RSMIN'
169   YCOMMENTUNIT='-'
170   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_RSMIN(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
171 ENDIF
172 !
173 YRECFM='L_GAMMA'
174 YCOMMENT=YRECFM
175  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_GAMMA,IRESP,HCOMMENT=YCOMMENT)
176 IF (LDATA_GAMMA) THEN
177   YRECFM='D_GAMMA'
178   YCOMMENT='X_Y_D_GAMMA'
179   YCOMMENTUNIT='-'
180   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_GAMMA(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
181 ENDIF
182 !
183 YRECFM='L_WRMAX_CF'
184 YCOMMENT=YRECFM
185  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_WRMAX_CF,IRESP,HCOMMENT=YCOMMENT)
186 IF (LDATA_WRMAX_CF) THEN
187   YRECFM='D_WRMAX_CF'
188   YCOMMENT='X_Y_D_WRMAX_CF'
189   YCOMMENTUNIT='-'
190   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_WRMAX_CF(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
191 ENDIF
192 !
193 YRECFM='L_RGL'
194 YCOMMENT=YRECFM
195  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_RGL,IRESP,HCOMMENT=YCOMMENT)
196 IF (LDATA_RGL) THEN
197   YRECFM='D_RGL'
198   YCOMMENT='X_Y_D_RGL'
199   YCOMMENTUNIT='-'
200   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_RGL(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
201 ENDIF
202 !
203 YRECFM='L_CV'
204 YCOMMENT=YRECFM
205  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_CV,IRESP,HCOMMENT=YCOMMENT)
206 IF (LDATA_CV) THEN
207   YRECFM='D_CV'
208   YCOMMENT='X_Y_D_CV'
209   YCOMMENTUNIT='-'
210   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_CV(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
211 ENDIF
212 !
213 YRECFM='L_Z0_O_Z0H'
214 YCOMMENT=YRECFM
215  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_Z0_O_Z0H,IRESP,HCOMMENT=YCOMMENT)
216 IF (LDATA_Z0_O_Z0H) THEN
217   YRECFM='D_Z0_O_Z0H'
218   YCOMMENT='X_Y_D_Z0_O_Z0H'
219   YCOMMENTUNIT='-'
220   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_Z0_O_Z0H(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
221 ENDIF
222 !
223 YRECFM='L_DG'
224 YCOMMENT=YRECFM
225  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_DG,IRESP,HCOMMENT=YCOMMENT)
226 IF (LDATA_DG) THEN
227   ALLOCATE(ZWORK(SIZE(XPAR_DG,1),SIZE(XPAR_DG,3)))
228   DO JLAYER=1,SIZE(XPAR_DG,2)
229     IF (JLAYER<10)  WRITE(YRECFM,FMT='(A4,I1.1)') 'D_DG',JLAYER
230     IF (JLAYER>=10) WRITE(YRECFM,FMT='(A4,I2.2)') 'D_DG',JLAYER
231     YCOMMENT='X_Y_'//YRECFM
232     DO JPATCH=1,SIZE(XPAR_DG,3)
233       ZWORK(:,JPATCH) = XPAR_DG(:,JLAYER,JPATCH)
234     END DO
235     YCOMMENTUNIT='-'
236     CALL WRITE_SURF_FIELD2D(HPROGRAM,ZWORK,YRECFM,YCOMMENT,YCOMMENTUNIT)
237   END DO
238   DEALLOCATE(ZWORK)
239 ENDIF
240 !
241 YRECFM='L_ROOTFRAC'
242 YCOMMENT=YRECFM
243  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_ROOTFRAC,IRESP,HCOMMENT=YCOMMENT)
244 IF (LDATA_ROOTFRAC) THEN
245   ALLOCATE(ZWORK(SIZE(XPAR_ROOTFRAC,1),SIZE(XPAR_ROOTFRAC,3)))
246   DO JLAYER=1,SIZE(XPAR_ROOTFRAC,2)
247     IF (JLAYER<10)  WRITE(YRECFM,FMT='(A10,I1.1)') 'D_ROOTFRAC',JLAYER
248     IF (JLAYER>=10) WRITE(YRECFM,FMT='(A10,I2.2)') 'D_ROOTFRAC',JLAYER
249     YCOMMENT='X_Y_'//YRECFM
250     DO JPATCH=1,SIZE(XPAR_ROOTFRAC,3)
251       ZWORK(:,JPATCH) = XPAR_ROOTFRAC(:,JLAYER,JPATCH)
252     END DO
253     YCOMMENTUNIT='-'
254     CALL WRITE_SURF_FIELD2D(HPROGRAM,ZWORK,YRECFM,YCOMMENT,YCOMMENTUNIT)
255   END DO
256   DEALLOCATE(ZWORK)
257 ENDIF
258 !
259 YRECFM='L_GROUND_DPT'
260 YCOMMENT=YRECFM
261  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_GROUND_DEPTH,IRESP,HCOMMENT=YCOMMENT)
262 IF (LDATA_GROUND_DEPTH) THEN
263   YRECFM='D_GROUND_DPT'
264   YCOMMENT='X_Y_'//YRECFM
265   YCOMMENTUNIT='-'
266   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_GROUND_DEPTH(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
267 ENDIF
268 !
269 YRECFM='L_ROOT_DEPTH'
270 YCOMMENT=YRECFM
271  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_ROOT_DEPTH,IRESP,HCOMMENT=YCOMMENT)
272 IF (LDATA_ROOT_DEPTH) THEN
273   YRECFM='D_ROOT_DEPTH'
274   YCOMMENT='X_Y_'//YRECFM
275   YCOMMENTUNIT='-'
276   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_ROOT_DEPTH(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
277 ENDIF
278 !
279 YRECFM='L_ROOT_EXT'
280 YCOMMENT=YRECFM
281  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_ROOT_EXTINCTION,IRESP,HCOMMENT=YCOMMENT)
282 IF (LDATA_ROOT_EXTINCTION) THEN
283   YRECFM='D_ROOT_EXT'
284   YCOMMENT='X_Y_'//YRECFM
285   YCOMMENTUNIT='-'
286   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_ROOT_EXTINCTION(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
287 ENDIF
288 !
289 YRECFM='L_ROOT_LIN'
290 YCOMMENT=YRECFM
291  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_ROOT_LIN,IRESP,HCOMMENT=YCOMMENT)
292 IF (LDATA_ROOT_LIN) THEN
293   YRECFM='D_ROOT_LIN'
294   YCOMMENT='X_Y_'//YRECFM
295   YCOMMENTUNIT='-'
296   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_ROOT_LIN(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
297 ENDIF
298 !
299 YRECFM='L_DICE'
300 YCOMMENT=YRECFM
301  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_DICE,IRESP,HCOMMENT=YCOMMENT)
302 IF (LDATA_DICE) THEN
303   YRECFM='D_DICE'
304   YCOMMENT='X_Y_'//YRECFM
305   YCOMMENTUNIT='-'
306   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_DICE(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
307 ENDIF
308 !
309 YRECFM='L_ALBNIR_VEG'
310 YCOMMENT=YRECFM
311  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_ALBNIR_VEG,IRESP,HCOMMENT=YCOMMENT)
312 IF (LDATA_ALBNIR_VEG) THEN
313   YRECFM='D_ALBNIR_VEG'
314   YCOMMENT='X_Y_'//YRECFM
315   YCOMMENTUNIT='-'
316   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_ALBNIR_VEG(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
317 ENDIF
318 !
319 YRECFM='L_ALBVIS_VEG'
320 YCOMMENT=YRECFM
321  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_ALBVIS_VEG,IRESP,HCOMMENT=YCOMMENT)
322 IF (LDATA_ALBVIS_VEG) THEN
323   YRECFM='D_ALBVIS_VEG'
324   YCOMMENT='X_Y_'//YRECFM
325   YCOMMENTUNIT='-'
326   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_ALBVIS_VEG(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
327 ENDIF
328 !
329 YRECFM='L_ALBUV_VEG'
330 YCOMMENT=YRECFM
331  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_ALBUV_VEG,IRESP,HCOMMENT=YCOMMENT)
332 IF (LDATA_ALBUV_VEG) THEN
333   YRECFM='D_ALBUV_VEG'
334   YCOMMENT='X_Y_'//YRECFM
335   YCOMMENTUNIT='-'
336   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_ALBUV_VEG(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
337 ENDIF
338 !
339 YRECFM='L_ALBNIR_SOI'
340 YCOMMENT=YRECFM
341  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_ALBNIR_SOIL,IRESP,HCOMMENT=YCOMMENT)
342 IF (LDATA_ALBNIR_SOIL) THEN
343   YRECFM='D_ALBNIR_SOI'
344   YCOMMENT='X_Y_'//YRECFM
345   YCOMMENTUNIT='-'
346   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_ALBNIR_SOIL(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
347 ENDIF
348 !
349 YRECFM='L_ALBVIS_SOI'
350 YCOMMENT=YRECFM
351  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_ALBVIS_SOIL,IRESP,HCOMMENT=YCOMMENT)
352 IF (LDATA_ALBVIS_SOIL) THEN
353   YRECFM='D_ALBVIS_SOI'
354   YCOMMENT='X_Y_'//YRECFM
355   YCOMMENTUNIT='-'
356   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_ALBVIS_SOIL(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
357 ENDIF
358 !
359 YRECFM='L_ALBUV_SOI'
360 YCOMMENT=YRECFM
361  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_ALBUV_SOIL,IRESP,HCOMMENT=YCOMMENT)
362 IF (LDATA_ALBUV_SOIL) THEN
363   YRECFM='D_ALBUV_SOI'
364   YCOMMENT='X_Y_'//YRECFM
365   YCOMMENTUNIT='-'
366   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_ALBUV_SOIL(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
367 ENDIF
368 !
369 YRECFM='L_GMES'
370 YCOMMENT=YRECFM
371  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_GMES,IRESP,HCOMMENT=YCOMMENT)
372 IF (LDATA_GMES) THEN
373   YRECFM='D_GMES'
374   YCOMMENT='X_Y_'//YRECFM
375   YCOMMENTUNIT='-'
376   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_GMES(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
377 ENDIF
378 !
379 YRECFM='L_BSLAI'
380 YCOMMENT=YRECFM
381  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_BSLAI,IRESP,HCOMMENT=YCOMMENT)
382 IF (LDATA_BSLAI) THEN
383   YRECFM='D_BSLAI'
384   YCOMMENT='X_Y_'//YRECFM
385   YCOMMENTUNIT='-'
386   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_BSLAI(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
387 ENDIF
388 !
389 YRECFM='L_LAIMIN'
390 YCOMMENT=YRECFM
391  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_LAIMIN,IRESP,HCOMMENT=YCOMMENT)
392 IF (LDATA_LAIMIN) THEN
393   YRECFM='D_LAIMIN'
394   YCOMMENT='X_Y_'//YRECFM
395   YCOMMENTUNIT='-'
396   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_LAIMIN(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
397 ENDIF
398 !
399 YRECFM='L_SEFOLD'
400 YCOMMENT=YRECFM
401  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_SEFOLD,IRESP,HCOMMENT=YCOMMENT)
402 IF (LDATA_SEFOLD) THEN
403   YRECFM='D_SEFOLD'
404   YCOMMENT='X_Y_'//YRECFM
405   YCOMMENTUNIT='-'
406   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_SEFOLD(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
407 ENDIF
408 !
409 YRECFM='L_GC'
410 YCOMMENT=YRECFM
411  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_GC,IRESP,HCOMMENT=YCOMMENT)
412 IF (LDATA_GC) THEN
413   YRECFM='D_GC'
414   YCOMMENT='X_Y_'//YRECFM
415   YCOMMENTUNIT='-'
416   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_GC(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
417 ENDIF
418 !
419 YRECFM='L_DMAX'
420 YCOMMENT=YRECFM
421  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_DMAX,IRESP,HCOMMENT=YCOMMENT)
422 IF (LDATA_DMAX) THEN
423   YRECFM='D_DMAX'
424   YCOMMENT='X_Y_'//YRECFM
425   YCOMMENTUNIT='-'
426   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_DMAX(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
427 ENDIF
428 !
429 YRECFM='L_F2I'
430 YCOMMENT=YRECFM
431  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_F2I,IRESP,HCOMMENT=YCOMMENT)
432 IF (LDATA_F2I) THEN
433   YRECFM='D_F2I'
434   YCOMMENT='X_Y_'//YRECFM
435   YCOMMENTUNIT='-'
436   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_F2I(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
437 ENDIF
438 !
439 YRECFM='L_STRESS'
440 YCOMMENT=YRECFM
441  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_STRESS,IRESP,HCOMMENT=YCOMMENT)
442 IF (LDATA_STRESS) THEN
443   ALLOCATE(ZWORK(SIZE(LPAR_STRESS,1),SIZE(LPAR_STRESS,2)))
444   ZWORK=0.
445   WHERE(LPAR_STRESS) ZWORK=1.
446   YRECFM='D_STRESS'
447   YCOMMENT='X_Y_'//YRECFM
448   YCOMMENTUNIT='-'
449   CALL WRITE_SURF_FIELD2D(HPROGRAM,ZWORK(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
450   DEALLOCATE(ZWORK)
451 ENDIF
452 !
453 YRECFM='L_H_TREE'
454 YCOMMENT=YRECFM
455  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_H_TREE,IRESP,HCOMMENT=YCOMMENT)
456 IF (LDATA_H_TREE) THEN
457   YRECFM='D_H_TREE'
458   YCOMMENT='X_Y_'//YRECFM
459   YCOMMENTUNIT='-'
460   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_H_TREE(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
461 ENDIF
462 !
463 YRECFM='L_RE25'
464 YCOMMENT=YRECFM
465  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_RE25,IRESP,HCOMMENT=YCOMMENT)
466 IF (LDATA_RE25) THEN
467   YRECFM='D_RE25'
468   YCOMMENT='X_Y_'//YRECFM
469   YCOMMENTUNIT='-'
470   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_RE25(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
471 ENDIF
472 !
473 YRECFM='L_CE_NITRO'
474 YCOMMENT=YRECFM
475  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_CE_NITRO,IRESP,HCOMMENT=YCOMMENT)
476 IF (LDATA_CE_NITRO) THEN
477   YRECFM='D_CE_NITRO'
478   YCOMMENT='X_Y_'//YRECFM
479   YCOMMENTUNIT='-'
480   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_CE_NITRO(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
481 ENDIF
482 !
483 YRECFM='L_CF_NITRO'
484 YCOMMENT=YRECFM
485  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_CF_NITRO,IRESP,HCOMMENT=YCOMMENT)
486 IF (LDATA_CF_NITRO) THEN
487   YRECFM='D_CF_NITRO'
488   YCOMMENT='X_Y_'//YRECFM
489   YCOMMENTUNIT='-'
490   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_CF_NITRO(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
491 ENDIF
492 !
493 YRECFM='L_CNA_NITRO'
494 YCOMMENT=YRECFM
495  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_CNA_NITRO,IRESP,HCOMMENT=YCOMMENT)
496 IF (LDATA_CNA_NITRO) THEN
497   YRECFM='D_CNA_NITRO'
498   YCOMMENT='X_Y_'//YRECFM
499   YCOMMENTUNIT='-'
500   CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_CNA_NITRO(:,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
501 ENDIF
502 !
503 YRECFM='L_IRRIG'
504 YCOMMENT=YRECFM
505  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_IRRIG,IRESP,HCOMMENT=YCOMMENT)
506 IF (LDATA_IRRIG) THEN
507   DO JTIME=1,NTIME
508     WRITE(YRECFM,FMT='(A9,I2.2)') 'D_IRRIG_T',JTIME
509     YCOMMENT='X_Y_IRRIG'
510     YCOMMENTUNIT='-'
511     CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_IRRIG(:,JTIME,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
512   ENDDO
513 ENDIF
514 !
515 YRECFM='L_WATSUP'
516 YCOMMENT=YRECFM
517  CALL WRITE_SURF(HPROGRAM,YRECFM,LDATA_WATSUP,IRESP,HCOMMENT=YCOMMENT)
518 IF (LDATA_WATSUP) THEN
519   DO JTIME=1,NTIME
520     WRITE(YRECFM,FMT='(A10,I2.2)') 'D_WATSUP_T',JTIME
521     YCOMMENT='X_Y_WATSUP'
522     YCOMMENTUNIT='-'
523     CALL WRITE_SURF_FIELD2D(HPROGRAM,XPAR_WATSUP(:,JTIME,:),YRECFM,YCOMMENT,YCOMMENTUNIT)
524   ENDDO
525 ENDIF
526 !
527 IF (LHOOK) CALL DR_HOOK('WRITESURF_PGD_ISBA_PAR_N',1,ZHOOK_HANDLE)
528 !
529 !-------------------------------------------------------------------------------
530 !
531 END SUBROUTINE WRITESURF_PGD_ISBA_PAR_n