source: tags/ORCHIDEE/src_stomate/lpj_kill.f90 @ 6

Last change on this file since 6 was 6, checked in by orchidee, 14 years ago

import first tag equivalent to CVS orchidee_1_9_5 + OOL_1_9_5

File size: 6.0 KB
Line 
1! kills pfts that obviously fare badly
2!
3! $Header: /home/ssipsl/CVSREP/ORCHIDEE/src_stomate/lpj_kill.f90,v 1.8 2009/01/06 15:01:25 ssipsl Exp $
4! IPSL (2006)
5!  This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
6!
7MODULE lpj_kill
8
9  ! modules used:
10
11  USE ioipsl
12  USE stomate_constants
13  USE constantes_veg
14
15  IMPLICIT NONE
16
17  ! private & public routines
18
19  PRIVATE
20  PUBLIC kill
21
22CONTAINS
23
24  SUBROUTINE kill (npts, whichroutine, lm_lastyearmax, &
25       ind, PFTpresent, cn_ind, biomass, senescence, RIP_time, &
26       lai, age, leaf_age, leaf_frac, &
27       when_growthinit, everywhere, veget, veget_max, bm_to_litter)
28
29    !
30    ! 0 declarations
31    !
32
33    ! 0.1 input
34
35    ! Domain size
36    INTEGER(i_std), INTENT(in)                                       :: npts
37    ! message
38    CHARACTER*10, INTENT(in)                                  :: whichroutine
39    ! last year's maximum leaf mass, for each PFT (gC/(m**2 of ground))
40    REAL(r_std), DIMENSION(npts,nvm), INTENT(in)              :: lm_lastyearmax
41
42    ! 0.2 modified fields
43
44    ! Number of individuals / m**2
45    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: ind
46    ! Is pft there
47    LOGICAL, DIMENSION(npts,nvm), INTENT(inout)              :: PFTpresent
48    ! crown area of individuals (m**2)
49    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: cn_ind
50    ! biomass (gC/(m**2 of ground))
51    REAL(r_std), DIMENSION(npts,nvm,nparts), INTENT(inout)    :: biomass
52    ! is the plant senescent? (only for deciduous trees - carbohydrate reserve)
53    LOGICAL, DIMENSION(npts,nvm), INTENT(inout)              :: senescence
54    ! How much time ago was the PFT eliminated for the last time (y)
55    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: RIP_time
56    ! leaf area index OF AN INDIVIDUAL PLANT
57    REAL(r_std), DIMENSION(npts,nvm), INTENT(in)           :: lai
58    ! mean age (years)
59    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: age
60    ! leaf age (days)
61    REAL(r_std), DIMENSION(npts,nvm,nleafages), INTENT(inout) :: leaf_age
62    ! fraction of leaves in leaf age class
63    REAL(r_std), DIMENSION(npts,nvm,nleafages), INTENT(inout) :: leaf_frac
64    ! how many days ago was the beginning of the growing season
65    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: when_growthinit
66    ! is the PFT everywhere in the grid box or very localized (after its introduction)
67    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: everywhere
68    ! fractional coverage on ground, taking into
69    !   account LAI (=grid-scale fpc)
70    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: veget
71    ! "maximal" coverage fraction of a PFT (LAI -> infinity) on ground
72    REAL(r_std), DIMENSION(npts,nvm), INTENT(inout)           :: veget_max
73    ! conversion of biomass to litter (gC/(m**2 of ground)) / day
74    REAL(r_std), DIMENSION(npts,nvm,nparts), INTENT(inout)    :: bm_to_litter
75
76    ! 0.3 local
77
78    ! indices
79    INTEGER(i_std)                                             :: j,m
80    ! bookkeeping
81    LOGICAL, DIMENSION(npts)                                  :: was_killed
82
83    ! =========================================================================
84
85    IF (bavard.GE.3) WRITE(numout,*) 'Entering kill'
86
87    DO j = 2,nvm
88
89       was_killed(:) = .FALSE.
90
91       ! only kill natural PFTs
92
93       IF ( natural(j) ) THEN
94
95          ! kill present plants if number of individuals or last year's leaf
96          ! mass is close to zero.
97          ! the "was_killed" business is necessary for a more efficient code on the VPP
98
99          WHERE ( PFTpresent(:,j) .AND. &
100               ( ( ind(:,j) .LT. min_stomate ) .OR. &
101               ( lm_lastyearmax(:,j) .LT. min_stomate ) ) )
102
103             was_killed(:) = .TRUE.
104
105          ENDWHERE
106
107          IF ( ANY( was_killed(:) ) ) THEN
108
109             WHERE ( was_killed(:) )
110
111                ind(:,j) = 0.0
112
113                bm_to_litter(:,j,ileaf) = bm_to_litter(:,j,ileaf) + biomass(:,j,ileaf)
114                bm_to_litter(:,j,isapabove) = bm_to_litter(:,j,isapabove) + biomass(:,j,isapabove)
115                bm_to_litter(:,j,isapbelow) = bm_to_litter(:,j,isapbelow) + biomass(:,j,isapbelow)
116                bm_to_litter(:,j,iheartabove) = bm_to_litter(:,j,iheartabove) + &
117                     biomass(:,j,iheartabove)
118                bm_to_litter(:,j,iheartbelow) = bm_to_litter(:,j,iheartbelow) + &
119                     biomass(:,j,iheartbelow)
120                bm_to_litter(:,j,iroot) = bm_to_litter(:,j,iroot) + biomass(:,j,iroot)
121                bm_to_litter(:,j,ifruit) = bm_to_litter(:,j,ifruit) + biomass(:,j,ifruit)
122                bm_to_litter(:,j,icarbres) = bm_to_litter(:,j,icarbres) + biomass(:,j,icarbres)
123
124                biomass(:,j,ileaf) = 0.0
125                biomass(:,j,isapabove) = 0.0
126                biomass(:,j,isapbelow) = 0.0
127                biomass(:,j,iheartabove) = 0.0
128                biomass(:,j,iheartbelow) = 0.0
129                biomass(:,j,iroot) = 0.0
130                biomass(:,j,ifruit) = 0.0
131                biomass(:,j,icarbres) = 0.0
132
133                PFTpresent(:,j) = .FALSE.
134
135                cn_ind(:,j) = 0.0
136
137                senescence(:,j) = .FALSE.
138
139
140                age(:,j) = 0.0
141
142                when_growthinit(:,j) = undef
143
144                everywhere(:,j) = 0.0
145
146                veget(:,j) = 0.0
147
148                veget_max(:,j) = 0.0
149
150                RIP_time(:,j) = 0.0
151
152             ENDWHERE   ! number of individuals very low
153
154             DO m = 1, nleafages
155
156                WHERE ( was_killed(:) )
157
158                   leaf_age(:,j,m) = 0.0 
159                   leaf_frac(:,j,m) = 0.0 
160
161                ENDWHERE
162
163             ENDDO
164
165             IF ( bavard .GE. 2 ) THEN
166
167                WRITE(numout,*) 'kill: eliminated ',PFT_name(j)
168                WRITE(numout,*) '  at ',COUNT( was_killed(:) ),' points after '//whichroutine
169
170             ENDIF
171
172          ENDIF     ! PFT must be killed at at least one place
173
174       ENDIF       ! PFT is natural
175
176    ENDDO         ! loop over PFTs
177
178    IF (bavard.GE.4) WRITE(numout,*) 'Leaving kill'
179
180  END SUBROUTINE kill
181
182END MODULE lpj_kill
Note: See TracBrowser for help on using the repository browser.