TreeMig Code
Loading...
Searching...
No Matches
GetBioclim.f90
Go to the documentation of this file.
1!==============================================================================
2! @brief GetBioClim
3! ****************
4! @details samples actual values of bioclimate (DD, WiT, DrStr) from interpolated means and standard deviations of the variables
5! @todo CURRENTLY NOT USED
6!
7! - ***USE:*** All_par
8! - ***IN:***
9! - @param year : current year (relative years)
10! @param lat, lon : coordinates (relative) of actual cell
11!
12! - *FROM All_par*
13! - newBioClim, oldBioClim :TYPE(BIOCLIMDATA) : bioclimate data for this year and last stored year
14! - simustartyear : INTEGER : start year of simulation in real years
15! - ***OUT:***
16! - @param ddegs : current value in grid cell of day degree sum [°C]
17! @param wtemp : current value in grid cell of minimum winter temperature [°C]
18! @param drstr : current value in grid cell of drought stress
19! - ***CALLED FROM:***
20! - GetEnvFactors in GetEnvFactors.f90
21!===============================================================
22! SUBROUTINE GetBioClim(year, lat, lon, ddegs, wtemp, drstr)
23!
24! !CALL modules for TYPE definitions and +- fixed variables>---------------------------------------------------------------
25! use All_par, only: newBioClim, oldBioClim, simustartyear
26!
27! IMPLICIT NONE
28!
29! !Passed variables>--------------------------------------------------------------------------------
30! INTEGER, INTENT(in) :: year, lat, lon
31! REAL, INTENT(out) :: ddegs, wtemp, drstr
32!
33! !Local variables>---------------------------------------------------------------------------------
34! REAL :: muDD, stdDD, muWiT, stdWiT, prop0DrStr, muDrStr, stdDrStr, oldT, newT, randomvalue, real_year
35!
36! !Here the SUBROUTINE starts>**********************************************************************
37! real_year = year + simustartyear
38! oldT = oldBioClim%cctime
39! newT = newBioClim%cctime
40! !---- interpolate linearly mean and standard deviation between the last and the current time point of the bioclimate data
41! !---- then sample a value from the normal distribution described by these parameters (GetVariate)
42! !---- DD
43! call Interpolate(real_year, oldT, newT, oldBioClim%bc(lat, lon)%muDD, &
44! newBioClim%bc(lat, lon)%muDD, muDD)
45! call Interpolate(real_year, oldT, newT, oldBioClim%bc(lat, lon)%stdDD, &
46! newBioClim%bc(lat, lon)%stdDD, stdDD)
47! call GetVariate(muDD, stdDD, ddegs)
48! !---- WiT
49! call Interpolate(real_year, oldT, newT, oldBioClim%bc(lat, lon)%muWiT, &
50! newBioClim%bc(lat, lon)%muWiT, muWiT)
51! call Interpolate(real_year, oldT, newT, oldBioClim%bc(lat, lon)%stdWiT, &
52! newBioClim%bc(lat, lon)%stdWiT, stdWiT)
53! call GetVariate(muWiT, stdWiT, wtemp)
54! !---- Drought stress, first pro0DrStr
55! call Interpolate(real_year, oldT, newT, oldBioClim%bc(lat, lon)%prop0DrStr, &
56! newBioClim%bc(lat, lon)%prop0DrStr, prop0DrStr)
57! call RANDOM_NUMBER(randomvalue)
58!
59! if (randomvalue <= prop0DrStr) then
60! drstr = 0.0
61! else
62! !---- Drought stress, interpolate and sample
63! call Interpolate(real_year, oldT, newT, oldBioClim%bc(lat, lon)%muDrStr, &
64! newBioClim%bc(lat, lon)%muDrStr, muDrStr)
65! call Interpolate(real_year, oldT, newT, oldBioClim%bc(lat, lon)%stdDrStr, &
66! newBioClim%bc(lat, lon)%stdDrStr, stdDrStr)
67!
68! call GetVariate(muDrStr, stdDrStr, drstr)
69! if (drstr < 0.0) drstr = 0.0
70! if (drstr > 1.0) drstr = 1.0
71! end if
72!
73! end SUBROUTINE GetBioClim
74!
75!==============================================================================
96!===============================================================
97SUBROUTINE getbioclimsimple(year, lat, lon, ddegs, wtemp, drstr, avnit, brwpr, disturb, germDrought)
98
99!CALL modules for TYPE definitions and +- fixed variables>---------------------------------------------------------------
100 use all_par, only: newbioclim
101
102 IMPLICIT NONE
103
104!Passed variables>--------------------------------------------------------------------------------
105 INTEGER, INTENT(in) :: year, lat, lon
106 REAL, INTENT(out) :: ddegs, wtemp, drstr, disturb, germDrought, avnit, brwpr
107
108!Local variables>---------------------------------------------------------------------------------
109 ddegs = newbioclim%bc(lat, lon)%muDD
110 wtemp = newbioclim%bc(lat, lon)%muWiT
111 drstr = newbioclim%bc(lat, lon)%muDrStr
112 disturb = newbioclim%bc(lat, lon)%disturb
113 germdrought =newbioclim%bc(lat, lon)%germDrought
114 brwpr =newbioclim%bc(lat, lon)%brwpr
115 avnit =newbioclim%bc(lat, lon)%avnit
116 if (drstr < 0.0) drstr = 0.0
117 if (drstr > 1.0) drstr = 1.0
118end SUBROUTINE getbioclimsimple
119
120!==============================================================================
133!===============================================================
134! SUBROUTINE Interpolate(x, x1, x2, y1, y2, y)
135! use LoggerModule
136! !CALL modules for TYPE definitions and +- fixed variables>---------------------------------------------------------------
137! IMPLICIT NONE
138!
139! !Passed variables>--------------------------------------------------------------------------------
140! REAL, INTENT(in) :: x, x1, x2, y1, y2
141! REAL, INTENT(out):: y
142!
143! !Here the SUBROUTINE starts>**********************************************************************
144! if (abs(x1 - x2) < 1.E-20) then
145! call LogError("x1 = x2 on interpolation: ")
146! write(LogMessage, "(2F15.6)") x1, x2
147! call LogError(LogMessage)
148! error stop
149! end if
150!
151! y = y1 + (x - x1)*(y2 - y1)/(x2 - x1)
152! end SUBROUTINE Interpolate
153!
154!==============================================================================
168!===============================================================
169! SUBROUTINE GetVariate(mu, stdev, x)
170!
171! !CALL modules for TYPE definitions and +- fixed variables>---------------------------------------------------------------
172! IMPLICIT NONE
173!
174! !Passed variables>--------------------------------------------------------------------------------
175! REAL, INTENT(in) :: mu, stdev
176! REAL, INTENT(out) :: x
177!
178! !Local variables>---------------------------------------------------------------------------------
179! REAL :: randomvalue
180!
181! !Here the SUBROUTINE starts>**********************************************************************
182! call RANDOM_NUMBER(randomvalue)
183! call DrawFromNormalDist(mu, stdev, x, randomvalue)
184!
185! end SUBROUTINE GetVariate
186!done
subroutine getbioclimsimple(year, lat, lon, ddegs, wtemp, drstr, avnit, brwpr, disturb, germdrought)
GetBioClimSimple.
type(bioclimdata) newbioclim
Definition All_par.f90:351