source: branches/publications/ORCHIDEE_CN_CAN_r5698/src_stomate/lpj_establish.f90 @ 7346

Last change on this file since 7346 was 5003, checked in by josefine.ghattas, 6 years ago

Correction of small syntax errors and lines too long, errors seen by compilation with gfortran.

  • Property svn:keywords set to HeadURL Date Author Revision
File size: 45.7 KB
Line 
1! =================================================================================================================================
2! MODULE       : lpj_establish
3!
4! CONTACT      : orchidee-help _at_ ipsl.jussieu.fr
5!
6! LICENCE      : IPSL (2006)
7! This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
8!
9!>\BRIEF        Establish pft's
10!!
11!!\n DESCRIPTION: None
12!!
13!! RECENT CHANGE(S): None
14!!
15!! REFERENCE(S) :
16!! - Sitch, S., B. Smith, et al. (2003), Evaluation of ecosystem dynamics,
17!!        plant geography and terrestrial carbon cycling in the LPJ dynamic
18!!        global vegetation model, Global Change Biology, 9, 161-185.\n
19!! - Haxeltine, A. and I. C. Prentice (1996), BIOME3: An equilibrium
20!!        terrestrial biosphere model based on ecophysiological constraints,
21!!        resource availability, and competition among plant functional types,
22!!        Global Biogeochemical Cycles, 10(4), 693-709.\n
23!! - Smith, B., I. C. Prentice, et al. (2001), Representation of vegetation
24!!        dynamics in the modelling of terrestrial ecosystems: comparing two
25!!        contrasting approaches within European climate space,
26!!        Global Ecology and Biogeography, 10, 621-637.\n
27!!
28!! SVN          :
29!! $HeadURL$
30!! $Date$
31!! $Revision$
32!! \n
33!_ ================================================================================================================================
34
35MODULE lpj_establish
36
37  ! modules used:
38  USE xios_orchidee
39  USE ioipsl_para
40  USE stomate_data
41  USE constantes
42  USE grid
43  USE function_library,    ONLY: biomass_to_lai
44
45  IMPLICIT NONE
46
47  ! private & public routines
48  PRIVATE
49  PUBLIC establish,establish_clear
50
51  LOGICAL, SAVE                          :: firstcall_establish = .TRUE.           !! first call
52!$OMP THREADPRIVATE(firstcall_establish)
53CONTAINS
54
55
56!! ================================================================================================================================
57!! SUBROUTINE   : fire_clear
58!!
59!>\BRIEF       Set the firstcall_establish flag to .TRUE. and activate initialization
60!_ ================================================================================================================================
61
62  SUBROUTINE establish_clear
63    firstcall_establish = .TRUE.
64  END SUBROUTINE establish_clear
65
66
67! =================================================================================================================================
68! SUBROUTINE   : establish
69!
70!>\BRIEF       Calculate sstablishment of new woody PFT and herbaceous PFTs
71!!
72!! DESCRIPTION : Establishments of new woody and herbaceous PFT are simulated.
73!! Maximum establishment rate (0.12) declines due to competition for light (space).
74!! There are two establishment estimates: one for the for DGVM and one for the
75!! static cases.\n
76!! In the case of DGVM, competitive process of establishment for the area of
77!! available space is represented using more detailed description compared with static
78!! one. Biomass and distribution of plant age are updated on the basis of changes
79!! in number of individuals. Finally excess sapwood of is converted to heartwood.
80!!
81!! \latexonly
82!! \input{equation_lpj_establish.tex}
83!! \endlatexonly
84!! \n
85!!
86!! RECENT CHANGE(S): None
87!!
88!! REFERENCE(S)    :
89!! Smith, B., I. C. Prentice, et al. (2001), Representation of vegetation
90!!    dynamics in the modelling of terrestrial ecosystems: comparing two
91!!    contrasting approaches within European climate space,
92!!    Global Ecology and Biogeography, 10, 621-637.
93!!
94!! FLOWCHART       :
95!! \latexonly
96!! \includegraphics[scale = 0.7]{establish.png}
97!! \endlatexonly
98!! \n
99!_ ================================================================================================================================
100 
101  SUBROUTINE establish (npts, dt, PFTpresent, regenerate, &
102       neighbours, resolution, need_adjacent, herbivores, &
103       precip_annual, gdd0, lm_lastyearmax, &
104       cn_ind, avail_tree, avail_grass,  npp_longterm, &
105       leaf_age, leaf_frac, &
106       ind, biomass, age, everywhere, co2_to_bm, &
107       soil_n_min, n_uptake, nstress_season, veget_max, woodmass_ind, &
108       mortality, bm_to_litter)
109
110    !! 0. Variable and parameter declaration
111   
112    !! 0.1 Input variables
113   
114    INTEGER(i_std), INTENT(in)                                :: npts            !! Domain size - number of pixels (dimensionless)   
115    REAL(r_std), INTENT(in)                                   :: dt              !! Time step of vegetation dynamics for stomate
116                                                                                 !! (days)           
117    LOGICAL, DIMENSION(npts,nvm), INTENT(in)                  :: PFTpresent      !! Is pft there (unitless)   
118    REAL(r_std), DIMENSION(npts,nvm), INTENT(in)              :: regenerate      !! Winter sufficiently cold (unitless)   
119    INTEGER(i_std), DIMENSION(npts,NbNeighb), INTENT(in)      :: neighbours      !! indices of the neighbours of each grid point
120                                                                                 !! (unitless); 
121                                                                                 !! [1=North and then clockwise] 
122    REAL(r_std), DIMENSION(npts,2), INTENT(in)                :: resolution      !! resolution at each grid point (m); 1=E-W, 2=N-S     
123    LOGICAL, DIMENSION(npts,nvm), INTENT(in)                  :: need_adjacent   !! in order for this PFT to be introduced, does it
124                                                                                 !! have to be present in an adjacent grid box? 
125    REAL(r_std), DIMENSION(npts,nvm), INTENT(in)              :: herbivores      !! time constant of probability of a leaf to
126                                                                                 !! be eaten by a herbivore (days)     
127    REAL(r_std), DIMENSION(npts), INTENT(in)                  :: precip_annual   !! annual precipitation (mm year^{-1})
128    REAL(r_std), DIMENSION(npts), INTENT(in)                  :: gdd0            !! growing degree days (degree C)
129    REAL(r_std), DIMENSION(npts,nvm), INTENT(in)              :: lm_lastyearmax  !! last year's maximum leaf mass for each PFT
130                                                                                 !! (gC m^{-2 })
131    REAL(r_std), DIMENSION(npts,nvm), INTENT(in)              :: cn_ind          !! crown area of individuals (m^2)           
132    REAL(r_std), DIMENSION(npts), INTENT(in)                  :: avail_tree      !! space availability for trees (unitless)     
133    REAL(r_std), DIMENSION(npts), INTENT(in)                  :: avail_grass     !! space availability for grasses (unitless) 
134    REAL(r_std), DIMENSION(npts,nvm), INTENT(in)              :: npp_longterm    !! longterm NPP, for each PFT (gC m^{-2})   
135    REAL(r_std), DIMENSION(npts,nvm), INTENT(in)              :: veget_max       !! "maximal" coverage fraction of a PFT
136                                                                                 !! (LAI -> infinity) on ground (unitless)
137    REAL(r_std), DIMENSION(npts,nvm),INTENT(in)               :: mortality       !! Fraction of individual dying this time
138                                                                                 !! step (0 to 1, unitless)
139
140    !! 0.2 Output variables
141   
142    !! 0.3 Modified variables
143
144    REAL(r_std), DIMENSION(npts,nvm,nleafages), INTENT(inout) :: leaf_age        !! leaf age (days)     
145    REAL(r_std), DIMENSION(npts,nvm,nleafages), INTENT(inout) :: leaf_frac       !! fraction of leaves in leaf age class (unitless)   
146    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: ind             !! Number of individuals (individuals m^{-2})         
147    REAL(r_std), DIMENSION(npts,nvm,nparts,nelements), INTENT(inout):: biomass   !! biomass (gC m^{-2 })     
148    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: age             !! mean age (years)       
149    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: everywhere      !! is the PFT everywhere in the grid box or very
150                                                                                 !! localized (unitless)   
151    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: co2_to_bm       !! biomass up take for establishment i.e.
152                                                                                 !! pseudo-photosynthesis (gC m^{-2} day^{-1})
153    REAL(r_std), DIMENSION(npts,nvm,nnspec), INTENT(inout)    :: soil_n_min      !! Nitrogen in mineral soil,   
154 !! (gN/(m**2 of PFT))
155 !! to correct for nitrogen creation associated with establishmnet   
156    REAL(r_std), DIMENSION(npts,nvm,nionspec), INTENT(inout)  :: n_uptake        !! Plant uptake of ammonium and nitrate 
157 !! (gN/m**2/day)
158    REAL(r_std), DIMENSION(npts,nvm), INTENT(in)              :: nstress_season  !! seasonal nitrogen stress 
159 !! (unitless)
160 !! (get's initialised at first establishment)
161    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: woodmass_ind    !! woodmass of the individual, needed to calculate
162                                                                                 !! crownarea in lpj_crownarea (gC m^{-2 }) 
163    REAL(r_std), DIMENSION(npts,nvm,nparts,nelements), INTENT(inout) :: bm_to_litter !!Biomass transfer to litter
164
165    !! 0.4 Local variables
166
167    REAL(r_std)                                               :: tau_eatup       !! time during which a sapling can be entirely
168                                                                                 !! eaten by herbivores (days)
169    REAL(r_std), DIMENSION(npts,nvm)                          :: fpc_nat         !! new fpc, foliage projective cover: fractional
170                                                                                 !! coverage (unitless)       
171    REAL(r_std), DIMENSION(npts)                              :: estab_rate_max_climate_tree  !! maximum tree establishment rate,
172                                                                                              !! based on climate only (unitless) 
173    REAL(r_std), DIMENSION(npts)                              :: estab_rate_max_climate_grass !! maximum grass establishment rate,
174                                                                                              !! based on climate only (unitless)
175    REAL(r_std), DIMENSION(npts)                              :: estab_rate_max_tree          !! maximum tree establishment rate,
176                                                                                              !! based on climate and fpc
177                                                                                              !! (unitless)
178    REAL(r_std), DIMENSION(npts)                              :: estab_rate_max_grass         !! maximum grass establishment rate,
179                                                                                              !! based on climate and fpc
180                                                                                              !! (unitless)
181    REAL(r_std), DIMENSION(npts)                              :: sumfpc          !! total natural fpc (unitless)
182    REAL(r_std), DIMENSION(npts)                              :: fracnat         !! total fraction occupied by natural
183                                                                                 !! vegetation (unitless) 
184    REAL(r_std), DIMENSION(npts)                              :: sumfpc_wood     !! total woody fpc (unitless)   
185    REAL(r_std), DIMENSION(npts)                              :: spacefight_grass!! for grasses, measures the total concurrence
186                                                                                 !! for available space (unitless)
187    REAL(r_std), DIMENSION(npts,nvm)                          :: d_ind           !! change in number of individuals per time step
188                                                                                 !! (individuals m^{-2} day{-1})         
189    REAL(r_std), DIMENSION(npts,nelements)                    :: bm_new          !! biomass increase (gC m^{-2 })       
190    REAL(r_std), DIMENSION(npts,nvm,nparts,nelements)         :: biomass_old     !! Save the original biomass passed into the subroutine
191    REAL(r_std), DIMENSION(npts,nelements)                    :: bm_non          !! Non-effective establishment: the "virtual" saplings that die instantly
192    REAL(r_std), DIMENSION(npts,nelements)                    :: bm_eff          !! Effective (or real) establishment 
193    REAL(r_std), DIMENSION(npts)                              :: dia             !! stem diameter (m)   
194    REAL(r_std), DIMENSION(npts)                              :: b1              !! temporary variable           
195    REAL(r_std), DIMENSION(npts)                              :: woodmass        !! woodmass of an individual (gC m^{-2}) 
196    REAL(r_std), DIMENSION(npts)                              :: leaf_mass_young !! carbon mass in youngest leaf age class
197                                                                                 !! (gC m^{-2})
198    REAL(r_std), DIMENSION(npts)                              :: factor          !! reduction factor for establishment if many
199                                                                                 !! trees or grasses are present (unitless) 
200    REAL(r_std), DIMENSION(npts,nelements)                    :: total_bm        !! Total carbon (or nitrogen) mass for all pools (gC m^{-2})   
201    REAL(r_std), DIMENSION(npts,nelements)                    :: total_bm_sapl   !! Total sappling biomass for all pools
202                                                                                 !! (gC(orN) m^{-2}) 
203    REAL(r_std), DIMENSION(npts,nelements)                    :: total_bm_sapl_non !! total non-effective sapling biomass
204
205    INTEGER(i_std)                                            :: nfrontx         !! from how many sides is the grid box invaded
206                                                                                 !! (unitless?)   
207    INTEGER(i_std)                                            :: nfronty         !! from how many sides is the grid box invaded
208                                                                                 !! (unitless?)   
209    REAL(r_std), DIMENSION(npts)                              :: vn              !! flow due to new individuals veget_max after
210                                                                                 !! establishment, to get a proper estimate of
211                                                                                 !! carbon and nitrogen
212    REAL(r_std), DIMENSION(npts,nvm)                          :: lai             !! leaf area index OF an individual plant
213    REAL(r_std), DIMENSION(npts)                              :: lai_ind         !! lai on each PFT surface (m^2 m^{-2})   
214    REAL(r_std), DIMENSION(npts)                              :: veget_max_tree  !! Sum of veget_max for the pft's which are trees
215    INTEGER(i_std)                                            :: nbtree          !! Number of PFT's which are trees
216    INTEGER(i_std)                                            :: i,j,k,m         !! indices (unitless)       
217    REAL(r_std), DIMENSION(npts)                              :: soil_n_constraint !! Soil inorganic N pool (gN m-2)
218    REAL(r_std), DIMENSION(npts)                              :: ntake           !! total N associated to establishment (gN)
219    REAL(r_std), DIMENSION(npts)                              :: ntake_nitrate   !! nitrate associated to establishment (gN)
220!_ ================================================================================================================================
221
222    IF (printlev>=3) WRITE(numout,*) 'Entering establish'
223
224  !! 0. Calculate the LAI from the biomass.
225  !! This is done to prevent passing an incorrect
226  !! LAI around, since LAI is diagnostic.
227  !! We can't do this if we use an LAI map! So this breaks DO_STOMATE=N
228    lai(:,ibare_sechiba) = zero
229    DO i = 1, npts
230       DO j = 1, nvm
231          lai(i,j) = biomass_to_lai(biomass(i,j,ileaf,icarbon),j)
232       ENDDO
233    ENDDO
234
235  !! 1. messages and initialization
236
237    ! Assumption: time durasion that sapling is completely eaten by hervioures is a half year?   
238    ! No reference
239    tau_eatup = one_year/2.
240   
241    ! Calculate the sum of the vegetation over the tree pft's and the number of pft's which are trees
242    veget_max_tree(:) = 0.0
243    nbtree=0
244    DO j = 1, nvm 
245       IF (is_tree(j)) THEN
246          veget_max_tree(:) = veget_max_tree(:) + veget_max(:,j)
247          nbtree = nbtree + 1
248       END IF
249    END DO
250    ! Set nbtree=1 to avoid zero division later if there are no tree PFT's.
251    ! For that case veget_max_tree=0 so there will not be any impact.
252    IF (nbtree == 0) nbtree=1
253
254    !! 1.1 First call only
255    IF ( firstcall_establish ) THEN
256
257       WRITE(numout,*) 'establish:'
258
259       WRITE(numout,*) '   > time during which a sapling can be entirely eaten by herbivores (d): ', &
260            tau_eatup
261
262       firstcall_establish = .FALSE.
263
264    ENDIF
265
266  !! 2. recalculate fpc
267
268    IF (ok_dgvm) THEN
269       fracnat(:) = un
270
271       !! 2.1 Only natural part of the grid cell
272       do j = 2,nvm ! Loop over # PFTs
273         
274          IF ( .NOT. natural(j) ) THEN
275             fracnat(:) = fracnat(:) - veget_max(:,j)
276          ENDIF
277       ENDDO ! Loop over # PFTs
278       
279       sumfpc(:) = zero
280
281       !! 2.2 Total natural fpc on grid
282       !      The overall fractional coverage of a PFT in a grid is calculated here.
283       !      FPC is related to mean individual leaf area index by the Lambert-Beer law.
284       !      See Eq. (1) in tex file.\n
285       DO j = 2,nvm ! Loop over # PFTs
286          IF ( natural(j) ) THEN
287             WHERE(fracnat(:).GT.min_stomate)
288                WHERE (lai(:,j) == val_exp) 
289                   fpc_nat(:,j) = cn_ind(:,j) * ind(:,j) / fracnat(:)
290                ELSEWHERE
291                   fpc_nat(:,j) = cn_ind(:,j) * ind(:,j) / fracnat(:) & 
292                        * ( un - exp( - biomass_to_lai(lm_lastyearmax(:,j),npts,j)* ext_coeff(j) ) )
293                ENDWHERE
294             ENDWHERE
295
296             WHERE ( PFTpresent(:,j) )
297                sumfpc(:) = sumfpc(:) + fpc_nat(:,j)
298             ENDWHERE
299          ELSE
300
301             fpc_nat(:,j) = zero
302
303          ENDIF
304
305       ENDDO ! Loop over # PFTs
306       
307       !! 2.3 Total woody fpc on grid and number of regenerative tree pfts
308       !      Total woody FPC increases by adding new FPC.
309       !      Under the condition that temperature in last winter is higher than a threshold,
310       !      woody plants is exposed in higher competitive environment.
311       sumfpc_wood(:) = zero
312
313       DO j = 2,nvm ! Loop over # PFTs
314
315          IF ( is_tree(j) .AND. natural(j) ) THEN
316
317             ! total woody fpc
318             WHERE ( PFTpresent(:,j) )
319                sumfpc_wood(:) = sumfpc_wood(:) + fpc_nat(:,j)
320             ENDWHERE
321
322          ENDIF
323
324       ENDDO ! Loop over # PFTs
325
326       !! 2.4 Total number of natural grasses on grid\n
327       !     Grass increment equals 'everywhere'\n
328       spacefight_grass(:) = zero
329
330       DO j = 2,nvm ! Loop over # PFTs
331
332          IF ( .NOT. is_tree(j) .AND. natural(j) ) THEN
333
334             ! Count a PFT fully only if it is present on a grid.
335             WHERE ( PFTpresent(:,j) )
336                spacefight_grass(:) = spacefight_grass(:) + everywhere(:,j)
337             ENDWHERE
338
339          ENDIF
340
341       ENDDO ! Loop over # PFTs
342
343       !! 2.5 Maximum establishment rate, based on climate only\n
344       WHERE ( ( precip_annual(:) .GE. precip_crit ) .AND. ( gdd0(:) .GE. gdd_crit_estab ) )
345
346          estab_rate_max_climate_tree(:) = estab_max_tree ! 'estab_max_*'; see 'stomate_constants.f90'
347          estab_rate_max_climate_grass(:) = estab_max_grass
348
349       ELSEWHERE
350
351          estab_rate_max_climate_tree(:) = zero
352          estab_rate_max_climate_grass(:) = zero
353
354       ENDWHERE
355
356       !! 2.6 Reduce maximum tree establishment rate if many trees are present.
357       !      In the original DGVM, this is done using a step function which yields a
358       !      reduction by factor 4 if sumfpc_wood(i) .GT.  fpc_crit - 0.05.
359       !      This can lead to small oscillations (without consequences however).
360       !      Here, a steady linear transition is used between fpc_crit-0.075 and
361       !      fpc_crit-0.025.
362       !      factor(:) = 1. - 15. * ( sumfpc_wood(:) - (fpc_crit-.075))
363       !      factor(:) = MAX( 0.25_r_std, MIN( 1._r_std, factor(:)))
364       !      S. Zaehle modified according to Smith et al. 2001
365       !      See Eq. (2) in header
366       factor(:)=(un - exp(- establish_scal_fact * (un - sumfpc_wood(:))))*(un - sumfpc_wood(:))
367       estab_rate_max_tree(:) = estab_rate_max_climate_tree(:) * factor(:)
368
369       !! 2.7 Modulate grass establishment rate.
370       !      If canopy is not closed (fpc < fpc_crit-0.05), normal establishment.
371       !      If canopy is closed, establishment is reduced by a factor 4.
372       !      Factor is linear between these two bounds.
373       !      This is different from the original DGVM where a step function is
374       !      used at fpc_crit-0.05 (This can lead to small oscillations,
375       !      without consequences however).
376       !      factor(:) = 1. - 15. * ( sumfpc(:) - (fpc_crit-.05))
377       !      factor(:) = MAX( 0.25_r_std, MIN( 1._r_std, factor(:)))
378       !      estab_rate_max_grass(:) = estab_rate_max_climate_grass(:) * factor(:)
379       !      S. Zaehle modified to true LPJ formulation, grasses are only allowed in the
380       !      fpc fraction not occupied by trees..., 080806
381       !      estab_rate_max_grass(:)=MAX(0.98-sumfpc(:),zero)
382       !      See Eq. (3) in header
383       estab_rate_max_grass(:) = MAX(MIN(estab_rate_max_climate_grass(:), max_tree_coverage - sumfpc(:)),zero)
384
385       !! 2.8 Longterm grass NPP for competition between C4 and C3 grasses
386       !      to avoid equal veget_max, the idea is that more reestablishment
387       !      is possible for the more productive PFT
388       factor(:) = min_stomate
389
390       DO j = 2,nvm ! Loop over # PFTs
391          IF ( natural(j) .AND. .NOT.is_tree(j)) & 
392               factor(:) = factor(:) + npp_longterm(:,j) * &
393               biomass_to_lai(lm_lastyearmax(:,j),npts,j)
394       ENDDO ! Loop over # PFTs
395
396       !! 2.9 Establish natural PFTs
397       d_ind(:,:) = zero
398
399       IF ( NbNeighb /= 8 ) THEN
400          CALL ipslerr(3, "establish", "This routine needs to be adapted to non rectengular grids", "Talk to Jan Polcher", " ")
401       ENDIF
402
403       DO j = 2,nvm ! Loop over # PFTs
404
405          IF ( natural(j) ) THEN ! only for natural PFTs
406
407             !! 2.9.1 PFT expansion across the grid box. Not to be confused with areal coverage.
408             IF ( treat_expansion ) THEN
409
410                ! only treat plants that are regenerative and present and still can expand
411                DO i = 1, npts ! Loop over # pixels - domain size
412
413                   IF ( PFTpresent(i,j) .AND. &
414                        ( everywhere(i,j) .LT. un ) .AND. &
415                        ( regenerate(i,j) .GT. regenerate_crit ) ) THEN
416
417                      ! from how many sides is the grid box invaded (separate x and y directions
418                      ! because resolution may be strongly anisotropic)
419                      ! For the moment we only look into 4 direction but that can be expanded (JP)
420                      nfrontx = 0
421                      IF ( neighbours(i,3) .GT. 0 ) THEN
422                         IF ( everywhere(neighbours(i,3),j) .GT. 1.-min_stomate ) nfrontx = nfrontx+1
423                      ENDIF
424                      IF ( neighbours(i,7) .GT. 0 ) THEN
425                         IF ( everywhere(neighbours(i,7),j) .GT. 1.-min_stomate ) nfrontx = nfrontx+1
426                      ENDIF
427
428                      nfronty = 0
429                      IF ( neighbours(i,1) .GT. 0 ) THEN
430                         IF ( everywhere(neighbours(i,1),j) .GT. 1.-min_stomate ) nfronty = nfronty+1
431                      ENDIF
432                      IF ( neighbours(i,5) .GT. 0 ) THEN
433                         IF ( everywhere(neighbours(i,5),j) .GT. 1.-min_stomate ) nfronty = nfronty+1
434                      ENDIF
435                     
436                      everywhere(i,j) = &
437                           everywhere(i,j) + migrate(j) * dt/one_year * &
438                           ( nfrontx / resolution(i,1) + nfronty / resolution(i,2) )
439                     
440                      IF ( .NOT. need_adjacent(i,j) ) THEN
441                         
442                         ! in that case, we also assume that the PFT expands from places within
443                         ! the grid box (e.g., oasis).
444                         ! What is this equation? No reference.
445                         everywhere(i,j) = &
446                              everywhere(i,j) + migrate(j) * dt/one_year * &
447                              2. * SQRT( pi*everywhere(i,j)/(resolution(i,1)*resolution(i,2)) )
448
449                      ENDIF
450
451                      everywhere(i,j) = MIN( everywhere(i,j), un )
452
453                   ENDIF
454
455                ENDDO ! Loop over # pixels - domain size
456
457             ENDIF ! treat expansion?
458
459             !! 2.9.2 Establishment rate
460             !      - Is lower if the PFT is only present in a small part of the grid box
461             !        (after its introduction), therefore multiplied by "everywhere".
462             !      - Is divided by the number of PFTs that compete ("spacefight").
463             !      - Is modulated by space availability (avail_tree, avail_grass).
464
465             !! 2.9.2.1 present and regenerative trees
466             IF ( is_tree(j) ) THEN
467
468                WHERE ( PFTpresent(:,j) .AND. ( regenerate(:,j) .GT. regenerate_crit ) )
469                   d_ind(:,j) = estab_rate_max_tree(:)*everywhere(:,j) * &
470                        avail_tree(:) * dt/one_year
471                ENDWHERE
472
473             !! 2.9.2.2 present and regenerative grasses
474             ELSE
475                WHERE ( PFTpresent(:,j) .AND. ( regenerate(:,j) .GT. regenerate_crit )  & 
476                     .AND.factor(:).GT.min_stomate .AND. spacefight_grass(:).GT. min_stomate) 
477                   
478                   d_ind(:,j) = estab_rate_max_grass(:)*everywhere(:,j)/spacefight_grass(:) * &
479                        MAX(min_stomate,npp_longterm(:,j)*biomass_to_lai(lm_lastyearmax(:,j),npts,j)/factor(:)) &
480                        * fracnat(:) * dt/one_year
481                ENDWHERE
482               
483             ENDIF  ! tree/grass
484             
485          ENDIF ! if natural
486       ENDDO  ! Loop over # PFTs
487       
488  !! 3. Lpj establishment in static case
489
490    !     Lpj establishment in static case, S. Zaehle 080806, account for real LPJ dynamics in
491    !     prescribed vegetation, i.e. population dynamics within a given area of the grid cell.
492    ELSE
493
494       d_ind(:,:) = zero
495
496       DO j = 2,nvm ! Loop over # PFTs
497          WHERE(ind(:,j)*cn_ind(:,j).GT.min_stomate)
498             lai_ind(:) = biomass_to_lai(lm_lastyearmax(:,j),npts,j)/(ind(:,j)*cn_ind(:,j))
499          ELSEWHERE
500             lai_ind(:) = zero
501          ENDWHERE
502
503          !! 3.1 For natural woody PFTs
504          IF ( natural(j) .AND. is_tree(j)) THEN 
505
506             ! See Eq. (4) in tex file.           
507             fpc_nat(:,j) =  MIN(un, cn_ind(:,j) * ind(:,j) * & 
508                  MAX( ( un - exp( - ext_coeff(j) * lai_ind(:) ) ), min_cover ) )
509
510
511             WHERE (veget_max(:,j).GT.min_stomate.AND.ind(:,j).LE.2.)
512
513                !! 3.1.1 Only establish into growing stands
514                !        Only establish into growing stands, ind can become very
515                !        large in the static mode because LAI is very low in poor
516                !        growing conditions, favouring continuous establishment.
517                !        To avoid this a maximum IND is set. BLARPP: This should be
518                !        replaced by a better stand density criteria.
519                factor(:)=(un - exp(-establish_scal_fact * (un - fpc_nat(:,j))))*(un - fpc_nat(:,j))
520
521                estab_rate_max_tree(:) = estab_max_tree * factor(:) * MAX(0.11 , nstress_season(:,j) )
522
523                !! 3.1.2 do establishment for natural PFTs\n
524                d_ind(:,j) = MAX( zero, estab_rate_max_tree(:) * dt/one_year)
525
526             ENDWHERE
527
528             !S. Zaehle: quickfix: to simulate even aged stand, uncomment the following lines...
529             !where (ind(:,j) .LE. min_stomate)
530             !d_ind(:,j) = 0.1 !MAX( 0.0, estab_rate_max_tree(:) * dt/one_year)
531             WHERE (veget_max(:,j).GT.min_stomate .AND. ind(:,j).EQ.zero)
532                d_ind(:,j) = ind_0_estab
533             ENDWHERE
534
535          !! 3.2 For natural grass PFTs
536          ELSEIF ( natural(j) .AND. .NOT.is_tree(j)) THEN
537
538             WHERE (veget_max(:,j).GT.min_stomate)
539
540                fpc_nat(:,j) =  cn_ind(:,j) * ind(:,j) * & 
541                     MAX( ( un - exp( - ext_coeff(j) * lai_ind(:) ) ), min_cover )
542
543                d_ind(:,j) = MAX(zero , (un - fpc_nat(:,j)) * dt/one_year )
544
545             ENDWHERE
546
547             WHERE (veget_max(:,j).GT.min_stomate .AND. ind(:,j).EQ. zero)
548                d_ind(:,j) = ind_0_estab 
549             ENDWHERE
550
551          ENDIF
552
553       ENDDO ! Loop over # PFTs
554
555    ENDIF ! DGVM OR NOT
556
557  !! 4. Biomass calculation
558
559    DO j = 2,nvm ! Loop over # PFTs
560
561       IF ( natural(j) ) THEN ! only for natural PFTs
562
563          !! 4.1 Herbivores reduce establishment rate
564          !      We suppose that saplings are vulnerable during a given time after establishment.
565          !      This is taken into account by preventively reducing the establishment rate.
566          IF ( ok_herbivores ) THEN
567
568             d_ind(:,j) = d_ind(:,j) * EXP( - tau_eatup/herbivores(:,j) )
569
570          ENDIF
571
572          !! 4.2 Total biomass.
573          !      Add biomass only if d_ind, over one year, is of the order of ind.
574          !      save old leaf mass to calculate leaf age
575          leaf_mass_young(:) = leaf_frac(:,j,1) * biomass(:,j,ileaf,icarbon)
576
577          ! total biomass of existing PFT to limit biomass added from establishment
578          total_bm(:,:) = zero
579
580          DO k = 1, nparts
581             total_bm(:,:) = total_bm(:,:) + biomass(:,j,k,:)
582          ENDDO
583          ! soil nitrogen available to feed plant establishment. 
584          ! This needs to be taken from soil N. Reason: plants must not produce nitrogen by establishment
585          ! (otherwise this creates N)
586          soil_n_constraint(:)=soil_n_min(:,j,iammonium)+soil_n_min(:,j,initrate) 
587
588
589          IF(ok_dgvm) THEN
590             vn(:) = veget_max(:,j)
591          ELSE
592             vn(:) = un
593          ENDIF
594
595          !! 4.3 Woodmass calculation
596
597          !! 4.3.1 with DGVM
598          IF(ok_dgvm) THEN
599
600             ! S. Zaehle calculate new woodmass_ind and veget_max after establishment (needed for correct scaling!)
601             ! essential correction for MERGE!
602             IF(is_tree(j))THEN
603                DO i=1,npts ! Loop over # pixels - domain size
604                   IF((d_ind(i,j)+ind(i,j)).GT.min_stomate) THEN
605
606                      IF((total_bm(i,icarbon).LE.min_stomate) .OR. (veget_max(i,j) .LE. min_stomate)) THEN
607
608                         ! new wood mass of PFT
609                         woodmass_ind(i,j) = &
610                              (((biomass(i,j,isapabove,icarbon) + biomass(i,j,isapbelow,icarbon) &
611                              + biomass(i,j,iheartabove,icarbon) + biomass(i,j,iheartbelow,icarbon))*veget_max(i,j)) &
612                              + (bm_sapl(j,isapabove,icarbon) + bm_sapl(j,isapbelow,icarbon) &
613                              + bm_sapl(j,iheartabove,icarbon) + bm_sapl(j,iheartbelow,icarbon))*d_ind(i,j))/(ind(i,j) + d_ind(i,j))
614
615                      ELSE
616 
617                         ! new biomass is added to the labile pool, hence there is no change
618                         ! in CA associated with establishment
619                         woodmass_ind(i,j) = &
620                              & (biomass(i,j,isapabove,icarbon) + biomass(i,j,isapbelow,icarbon) &
621                              & +biomass(i,j,iheartabove,icarbon) + biomass(i,j,iheartbelow,icarbon))*veget_max(i,j) &
622                              & /(ind(i,j) + d_ind(i,j))
623
624                      ENDIF
625
626                      ! new diameter of PFT
627                      dia(i) = (woodmass_ind(i,j)/(pipe_density(j)*pi/4.*pipe_tune2(j))) &
628                           &                **(1./(2.+pipe_tune3(j)))
629                      vn(i) = (ind(i,j) + d_ind(i,j))*pipe_tune1(j)*MIN(dia(i),maxdia(j))**pipe_tune_exp_coeff(j)
630
631                   ENDIF
632                ENDDO ! Loop over # pixels - domain size
633             ELSE ! for grasses, cnd=1, so the above calculation cancels
634                vn(:) = ind(:,j) + d_ind(:,j)
635             ENDIF
636
637          !! 4.3.2 without DGVM (static)\n
638          ELSE
639             DO i=1,npts ! Loop over # pixels - domain size
640                IF(is_tree(j).AND.(d_ind(i,j)+ind(i,j)).GT.min_stomate) THEN
641                   IF(total_bm(i,icarbon).LE.min_stomate) THEN
642
643                      ! new wood mass of PFT
644                      woodmass_ind(i,j) = &
645                           & (((biomass(i,j,isapabove,icarbon) + biomass(i,j,isapbelow,icarbon) &
646                           & + biomass(i,j,iheartabove,icarbon) + biomass(i,j,iheartbelow,icarbon))) &
647                           & + (bm_sapl(j,isapabove,icarbon) + bm_sapl(j,isapbelow,icarbon) &
648                           & + bm_sapl(j,iheartabove,icarbon) + bm_sapl(j,iheartbelow,icarbon))*d_ind(i,j))/(ind(i,j)+d_ind(i,j))
649
650                   ELSE
651 
652                      ! new biomass is added to the labile pool, hence there is no change
653                      ! in CA associated with establishment
654                      woodmass_ind(i,j) = &
655                           & (biomass(i,j,isapabove,icarbon) + biomass(i,j,isapbelow,icarbon) &
656                           & + biomass(i,j,iheartabove,icarbon) + biomass(i,j,iheartbelow,icarbon)) &
657                           & /(ind(i,j) + d_ind(i,j))
658
659                   ENDIF
660                ENDIF
661             ENDDO ! Loop over # pixels - domain size
662
663             vn(:) = un ! cannot change in static!, and veget_max implicit in d_ind
664
665          ENDIF
666
667          !! 4.4 total biomass of PFT added by establishment defined over veget_max ...
668
669          total_bm_sapl(:,:) = zero
670          total_bm_sapl_non(:,:) = zero
671          biomass_old(:,j,:,:)=biomass(:,j,:,:)
672          DO k = 1, nparts ! Loop over # litter tissues (nparts=8); see 'stomate_constants.f90'
673             WHERE(d_ind(:,j).GT.min_stomate.AND.total_bm(:,icarbon).GT.min_stomate.AND.vn(:).GT.min_stomate)
674
675                total_bm_sapl(:,icarbon) = total_bm_sapl(:,icarbon) + bm_sapl(j,k,icarbon) * d_ind(:,j) / vn(:)
676                total_bm_sapl(:,initrogen) = total_bm_sapl(:,initrogen) + bm_sapl(j,k,initrogen) * d_ind(:,j)  / vn(:) 
677
678                ! non-effective establishment
679                total_bm_sapl_non(:,icarbon) = total_bm_sapl_non(:,icarbon) + &
680                     bm_sapl(j,k,icarbon) * (ind(:,j)+d_ind(:,j))*mortality(:,j) / vn(:)
681
682                total_bm_sapl_non(:,initrogen) = total_bm_sapl_non(:,initrogen) + &
683                     bm_sapl(j,k,initrogen) * (ind(:,j)+d_ind(:,j))*mortality(:,j) / vn(:)
684               
685
686             ENDWHERE
687          ENDDO ! Loop over # litter tissues
688
689
690          total_bm_sapl(:,initrogen)=MIN(total_bm_sapl(:,initrogen),soil_n_constraint(:)) 
691          ntake(:)=zero 
692!Dan Zhu modification: there is a problem here, if DGVM is activated, co2_to_bm will never reach
693!0 due to establishment, where d_ind is still large at equilibrium (=ind*mortality). So we
694!need to subtract it from litter (not biomass, because the
695!corresponding biomass has been lost in lpj_gap).
696
697          !! 4.5 Update biomass at each component
698          DO k = 1, nparts ! Loop over # litter tissues
699
700             bm_new(:,:) = zero
701             bm_non(:,:) = zero
702             bm_eff(:,:) = zero
703
704             ! first ever establishment, C flows
705             WHERE( d_ind(:,j).GT.min_stomate .AND. &
706                  total_bm(:,icarbon).LE.min_stomate .AND. &
707                  vn(:).GT.min_stomate)
708
709                bm_new(:,icarbon) = d_ind(:,j) * bm_sapl(j,k,icarbon) / vn(:)
710                biomass(:,j,k,icarbon) = biomass(:,j,k,icarbon) + bm_new(:,icarbon)
711
712                bm_new(:,initrogen) = d_ind(:,j) * (bm_sapl(j,k,initrogen)) / vn(:)
713                biomass(:,j,k,initrogen) = biomass(:,j,k,initrogen) + bm_new(:,initrogen)
714
715                ! bm_to_litter minus the 'non-effective' establishment (mortality), but cannot be less than 0
716                WHERE((veget_max_tree(:) .GT. 0.1) .AND. (veget_max(:,j) .LT. veget_max_tree(:)/nbtree) )
717
718                   bm_non(:,icarbon) = MIN( biomass(:,j,k,icarbon)+bm_to_litter(:,j,k,icarbon), &
719                        (ind(:,j)+d_ind(:,j))*mortality(:,j) * bm_sapl(j,k,icarbon)/vn(:) )
720                   bm_eff(:,icarbon) = MIN( npp_longterm(:,j)/one_year, bm_new(:,icarbon)-bm_non(:,icarbon) )
721                   bm_non(:,icarbon) = MIN( biomass(:,j,k,icarbon)+bm_to_litter(:,j,k,icarbon), &
722                        bm_new(:,icarbon)-bm_eff(:,icarbon) )
723
724                   bm_non(:,initrogen) = MIN( biomass(:,j,k,initrogen)+bm_to_litter(:,j,k,initrogen), &
725                        (ind(:,j)+d_ind(:,j))*mortality(:,j) * bm_sapl(j,k,initrogen)/vn(:) )
726                   bm_eff(:,initrogen) = bm_new(:,initrogen)-bm_non(:,initrogen) 
727                   bm_non(:,initrogen) = MIN( biomass(:,j,k,initrogen)+bm_to_litter(:,j,k,initrogen), &
728                        bm_new(:,initrogen)-bm_eff(:,initrogen) )
729                   ! I think there was an error
730                   ! co2_to_bm(:,j)=co2_to_bm(:,j) + bm_new(:) - bm_non(:)
731                   co2_to_bm(:,j)=co2_to_bm(:,j) + bm_new(:,icarbon)/dt - bm_non(:,icarbon)/dt
732                   ntake(:) = ntake(:) + bm_new(:,initrogen) - bm_non(:,initrogen)
733
734                   WHERE( bm_to_litter(:,j,k,icarbon) .LT. bm_non(:,icarbon) )
735                      biomass(:,j,k,icarbon) = biomass(:,j,k,icarbon) - &
736                           ( bm_non(:,icarbon) - bm_to_litter(:,j,k,icarbon) )
737                   ENDWHERE
738                   bm_to_litter(:,j,k,icarbon) = bm_to_litter(:,j,k,icarbon) - &
739                        MIN(bm_to_litter(:,j,k,icarbon), bm_non(:,icarbon) )
740
741                   WHERE( bm_to_litter(:,j,k,initrogen) .LT. bm_non(:,initrogen) )
742                      biomass(:,j,k,initrogen) = biomass(:,j,k,initrogen) - &
743                           ( bm_non(:,initrogen) - bm_to_litter(:,j,k,initrogen) )
744                   ENDWHERE
745                   bm_to_litter(:,j,k,initrogen) = bm_to_litter(:,j,k,initrogen) - &
746                        MIN(bm_to_litter(:,j,k,initrogen), bm_non(:,initrogen) )
747
748                ELSEWHERE
749
750                   bm_non(:,icarbon) = MIN( bm_to_litter(:,j,k,icarbon), &
751                        (ind(:,j)+d_ind(:,j))*mortality(:,j) * bm_sapl(j,k,icarbon)/vn(:) )
752                   co2_to_bm(:,j)=co2_to_bm(:,j) + bm_new(:,icarbon)/dt - bm_non(:,icarbon)/dt
753                   bm_to_litter(:,j,k,icarbon)=bm_to_litter(:,j,k,icarbon)- bm_non(:,icarbon)
754
755                   bm_non(:,initrogen) = MIN( bm_to_litter(:,j,k,initrogen), &
756                        (ind(:,j)+d_ind(:,j))*mortality(:,j) * bm_sapl(j,k,initrogen)/vn(:) )
757                   ntake(:)= ntake(:) + bm_new(:,initrogen) - bm_non(:,initrogen)
758                   bm_to_litter(:,j,k,initrogen)=bm_to_litter(:,j,k,initrogen)- bm_non(:,initrogen)
759                ENDWHERE
760
761             ENDWHERE
762
763             ! establishment into existing population, C flows
764             WHERE(d_ind(:,j).GT.min_stomate.AND.total_bm(:,icarbon).GT.min_stomate)
765
766                bm_new(:,icarbon) = total_bm_sapl(:,icarbon) * biomass_old(:,j,k,icarbon) / total_bm(:,icarbon)
767                biomass(:,j,k,icarbon) = biomass(:,j,k,icarbon) + bm_new(:,icarbon)
768
769                bm_new(:,initrogen) = total_bm_sapl(:,initrogen) * biomass_old(:,j,k,initrogen) / total_bm(:,initrogen)
770                biomass(:,j,k,initrogen) = biomass(:,j,k,initrogen) + bm_new(:,initrogen)
771
772                WHERE((veget_max_tree(:) .GT. 0.1) .AND. (veget_max(:,j) .LT. veget_max_tree(:)/nbtree) )
773
774                   bm_non(:,icarbon) = MIN( biomass(:,j,k,icarbon)+bm_to_litter(:,j,k,icarbon), &
775                        total_bm_sapl_non(:,icarbon) *biomass_old(:,j,k,icarbon)/total_bm(:,icarbon) )
776                   bm_eff(:,icarbon) = MIN( npp_longterm(:,j)/one_year, bm_new(:,icarbon)-bm_non(:,icarbon) )
777                   bm_non(:,icarbon) = MAX( zero, MIN( biomass(:,j,k,icarbon)+bm_to_litter(:,j,k,icarbon)-min_stomate, &
778                        bm_new(:,icarbon)-bm_eff(:,icarbon) ) )
779
780                   bm_non(:,initrogen) = MIN( biomass(:,j,k,initrogen)+bm_to_litter(:,j,k,initrogen), &
781                        total_bm_sapl_non(:,initrogen) *biomass_old(:,j,k,initrogen)/total_bm(:,initrogen) )
782                   bm_eff(:,initrogen) = bm_new(:,initrogen)-bm_non(:,initrogen)
783                   bm_non(:,initrogen) = MAX( zero, MIN( biomass(:,j,k,initrogen)+bm_to_litter(:,j,k,initrogen)-min_stomate, &
784                        bm_new(:,initrogen)-bm_eff(:,initrogen) ) )
785
786                   co2_to_bm(:,j)=co2_to_bm(:,j) + bm_new(:,icarbon) - bm_non(:,icarbon)
787                   ntake(:) = ntake(:) + bm_new(:,initrogen) - bm_non(:,initrogen)
788
789                   WHERE( bm_to_litter(:,j,k,icarbon) .LT. bm_non(:,icarbon) )
790                      biomass(:,j,k,icarbon) = biomass(:,j,k,icarbon) - ( bm_non(:,icarbon) - bm_to_litter(:,j,k,icarbon) )
791                   ENDWHERE
792                   bm_to_litter(:,j,k,icarbon) = bm_to_litter(:,j,k,icarbon) - MIN(bm_to_litter(:,j,k,icarbon), bm_non(:,icarbon) )
793
794                   WHERE( bm_to_litter(:,j,k,initrogen) .LT. bm_non(:,initrogen) )
795                      biomass(:,j,k,initrogen) = biomass(:,j,k,initrogen) - ( bm_non(:,initrogen) - bm_to_litter(:,j,k,initrogen) )
796                   ENDWHERE
797                   bm_to_litter(:,j,k,initrogen) = bm_to_litter(:,j,k,initrogen) - &
798                        MIN(bm_to_litter(:,j,k,initrogen), bm_non(:,initrogen) )
799
800                ELSEWHERE
801
802                   bm_non(:,icarbon) = MIN( bm_to_litter(:,j,k,icarbon), &
803                        total_bm_sapl_non(:,icarbon) *biomass_old(:,j,k,icarbon)/total_bm(:,icarbon) )
804                   co2_to_bm(:,j) = co2_to_bm(:,j) + bm_new(:,icarbon)/dt - bm_non(:,icarbon)/dt
805                   bm_to_litter(:,j,k,icarbon)=bm_to_litter(:,j,k,icarbon)- bm_non(:,icarbon)
806
807                   bm_non(:,initrogen) = MIN( bm_to_litter(:,j,k,initrogen), &
808                        total_bm_sapl_non(:,initrogen) *biomass_old(:,j,k,initrogen)/total_bm(:,initrogen) )
809                   ntake(:) = ntake(:) + bm_new(:,initrogen) - bm_non(:,initrogen)
810                   bm_to_litter(:,j,k,initrogen)=bm_to_litter(:,j,k,initrogen)- bm_non(:,initrogen)
811                ENDWHERE
812
813             ENDWHERE
814
815          ENDDO ! Loop over # litter tissues
816
817          ntake_nitrate(:)=MIN(ntake(:),MAX(soil_n_min(:,j,iammonium)-min_stomate,0.0)) 
818          soil_n_min(:,j,iammonium)=soil_n_min(:,j,iammonium)-ntake_nitrate(:) 
819          n_uptake(:,j,iammonium)=n_uptake(:,j,iammonium) + ntake_nitrate(:)/dt 
820 
821          ntake(:)=MIN(ntake(:)-ntake_nitrate(:),MAX(soil_n_min(:,j,initrate)-min_stomate,0.0)) 
822          soil_n_min(:,j,initrate)=soil_n_min(:,j,initrate)-ntake(:) 
823          n_uptake(:,j,initrate)=n_uptake(:,j,initrate) + ntake(:)/dt 
824
825          IF (ANY( bm_to_litter(:,j,:,icarbon) .LT. 0.0 ) .OR. ANY( biomass(:,j,:,icarbon) .LT. 0.0 ) ) THEN
826             CALL ipslerr_p(3,'establish','something wrong in establish/gap.','','')
827          ENDIF 
828
829          !! 4.6 Decrease leaf age in youngest class if new leaf biomass is higher than old one.
830          WHERE ( d_ind(:,j) * bm_sapl(j,ileaf,icarbon) .GT. min_stomate )
831 
832             ! reset leaf ages. Should do a real calculation like in the npp routine,
833             ! but this case is rare and not worth messing around.
834             ! S. Zaehle 080806, added real calculation now, because otherwise leaf_age/leaf_frac
835             ! are not initialised for the calculation of vmax, and hence no growth at all.
836             ! logic follows that of stomate_npp.f90, just that it's been adjusted for the code here
837             leaf_age(:,j,1) = leaf_age(:,j,1) * leaf_mass_young(:) / &
838                  ( leaf_mass_young(:) + d_ind(:,j) * bm_sapl(j,ileaf,icarbon) )
839
840          ENDWHERE
841
842          leaf_mass_young(:) = leaf_mass_young(:) + d_ind(:,j) * bm_sapl(j,ileaf,icarbon)   
843
844          !! 4.7 Youngest class: new mass in youngest class divided by total new mass
845          WHERE ( biomass(:,j,ileaf,icarbon) .GT. min_stomate )
846             ! new age class fractions (fraction in youngest class increases)
847             leaf_frac(:,j,1) = leaf_mass_young(:) / biomass(:,j,ileaf,icarbon)
848
849          ENDWHERE
850
851          !! 4.8 Other classes: old mass in leaf age class divided by new mass
852          DO m = 2, nleafages
853
854             WHERE ( biomass(:,j,ileaf,icarbon) .GT. min_stomate )
855
856                leaf_frac(:,j,m) = leaf_frac(:,j,m) * & 
857                     ( biomass(:,j,ileaf,icarbon) + d_ind(:,j) * bm_sapl(j,ileaf,icarbon) ) /  biomass(:,j,ileaf,icarbon)
858
859             ENDWHERE
860
861          ENDDO
862
863          !! 4.9 Update age and number of individuals
864          WHERE ( d_ind(:,j) .GT. min_stomate )
865
866             age(:,j) = age(:,j) * ind(:,j) / ( ind(:,j) + d_ind(:,j) )
867
868             ind(:,j) = ind(:,j) + d_ind(:,j)
869
870          ENDWHERE
871
872          !! 4.10 Convert excess sapwood to heartwood
873          !!      No longer done : supressed by S. Zaehle given that the LPJ logic of carbon allocation was
874          !!      contradictory to SLAVE allocation. See CVS tag 1_5 for initial formulation.
875
876
877       ENDIF ! natural
878
879    ENDDO ! Loop over # PFTs
880
881  !! 5. history
882
883    d_ind = d_ind / dt
884
885    CALL xios_orchidee_send_field("IND_ESTAB",d_ind)
886    CALL xios_orchidee_send_field("ESTABTREE",estab_rate_max_tree)
887    CALL xios_orchidee_send_field("ESTABGRASS",estab_rate_max_grass)
888
889    CALL histwrite_p (hist_id_stomate, 'IND_ESTAB', itime, d_ind, npts*nvm, horipft_index)
890    CALL histwrite_p (hist_id_stomate, 'ESTABTREE', itime, estab_rate_max_tree, npts, hori_index)
891    CALL histwrite_p (hist_id_stomate, 'ESTABGRASS', itime, estab_rate_max_grass, npts, hori_index)
892
893    IF (printlev>=4) WRITE(numout,*) 'Leaving establish'
894
895  END SUBROUTINE establish
896
897END MODULE lpj_establish
Note: See TracBrowser for help on using the repository browser.