Juan 24/11/2015: modif for PREPLL from M.Mogié
[MNH-git_open_source-lfs.git] / src / SURFEX / read_isban.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_ISBA_n(HPROGRAM)
7 !     ##################################
8 !
9 !!****  *READ_ISBA_n* - routine to initialise ISBA variables
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 !!
37 !!      READ_SURF for general reading : 08/2003 (S.Malardel)
38 !!      B. Decharme  2008    : Floodplains
39 !!      B. Decharme  01/2009 : Optional Arpege deep soil temperature read
40 !!      A.L. Gibelin   03/09 : modifications for CENTURY model 
41 !!      A.L. Gibelin    04/2009 : BIOMASS and RESP_BIOMASS arrays 
42 !!      A.L. Gibelin    06/2009 : Soil carbon variables for CNT option
43 !!      B. Decharme  09/2012 : suppress NWG_LAYER (parallelization problems)
44 !!        M.Moge    08/2015  reading SURFEX 3D fields one patch at a time for Z-parallel splitting with MNH
45 !!
46 !-------------------------------------------------------------------------------
47 !
48 !*       0.    DECLARATIONS
49 !              ------------
50 !
51 !
52 USE MODD_CO2V_PAR,       ONLY : XANFMINIT, XCONDCTMIN
53 USE MODD_ISBA_n,         ONLY : NGROUND_LAYER, NPATCH, NNBIOMASS,   &
54                                   NNLITTER, NNLITTLEVS, NNSOILCARB,   &
55                                   CPHOTO, CRESPSL, XTSRAD_NAT,        &
56                                   XTG, XWG, XWGI, XWR, XLAI, TSNOW,   &
57                                   XRESA, XANFM, XAN, XLE, XANDAY,     &
58                                   XBSLAI, XBIOMASS, XRESP_BIOMASS,    &
59                                   XLITTER, XSOILCARB, XLIGNIN_STRUC,  &
60                                   LFLOOD, XZ0_FLOOD, LTEMP_ARP,       &
61                                   NTEMPLAYER_ARP, LGLACIER, XICE_STO  
62 !                                
63 USE MODD_SURF_PAR,       ONLY : XUNDEF, NUNDEF
64 USE MODD_SNOW_PAR,       ONLY : XZ0SN
65 !
66 USE MODI_READ_SURF
67 !
68 USE MODI_READ_GR_SNOW
69 !
70 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
71 USE PARKIND1  ,ONLY : JPRB
72 !
73 USE MODI_GET_TYPE_DIM_n
74 !
75 IMPLICIT NONE
76 !
77 !*       0.1   Declarations of arguments
78 !              -------------------------
79 !
80  CHARACTER(LEN=6),  INTENT(IN)  :: HPROGRAM ! calling program
81 !
82 !*       0.2   Declarations of local variables
83 !              -------------------------------
84 INTEGER           :: ILU          ! 1D physical dimension
85 !
86 INTEGER           :: IRESP          ! Error code after redding
87 !
88  CHARACTER(LEN=12) :: YRECFM         ! Name of the article to be read
89 !
90  CHARACTER(LEN=4)  :: YLVL
91  CHARACTER(LEN=8)  :: YPATCH
92 !
93 REAL, DIMENSION(:,:),ALLOCATABLE  :: ZWORK      ! 2D array to write data in file
94 !
95 INTEGER :: IWORK   ! Work integer
96 !
97 INTEGER :: JP, JL, JNBIOMASS, JNLITTER, JNSOILCARB, JNLITTLEVS  ! loop counter on layers
98 INTEGER :: JPATCH  ! loop counter on patches
99 !
100 INTEGER           :: IVERSION       ! surface version
101 INTEGER           :: IBUGFIX
102 !
103 REAL(KIND=JPRB) :: ZHOOK_HANDLE
104 !
105 !-------------------------------------------------------------------------------
106 !
107 !
108 !* 1D physical dimension
109 !
110 IF (LHOOK) CALL DR_HOOK('READ_ISBA_N',0,ZHOOK_HANDLE)
111 YRECFM='SIZE_NATURE'
112  CALL GET_TYPE_DIM_n('NATURE',ILU)
113 !
114 !
115 !*       2.     Prognostic fields:
116 !               -----------------
117 !
118 ALLOCATE(ZWORK(ILU,NPATCH))
119 !* soil temperatures
120 !
121 IF(LTEMP_ARP)THEN
122   IWORK=NTEMPLAYER_ARP
123 ELSE
124   IWORK=NGROUND_LAYER
125 ENDIF
126 !
127 ALLOCATE(XTG(ILU,IWORK,NPATCH))
128 !
129 DO JL=1,IWORK
130 #ifdef MNH_PARALLEL
131   DO JPATCH=1,NPATCH
132     IF (JL >= 10) WRITE(YPATCH,'(I2,I4.4)') JL,JPATCH
133     IF (JL < 10)  WRITE(YPATCH,FMT='(I1,I4.4)') JL,JPATCH
134     YRECFM='TG'//ADJUSTL(YPATCH(:LEN_TRIM(YPATCH)))
135     CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,JPATCH),IRESP)
136     XTG(:,JL,JPATCH)=ZWORK(:,JPATCH)
137   END DO
138 #else
139   WRITE(YLVL,'(I4)') JL
140   YRECFM='TG'//ADJUSTL(YLVL(:LEN_TRIM(YLVL)))
141   CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,:),IRESP)
142   XTG(:,JL,:)=ZWORK
143 #endif
144 END DO
145 !
146 !
147 !* soil liquid and ice water contents
148 !
149 ALLOCATE(XWG (ILU,NGROUND_LAYER,NPATCH))
150 ALLOCATE(XWGI(ILU,NGROUND_LAYER,NPATCH))
151 !
152 XWG (:,:,:)=XUNDEF
153 XWGI(:,:,:)=XUNDEF
154 !
155 DO JL=1,NGROUND_LAYER
156 #ifdef MNH_PARALLEL
157   DO JPATCH=1,NPATCH
158     IF (JL >= 10) WRITE(YPATCH,'(I2,I4.4)') JL,JPATCH
159     IF (JL < 10)  WRITE(YPATCH,FMT='(I1,I4.4)') JL,JPATCH
160     YRECFM='WG'//ADJUSTL(YPATCH(:LEN_TRIM(YPATCH)))
161     CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,JPATCH),IRESP)
162     XWG(:,JL,JPATCH)=ZWORK(:,JPATCH)
163   END DO
164 #else
165   WRITE(YLVL,'(I4)') JL
166   YRECFM='WG'//ADJUSTL(YLVL(:LEN_TRIM(YLVL)))
167    CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,:),IRESP)
168    XWG(:,JL,:)=ZWORK
169 #endif
170 END DO
171 !
172 DO JL=1,NGROUND_LAYER
173 #ifdef MNH_PARALLEL
174   DO JPATCH=1,NPATCH
175     IF (JL >= 10) WRITE(YPATCH,'(I2,I4.4)') JL,JPATCH
176     IF (JL < 10)  WRITE(YPATCH,FMT='(I1,I4.4)') JL,JPATCH
177     YRECFM='WGI'//ADJUSTL(YPATCH(:LEN_TRIM(YPATCH)))
178     CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,JPATCH),IRESP)
179     XWGI(:,JL,JPATCH)=ZWORK(:,JPATCH)
180   END DO
181 #else
182   WRITE(YLVL,'(I4)') JL
183   YRECFM='WGI'//ADJUSTL(YLVL(:LEN_TRIM(YLVL)))
184   CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,:),IRESP)
185   XWGI(:,JL,:)=ZWORK
186 #endif
187 END DO
188 !
189 !* water intercepted on leaves
190 !
191 ALLOCATE(XWR(ILU,NPATCH))
192 !
193 YRECFM = 'WR'
194 #ifdef MNH_PARALLEL
195 DO JPATCH=1,NPATCH
196   WRITE(YRECFM,'(A2,I4.4)') 'WR',JPATCH
197   CALL READ_SURF(HPROGRAM,YRECFM,XWR(:,JPATCH),IRESP)
198 END DO
199 #else
200  CALL READ_SURF(HPROGRAM,YRECFM,XWR(:,:),IRESP)
201 #endif
202 !
203 !* roughness length of Flood water
204 !
205 IF(LFLOOD)THEN
206   ALLOCATE(XZ0_FLOOD(ILU,NPATCH))
207   YRECFM = 'Z0_FLOOD'
208 #ifdef MNH_PARALLEL
209   DO JPATCH=1,NPATCH
210     WRITE(YRECFM,'(A8,I4.4)') 'Z0_FLOOD',JPATCH
211     CALL READ_SURF(HPROGRAM,YRECFM,XZ0_FLOOD(:,JPATCH),IRESP)
212   END DO
213 #else
214   CALL READ_SURF(HPROGRAM,YRECFM,XZ0_FLOOD(:,:),IRESP)
215 #endif
216 ENDIF
217 !
218 !* Leaf Area Index
219 !
220 IF (CPHOTO=='LAI' .OR. CPHOTO=='LST' .OR. CPHOTO=='NIT' .OR. CPHOTO=='NCB') THEN
221   YRECFM = 'LAI'
222 #ifdef MNH_PARALLEL
223   DO JPATCH=1,NPATCH
224     WRITE(YRECFM,'(A3,I4.4)') 'LAI',JPATCH
225     CALL READ_SURF(HPROGRAM,YRECFM,XLAI(:,JPATCH),IRESP)
226   END DO
227 #else
228   CALL READ_SURF(HPROGRAM,YRECFM,XLAI(:,:),IRESP)
229 #endif
230 END IF
231 !
232 !* snow mantel
233 !
234  CALL READ_GR_SNOW(HPROGRAM,'VEG','     ',ILU,NPATCH,TSNOW  )
235 !
236 YRECFM='VERSION'
237  CALL READ_SURF(HPROGRAM,YRECFM,IVERSION,IRESP)
238 !
239 YRECFM='BUG'
240  CALL READ_SURF(HPROGRAM,YRECFM,IBUGFIX,IRESP)
241 !
242 IF(LGLACIER)THEN
243   ALLOCATE(XICE_STO(ILU,NPATCH))
244   IF (IVERSION>7 .OR. IVERSION==7 .AND. IBUGFIX>=2) THEN
245     YRECFM = 'ICE_STO'
246 #ifdef MNH_PARALLEL
247     DO JPATCH=1,NPATCH
248       WRITE(YRECFM,'(A7,I4.4)') 'ICE_STO',JPATCH
249       CALL READ_SURF(HPROGRAM,YRECFM,XICE_STO(:,JPATCH),IRESP)
250     END DO
251 #else
252     CALL READ_SURF(HPROGRAM,YRECFM,XICE_STO(:,:),IRESP)
253 #endif
254   ELSE
255     XICE_STO(:,:) = 0.0
256   ENDIF
257 ENDIF
258 !
259 !-------------------------------------------------------------------------------
260 !
261 !*       4.  Semi-prognostic variables
262 !            -------------------------
263 !
264 ALLOCATE(XRESA(ILU,NPATCH))
265 ALLOCATE(XLE  (ILU,NPATCH))
266 IF (CPHOTO/='NON') THEN
267   ALLOCATE(XANFM  (ILU,NPATCH))
268   ALLOCATE(XAN    (ILU,NPATCH))
269   ALLOCATE(XANDAY (ILU,NPATCH))
270 END IF
271 !
272 IF(CPHOTO/='NON') THEN
273   ALLOCATE(XBIOMASS         (ILU,NNBIOMASS,NPATCH))
274   ALLOCATE(XRESP_BIOMASS    (ILU,NNBIOMASS,NPATCH))
275 END IF
276 !
277 !
278 !* aerodynamical resistance
279 !
280 YRECFM = 'RESA'
281 XRESA(:,:) = 100.
282 #ifdef MNH_PARALLEL
283 DO JPATCH=1,NPATCH
284   WRITE(YRECFM,'(A4,I4.4)') 'RESA',JPATCH
285   CALL READ_SURF(HPROGRAM,YRECFM,XRESA(:,JPATCH),IRESP)
286 END DO
287 #else
288  CALL READ_SURF(HPROGRAM,YRECFM,XRESA(:,:),IRESP)
289 #endif
290 !
291 !* patch averaged radiative temperature (K)
292 !
293 ALLOCATE(XTSRAD_NAT(ILU))
294 IF (IVERSION<6) THEN
295   XTSRAD_NAT(:)=0.
296   DO JP=1,NPATCH
297     XTSRAD_NAT(:)=XTSRAD_NAT(:)+XTG(:,1,JP)
298   ENDDO
299   XTSRAD_NAT(:)=XTSRAD_NAT(:)/NPATCH
300 ELSE
301   YRECFM='TSRAD_NAT'
302   CALL READ_SURF(HPROGRAM,YRECFM,XTSRAD_NAT(:),IRESP)
303 ENDIF
304 !
305 XLE(:,:) = XUNDEF
306 !
307 !*       5. ISBA-AGS variables
308 !
309 IF (CPHOTO/='NON') THEN
310   YRECFM = 'AN'
311   XAN(:,:) = 0.
312 #ifdef MNH_PARALLEL
313   DO JPATCH=1,NPATCH
314     WRITE(YRECFM,'(A2,I4.4)') 'AN',JPATCH
315     CALL READ_SURF(HPROGRAM,YRECFM,XAN(:,JPATCH),IRESP)
316   END DO
317 #else
318   CALL READ_SURF(HPROGRAM,YRECFM,XAN(:,:),IRESP)
319 #endif
320   !
321   YRECFM = 'ANDAY'
322   XANDAY(:,:) = 0.
323 #ifdef MNH_PARALLEL
324   DO JPATCH=1,NPATCH
325     WRITE(YRECFM,'(A5,I4.4)') 'ANDAY',JPATCH
326     CALL READ_SURF(HPROGRAM,YRECFM,XANDAY(:,JPATCH),IRESP)
327   END DO
328 #else
329   CALL READ_SURF(HPROGRAM,YRECFM,XANDAY(:,:),IRESP)
330 #endif
331   !
332   YRECFM = 'ANFM'
333   XANFM(:,:) = XANFMINIT
334 #ifdef MNH_PARALLEL
335   DO JPATCH=1,NPATCH
336     WRITE(YRECFM,'(A4,I4.4)') 'ANFM',JPATCH
337     CALL READ_SURF(HPROGRAM,YRECFM,XANFM(:,JPATCH),IRESP)
338   END DO
339 #else
340   CALL READ_SURF(HPROGRAM,YRECFM,XANFM(:,:),IRESP)
341 #endif
342   !
343   YRECFM = 'LE_AGS'
344   XLE(:,:) = 0.
345 #ifdef MNH_PARALLEL
346   DO JPATCH=1,NPATCH
347     WRITE(YRECFM,'(A6,I4.4)') 'LE_AGS',JPATCH
348     CALL READ_SURF(HPROGRAM,YRECFM,XLE(:,JPATCH),IRESP)
349   END DO
350 #else
351   CALL READ_SURF(HPROGRAM,YRECFM,XLE(:,:),IRESP)
352 #endif
353 END IF
354 !
355 IF (CPHOTO=='AGS' .OR. CPHOTO=='AST') THEN
356   !
357   XBIOMASS(:,:,:) = 0.
358   XRESP_BIOMASS(:,:,:) = 0.
359
360 ELSEIF (CPHOTO=='LAI' .OR. CPHOTO=='LST') THEN
361   !
362   XBIOMASS(:,1,:) = XBSLAI(:,:) * XLAI(:,:)
363   XRESP_BIOMASS(:,:,:) = 0.
364
365 ELSEIF (CPHOTO=='NIT') THEN
366   !
367   XBIOMASS(:,:,:) = 0.
368   DO JNBIOMASS=1,NNBIOMASS
369 #ifdef MNH_PARALLEL
370     DO JPATCH=1,NPATCH
371       WRITE(YPATCH,'(I1,I4.4)') JNBIOMASS,JPATCH
372       IF (IVERSION>7 .OR. IVERSION==7 .AND. IBUGFIX>=3) THEN
373         YRECFM='BIOMA'//ADJUSTL(YPATCH(:LEN_TRIM(YPATCH)))
374       ELSE
375         YRECFM='BIOMASS'//ADJUSTL(YPATCH(:LEN_TRIM(YPATCH)))
376       ENDIF
377       CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,JPATCH),IRESP)
378       XBIOMASS(:,JNBIOMASS,JPATCH)=ZWORK(:,JPATCH)
379     END DO
380 #else
381     WRITE(YLVL,'(I1)') JNBIOMASS
382     IF (IVERSION>7 .OR. IVERSION==7 .AND. IBUGFIX>=3) THEN
383       YRECFM='BIOMA'//ADJUSTL(YLVL(:LEN_TRIM(YLVL)))
384     ELSE
385       YRECFM='BIOMASS'//ADJUSTL(YLVL(:LEN_TRIM(YLVL)))
386     ENDIF
387     CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,:),IRESP)
388     XBIOMASS(:,JNBIOMASS,:)=ZWORK
389 #endif
390   END DO
391
392   XRESP_BIOMASS(:,:,:) = 0.
393   DO JNBIOMASS=2,NNBIOMASS
394 #ifdef MNH_PARALLEL
395     DO JPATCH=1,NPATCH
396       WRITE(YPATCH,'(I1,I4.4)') JNBIOMASS,JPATCH
397       IF (IVERSION>7 .OR. IVERSION==7 .AND. IBUGFIX>=3) THEN
398         YRECFM='RESPI'//ADJUSTL(YPATCH(:LEN_TRIM(YPATCH)))
399       ELSE
400         YRECFM='RESP_BIOM'//ADJUSTL(YPATCH(:LEN_TRIM(YPATCH)))
401       ENDIF
402       CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,JPATCH),IRESP)
403       XRESP_BIOMASS(:,JNBIOMASS,JPATCH)=ZWORK(:,JPATCH)
404     END DO
405 #else
406     WRITE(YLVL,'(I1)') JNBIOMASS
407     IF (IVERSION>7 .OR. IVERSION==7 .AND. IBUGFIX>=3) THEN
408       YRECFM='RESPI'//ADJUSTL(YLVL(:LEN_TRIM(YLVL)))
409     ELSE
410       YRECFM='RESP_BIOM'//ADJUSTL(YLVL(:LEN_TRIM(YLVL)))
411     ENDIF    
412     CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,:),IRESP)
413     XRESP_BIOMASS(:,JNBIOMASS,:)=ZWORK
414 #endif
415   END DO
416
417 ELSEIF (CPHOTO=='NCB') THEN
418   !
419   XBIOMASS(:,:,:) = 0.
420   DO JNBIOMASS=1,NNBIOMASS
421 #ifdef MNH_PARALLEL
422     DO JPATCH=1,NPATCH
423       WRITE(YPATCH,'(I1,I4.4)') JNBIOMASS,JPATCH
424       IF (IVERSION>7 .OR. IVERSION==7 .AND. IBUGFIX>=3) THEN
425         YRECFM='BIOMA'//ADJUSTL(YPATCH(:LEN_TRIM(YPATCH)))
426       ELSE
427         YRECFM='BIOMASS'//ADJUSTL(YPATCH(:LEN_TRIM(YPATCH)))
428       ENDIF
429       CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,JPATCH),IRESP)
430       XBIOMASS(:,JNBIOMASS,JPATCH)=ZWORK(:,JPATCH)
431     END DO
432 #else
433     WRITE(YLVL,'(I1)') JNBIOMASS
434     IF (IVERSION>7 .OR. IVERSION==7 .AND. IBUGFIX>=3) THEN
435       YRECFM='BIOMA'//ADJUSTL(YLVL(:LEN_TRIM(YLVL)))
436     ELSE
437       YRECFM='BIOMASS'//ADJUSTL(YLVL(:LEN_TRIM(YLVL)))
438     ENDIF    
439     CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,:),IRESP)
440     XBIOMASS(:,JNBIOMASS,:)=ZWORK
441 #endif
442   END DO
443
444   XRESP_BIOMASS(:,:,:) = 0.
445   DO JNBIOMASS=2,NNBIOMASS-2
446 #ifdef MNH_PARALLEL
447     DO JPATCH=1,NPATCH
448       WRITE(YPATCH,'(I1,I4.4)') JNBIOMASS,JPATCH
449       IF (IVERSION>7 .OR. IVERSION==7 .AND. IBUGFIX>=3) THEN
450         YRECFM='RESPI'//ADJUSTL(YPATCH(:LEN_TRIM(YPATCH)))
451       ELSE
452         YRECFM='RESP_BIOM'//ADJUSTL(YPATCH(:LEN_TRIM(YPATCH)))
453       ENDIF
454       CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,JPATCH),IRESP)
455       XRESP_BIOMASS(:,JNBIOMASS,JPATCH)=ZWORK(:,JPATCH)
456     END DO
457 #else
458     WRITE(YLVL,'(I1)') JNBIOMASS
459     IF (IVERSION>7 .OR. IVERSION==7 .AND. IBUGFIX>=3) THEN
460       YRECFM='RESPI'//ADJUSTL(YLVL(:LEN_TRIM(YLVL)))
461     ELSE
462       YRECFM='RESP_BIOM'//ADJUSTL(YLVL(:LEN_TRIM(YLVL)))
463     ENDIF    
464     CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,:),IRESP)
465     XRESP_BIOMASS(:,JNBIOMASS,:)=ZWORK
466 #endif
467   END DO
468   !
469 ENDIF
470 !
471 !*       6. Soil carbon
472 !
473 !
474 IF (CRESPSL=='CNT') THEN
475   ALLOCATE(XLITTER          (ILU,NNLITTER,NNLITTLEVS,NPATCH))
476   ALLOCATE(XSOILCARB        (ILU,NNSOILCARB,NPATCH))
477   ALLOCATE(XLIGNIN_STRUC    (ILU,NNLITTLEVS,NPATCH))
478 END IF
479 !
480 IF (CRESPSL=='CNT') THEN
481   !
482   XLITTER(:,:,:,:) = 0.
483   DO JNLITTER=1,NNLITTER
484     DO JNLITTLEVS=1,NNLITTLEVS
485 #ifdef MNH_PARALLEL
486       DO JPATCH=1,NPATCH
487         WRITE(YPATCH,'(I1,A1,I1,I4.4)') JNLITTER,'_',JNLITTLEVS,JPATCH
488         YRECFM='LITTER'//ADJUSTL(YPATCH(:LEN_TRIM(YPATCH)))
489         CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,JPATCH),IRESP)
490         XLITTER(:,JNLITTER,JNLITTLEVS,JPATCH)=ZWORK(:,JPATCH)
491       END DO
492 #else
493       WRITE(YLVL,'(I1,A1,I1)') JNLITTER,'_',JNLITTLEVS
494       YRECFM='LITTER'//ADJUSTL(YLVL(:LEN_TRIM(YLVL)))
495       CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,:),IRESP)
496       XLITTER(:,JNLITTER,JNLITTLEVS,:)=ZWORK
497 #endif
498     END DO
499   END DO
500
501   XSOILCARB(:,:,:) = 0.
502   DO JNSOILCARB=1,NNSOILCARB
503 #ifdef MNH_PARALLEL
504     DO JPATCH=1,NPATCH
505       WRITE(YPATCH,'(I4,I4.4)') JNSOILCARB,JPATCH
506       YRECFM='SOILCARB'//ADJUSTL(YPATCH(:LEN_TRIM(YPATCH)))
507       CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,JPATCH),IRESP)
508       XSOILCARB(:,JNSOILCARB,JPATCH)=ZWORK(:,JPATCH)
509     END DO
510 #else
511     WRITE(YLVL,'(I4)') JNSOILCARB
512     YRECFM='SOILCARB'//ADJUSTL(YLVL(:LEN_TRIM(YLVL)))
513     CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,:),IRESP)
514     XSOILCARB(:,JNSOILCARB,:)=ZWORK
515 #endif
516   END DO
517 !
518   XLIGNIN_STRUC(:,:,:) = 0.
519   DO JNLITTLEVS=1,NNLITTLEVS
520 #ifdef MNH_PARALLEL
521     DO JPATCH=1,NPATCH
522       WRITE(YPATCH,'(I4,I4.4)') JNLITTLEVS,JPATCH
523       YRECFM='LIGNIN_STR'//ADJUSTL(YPATCH(:LEN_TRIM(YPATCH)))
524       CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,JPATCH),IRESP)
525       XLIGNIN_STRUC(:,JNLITTLEVS,JPATCH)=ZWORK(:,JPATCH)
526     END DO
527 #else
528     WRITE(YLVL,'(I4)') JNLITTLEVS
529     YRECFM='LIGNIN_STR'//ADJUSTL(YLVL(:LEN_TRIM(YLVL)))
530     CALL READ_SURF(HPROGRAM,YRECFM,ZWORK(:,:),IRESP)
531     XLIGNIN_STRUC(:,JNLITTLEVS,:)=ZWORK
532 #endif
533   END DO
534 !
535 ENDIF
536 !
537 !
538 DEALLOCATE(ZWORK)
539 IF (LHOOK) CALL DR_HOOK('READ_ISBA_N',1,ZHOOK_HANDLE)
540 !
541 !-------------------------------------------------------------------------------
542 !
543 END SUBROUTINE READ_ISBA_n