source: tags/ORCHIDEE_2_0/ORCHIDEE/src_stomate/stomate_npp.f90 @ 5110

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

Modification on co2_to_bm and respiration maintanence. See ticket #419

  • Property svn:keywords set to HeadURL Date Author Revision
File size: 27.9 KB
Line 
1! =================================================================================================================================
2! MODULE          : stomate_npp
3!
4! CONTACT         : orchidee-help _at_ listes.ipsl.fr
5!
6! LICENCE         : IPSL (2006)
7!                 This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
8!
9!>\BRIEF          This modules calculates NPP: Maintenance and growth respiration
10!!
11!!\n DESCRIPTION: We calculate first the maintenance respiration. This is substracted from the
12!!                allocatable biomass (and from the present biomass if the GPP is too low).\n
13!!                Of the rest, a part is lost as growth respiration, while the other part is
14!!                effectively allocated.
15!!
16!! RECENT CHANGE(S): None
17!!
18!! REFERENCE(S) :
19!!
20!! SVN          :
21!! $HeadURL$
22!! $Date$
23!! $Revision$
24!! \n
25!_ ================================================================================================================================
26
27MODULE stomate_npp
28
29  ! modules used:
30  USE xios_orchidee
31  USE ioipsl_para
32  USE stomate_data
33  USE constantes
34  USE constantes_soil
35  USE pft_parameters
36
37  IMPLICIT NONE
38
39  ! private & public routines
40
41  PRIVATE
42  PUBLIC npp_calc,npp_calc_clear
43
44  LOGICAL, SAVE                                              :: firstcall_npp = .TRUE.         !! first call
45!$OMP THREADPRIVATE(firstcall_npp)
46
47CONTAINS
48
49!! ================================================================================================================================
50!! SUBROUTINE   : npp_calc_clear
51!!
52!>\BRIEF        : Set the flag ::firstcall_npp to .TRUE. and as such activate section
53!! 1.1 of the subroutine npp_calc (see below).\n
54!_ ================================================================================================================================
55
56  SUBROUTINE npp_calc_clear
57    firstcall_npp=.TRUE.
58  END SUBROUTINE npp_calc_clear
59
60
61
62
63
64!! ================================================================================================================================
65!! SUBROUTINE   : npp_calc
66!!
67!>\BRIEF        Calculate NPP as the difference between GPP and respiration (= growth + maintenance respiration).
68!!              Update biomass of all compartments after calculating respiration and allocation.
69!!
70!!
71!! DESCRIPTION  : NPP is calculated from three components: Gross Primary Productivity (GPP), maintenance respiration
72!! and growth respiration (all in @tex $ gC.m^{-2}dt^{-1} $ @endtex), following the convention that positive fluxes denote
73!! fluxes plants to the atmosphere. GPP is the input variable from which, in the end, NPP or total allocatable biomass
74!! @tex $(gC.m^{-2}dt^{-1}))$ @endtex is calculated. Net primary production is then calculated as:\n   
75!! NPP = GPP - growth_resp - maint-resp   [eq. 1]\n   
76!!     
77!! The calculation of maintenance respiration is done in routine stomate_resp.f90. Maintenance respiration is calculated for
78!! the whole plant and is therefore removed from the total allocatable biomass. In order to prevent all allocatable biomass
79!! from being used for maintenance respiration, a limit fraction of total allocatable biomass, tax_max, is defined (in
80!! variables declaration). If maintenance respiration exceeds tax_max (::bm_tax_max), the maximum allowed allocatable biomass
81!! will be respired and the remaining respiration, required in excess of tax_max, is taken out from tissues already present in
82!! the plant (biomass).\n 
83!!
84!! After total allocatable biomass has been updated by removing maintenance respiration, total allocatable biomass is distributed
85!! to all plant compartments according to the f_alloc fractions calculated in stomate_alloc.f90.\n
86!!
87!! Growth respiration is calculated as a fraction of allocatable biomass for each part of the plant. The fraction coefficient
88!! ::frac_growth_resp is defined in stomate_constants.f90 and is currently set to be the same for all plant compartments.
89!! Allocatable biomass of all plant compartments are updated by removing what is lost through growth respiration. Net allocatable
90!! biomass (total allocatable biomass after maintenance and growth respiration) is added to the current biomass for  each plant
91!! compartment.
92!!
93!! Finally, leaf age and plant age are updated. Leaf age is described with the concept of "leaf age classes". A number of leaf
94!! age classes (nleafages) is defined in stomate_constants.f90. Each leaf age class contains a fraction (::leaf_frac) of the
95!! total leaf biomass. When new biomass is added to leaves, the age of the biomass in the youngest leaf age class is decreased.
96!! The fractions of leaves in the other leaf ages classes are also updated as the total biomass has increased. Plant age is
97!! updated first by increasing the age of the previous biomass by one time step, and then by adjusting this age as the average
98!! of the ages of the previous and the new biomass.
99!!
100!! RECENT CHANGE(S): None
101!!
102!! MAIN OUTPUT VARIABLE(S): ::npp
103!!
104!! REFERENCE(S) :
105!! - F.W.T.Penning De Vries, A.H.M. Brunsting, H.H. Van Laar. 1974. Products, requirements and efficiency of biosynthesis a
106!! quantitative approach. Journal of Theoretical Biology, Volume 45, Issue 2, June 1974, Pages 339-377.
107!!
108!! FLOWCHART :
109!! \latexonly
110!! \includegraphics[scale=0.14]{stomate_npp_flow.jpg}
111!! \endlatexonly
112!! \n
113!_ ================================================================================================================================
114
115  SUBROUTINE npp_calc (npts, dt, &
116       PFTpresent, &
117       t2m, tsoil, lai, rprof, &
118       gpp, f_alloc, bm_alloc, resp_maint_part,&
119       biomass, leaf_age, leaf_frac, age, &
120       resp_maint, resp_growth, npp, co2_to_bm)
121   
122!! 0 Variable and parameter declaration
123
124    !! 0.1 Input variables
125
126    INTEGER(i_std), INTENT(in)                                :: npts             !! Domain size - number of pixels (unitless)
127    REAL(r_std), INTENT(in)                                   :: dt               !! Time step (days)
128    LOGICAL, DIMENSION(npts,nvm), INTENT(in)                  :: PFTpresent       !! PFT exists (true/false)
129    REAL(r_std), DIMENSION(npts), INTENT(in)                  :: t2m              !! Temperature at 2 meter (K)
130    REAL(r_std), DIMENSION(npts,nslm), INTENT(in)             :: tsoil            !! Soil temperature of each soil layer (K)
131    REAL(r_std), DIMENSION(npts,nvm), INTENT(in)              :: lai              !! PFT leaf area index (unitless)
132    REAL(r_std), DIMENSION(npts,nvm), INTENT(in)              :: rprof            !! PFT root depth as calculated in stomate.f90
133                                                                                  !! from root profile parameter humcste (m)
134    REAL(r_std), DIMENSION(npts,nvm), INTENT(in)              :: gpp              !! PFT gross primary productivity
135                                                                                  !! @tex $(gC.m^{-2}dt^{-1})$ @endtex
136    REAL(r_std), DIMENSION(npts,nvm,nparts), INTENT(in)       :: f_alloc          !! Fraction of total allocatable biomass that
137                                                                                  !! goes into each plant part (unitless)
138    REAL(r_std), DIMENSION(npts,nvm,nparts), INTENT(in)       :: resp_maint_part  !! Maintenance respiration of different plant
139                                                                                  !! parts @tex $(gC.m^{-2}dt^{-1})$ @endtex
140    !! 0.2 Output variables
141
142    REAL(r_std), DIMENSION(npts,nvm), INTENT(out)             :: resp_maint       !! PFT maintenance respiration
143                                                                                  !! @tex $(gC.m^{-2}dt^{-1})$ @endtex             
144    REAL(r_std), DIMENSION(npts,nvm), INTENT(out)             :: resp_growth      !! PFT growth respiration
145                                                                                  !! @tex $(gC.m^{-2}dt^{-1})$ @endtex                         
146    REAL(r_std), DIMENSION(npts,nvm), INTENT(out)             :: npp              !! PFT net primary productivity
147                                                                                  !! @tex $(gC.m^{-2}dt^{-1})$ @endtex         
148    REAL(r_std), DIMENSION(npts,nvm,nparts,nelements), INTENT(out) :: bm_alloc    !! PFT biomass increase, i.e. NPP per plant part
149                                                                                  !! @tex $(gC.m^{-2}dt^{-1})$ @endtex         
150
151    !! 0.3 Modified variables
152
153    REAL(r_std), DIMENSION(npts,nvm,nparts,nelements), INTENT(inout) :: biomass   !! PFT total biomass of each plant part
154                                                                                  !! @tex $(gC.m^{-2})$ @endtex
155    REAL(r_std), DIMENSION(npts,nvm,nleafages), INTENT(inout) :: leaf_age         !! PFT age of different leaf age classes (days)
156    REAL(r_std), DIMENSION(npts,nvm,nleafages), INTENT(inout) :: leaf_frac        !! PFT fraction of total leaves in leaf age
157                                                                                  !! class (unitless)
158    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: age              !! PFT age (years)
159    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: co2_to_bm        !! virtual gpp @tex $(gC.m^{-2})$ @endtex
160
161    !! 0.4 Local variables
162
163    REAL(r_std), DIMENSION(npts,nvm)                          :: t_root           !! Root temperature (convolution of root and
164                                                                                  !! soil temperature profiles)(K)
165    REAL(r_std), DIMENSION(npts,nvm,nparts)                   :: coeff_maint      !! PFT maintenance respiration coefficients of
166                                                                                  !! different plant compartments at 0 deg C
167                                                                                  !! @tex $(g.g^{-1}dt^{-1})$ @endtex
168    REAL(r_std), DIMENSION(npts,nparts)                       :: t_maint          !! Temperature which is pertinent for maintenance
169                                                                                  !! respiration, which is air/root temperature for
170                                                                                  !! above/below-ground compartments (K)
171    REAL(r_std), DIMENSION(npts)                              :: rpc              !! Scaling factor for integrating vertical soil
172                                                                                  !! profiles (unitless)
173    REAL(r_std), DIMENSION(npts)                              :: tl               !! Long term annual mean temperature (C)
174    REAL(r_std), DIMENSION(npts)                              :: slope            !! Slope of maintenance respiration coefficient
175                                                                                  !! (1/K)
176    REAL(r_std), DIMENSION(npts,nparts)                       :: resp_growth_part !! Growth respiration of different plant parts
177                                                                                  !! @tex $(gC.m^{-2}dt^{-1})$ @endtex         
178    REAL(r_std), DIMENSION(npts,nvm)                          :: bm_alloc_tot     !! Allocatable biomass for the whole plant
179                                                                                  !! @tex $(gC.m^{-2})$ @endtex
180    REAL(r_std), DIMENSION(npts)                              :: bm_add           !! Biomass increase @tex $(gC.m^{-2})$ @endtex               
181    REAL(r_std), DIMENSION(npts)                              :: bm_new           !! New biomass @tex $(gC.m^{-2})$ @endtex     
182    REAL(r_std), DIMENSION(npts,nvm)                          :: leaf_mass_young  !! Leaf mass in youngest age class
183                                                                                  !! @tex $(gC.m^{-2})$ @endtex         
184    REAL(r_std), DIMENSION(npts,nvm)                          :: lm_old           !! Leaf mass after maintenance respiration
185                                                                                  !! @tex $(gC.m^{-2})$ @endtex                 
186    REAL(r_std), DIMENSION(npts,nvm)                          :: bm_create        !! Biomass created when biomass<0 because of dark
187                                                                                  !! respiration @tex $(gC.m^{-2})$ @endtex
188    REAL(r_std), DIMENSION(npts)                              :: bm_tax_max       !! Maximum part of allocatable biomass used for
189                                                                                  !! respiration @tex $(gC.m^{-2})$ @endtex     
190    REAL(r_std), DIMENSION(npts)                              :: bm_pump          !! Biomass that remains to be taken away
191                                                                                  !! @tex $(gC.m^{-2})$ @endtex
192    INTEGER(i_std)                                            :: i,j,k,l,m        !! Indeces(unitless)
193    INTEGER(i_std)                                            :: ier              !! Error handling
194
195!_ ================================================================================================================================
196
197    IF (printlev>=3) WRITE(numout,*) 'Entering npp'
198   
199 !! 1. Initializations
200   
201    !! 1.1 First call
202    IF ( firstcall_npp ) THEN
203
204       !! 1.1.2 Output message
205       !  Write message including value used for tax_max       
206       IF (printlev >= 2) THEN
207          WRITE(numout,*) 'npp:'
208
209          WRITE(numout,*) '   > max. fraction of allocatable biomass used for'// &
210               ' maint. resp.:', tax_max
211       END IF
212       firstcall_npp = .FALSE.
213
214    ENDIF ! End if first call
215
216    !! 1.2 Set output variables to zero
217    bm_alloc(:,:,:,:) = zero
218    resp_maint(:,:) = zero
219    resp_growth(:,:) = zero
220    npp(:,:) = zero
221
222    !! 1.3 Total allocatable biomass
223    ! total allocatable biomass during this time step determined from GPP.
224    ! GPP was calculated as CO2 assimilation in enerbil.f90
225    bm_alloc_tot(:,:) = gpp(:,:) * dt
226
227   
228 
229    !! 3. Calculate maintenance and growth respiration
230    ! First, total maintenance respiration for the whole plant is calculated by summing maintenance
231    ! respiration of the different plant compartments. Then, maintenance respiration is subtracted
232    ! from whole-plant allocatable biomass (up to a maximum fraction of the total allocatable biomass).
233    ! Growth respiration is then calculated for each plant compartment as a fraction of remaining
234    ! allocatable biomass for this compartment. NPP is calculated by substracting total autotrophic
235    ! respiration from GPP i.e. NPP = GPP - maintenance resp - growth resp.
236    DO j = 2,nvm        ! Loop over # of PFTs
237
238       !! 3.1 Maintenance respiration of the different plant parts
239       !      Maintenance respiration of the different plant parts is calculated in
240       !      stomate_resp.f90 as a function of the plant's temperature,
241       !      the long term temperature and plant coefficients
242       !      VPP killer:
243       resp_maint(:,j) = zero
244
245       !  Following the calculation of hourly maintenance respiration, verify that
246       !  the PFT has not been killed after calcul of resp_maint_part in stomate.
247       DO k= 1, nparts
248          WHERE (PFTpresent(:,j))
249             resp_maint(:,j) = resp_maint(:,j) + resp_maint_part(:,j,k)
250          ENDWHERE
251       ENDDO
252       
253       !! 3.2 Substract maintenance respiration from allocatable biomass
254       !      The total maintenance respiration calculated in 3.2 is substracted  from the newly
255       !      produced allocatable biomass (bm_alloc_tot). However, ensure that not all allocatable
256       !      biomass is removed by setting a maximum to the fraction of allocatable biomass used
257       !      for maintenance respiration: tax_max. If the maintenance respiration is larger than
258       !      tax_max,the amount tax_max is taken from allocatable biomass, and the remaining of
259       !      maintenance respiration is taken from the tissues themselves (biomass). We suppose
260       !      that respiration is not dependent on leaf age -> therefore the leaf age structure is
261       !      not changed.
262       !      The maximum fraction of allocatable biomass used for respiration is defined as tax_max.
263       !      The value of tax_max is set in the declarations section (0.4 Local variables) of this
264       !      routine
265       bm_tax_max(:) = tax_max * bm_alloc_tot(:,j)
266
267       DO i = 1, npts   ! Loop over # of pixels
268
269          ! If there is enough allocatable biomass to cover maintenance respiration,
270          ! then biomass associated with maintenance respiration is removed from allocatable biomass
271          IF ( bm_alloc_tot(i,j) .GT. zero ) THEN
272               IF ( ( resp_maint(i,j) * dt ) .LT. bm_tax_max(i) )  THEN
273       
274                  bm_alloc_tot(i,j) = bm_alloc_tot(i,j) - resp_maint(i,j) * dt
275
276                  ! If there is not enough allocatable biomass to cover maintenance respiration, the 
277                  ! - maximum allowed allocatable biomass (bm_tax_max) is removed from allocatable biomass.
278               ELSE
279             
280                  bm_alloc_tot(i,j) = bm_alloc_tot(i,j) - bm_tax_max(i)
281
282                  ! ::bm_pump is the amount of maintenance respiration that exceeds the maximum allocatable biomass
283                  ! This amount of biomass still needs to be respired and will be removed from tissues biomass of each
284                  ! plant compartment
285                  bm_pump(i) = resp_maint(i,j) * dt - bm_tax_max(i)
286
287                  ! The biomass is removed from each plant compartment tissues as the ratio of the maintenance         
288                  ! respiration of the plant compartment to the total maintenance respiration (resp_maint_part/resp_maint)
289                  biomass(i,j,ileaf,icarbon) = biomass(i,j,ileaf,icarbon) - &
290                       bm_pump(i) * resp_maint_part(i,j,ileaf) / resp_maint(i,j)
291                  biomass(i,j,isapabove,icarbon) = biomass(i,j,isapabove,icarbon) - &
292                       bm_pump(i) * resp_maint_part(i,j,isapabove) / resp_maint(i,j)
293                  biomass(i,j,isapbelow,icarbon) = biomass(i,j,isapbelow,icarbon) - &
294                       bm_pump(i) * resp_maint_part(i,j,isapbelow) / resp_maint(i,j)
295                  biomass(i,j,iroot,icarbon) = biomass(i,j,iroot,icarbon) - &
296                       bm_pump(i) * resp_maint_part(i,j,iroot) / resp_maint(i,j)
297                  biomass(i,j,ifruit,icarbon) = biomass(i,j,ifruit,icarbon) - &
298                       bm_pump(i) * resp_maint_part(i,j,ifruit) / resp_maint(i,j)
299                  biomass(i,j,icarbres,icarbon) = biomass(i,j,icarbres,icarbon) - &
300                       bm_pump(i) * resp_maint_part(i,j,icarbres) / resp_maint(i,j)
301               ENDIF
302          ELSE
303             biomass(i,j,icarbres,icarbon) = biomass(i,j,icarbres,icarbon) + & 
304                  bm_alloc_tot(i,j) - resp_maint(i,j) * dt 
305             bm_alloc_tot(i,j) = 0. 
306          ENDIF ! End if there is enough allocatable biomass to cover maintenance respiration
307
308       ENDDO   ! Fortran95: WHERE - ELSEWHERE construct
309
310       
311       !! 3.3 Allocate allocatable biomass to different plant compartments.
312       !      The amount of allocatable biomass of each compartment is a fraction according f_alloc of total
313       !      allocatable biomass (the f_alloc of the different plant parts are calculated in stomate_alloc.f90)
314       DO k = 1, nparts
315          bm_alloc(:,j,k,icarbon) = f_alloc(:,j,k) * bm_alloc_tot(:,j)
316       ENDDO
317
318       
319       !! 3.4 Calculate growth respiration of each plant compartment.
320       !      Growth respiration of a plant compartment is a fraction of the allocatable biomass remaining after
321       !      maintenance respiration losses have been taken into account. The fraction of allocatable biomass
322       !      removed for growth respiration is the same for all plant compartments and is defined by the parameter
323       !      frac_growth_resp in stomate_constants.f90. Allocatable biomass ::bm_alloc is updated as a result of
324       !      the removal of growth resp.
325       resp_growth_part(:,:) = frac_growthresp(j) * bm_alloc(:,j,:,icarbon) / dt
326       bm_alloc(:,j,:,icarbon) = ( un - frac_growthresp(j) ) * bm_alloc(:,j,:,icarbon)
327
328       
329       !! 3.5 Total growth respiration
330       !      Calculate total growth respiration of the plant as the sum of growth respiration of all plant parts       
331       resp_growth(:,j) = zero
332
333       DO k = 1, nparts
334          resp_growth(:,j) = resp_growth(:,j) + resp_growth_part(:,k)
335       ENDDO
336
337    ENDDO ! # End Loop over # of PFTs
338
339   
340 !! 4. Update the biomass with newly allocated biomass after respiration
341 
342    !  Save the old leaf biomass for later. "old" leaf mass is leaf mass after maintenance respiration in the case
343    !  where maintenance respiration has required taking biomass from tissues in section 3.3
344    lm_old(:,:) = biomass(:,:,ileaf,icarbon)
345    biomass(:,:,:,:) = biomass(:,:,:,:) + bm_alloc(:,:,:,:)
346
347   
348 !! 5. Deal with negative biomasses
349   
350    !  Biomass can become negative in some rare cases, as the GPP can be negative. This corresponds to 
351    !  situations that can be seen as the 'creation' of a seed ('virtual photosynthesis'). In this case, we set
352    !  biomass to a small value (min_stomate). For carbon budget to remain balanced, this creation of matter (carbon)
353    !  is added to co2_to_bm. In previous versions, this carbon was taken from the autotrophic respiration.
354    DO k = 1, nparts    ! Loop over # of plant parts
355
356       DO j = 2,nvm     ! Loop over # of PFTs
357
358          WHERE ( biomass(:,j,k,icarbon) .LT. zero )
359           
360             bm_create(:,j) = min_stomate - biomass(:,j,k,icarbon)
361
362             ! Set biomass to min_stomate
363             biomass(:,j,k,icarbon) = biomass(:,j,k,icarbon) + bm_create(:,j)
364
365             co2_to_bm(:,j) = co2_to_bm(:,j) + bm_create(:,j) 
366
367          ENDWHERE
368
369       ENDDO    ! Loop over # of PFTs
370
371    ENDDO       ! Loop over # plant parts
372
373   
374 !! 6. Calculate NPP (See Eq 1 in header)
375   
376    !  Calculate the NPP @tex $(gC.m^{-2}dt^{-1})$ @endtex as the difference between GPP
377    !  and autotrophic respiration (maintenance and growth respirations)
378    DO j = 2,nvm        ! Loop over # PFTs
379       npp(:,j) = gpp(:,j) - resp_growth(:,j) - resp_maint(:,j)
380    ENDDO       ! Loop over # PFTs
381
382   
383 !! 7. Update leaf age
384
385    !  Leaf age is needed for calculation of turnover and vmax in stomate_turnover.f90 and stomate_vmax.f90 routines.
386    !  Leaf biomass is distributed according to its age into several "age classes" with age class=1 representing the
387    !  youngest class, and consisting of the most newly allocated leaf biomass
388   
389    !! 7.1 Update quantity and age of the leaf biomass in the youngest class
390    !      The new amount of leaf biomass in the youngest age class (leaf_mass_young) is the sum of :
391    !      - the leaf biomass that was already in the youngest age class (leaf_frac(:,j,1) * lm_old(:,j)) with the
392    !        leaf age given in leaf_age(:,j,1)
393    !      - and the new biomass allocated to leaves (bm_alloc(:,j,ileaf)) with a leaf age of zero.
394    DO j = 2,nvm
395       leaf_mass_young(:,j) = leaf_frac(:,j,1) * lm_old(:,j) + bm_alloc(:,j,ileaf,icarbon)
396    ENDDO
397
398    ! The age of the updated youngest age class is the average of the ages of its 2 components: bm_alloc(leaf) of age
399    ! '0', and leaf_frac*lm_old(=leaf_mass_young-bm_alloc) of age 'leaf_age(:,j,1)'
400    DO j = 2,nvm
401       WHERE ( ( bm_alloc(:,j,ileaf,icarbon) .GT. zero ) .AND. &
402         ( leaf_mass_young(:,j) .GT. min_sechiba ) )
403
404          leaf_age(:,j,1) = MAX ( zero, &
405               & leaf_age(:,j,1) * &
406               & ( leaf_mass_young(:,j) - bm_alloc(:,j,ileaf,icarbon) ) / &
407               & leaf_mass_young(:,j) )
408         
409       ENDWHERE
410    ENDDO
411
412    !! 7.2 Update leaf age
413    !      Update fractions of leaf biomass in each age class (fraction in youngest class increases)
414
415    !! 7.2.1 Update age of youngest leaves
416    !        For age class 1 (youngest class), because we have added biomass to the youngest class, we need to update
417    !        the fraction of total leaf biomass that belongs to the youngest age class : updated mass in class divided
418    !        by new total leaf mass
419    DO j = 2,nvm
420       WHERE ( biomass(:,j,ileaf,icarbon) .GT. min_stomate )
421
422          leaf_frac(:,j,1) = leaf_mass_young(:,j) / biomass(:,j,ileaf,icarbon)
423
424       ENDWHERE
425    ENDDO
426
427    !! 7.2.2 Update age of other age classes
428    !        Because the total leaf biomass has changed, we need to update the fraction of leaves in each age class:
429    !        mass in leaf age class (from previous fraction of leaves in this class and previous total leaf biomass)
430    !        divided by new total mass
431    DO m = 2, nleafages ! Loop over # leaf age classes
432
433       DO j = 2,nvm     ! Loop over # PFTs
434          WHERE ( biomass(:,j,ileaf,icarbon) .GT. min_stomate )
435
436             leaf_frac(:,j,m) = leaf_frac(:,j,m) * lm_old(:,j) / biomass(:,j,ileaf,icarbon)
437
438          ENDWHERE
439       ENDDO
440
441    ENDDO       ! Loop over # leaf age classes
442
443 !! 8. Update whole-plant age
444   
445    !! 8.1 PFT age
446    !      At every time step, increase age of the biomass that was already present at previous time step.
447    !      Age is expressed in years, and the time step 'dt' in days so age increase is: dt divided by number
448    !      of days in a year.
449    WHERE ( PFTpresent(:,:) )
450
451       age(:,:) = age(:,:) + dt/one_year
452
453    ELSEWHERE
454
455       age(:,:) = zero
456
457    ENDWHERE
458
459    !! 8.2 Age of grasses and crops
460    !  For grasses and crops, biomass with age 0 has been added to the whole plant with age 'age'. New biomass is the sum of
461    !  the current total biomass in all plant parts (bm_new), bm_new(:) = SUM( biomass(:,j,:), DIM=2 ). The biomass that has
462    !  just been added is the sum of the allocatable biomass of all plant parts (bm_add), its age is zero. bm_add(:) =
463    !  SUM( bm_alloc(:,j,:), DIM=2 ). Before allocation, the plant biomass is bm_new-bm_add, its age is "age(:,j)". The age of
464    !  the new biomass is the average of the ages of previous and added biomass.
465    !  For trees, age is treated in "establish" if vegetation is dynamic, and in turnover routines if it is static (in this
466    !  case, only the age of the heartwood is accounted for).
467    DO j = 2,nvm
468
469       IF ( .NOT. is_tree(j) ) THEN
470
471          bm_new(:) = biomass(:,j,ileaf,icarbon) + biomass(:,j,isapabove,icarbon) + &
472               biomass(:,j,iroot,icarbon) + biomass(:,j,ifruit,icarbon)
473          bm_add(:) = bm_alloc(:,j,ileaf,icarbon) + bm_alloc(:,j,isapabove,icarbon) + &
474               bm_alloc(:,j,iroot,icarbon) + bm_alloc(:,j,ifruit,icarbon)
475
476          WHERE ( ( bm_new(:) .GT. min_sechiba ) .AND. ( bm_add(:) .GT. zero ) )
477             age(:,j) = age(:,j) * ( bm_new(:) - bm_add(:) ) / bm_new(:)
478          ENDWHERE
479
480       ENDIF
481
482    ENDDO
483
484 !! 9. Write history files
485
486    CALL xios_orchidee_send_field("BM_ALLOC_LEAF",bm_alloc(:,:,ileaf,icarbon))
487    CALL xios_orchidee_send_field("BM_ALLOC_SAP_AB",bm_alloc(:,:,isapabove,icarbon))
488    CALL xios_orchidee_send_field("BM_ALLOC_SAP_BE",bm_alloc(:,:,isapbelow,icarbon))
489    CALL xios_orchidee_send_field("BM_ALLOC_ROOT",bm_alloc(:,:,iroot,icarbon))
490    CALL xios_orchidee_send_field("BM_ALLOC_FRUIT",bm_alloc(:,:,ifruit,icarbon))
491    CALL xios_orchidee_send_field("BM_ALLOC_RES",bm_alloc(:,:,icarbres,icarbon))
492
493
494    ! Save in history file the variables describing the biomass allocated to the plant parts
495    CALL histwrite_p (hist_id_stomate, 'BM_ALLOC_LEAF', itime, &
496         bm_alloc(:,:,ileaf,icarbon), npts*nvm, horipft_index)
497    CALL histwrite_p (hist_id_stomate, 'BM_ALLOC_SAP_AB', itime, &
498         bm_alloc(:,:,isapabove,icarbon), npts*nvm, horipft_index)
499    CALL histwrite_p (hist_id_stomate, 'BM_ALLOC_SAP_BE', itime, &
500         bm_alloc(:,:,isapbelow,icarbon), npts*nvm, horipft_index)
501    CALL histwrite_p (hist_id_stomate, 'BM_ALLOC_ROOT', itime, &
502         bm_alloc(:,:,iroot,icarbon), npts*nvm, horipft_index)
503    CALL histwrite_p (hist_id_stomate, 'BM_ALLOC_FRUIT', itime, &
504         bm_alloc(:,:,ifruit,icarbon), npts*nvm, horipft_index)
505    CALL histwrite_p (hist_id_stomate, 'BM_ALLOC_RES', itime, &
506         bm_alloc(:,:,icarbres,icarbon), npts*nvm, horipft_index)
507
508
509    IF (printlev>=4) WRITE(numout,*) 'Leaving npp'
510
511  END SUBROUTINE npp_calc
512
513END MODULE stomate_npp
Note: See TracBrowser for help on using the repository browser.