TreeMig Code
Loading...
Searching...
No Matches
GetSpc.f90
Go to the documentation of this file.
1!==============================================================================
36!===============================================================
37SUBROUTINE getspc(nspc, doFFT)
40 use loggermodule
41 ! use GFT
42 ! CALL modules for TYPEdefinitions>---------------------------------------------------------------
43 use all_par, only: maxhc, birht, maxspc, a1, a2, c1, c2, kn1, kn2, &
49
50 IMPLICIT NONE
51
52 ! Passed variables>--------------------------------------------------------------------------------
53 LOGICAL, INTENT(IN) :: doFFT ! dispersal with FFT or direct?
54
55 INTEGER, INTENT(out) :: nspc ! number of species[=spec]
56
57 ! Local variables>---------------------------------------------------------------------------------
58 INTEGER :: err, & ! I/O error handling
59 ht, & ! height index for calculating seedsproduced per height class ! DSP
60 i, & ! looping variable for species and immigration dates
61 ltcl
62 REAL :: sumprop, & ! sum to calculate proportion of seedper height class (of max) ! DSP
63 swidth, & ! step width for scaling seedfraction along height classes ! DSP
64 seedMaxAge, & ! maximum seed ager
65 lih, lidep
66
67 character*1 :: tab
68 character(len=100) :: nameLong
69 character(len=100) :: nameShort
70 LOGICAL :: finish
71
72 ! Here the SUBROUTINEstarts>**********************************************************************
73 finish = .false.
74 !----- <First, open file for reading species parameter and kernel informations>
75 if (readdispersalkernel) then
76 call openfiler(dispersalkernel_file, err) ! closed (this l. 292)
77 if (err /= 0) then
78 call logerror("Could not open dispersal kernel file: "//dispersalkernel_file%path)
79 error stop
80 end if
81 end if
82
83 call openfilew(dispersalkernelnew_file, err) ! closed (this l. 290)
84 if (err /= 0) then
85 call logerror("Could not open new dispersal kernel file: "//dispersalkernelnew_file%path)
86 error stop
87 end if
88 !----- Read the species parameters ---------------------------------------------
89 call openfiler(species_file, err) ! closed (this l. 288)
90 if (err /= 0) then
91 call logerror("Could not open species-pars file: "//species_file%path)
92 error stop
93 end if
94
95 read (species_file%unit, "(A)") ! Skip header
96
97 nspc = 0
98 read_spec: do i = 1, maxspc
99 !----- Read data strings into object spec
100 nspc = nspc + 1
101 read (species_file%unit, *, iostat=err) &
102 namelong, nameshort, spec(i)%stb, spec(i)%stn, spec(i)%kdmax, &
103 spec(i)%khmax, spec(i)%kamax, spec(i)%kg, spec(i)%kddmin, spec(i)%kddmax, spec(i)%kwit, &
104 spec(i)%kdrt, spec(i)%kGermDrSens, spec(i)%kntol, spec(i)%kbrow, spec(i)%klighs, spec(i)%kligha, spec(i)%klq, &
105 spec(i)%kimm, spec(i)%resld, spec(i)%ploto, spec(i)%par0, spec(i)%par1, spec(i)%par2, &
106 spec(i)%minmat, &
107 spec(i)%seedGerm, spec(i)%seedLoss, seedmaxage, &
108 spec(i)%period, spec(i)%maxseed, spec(i)%dispFac, spec(i)%alfa1, spec(i)%alfa2, &
109 spec(i)%repFac
110 spec(i)%nl = trim(namelong)
111 spec(i)%ns = trim(nameshort)
112
113 spec(i)%nb = i
114 !----- If EOF, then exit the read loop
115 exit_loop: if (err /= 0) then
116 nspc = nspc - 1
117 exit read_spec
118 end if exit_loop
119 end do read_spec
120 write (logmessage, '(A,I4,A)') "Read ", nspc, " species from "//species_file%path
121 call loginfo(logmessage)
122 spec%maxdhm = real(spec%kdmax)/100.0
123 spec%maxgro = real(spec%kg)/100.0
124
125 defmort: do i = 1, nspc
126 spec(i)%cmort = 4.605/real(spec(i)%kamax) ! tree const. mortality is derived from maximum tree age
127 spec(i)%seedSurv = 0.05**(1.0/seedmaxage) ! seed survival is derived from maximum age
128 end do defmort
129
130 !----- Derive additional species properties from parameters and put them into spec and specCl>
131
132 spec%tb = 2.0
133 where (spec%stb == "C") spec%tb = 1
134 !----- get critical light threshold for establishment for the species from the parameter klighs
135 spec%lthres = (0.1*real(spec%klighs)) - 0.4
136 where (spec%klighs < 5) spec%lthres = 0.025*real(spec%klighs - 1.0)
137 where (spec%lthres < 0.0) spec%lthres = 0.0
138 !----- calculate for each species the light dependence value in the light classes
139 do i = 1, nspc
140 do ltcl = 1, maxlc
141 lih = real(ltcl*(ltcl + 1))/real(maxlc*(maxlc + 1)) ! available light in light class
142 call contlightdep(lih, spec(i)%kligha, lidep) ! dependence of the adults of the species on this light
143 speccl(i)%lightDepA(ltcl) = lidep
144 call contlightdep(lih, spec(i)%klighs, lidep) ! dependence for the establishment of the species on this light
145 speccl(i)%lightDepE(ltcl) = lidep
146 end do ! ltcl
147 end do ! i species
148 !----- <Calculate absolute MAX height over all trees>
149 htmax = maxval(spec%khmax)
150
151 hcwidth = (real(htmax) - birht)/real(maxhc - 1) !----- height class width; Heike's version
152
153 !----- <Calculate absolute MAX height class of one species>
154 spec%maxhtc = min(floor(real(maxhc - 1)* &
155 (real(spec%khmax) - birht)/(real(htmax) - birht) + 1.0), maxhc) !----- Heike's version
156
157 !----- Set values to the coefficients for LA & BIOMASS calculations
158 a1 = (/exp(-2.5), exp(-2.3), exp(-2.9), exp(-1.8), exp(-1.5)/)
159 a2 = (/1.4, 1.4, 1.7, 1.4, 1.6/)
160 c1 = (/0.45, 0.35/)
161 c2 = (/6.0, 12.0/)
162
163 kn1 = (/-0.016, -0.022, -0.016/)
164 kn2 = (/2.245, 30.605, 43.973/)
165
166
167 !----- min. maturation height, is read from parameter file
168 if (.NOT. mathgtdifferent) &
169 spec%minmat = birht + 0.8*(spec%khmax - birht)
170
171 !----- This is converting the minmat variable into a REAL number of classproportion
172 spec%mathcp = ((real(maxhc - 1)*(spec%minmat - birht)/(real(htmax) - birht)) + 1.0)
173
174 !----- derive several other properties for species
175
176 speciesproperties: do i = 1, nspc
177 !----- This is setting up the fraction of seeds produced by height class of the potential maximum
178 !----- max. seed number, dispersal distance and mast seeding period are set to standard values, if these scenarios are not used
179 if (.NOT. seedsdifferent) &
180 spec(i)%maxseed = 10000.0*spec(i)%khmax/htmax !----- read from parameterfile
181 if (.NOT. dispersaldifferent) spec(i)%alfa1 = alpha_all
182 if (.NOT. mastseeding) spec(i)%period = 1.0
183
184 sumprop = 0.0
185 speccl(i)%seedprod = 0.0
186
187 !----- Here the amount of seeds produced in each height class per tree is calculated (ask Nick for details...)
188 if (spec(i)%mathcp > real(spec(i)%maxhtc)) then
189 spec(i)%mathcp = spec(i)%maxhtc
190 end if
191 swidth = 11.0/real(spec(i)%maxhtc - floor(spec(i)%mathcp) + 1) !----- stepwidth to scale grad. of htcl
192
193 init_sdht: do ht = floor(spec(i)%mathcp), spec(i)%maxhtc
194 !----- range between 0 = 10 for x along height classes (ranging fromminmat to maxhtc); divided by
195 !----- 100.0 to scale from 0.1 to 1.0; ((ht-1)*swidth)=x of y=(10.+(.9*x**2))/100; scaled by sum!!
196 speccl(i)%seedprod(ht) = (10.+(.9*((real(ht - floor(spec(i)%mathcp))*swidth)**2)))/100.0
197 sumprop = sumprop + speccl(i)%seedprod(ht)
198 end do init_sdht
199
200 speccl(i)%seedprod = speccl(i)%seedprod/sumprop
201
202 ! ----- Calculates and stores dispersal kernel for this species
203
204 end do speciesproperties ! i species, index i
205 do i = 1, nspc
207
208 end do ! i species, index i
209
210 ! Write out read in parameters as a control
211 if (tabsepoutput) then
212 tab = char(9)
213 else
214 tab = ','
215 end if
216
217 call openfilew(speciesout_file, err) ! closed (this l. 289)
218 if (err /= 0) then
219 call logerror("Could not create species output file: "//speciesout_file%path)
220 error stop
221 end if
222 write (speciesout_file%unit, "(A)") 'Species'//tab//'Abbrv'//tab//'sType/B'//tab//'sType/N'//tab//'kDMax'//tab// &
223 'kHMax'//tab//'kAMax'//tab//'kG'//tab//'kDDMin'//tab//'kDD75'//tab// &
224 'kWiT'//tab//'kDrT'//tab//'kGermDrSens'//tab//'kNTol'//tab//'kbrow'//tab//'klighs'//tab// &
225 'kligha'//tab//'klq'//tab//'kimm'//tab//'resID'//tab//'ploto'//tab// &
226 'par0'//tab//'par1'//tab//'par2'//tab//'inmat'//tab//'seedGerm'//tab// &
227 'seedLoss'//tab//'seedMaxAge'//tab//'period'//tab//'maxseed'//tab//'dispFac'//tab// &
228 'alfa1'//tab//'alfa2'//tab//'repFac'//tab//'red'//tab//'green'//tab//'blue'
229 do i = 1, nspc
230 write (speciesout_file%unit, '(3(A,A1),8(I6,A1),2(F18.6,A1),11(I8,A1),10(F18.6,A1),2(I8,A1),1(I8))') &
231 spec(i)%nl, tab, spec(i)%ns, tab, &
232 spec(i)%stb, tab, spec(i)%stn, tab, spec(i)%kdmax, tab, &
233 spec(i)%khmax, tab, spec(i)%kamax, tab, spec(i)%kg, tab, spec(i)%kddmin, tab, spec(i)%kddmax, tab, &
234 spec(i)%kwit, tab, spec(i)%kdrt, tab, spec(i)%kGermDrSens,tab, spec(i)%kntol, tab, &
235 spec(i)%kbrow, tab, spec(i)%klighs, tab, &
236 spec(i)%kligha, tab, spec(i)%klq, tab, spec(i)%kimm, tab, spec(i)%resld, tab, spec(i)%ploto, tab, &
237 spec(i)%par0, tab, spec(i)%par1, tab, spec(i)%par2, tab, spec(i)%minmat, tab, spec(i)%seedGerm, tab, &
238 spec(i)%seedLoss, tab, seedmaxage, tab, spec(i)%period, tab, spec(i)%maxseed, tab, &
239 spec(i)%dispFac, tab, spec(i)%alfa1, tab, spec(i)%alfa2, tab, spec(i)%repFac, tab, &
240 spec(i)%red, tab, spec(i)%green, tab, spec(i)%blue
241 end do
242
243 ! close the files
247 if (readdispersalkernel) then
249 end if
250 !----- Immigration input
251 call readimmigrationdata(nspc)
252
253end SUBROUTINE getspc
254
255
256
subroutine contlightdep(light, shade_sens_class, lidep)
ContLightDep.
subroutine calculateandstoredispersalkernelofspecies(isp, dofft)
CalculateAndStoreDispersalKernelOfSpecies
subroutine getspc(nspc, dofft)
GetSpc
Definition GetSpc.f90:38
subroutine readimmigrationdata(nspc)
ReadImmigrationData
integer, parameter maxhc
Definition All_par.f90:99
real hcwidth
Definition All_par.f90:357
real, dimension(3) kn2
Definition All_par.f90:135
type(specpropertiesincl), dimension(maxspc) speccl
Definition All_par.f90:346
type(specproperties), dimension(maxspc) spec
Definition All_par.f90:345
real, dimension(5) a2
Definition All_par.f90:131
logical dispersaldifferent
Definition All_par.f90:72
integer, parameter maxlc
Definition All_par.f90:100
real, dimension(2) c1
Definition All_par.f90:132
real, dimension(5) a1
Definition All_par.f90:130
integer real
Definition All_par.f90:27
logical seedsdifferent
Definition All_par.f90:70
real, parameter birht
Definition All_par.f90:120
logical mastseeding
Definition All_par.f90:74
real, dimension(2) c2
Definition All_par.f90:133
logical tabsepoutput
Definition All_par.f90:89
integer htmax
Definition All_par.f90:358
logical mathgtdifferent
Definition All_par.f90:71
real, dimension(3) kn1
Definition All_par.f90:134
type(wroutp) false
Definition All_par.f90:143
integer, parameter maxspc
Definition All_par.f90:98
real alpha_all
Definition All_par.f90:62
logical readdispersalkernel
Definition All_par.f90:76
subroutine closefile(thefile)
closeFile
subroutine openfiler(thefile, err)
openFileR
subroutine openfilew(thefile, err)
openFileW
type(file) dispersalkernelnew_file
type(file) dispersalkernel_file
type(file) speciesout_file
type(file) species_file
LoggerModule.
subroutine loginfo(msg)
LogInfo
character(len=1024) logmessage
subroutine logerror(msg)
LogError