TreeMig Code
Loading...
Searching...
No Matches
LfCalc.f90
Go to the documentation of this file.
1!==============================================================================
2!
3! Name : Lfcalc
4!
5! Purpose:
6!
7! Remarks: contains the SUBROUTINE
8!
9! Lfcalc (<LocalDynOneTimeStep<LocalDynOneTimeStep<DistrLocalDynThisTime<
10! TimeLoop<TreeMig)
11!
12!
13!==============================================================================
14! design : H. Lischke, N. Zimmermann
15! author(s) : H. Lischke, N. Zimmermann
16! implementation : H. Lischke, N. Zimmermann
17! cleaner : T.J. Loeffler
18! copyright : (c) 1999, 03 by H. Lischke
19!==============================================================================
20!=====================================================================
58!===============================================================
59
60SUBROUTINE lfcalc(nspc, heightcl, LAIsum, LAIsqsum, numin0)
61
62 ! <CALL modules for TYPE definitions and +- fixed variables>---------------------------------------------------------------
63 use all_par, only: maxspc, maxhc, maxlc, pltsiz, facvar, &
64 ltfrq, ltcum, ltprf, la, &
65 speccl ! Use control, stand and species parameters
66 IMPLICIT NONE
67
68 ! <Passed variables>--------------------------------------------------------------------------------
69 INTEGER, INTENT(in) :: heightcl, & ! height class [=height]
70 nspc ! number of species [=spec]
71 REAL, INTENT(in) :: numin0(0:maxhc, 1:maxspc) ! temp var originating from numNInH [=..]
72 REAL, INTENT(inout) :: LAIsqsum, & ! sq. sum of LA [=LAIsqrSum]
73 LAIsum ! leave area (LA) [=LAISum]
74
75 ! <Local variables>---------------------------------------------------------------------------------
76 INTEGER :: lightcl, & ! lightclass index variable [=l]
77 i ! looping variable for species
78 REAL :: ntinh, & ! # tree in height class [=nInH]
79 newla, newla2, & ! new lai and squared lai [=rNewLeafArea]
80 treelai, & ! lai per tree [=rNewLeafArea]
81 sigma, & ! std? [=sigma]
82 sum, & ! running sum [=sum]
83 disbot(maxlc), & ! Distr. of light (bottom of class)? [=distrBot]
84 distop, & ! Distr. of light (top of class)? [=distrTop]
85 value ! Out-variable from NormDist
86
87 ! <Here the SUBROUTINE starts>**********************************************************************
88 !----- By species, the number of trees is calculated and evaluated per height class
89 byspecies: do i = 1, nspc
90 !----- The current height class is completely included, i.e. there is also competition between trees in this height class
91 ntinh = numin0(heightcl, i)
92 !----- The leaf area and the squared leaf area are calculated
93 if (ntinh /= 0.0) then
94 treelai = speccl(i)%lain(heightcl)/pltsiz
95 newla = ntinh*treelai
96 newla2 = ntinh*treelai**2
97 laisum = laisum + newla
98 laisqsum = laisqsum + newla2
99 end if
100 end do byspecies
101
102 !----- LAIsum is the mean, sigma the standard deviation of the leaf area Normal distribution
103 !----- facvar describes how narrow the Normal distributions is.
104 !----- 0: uniform spatial distribution, 1: random spat. distribution, >1 clumped spatial distribution.
105 !----- It is parameterized in All_PAR
106
107 if ((facvar <= 0.0) .or. (laisqsum < 1.e-7)) then
108 sigma = 0.001 !----- sigma has to be larger 0
109 else
110 sigma = sqrt(laisqsum)*facvar
111 end if
112
113 ltfrq = 0.0
114 !----- if there are (nearly) no leaves, then there is full light...
115 if (abs(laisum) < 1.e-10) then
116 ltfrq(maxlc) = 1.0
117 sum = 1.0
118 else
119 !----- ... otherwise for each light class from full light (lightcl=maxlc ) to complete darkness (lightcl=1)
120 !----- the (cumulative) normal distribution function with parameters LAIsum and sigma is evaluated
121 !----- at the leaf area (la(light)) required to produce the light value. The difference between
122 !----- two values of the distribution function is the frequency of these leaf areas, resp. light values.
123 sum = 0.0
124 call normdist(value, laisum, sigma, la(1))
125 ltfrq(1) = 1 - value
126 sum = sum + 1 - value
127 call normdist(value, laisum, sigma, la(maxlc - 1))
128 ltfrq(maxlc) = value
129 sum = sum + value
130 distop = value
131
132 byltcls1: do lightcl = maxlc - 1, 2, -1
133 call normdist(value, laisum, sigma, la(lightcl - 1))
134 disbot(lightcl) = value
135 ltfrq(lightcl) = disbot(lightcl) - distop
136 sum = sum + ltfrq(lightcl)
137 distop = disbot(lightcl)
138 end do byltcls1
139 end if
140
141 !----- If the leaf area is so large that even the la value set for the lowest light class is much lower,
142 !----- and all lftrq's are 0, then the lowest light class frequency is set to 1
143 if (abs(sum) < 1.e-20) then
144 ltfrq(1) = 1.0
145 sum = 1.0
146 end if
147
148 !----- The light distribution is normalized, because it is truncated a 0
149 ltfrq(maxlc) = ltfrq(maxlc)/sum
150 ltprf(heightcl, maxlc) = ltfrq(maxlc)
151 ltcum(maxlc) = ltfrq(maxlc)
152
153 byltcls2: do lightcl = maxlc - 1, 1, -1
154 ltfrq(lightcl) = ltfrq(lightcl)/sum
155 ltprf(heightcl, lightcl) = ltfrq(lightcl)
156 ltcum(lightcl) = ltcum(lightcl + 1) + ltfrq(lightcl)
157 end do byltcls2
158
159end SUBROUTINE lfcalc
160!done
subroutine lfcalc(nspc, heightcl, laisum, laisqsum, numin0)
Lfcalc: light distributions.
Definition LfCalc.f90:61
subroutine normdist(val, mu, s, x)
NormDist.
Definition NormDist.f90:24
real pltsiz
Definition All_par.f90:125
real, dimension(0:maxhc, maxlc) ltprf
Definition All_par.f90:369
integer, parameter maxhc
Definition All_par.f90:99
type(specpropertiesincl), dimension(maxspc) speccl
Definition All_par.f90:346
integer, parameter maxlc
Definition All_par.f90:100
character(len=:), allocatable e
Definition All_par.f90:93
real, dimension(maxlc) la
Definition All_par.f90:130
real, dimension(maxlc) ltfrq
Definition All_par.f90:367
real, dimension(maxlc) ltcum
Definition All_par.f90:368
real facvar
Definition All_par.f90:122
integer, parameter maxspc
Definition All_par.f90:98