SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
pgd_isba.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! #########
6  SUBROUTINE pgd_isba (DTCO, DTI, DGU, IG, I, UG, U, USS, &
7  hprogram,oecoclimap)
8 ! ##############################################################
9 !
10 !!**** *PGD_ISBA* monitor for averaging and interpolations of ISBA physiographic fields
11 !!
12 !! PURPOSE
13 !! -------
14 !!
15 !! METHOD
16 !! ------
17 !!
18 !
19 !! EXTERNAL
20 !! --------
21 !!
22 !! IMPLICIT ARGUMENTS
23 !! ------------------
24 !!
25 !! REFERENCE
26 !! ---------
27 !!
28 !! AUTHOR
29 !! ------
30 !!
31 !! V. Masson Meteo-France
32 !!
33 !! MODIFICATION
34 !! ------------
35 !!
36 !! Original 10/12/97
37 !! P. Le Moigne 12/2004 : add type of photosynthesis and correct computation
38 !! of ground layers number in diffusion case
39 !! P. Le Moigne 09/2005 : AGS modifs of L. Jarlan
40 !! B. Decharme 2008 : XWDRAIN
41 !! E. Martin 12/2008 : files of data for runoffb and wdrain
42 !! B. Decharme 06/2009 : files of data for topographic index
43 !! A.L. Gibelin 04/2009 : dimension NBIOMASS for ISBA-A-gs
44 !! R. Alkama 05/2012 : npatch must be 12 or 19 if CPHOTO/='NON'
45 !! B. Decharme 11/2013 : groundwater distribution for water table/surface coupling
46 !! P. Samuelsson 02/2012 : MEB
47 !!
48 !----------------------------------------------------------------------------
49 !
50 !* 0. DECLARATION
51 ! -----------
52 !
54 USE modd_data_isba_n, ONLY : data_isba_t
56 USE modd_isba_grid_n, ONLY : isba_grid_t
57 USE modd_isba_n, ONLY : isba_t
59 USE modd_surf_atm_n, ONLY : surf_atm_t
61 !
62 USE modd_surf_par, ONLY : xundef, nundef
63 USE modd_pgd_grid, ONLY : nl
64 USE modd_pgdwork, ONLY : catype
65 USE modd_data_cover_par, ONLY : nvegtype, jpcover
66 !
67 USE modd_isba_par, ONLY : noptimlayer, xoptimgrid
68 !
69 USE modi_get_luout
70 USE modi_read_nam_pgd_isba
71 USE modi_read_nam_pgd_isba_meb
72 USE modi_pgd_field
74 !
75 USE modi_get_aos_n
76 USE modi_get_sso_n
77 USE modi_get_surf_size_n
78 USE modi_pack_pgd_isba
79 USE modi_pack_pgd
80 USE modi_write_cover_tex_isba
81 USE modi_write_cover_tex_isba_par
82 USE modi_pgd_topo_index
83 USE modi_open_namelist
84 USE modi_close_namelist
85 USE modi_pgd_isba_par
86 USE modi_pgd_topd
87 USE mode_pos_surf
88 !
90 USE modi_init_io_surf_n
91 USE modi_end_io_surf_n
92 !
93 #ifdef SFX_ASC
94 USE modd_io_surf_asc, ONLY : cfilein
95 #endif
96 #ifdef SFX_FA
97 USE modd_io_surf_fa, ONLY : cfilein_fa
98 #endif
99 #ifdef SFX_LFI
100 USE modd_io_surf_lfi, ONLY : cfilein_lfi
101 #endif
102 !
103 USE yomhook ,ONLY : lhook, dr_hook
104 USE parkind1 ,ONLY : jprb
105 !
106 USE modi_abor1_sfx
107 !
108 IMPLICIT NONE
109 !
110 !* 0.1 Declaration of arguments
111 ! ------------------------
112 !
113 !
114 TYPE(data_cover_t), INTENT(INOUT) :: dtco
115 TYPE(data_isba_t), INTENT(INOUT) :: dti
116 TYPE(diag_surf_atm_t), INTENT(INOUT) :: dgu
117 TYPE(isba_grid_t), INTENT(INOUT) :: ig
118 TYPE(isba_t), INTENT(INOUT) :: i
119 TYPE(surf_atm_grid_t), INTENT(INOUT) :: ug
120 TYPE(surf_atm_t), INTENT(INOUT) :: u
121 TYPE(surf_atm_sso_t), INTENT(INOUT) :: uss
122 !
123  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! program calling surf. schemes
124 LOGICAL, INTENT(IN) :: oecoclimap ! T if parameters are computed with ecoclimap
125 ! ! F if all parameters must be specified
126 !
127 !
128 !* 0.2 Declaration of local variables
129 ! ------------------------------
130 !
131 INTEGER :: iluout ! output listing logical unit
132 INTEGER :: jlayer ! loop counter
133 INTEGER :: ilu ! number of points
134 INTEGER :: ilunam ! namelist file logical unit
135 REAL, DIMENSION(NL) :: zaosip ! A/S i+ on all surface points
136 REAL, DIMENSION(NL) :: zaosim ! A/S i- on all surface points
137 REAL, DIMENSION(NL) :: zaosjp ! A/S j+ on all surface points
138 REAL, DIMENSION(NL) :: zaosjm ! A/S j- on all surface points
139 REAL, DIMENSION(NL) :: zho2ip ! h/2 i+ on all surface points
140 REAL, DIMENSION(NL) :: zho2im ! h/2 i- on all surface points
141 REAL, DIMENSION(NL) :: zho2jp ! h/2 j+ on all surface points
142 REAL, DIMENSION(NL) :: zho2jm ! h/2 j- on all surface points
143 REAL, DIMENSION(NL) :: zsso_slope! subgrid slope on all surface points
144 INTEGER :: iresp ! error code
145 LOGICAL :: gmeb ! Multi-energy balance (MEB)
146 LOGICAL :: gfound ! flag when namelist is present
147 !
148 !* 0.3 Declaration of namelists
149 ! ------------------------
150 !
151 !
152 INTEGER :: ipatch ! number of patches
153 INTEGER :: iground_layer ! number of soil layers
154  CHARACTER(LEN=3) :: yisba ! ISBA option
155  CHARACTER(LEN=4) :: ypedotf ! Pedo transfert function for DIF
156  CHARACTER(LEN=3) :: yphoto ! photosynthesis option
157 LOGICAL :: gtr_ml ! new radiative transfert
158 REAL :: zrm_patch ! threshold to remove little fractions of patches
159  CHARACTER(LEN=28) :: ysand ! file name for sand fraction
160  CHARACTER(LEN=28) :: yclay ! file name for clay fraction
161  CHARACTER(LEN=28) :: ysoc_top ! file name for organic carbon top soil
162  CHARACTER(LEN=28) :: ysoc_sub ! file name for organic carbon sub soil
163  CHARACTER(LEN=28) :: ycti ! file name for topographic index
164  CHARACTER(LEN=28) :: yrunoffb ! file name for runoffb parameter
165  CHARACTER(LEN=28) :: ywdrain ! file name for wdrain parameter
166  CHARACTER(LEN=28) :: yperm ! file name for permafrost distribution
167  CHARACTER(LEN=28) :: ygw ! file name for groundwater map
168  CHARACTER(LEN=6) :: ysandfiletype ! sand data file type
169  CHARACTER(LEN=6) :: yclayfiletype ! clay data file type
170  CHARACTER(LEN=6) :: ysocfiletype ! organic carbon data file type
171  CHARACTER(LEN=6) :: yctifiletype ! topographic index data file type
172  CHARACTER(LEN=6) :: yrunoffbfiletype ! subgrid runoff data file type
173  CHARACTER(LEN=6) :: ywdrainfiletype ! subgrid drainage data file type
174  CHARACTER(LEN=6) :: ypermfiletype ! permafrost distribution data file type
175  CHARACTER(LEN=6) :: ygwfiletype ! groundwater distribution data file type
176 REAL :: xunif_sand ! uniform value of sand fraction (-)
177 REAL :: xunif_clay ! uniform value of clay fraction (-)
178 REAL :: xunif_soc_top ! uniform value of organic carbon top soil (kg/m2)
179 REAL :: xunif_soc_sub ! uniform value of organic carbon sub soil (kg/m2)
180 REAL :: xunif_runoffb ! uniform value of subgrid runoff coefficient
181 REAL :: xunif_wdrain ! uniform subgrid drainage parameter
182 REAL :: xunif_perm ! uniform permafrost distribution
183 REAL :: xunif_gw ! uniform groundwater distribution
184 LOGICAL :: limp_sand ! Imposed maps of Sand
185 LOGICAL :: limp_clay ! Imposed maps of Clay
186 LOGICAL :: limp_soc ! Imposed maps of organic carbon
187 LOGICAL :: limp_cti ! Imposed maps of topographic index statistics
188 LOGICAL :: limp_perm ! Imposed maps of permafrost distribution
189 LOGICAL :: limp_gw ! Imposed maps of groundwater distribution
190 REAL, DIMENSION(150) :: zsoilgrid ! Soil grid reference for DIF
191  CHARACTER(LEN=28) :: yph ! file name for pH
192  CHARACTER(LEN=28) :: yfert ! file name for fertilisation rate
193  CHARACTER(LEN=6) :: yphfiletype ! pH data file type
194  CHARACTER(LEN=6) :: yfertfiletype ! fertilisation data file type
195 REAL :: xunif_ph ! uniform value of pH
196 REAL :: xunif_fert ! uniform value of fertilisation rate
197 LOGICAL, DIMENSION(19) :: gmeb_patch
198 LOGICAL, DIMENSION(19) :: gmeb_patch_rec ! Recommended MEB patch settings
199 !
200 REAL(KIND=JPRB) :: zhook_handle
201 !
202 !-------------------------------------------------------------------------------
203 !
204 IF (lhook) CALL dr_hook('PGD_ISBA',0,zhook_handle)
205 !
206  CALL get_luout(hprogram,iluout)
207 !
208 !-------------------------------------------------------------------------------
209 !
210 !* 2.1 Reading of ISBA namelist
211 ! -------------------------
212 !
213  CALL read_nam_pgd_isba(hprogram, ipatch, iground_layer, &
214  yisba, ypedotf, yphoto, gtr_ml, zrm_patch, &
215  yclay, yclayfiletype, xunif_clay, limp_clay, &
216  ysand, ysandfiletype, xunif_sand, limp_sand, &
217  ysoc_top, ysoc_sub, ysocfiletype, xunif_soc_top, &
218  xunif_soc_sub, limp_soc, ycti, yctifiletype, limp_cti, &
219  yperm, ypermfiletype, xunif_perm, limp_perm, gmeb, &
220  ygw, ygwfiletype, xunif_gw, limp_gw, &
221  yrunoffb, yrunoffbfiletype, xunif_runoffb, &
222  ywdrain, ywdrainfiletype , xunif_wdrain, zsoilgrid, &
223  yph, yphfiletype, xunif_ph, yfert, yfertfiletype, &
224  xunif_fert )
225 !
226 i%NPATCH = ipatch
227 i%NGROUND_LAYER = iground_layer
228 i%CISBA = yisba
229 i%CPEDOTF = ypedotf
230 i%CPHOTO = yphoto
231 i%LTR_ML = gtr_ml
232 i%XRM_PATCH = max(min(zrm_patch,1.),0.)
233 !
234 !
235 !-------------------------------------------------------------------------------
236 !
237 !* 2.2 Reading of ISBA MEB namelist
238 ! -----------------------------
239 !
240 IF (i%NPATCH<1 .OR. i%NPATCH>nvegtype) THEN
241  WRITE(iluout,*) '*****************************************'
242  WRITE(iluout,*) '* Number of patch must be between 1 and ', nvegtype
243  WRITE(iluout,*) '* You have chosen NPATCH = ', i%NPATCH
244  WRITE(iluout,*) '*****************************************'
245  CALL abor1_sfx('PGD_ISBA: NPATCH MUST BE BETWEEN 1 AND NVEGTYPE')
246 END IF
247 !
248 ALLOCATE(i%LMEB_PATCH(i%NPATCH))
249 !
250 i%LMEB_PATCH(:) = .false.
251 i%LFORC_MEASURE = .false.
252 i%LMEB_LITTER = .false.
253 i%LMEB_GNDRES = .false.
254 
255 IF(gmeb)THEN
256 
257  i%LTR_ML = .true. ! Always use this SW radiative transfer option with MEB
258 
259  CALL read_nam_pgd_isba_meb(hprogram,iluout,gmeb_patch,i%LFORC_MEASURE,i%LMEB_LITTER,i%LMEB_GNDRES)
260 
261 ! Current recommendation is to use MEB for tree patches only.
262 ! Here follows a test in which non-tree patches in LMEB_PATCH are set to FALSE.
263 ! Thus, if you wish to test MEB for non-tree patches you can set
264 ! GMEB_PATCH_REC(:)=.TRUE.
265 ! in the following line:
266 
267  gmeb_patch_rec(:)=.false.
268 
269  IF(i%NPATCH==1 .AND. gmeb_patch(1))THEN
270  WRITE(iluout,*) '*****************************************'
271  WRITE(iluout,*) '* WARNING!'
272  WRITE(iluout,*) '* Using MEB for one patch only is not recommended.'
273  WRITE(iluout,*) '* LMEB_PATCH(1) has been set to .FALSE.'
274  WRITE(iluout,*) '*****************************************'
275  ELSEIF(i%NPATCH>=2 .AND. i%NPATCH<=6)THEN
276  gmeb_patch_rec(2)=.true. ! Only the tree patch (number 2) is allowed to be TRUE
277  ELSEIF(i%NPATCH>=7 .AND. i%NPATCH<=8)THEN
278  gmeb_patch_rec(3)=.true. ! Only the tree patch (number 3) is allowed to be TRUE
279  ELSEIF(i%NPATCH==9)THEN
280  gmeb_patch_rec(3:4)=(/.true.,.true./) ! Only the tree patches (numbers 3-4) are allowed to be TRUE
281  ELSEIF(i%NPATCH==10)THEN
282  gmeb_patch_rec(3:5)=(/.true.,.true.,.true./) ! Only the tree patches (numbers 3-5) are allowed to be TRUE
283  ELSEIF(i%NPATCH>=11 .AND. i%NPATCH<=12)THEN
284  gmeb_patch_rec(4:6)=(/.true.,.true.,.true./) ! Only the tree patches (numbers 4-6) are allowed to be TRUE
285  ELSEIF(i%NPATCH==19)THEN
286  gmeb_patch_rec(4:6)=(/.true.,.true.,.true./) ! The "old" tree patches (numbers 4-6) are allowed to be TRUE
287  gmeb_patch_rec(13:17)=(/.true.,.true.,.true.,.true.,.true./) ! The "new" tree patches (numbers 13-17) are allowed to be TRUE
288  ENDIF
289 
290  IF(count(.NOT.gmeb_patch_rec(:) .AND. gmeb_patch(:))>0)THEN
291  WRITE(iluout,*) '*****************************************'
292  WRITE(iluout,*) '* WARNING!'
293  WRITE(iluout,*) '* Using MEB for non-tree patches is not yet recommended.'
294  WRITE(iluout,*) '* Therefor, LMEB_PATCH for non-tree patches has been set to .FALSE.'
295  WRITE(iluout,*) '* The final LMEB_PATCH vector becomes:'
296  WRITE(iluout,*) gmeb_patch(1:i%NPATCH).AND.gmeb_patch_rec(1:i%NPATCH)
297  WRITE(iluout,*) '*****************************************'
298  ENDIF
299  gmeb_patch(:)=gmeb_patch(:).AND.gmeb_patch_rec(:)
300 
301  i%LMEB_PATCH(1:i%NPATCH) = gmeb_patch(1:i%NPATCH)
302 !
303  IF (i%LMEB_LITTER) THEN
304  i%LMEB_GNDRES = .false.
305  ENDIF
306 !
307 ENDIF
308 !
309 !-------------------------------------------------------------------------------
310 !
311 !* 3. Coherence of options
312 ! --------------------
313 !
314  CALL test_nam_var_surf(iluout,'CISBA',i%CISBA,'2-L','3-L','DIF')
315  CALL test_nam_var_surf(iluout,'CPEDOTF',i%CPEDOTF,'CH78','CO84')
316  CALL test_nam_var_surf(iluout,'CPHOTO',i%CPHOTO,'NON','AGS','LAI','AST','LST','NIT','NCB')
317 !
318 SELECT CASE (i%CISBA)
319 !
320  CASE ('2-L')
321 !
322  i%NGROUND_LAYER = 2
323  i%CPEDOTF ='CH78'
324  WRITE(iluout,*) '*****************************************'
325  WRITE(iluout,*) '* With option CISBA = ',i%CISBA,' *'
326  WRITE(iluout,*) '* the number of soil layers is set to 2 *'
327  WRITE(iluout,*) '* Pedo transfert function = CH78 *'
328  WRITE(iluout,*) '*****************************************'
329 !
330  CASE ('3-L')
331 !
332  i%NGROUND_LAYER = 3
333  i%CPEDOTF ='CH78'
334  WRITE(iluout,*) '*****************************************'
335  WRITE(iluout,*) '* With option CISBA = ',i%CISBA,' *'
336  WRITE(iluout,*) '* the number of soil layers is set to 3 *'
337  WRITE(iluout,*) '* Pedo transfert function = CH78 *'
338  WRITE(iluout,*) '*****************************************'
339 !
340  CASE ('DIF')
341 !
342  IF(i%NGROUND_LAYER==nundef)THEN
343  IF(oecoclimap)THEN
344  i%NGROUND_LAYER=noptimlayer
345  ELSE
346  WRITE(iluout,*) '****************************************'
347  WRITE(iluout,*) '* Number of ground layer not specified *'
348  WRITE(iluout,*) '****************************************'
349  CALL abor1_sfx('PGD_ISBA: NGROUND_LAYER MUST BE DONE IN NAM_ISBA')
350  ENDIF
351  ENDIF
352 !
353  ALLOCATE(i%XSOILGRID(i%NGROUND_LAYER))
354  i%XSOILGRID(:)=xundef
355  i%XSOILGRID(:)=zsoilgrid(1:i%NGROUND_LAYER)
356  IF (all(zsoilgrid(:)==xundef)) THEN
357  IF(oecoclimap) i%XSOILGRID(1:i%NGROUND_LAYER)=xoptimgrid(1:i%NGROUND_LAYER)
358  ELSEIF (count(i%XSOILGRID/=xundef)/=i%NGROUND_LAYER) THEN
359  WRITE(iluout,*) '********************************************************'
360  WRITE(iluout,*) '* Soil grid reference values /= number of ground layer *'
361  WRITE(iluout,*) '********************************************************'
362  CALL abor1_sfx('PGD_ISBA: XSOILGRID must be coherent with NGROUND_LAYER in NAM_ISBA')
363  ELSEIF (i%XSOILGRID(1).GT.0.01) THEN
364  CALL abor1_sfx('PGD_ISBA: First layer of XSOILGRID must be lower than 1cm')
365  ENDIF
366 !
367  WRITE(iluout,*) '*****************************************'
368  WRITE(iluout,*) '* Option CISBA = ',i%CISBA
369  WRITE(iluout,*) '* Pedo transfert function = ',i%CPEDOTF
370  WRITE(iluout,*) '* Number of soil layers = ',i%NGROUND_LAYER
371  IF(oecoclimap)THEN
372  WRITE(iluout,*) '* Soil layers grid (m) = ',i%XSOILGRID(1:i%NGROUND_LAYER)
373  ENDIF
374  WRITE(iluout,*) '*****************************************'
375 !
376 END SELECT
377 !
378 SELECT CASE (i%CPHOTO)
379  CASE ('AGS','LAI','AST','LST')
380  i%NNBIOMASS = 1
381  CASE ('NIT')
382  i%NNBIOMASS = 3
383  CASE ('NCB')
384  i%NNBIOMASS = 6
385 END SELECT
386 WRITE(iluout,*) '*****************************************'
387 WRITE(iluout,*) '* With option CPHOTO = ',i%CPHOTO,' *'
388 WRITE(iluout,*) '* the number of biomass pools is set to ', i%NNBIOMASS
389 WRITE(iluout,*) '*****************************************'
390 !
391 IF ( i%CPHOTO/='NON' .AND. i%NPATCH/=12 .AND. i%NPATCH/=19 ) THEN
392  WRITE(iluout,*) '*****************************************'
393  WRITE(iluout,*) '* With option CPHOTO = ', i%CPHOTO
394  WRITE(iluout,*) '* Number of patch must be equal to 12 or 19'
395  WRITE(iluout,*) '* But you have chosen NPATCH = ', i%NPATCH
396  WRITE(iluout,*) '*****************************************'
397  CALL abor1_sfx('PGD_ISBA: CPHOTO='//i%CPHOTO//' REQUIRES NPATCH=12 or 19')
398 END IF
399 !
400 IF ( i%CPHOTO=='NON' .AND. i%LTR_ML .AND. .NOT. gmeb) THEN
401  WRITE(iluout,*) '*****************************************'
402  WRITE(iluout,*) '* With option CPHOTO == NON '
403  WRITE(iluout,*) '* And With MEB = F '
404  WRITE(iluout,*) '* New radiative transfert TR_ML '
405  WRITE(iluout,*) '* cant be used '
406  WRITE(iluout,*) '*****************************************'
407  CALL abor1_sfx('PGD_ISBA: WITH CPHOTO= NON LTR_ML MUST BE FALSE')
408 END IF
409 !
410 !-------------------------------------------------------------------------------
411 !
412 !* 4. Number of points and packing of general fields
413 ! ----------------------------------------------
414 !
415  CALL get_surf_size_n(dtco, u, &
416  'NATURE',ilu)
417 !
418 ALLOCATE(i%LCOVER (jpcover))
419 ALLOCATE(i%XZS (ilu))
420 ALLOCATE(ig%XLAT (ilu))
421 ALLOCATE(ig%XLON (ilu))
422 ALLOCATE(ig%XMESH_SIZE (ilu))
423 ALLOCATE(i%XZ0EFFJPDIR(ilu))
424 !
425  CALL pack_pgd(dtco, u, &
426  hprogram, 'NATURE', &
427  ig%CGRID, ig%XGRID_PAR, &
428  i%LCOVER, i%XCOVER, i%XZS, &
429  ig%XLAT, ig%XLON, ig%XMESH_SIZE, i%XZ0EFFJPDIR )
430 !
431 !-------------------------------------------------------------------------------
432 !
433 !* 5. Packing of ISBA specific fields
434 ! -------------------------------
435 !
436  CALL get_aos_n(uss, &
437  hprogram,nl,zaosip,zaosim,zaosjp,zaosjm,zho2ip,zho2im,zho2jp,zho2jm)
438  CALL get_sso_n(uss, &
439  hprogram,nl,zsso_slope)
440 !
441  CALL pack_pgd_isba(dtco, ig, i, u, &
442  hprogram, &
443  zaosip, zaosim, zaosjp, zaosjm, &
444  zho2ip, zho2im, zho2jp, zho2jm, &
445  zsso_slope )
446 !
447 !-------------------------------------------------------------------------------
448 !
449 !* 6. Topographic index for TOPMODEL
450 ! ------------------------------
451 !
452  CALL pgd_topo_index(dgu, dtco, ug, u, uss, i, &
453  hprogram,ilu,ycti,yctifiletype,limp_cti)
454 !
455 !-------------------------------------------------------------------------------
456 !
457 !* 7. Sand fraction
458 ! -------------
459 !
460  catype='ARI'
461 !
462 ALLOCATE(i%XSAND(ilu,i%NGROUND_LAYER))
463 !
464 IF(limp_sand)THEN
465 !
466  IF(ysandfiletype=='NETCDF')THEN
467  CALL abor1_sfx('Use another format than netcdf for sand input file with LIMP_SAND')
468  ELSE
469 #ifdef SFX_ASC
470  cfilein = adjustl(adjustr(ysand)//'.txt')
471 #endif
472 #ifdef SFX_FA
473  cfilein_fa = adjustl(adjustr(ysand)//'.fa')
474 #endif
475 #ifdef SFX_LFI
476  cfilein_lfi = adjustl(ysand)
477 #endif
478  CALL init_io_surf_n(dtco, dgu, u, &
479  ysandfiletype,'NATURE','ISBA ','READ ')
480  ENDIF
481 !
482  CALL read_surf(&
483  ysandfiletype,'SAND',i%XSAND(:,1),iresp)
484 !
485  CALL end_io_surf_n(ysandfiletype)
486 !
487 ELSE
488  CALL pgd_field(dtco, ug, u, uss, &
489  hprogram,'sand fraction','NAT',ysand,ysandfiletype,xunif_sand,i%XSAND(:,1))
490 ENDIF
491 !
492 DO jlayer=1,i%NGROUND_LAYER
493  i%XSAND(:,jlayer) = i%XSAND(:,1)
494 END DO
495 !-------------------------------------------------------------------------------
496 !
497 !* 8. Clay fraction
498 ! -------------
499 !
500 ALLOCATE(i%XCLAY(ilu,i%NGROUND_LAYER))
501 !
502 IF(limp_clay)THEN
503 !
504  IF(yclayfiletype=='NETCDF')THEN
505  CALL abor1_sfx('Use another format than netcdf for clay input file with LIMP_CLAY')
506  ELSE
507 #ifdef SFX_ASC
508  cfilein = adjustl(adjustr(yclay)//'.txt')
509 #endif
510 #ifdef SFX_FA
511  cfilein_fa = adjustl(adjustr(yclay)//'.fa')
512 #endif
513 #ifdef SFX_LFI
514  cfilein_lfi = adjustl(yclay)
515 #endif
516  CALL init_io_surf_n(dtco, dgu, u, &
517  yclayfiletype,'NATURE','ISBA ','READ ')
518  ENDIF
519 !
520  CALL read_surf(&
521  yclayfiletype,'CLAY',i%XCLAY(:,1),iresp)
522 !
523  CALL end_io_surf_n(yclayfiletype)
524 !
525 ELSE
526  CALL pgd_field(dtco, ug, u, uss, &
527  hprogram,'clay fraction','NAT',yclay,yclayfiletype,xunif_clay,i%XCLAY(:,1))
528 ENDIF
529 !
530 DO jlayer=1,i%NGROUND_LAYER
531  i%XCLAY(:,jlayer) = i%XCLAY(:,1)
532 END DO
533 !
534 !-------------------------------------------------------------------------------
535 !
536 !* 9. organic carbon profile
537 ! ----------------------
538 !
539 IF(len_trim(ysocfiletype)/=0.OR.(xunif_soc_top/=xundef.AND.xunif_soc_sub/=xundef))THEN
540 !
541  ALLOCATE(i%XSOC(ilu,i%NGROUND_LAYER))
542 !
543  i%LSOCP=.true.
544 !
545  IF((len_trim(ysoc_top)==0.AND.len_trim(ysoc_sub)/=0).OR.(len_trim(ysoc_top)/=0.AND.len_trim(ysoc_sub)==0))THEN
546  WRITE(iluout,*) ' '
547  WRITE(iluout,*) '***********************************************************'
548  WRITE(iluout,*) '* Error in soil organic carbon preparation *'
549  WRITE(iluout,*) '* If used, sub and top soil input file must be given *'
550  WRITE(iluout,*) '***********************************************************'
551  WRITE(iluout,*) ' '
552  CALL abor1_sfx('PGD_ISBA: TOP AND SUB SOC INPUT FILE REQUIRED')
553  ENDIF
554 !
555  IF(limp_soc)THEN
556 !
557 ! Topsoil
558 !
559  IF(ysocfiletype=='NETCDF')THEN
560  CALL abor1_sfx('Use another format than netcdf for organic carbon input file with LIMP_SOC')
561  ELSE
562 #ifdef SFX_ASC
563  cfilein = adjustl(adjustr(ysoc_top)//'.txt')
564 #endif
565 #ifdef SFX_FA
566  cfilein_fa = adjustl(adjustr(ysoc_top)//'.fa')
567 #endif
568 #ifdef SFX_LFI
569  cfilein_lfi = adjustl(ysoc_top)
570 #endif
571  CALL init_io_surf_n(dtco, dgu, u, &
572  ysocfiletype,'NATURE','ISBA ','READ ')
573  ENDIF
574 !
575  CALL read_surf(&
576  ysocfiletype,'SOC_TOP',i%XSOC(:,1),iresp)
577 !
578  CALL end_io_surf_n(ysocfiletype)
579 !
580 ! Subsoil
581 !
582  IF(ysocfiletype=='NETCDF')THEN
583  CALL abor1_sfx('Use another format than netcdf for organic carbon input file with LIMP_SOC')
584  ELSE
585 #ifdef SFX_ASC
586  cfilein = adjustl(adjustr(ysoc_sub)//'.txt')
587 #endif
588 #ifdef SFX_FA
589  cfilein_fa = adjustl(adjustr(ysoc_sub)//'.fa')
590 #endif
591 #ifdef SFX_LFI
592  cfilein_lfi = adjustl(ysoc_sub)
593 #endif
594  CALL init_io_surf_n(dtco, dgu, u, &
595  ysocfiletype,'NATURE','ISBA ','READ ')
596  ENDIF
597 !
598  CALL read_surf(&
599  ysocfiletype,'SOC_SUB',i%XSOC(:,2),iresp)
600 !
601  CALL end_io_surf_n(ysocfiletype)
602 !
603  ELSE
604  CALL pgd_field(dtco, ug, u, uss, &
605  hprogram,'organic carbon','NAT',ysoc_top,ysocfiletype,xunif_soc_top,i%XSOC(:,1))
606  CALL pgd_field(dtco, ug, u, uss, &
607  hprogram,'organic carbon','NAT',ysoc_sub,ysocfiletype,xunif_soc_sub,i%XSOC(:,2))
608  ENDIF
609 !
610  DO jlayer=2,i%NGROUND_LAYER
611  i%XSOC(:,jlayer) = i%XSOC(:,2)
612  END DO
613 !
614 ELSE
615 !
616  i%LSOCP=.false.
617  ALLOCATE(i%XSOC(0,0))
618 !
619 ENDIF
620 !
621 !* 10. Permafrost distribution
622 ! -----------------------
623 !
624 IF(len_trim(yperm)/=0.OR.xunif_perm/=xundef)THEN
625 !
626  ALLOCATE(i%XPERM(ilu))
627 !
628  i%LPERM=.true.
629 !
630  IF(limp_perm)THEN
631 !
632  IF(ypermfiletype=='NETCDF')THEN
633  CALL abor1_sfx('Use another format than netcdf for permafrost input file with LIMP_PERM')
634  ELSE
635 #ifdef SFX_ASC
636  cfilein = adjustl(adjustr(yperm)//'.txt')
637 #endif
638 #ifdef SFX_FA
639  cfilein_fa = adjustl(adjustr(yperm)//'.fa')
640 #endif
641 #ifdef SFX_LFI
642  cfilein_lfi = adjustl(yperm)
643 #endif
644  CALL init_io_surf_n(dtco, dgu, u, &
645  ypermfiletype,'NATURE','ISBA ','READ ')
646  ENDIF
647 !
648  CALL read_surf(&
649  ypermfiletype,'PERM',i%XPERM(:),iresp)
650 !
651  CALL end_io_surf_n(ypermfiletype)
652  ELSE
653  CALL pgd_field(dtco, ug, u, uss, &
654  hprogram,'permafrost mask','NAT',yperm,ypermfiletype,xunif_perm,i%XPERM(:))
655  ENDIF
656 !
657 ELSE
658 !
659  i%LPERM=.false.
660  ALLOCATE(i%XPERM(0))
661 !
662 ENDIF
663 !
664 !* 11. Groundwater bassin distribution
665 ! -----------------------
666 !
667 IF(len_trim(ygw)/=0.OR.xunif_gw/=xundef)THEN
668 !
669  ALLOCATE(i%XGW(ilu))
670 !
671  i%LGW=.true.
672 !
673  IF(limp_gw)THEN
674 !
675  IF(ygwfiletype=='NETCDF')THEN
676  CALL abor1_sfx('Use another format than netcdf for groundwater input file with LIMP_GW')
677  ELSE
678 #ifdef SFX_ASC
679  cfilein = adjustl(adjustr(ygw)//'.txt')
680 #endif
681 #ifdef SFX_FA
682  cfilein_fa = adjustl(adjustr(ygw)//'.fa')
683 #endif
684 #ifdef SFX_LFI
685  cfilein_lfi = adjustl(ygw)
686 #endif
687  CALL init_io_surf_n(dtco, dgu, u, &
688  ygwfiletype,'NATURE','ISBA ','READ ')
689  ENDIF
690 !
691  CALL read_surf(&
692  ygwfiletype,'GW',i%XGW(:),iresp)
693 !
694  CALL end_io_surf_n(ygwfiletype)
695  ELSE
696  CALL pgd_field(dtco, ug, u, uss, &
697  hprogram,'Groundwater bassin','NAT',ygw,ygwfiletype,xunif_gw,i%XGW(:))
698  ENDIF
699 !
700 ELSE
701 !
702  i%LGW=.false.
703  ALLOCATE(i%XGW(0))
704 !
705 ENDIF
706 !
707 !-------------------------------------------------------------------------------
708 !
709 !* 12. pH and fertlisation data
710 ! --------------------------
711 !
712 IF((len_trim(yphfiletype)/=0.OR.xunif_ph/=xundef) .AND. (len_trim(yfertfiletype)/=0.OR.xunif_fert/=xundef)) THEN
713  !
714  ALLOCATE(i%XPH(ilu))
715  ALLOCATE(i%XFERT(ilu))
716  !
717  i%LNOF = .true.
718  !
719  CALL pgd_field(dtco, ug, u, uss, &
720  hprogram,'pH value','NAT',yph,yphfiletype,xunif_ph,i%XPH(:))
721  CALL pgd_field(dtco, ug, u, uss, &
722  hprogram,'fertilisation','NAT',yfert,yfertfiletype,xunif_fert,i%XFERT(:))
723  !
724 ENDIF
725 !
726 !-------------------------------------------------------------------------------
727 !
728 !* 13. Subgrid runoff
729 ! --------------
730 !
731 ALLOCATE(i%XRUNOFFB(ilu))
732  CALL pgd_field(dtco, ug, u, uss, &
733  hprogram,'subgrid runoff','NAT',yrunoffb,yrunoffbfiletype,xunif_runoffb,i%XRUNOFFB(:))
734 !
735 !-------------------------------------------------------------------------------
736 !
737 !* 14. Drainage coefficient
738 ! --------------------
739 !
740 ALLOCATE(i%XWDRAIN(ilu))
741  CALL pgd_field(dtco, ug, u, uss, &
742  hprogram,'subgrid drainage','NAT',ywdrain,ywdrainfiletype,xunif_wdrain,i%XWDRAIN(:))
743 !
744 !-------------------------------------------------------------------------------
745 !
746 !* 15. ISBA specific fields
747 ! --------------------
748 !
749 i%LECOCLIMAP = oecoclimap
750 !
751  CALL pgd_isba_par(dtco, dgu, ug, u, uss, dti, i, ig, &
752  hprogram)
753 !
754 !-------------------------------------------------------------------------------
755 !
756  CALL pgd_topd(i, ug, u, uss, &
757  hprogram)
758 !
759 !-------------------------------------------------------------------------------
760 !
761 !* 16. Prints of cover parameters in a tex file
762 ! ----------------------------------------
763 !
764 IF (oecoclimap) THEN
765  CALL write_cover_tex_isba(i%NPATCH,i%NGROUND_LAYER,i%CISBA)
766  CALL write_cover_tex_isba_par(dtco, i, &
767  i%NPATCH,i%NGROUND_LAYER,i%CISBA,i%CPHOTO,i%XSOILGRID)
768 END IF
769 IF (lhook) CALL dr_hook('PGD_ISBA',1,zhook_handle)
770 !
771 !-------------------------------------------------------------------------------
772 !
773 END SUBROUTINE pgd_isba
subroutine get_surf_size_n(DTCO, U, HTYPE, KL)
subroutine pack_pgd(DTCO, U, HPROGRAM, HSURF, HGRID, PGRID_PAR, OCOVER, PCOVER, PZS, PLAT, PLON, PMESH_SIZE, PDIR)
Definition: pack_pgd.F90:6
subroutine read_nam_pgd_isba(HPROGRAM, KPATCH, KGROUND_LAYER, HISBA, HPEDOTF, HPHOTO, OTR_ML, PRM_PATCH, HCLAY, HCLAYFILETYPE, PUNIF_CLAY, OIMP_CLAY, HSAND, HSANDFILETYPE, PUNIF_SAND, OIMP_SAND, HSOC_TOP, HSOC_SUB, HSOCFILETYPE, PUNIF_SOC_TOP, PUNIF_SOC_SUB, OIMP_SOC, HCTI, HCTIFILETYPE, OIMP_CTI, HPERM, HPERMFILETYPE, PUNIF_PERM, OIMP_PERM, OMEB, HGW, HGWFILETYPE, PUNIF_GW, OIMP_GW, HRUNOFFB, HRUNOFFBFILETYPE, PUNIF_RUNOFFB, HWDRAIN, HWDRAINFILETYPE, PUNIF_WDRAIN, PSOILGRID, HPH, HPHFILETYPE, PUNIF_PH, HFERT, HFERTFILETYPE, PUNIF_FERT)
subroutine init_io_surf_n(DTCO, DGU, U, HPROGRAM, HMASK, HSCHEME, HACTION)
subroutine get_aos_n(USS, HPROGRAM, KI, PAOSIP, PAOSIM, PAOSJP, PAOSJM, PHO2IP, PHO2IM, PHO2JP, PHO2JM)
Definition: get_aosn.F90:6
subroutine pgd_topd(I, UG, U, USS, HPROGRAM)
Definition: pgd_topd.F90:7
subroutine write_cover_tex_isba_par(DTCO, I, KPATCH, KLAYER, HISBA, HPHOTO, PSOILGRID)
subroutine pgd_field(DTCO, UG, U, USS, HPROGRAM, HFIELD, HAREA, HFILE, HFILETYPE, PUNIF, PFIELD, OPRESENT)
Definition: pgd_field.F90:6
subroutine pgd_topo_index(DGU, DTCO, UG, U, USS, I, HPROGRAM, KLU, HCTI, HCTIFILETYPE, OIMP_CTI)
subroutine pgd_isba(DTCO, DTI, DGU, IG, I, UG, U, USS, HPROGRAM, OECOCLIMAP)
Definition: pgd_isba.F90:6
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine get_sso_n(USS, HPROGRAM, KI, PSSO_SLOPE)
Definition: get_sson.F90:6
subroutine end_io_surf_n(HPROGRAM)
Definition: end_io_surfn.F90:6
subroutine read_nam_pgd_isba_meb(HPROGRAM, KLUOUT, OMEB_PATCH, OFORC_MEASURE, OMEB_LITTER, OMEB_GNDRES)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6
subroutine pack_pgd_isba(DTCO, IG, I, U, HPROGRAM, PAOSIP, PAOSIM, PAOSJP, PAOSJM, PHO2IP, PHO2IM, PHO2JP, PHO2JM, PSSO_SLOPE)
subroutine pgd_isba_par(DTCO, DGU, UG, U, USS, DTI, I, IG, HPROGRAM)
Definition: pgd_isba_par.F90:6