SUEWS API Site
Documentation of SUEWS source code
suews_phys_dailystate.f95
Go to the documentation of this file.
2  USE allocatearray, ONLY: &
4 
5  IMPLICIT NONE
6  ! INTEGER,PARAMETER::ndays=366
7  ! INTEGER,PARAMETER::nvegsurf=3
8  ! INTEGER,PARAMETER::ncolumnsDataOutDailyState=46
9 
10 CONTAINS
11 
12  ! Calculation of daily state variables
13  ! Responds to what has happened in the past (temperature, rainfall, etc)
14  ! Updates each time step, but for many variables, correct values are calculated only at the end of each day!
15  ! --> for these variables, the rest of the code MUST use values from the previous day
16  ! N.B. Some of this code is repeated in SUEWS_Initial
17  ! --> so if changes are made here, SUEWS_Initial may also need to be updated accordingly
18  ! N.B. Currently, daily variables are calculated using 00:00-23:55 timestamps (for 5-min resolution); should use 00:05-00:00
19  !
20  ! Last modified:
21  ! TS 09 Jul 2018 - Modified HDD array to hold values for actual calculation
22  ! TS 18 Sep 2017 - Added explicit interface
23  ! TS 07 Jun 2017 - Improve the format of output with more friendly alignment
24  ! HCW 04 Jul 2016 - GridID can now be up to 10 digits long
25  ! HCW 25 May 2016 - Added extra columns to daily state file (albedo for EveTr and Grass)
26  ! HCW 24 May 2016 - Bug fixed in naming of SUEWS_cal_DailyState file (now uses GridIDmatrix(Gridiv) rather than Gridiv)
27  ! LJ 27 Jan 2016 - Removal of tabs
28  ! HCW 20 Aug 2015 - Sign of the porosity change corrected so that porosity is greatest when LAI is smallest
29  ! HCW 03 Jul 2015 - Increased output resolution of P/day in SUEWS_cal_DailyState file to avoid rounding errors.
30  ! Albedo of EveTr and Grass now adjusted based on change in LAI for EveTr and Grass
31  ! (rather than DecTr)
32  ! HCW 29 Jun 2015 - Added albChange for EveTr and Grass surfaces
33  ! HCW 11 Jun 2015 - Bug fix from 05 Jun now fixed in a different way -
34  ! DecidCap is now treated the same as DecidAlb so should be able to cope with multiple grids.
35  ! HCW 05 Jun 2015 - Bug fix - set all current storage capacities (StoreDrainPrm(6,)) to min. value, then set for DecTr
36  ! LJ 11 Mar 2015 - Removed switch as no longer necessary
37  ! HCW 06 Mar 2015 - iy used instead of year which does not have a value here
38  ! HCW 20 Feb 2015 - Added StoreDrainPrm(6,is) for the current storage capacity
39  ! Updated and corrected SUEWS_cal_DailyState output file
40  ! LJ 05 Feb 2015 - SUEWS_cal_DailyState saving fixed. Now header is printed and the file closed and opened as suggested.
41  ! N.B. Bug in daily Precip - needs fixing!!! - HCW thinks this is fixed 20 Feb 2015
42  ! HCW 26 Jan 2015 - sfr and IrrFracs deleted from WUDay calculations, so that WUDay is not spread over
43  ! the total area
44  ! HCW 23 Jan 2015 - WUDay now has 9 columns (EveTr, DecTr, Grass; automatic, manual, total)
45  ! HCW 27 Nov 2014 - Handles values for different grids (Gridiv & ir arguments)
46  ! Added the calculation of surface temperature
47  ! LJ 22 Feb 2013 - Snow albedo aging and calculation of snow density added,
48  ! LJ 22 Jul 2013 - Calculation of LAI senescence from previous day length added
49  ! sg feb 2012 - rewritten from LUMPS_LAI so done in real time
50  !
51  ! To Do
52  ! - Account for change of year in 5-day running mean
53  ! - Check LAI calcs (N/S hemisphere similarities; use of day length)
54  ! - Take out doy limits (140,170, etc) and code as parameters
55  ! - Could add different coefficients (Ie_m, Ie_a) for each vegetation type
56  !==============================================================================
57  SUBROUTINE suews_cal_dailystate( &
58  iy, id, it, imin, isec, tstep, tstep_prev, dt_since_start, DayofWeek_id, &!input
59  Tmin_id_prev, Tmax_id_prev, lenDay_id_prev, &
60  WaterUseMethod, Ie_start, Ie_end, &
61  LAICalcYes, LAIType, &
62  nsh_real, avkdn, Temp_C, Precip, BaseTHDD, &
63  lat, Faut, LAI_obs, &
64  AlbMax_DecTr, AlbMax_EveTr, AlbMax_Grass, &
65  AlbMin_DecTr, AlbMin_EveTr, AlbMin_Grass, &
66  CapMax_dec, CapMin_dec, PorMax_dec, PorMin_dec, &
67  Ie_a, Ie_m, DayWatPer, DayWat, &
68  BaseT, BaseTe, GDDFull, SDDFull, LAIMin, LAIMax, LAIPower, &
69  DecidCap_id_prev, StoreDrainPrm_prev, LAI_id_prev, GDD_id_prev, SDD_id_prev, &
70  albDecTr_id_prev, albEveTr_id_prev, albGrass_id_prev, porosity_id_prev, &!input
71  HDD_id_prev, &!input
72  HDD_id_next, &!output
73  Tmin_id_next, Tmax_id_next, lenDay_id_next, &
74  albDecTr_id_next, albEveTr_id_next, albGrass_id_next, porosity_id_next, &!output
75  DecidCap_id_next, StoreDrainPrm_next, LAI_id_next, GDD_id_next, SDD_id_next, deltaLAI, WUDay_id)!output
76 
77  ! USE Snow_module, ONLY: SnowUpdate
78  USE datetime_module, ONLY: datetime, timedelta
79 
80  IMPLICIT NONE
81 
82  INTEGER, INTENT(IN)::iy
83  INTEGER, INTENT(IN)::id
84  INTEGER, INTENT(IN)::it
85  INTEGER, INTENT(IN)::imin
86  INTEGER, INTENT(IN)::isec
87  INTEGER, INTENT(IN)::tstep
88  INTEGER, INTENT(IN)::tstep_prev
89  INTEGER, INTENT(IN)::dt_since_start
90 
91  INTEGER, INTENT(IN)::WaterUseMethod
92  INTEGER, INTENT(IN)::Ie_start !Starting time of water use (DOY)
93  INTEGER, INTENT(IN)::Ie_end !Ending time of water use (DOY)
94  INTEGER, INTENT(IN)::LAICalcYes
95 
96  INTEGER, DIMENSION(nvegsurf), INTENT(IN):: LAIType !LAI equation to use: original (0) or new (1)
97 
98  REAL(KIND(1d0)), INTENT(IN)::nsh_real
99  REAL(KIND(1d0)), INTENT(IN)::avkdn
100  REAL(KIND(1d0)), INTENT(IN)::Temp_C
101  REAL(KIND(1d0)), INTENT(IN)::Precip
102  REAL(KIND(1d0)), INTENT(IN)::BaseTHDD
103  REAL(KIND(1d0)), INTENT(IN)::lat
104  REAL(KIND(1d0)), INTENT(IN)::Faut
105  REAL(KIND(1d0)), INTENT(IN)::LAI_obs
106  ! REAL(KIND(1D0)), INTENT(IN)::tau_a
107  ! REAL(KIND(1D0)), INTENT(IN)::tau_f
108  ! REAL(KIND(1D0)), INTENT(IN)::tau_r
109  ! REAL(KIND(1D0)), INTENT(IN)::SnowDensMax
110  ! REAL(KIND(1D0)), INTENT(IN)::SnowDensMin
111  ! REAL(KIND(1D0)), INTENT(in)::SnowAlbMax
112  ! REAL(KIND(1D0)), INTENT(IN)::SnowAlbMin
113  REAL(KIND(1d0)), INTENT(IN)::AlbMax_DecTr
114  REAL(KIND(1d0)), INTENT(IN)::AlbMax_EveTr
115  REAL(KIND(1d0)), INTENT(IN)::AlbMax_Grass
116  REAL(KIND(1d0)), INTENT(IN)::AlbMin_DecTr
117  REAL(KIND(1d0)), INTENT(IN)::AlbMin_EveTr
118  REAL(KIND(1d0)), INTENT(IN)::AlbMin_Grass
119  REAL(KIND(1d0)), INTENT(IN)::CapMax_dec
120  REAL(KIND(1d0)), INTENT(IN)::CapMin_dec
121  REAL(KIND(1d0)), INTENT(IN)::PorMax_dec
122  REAL(KIND(1d0)), INTENT(IN)::PorMin_dec
123  ! REAL(KIND(1d0)),INTENT(IN) ::VegPhenLumps
124 
125  REAL(KIND(1d0)), DIMENSION(3), INTENT(IN) ::Ie_a
126  REAL(KIND(1d0)), DIMENSION(3), INTENT(IN) ::Ie_m !Coefficients for automatic and manual irrigation models
127  REAL(KIND(1d0)), DIMENSION(7), INTENT(IN) ::DayWatPer !% of houses following daily water
128  REAL(KIND(1d0)), DIMENSION(7), INTENT(IN) ::DayWat !Days of watering allowed
129 
130  ! REAL(KIND(1d0)), DIMENSION(nsurf), INTENT(IN) ::SnowPack
131  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) ::BaseT !Base temperature for growing degree days [degC]
132  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) ::BaseTe !Base temperature for senescence degree days [degC]
133  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) ::GDDFull !Growing degree days needed for full capacity [degC]
134  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) ::SDDFull !Senescence degree days needed to initiate leaf off [degC]
135  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) ::LAIMin !Min LAI [m2 m-2]
136  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) ::LAIMax !Max LAI [m2 m-2]
137  REAL(KIND(1d0)), DIMENSION(4, nvegsurf), INTENT(IN) ::LAIPower !Coeffs for LAI equation: 1,2 - leaf growth; 3,4 - leaf off
138 
139  ! REAL(KIND(1d0)), INTENT(INOUT)::SnowAlb
140 
141  REAL(KIND(1d0)), DIMENSION(3) :: GDD_id ! Growing Degree Days (see SUEWS_DailyState.f95)
142  REAL(KIND(1d0)), DIMENSION(3), INTENT(IN) :: GDD_id_prev ! Growing Degree Days (see SUEWS_DailyState.f95)
143  REAL(KIND(1d0)), DIMENSION(3), INTENT(OUT) :: GDD_id_next ! Growing Degree Days (see SUEWS_DailyState.f95)
144  REAL(KIND(1d0)), DIMENSION(3) :: SDD_id ! Growing Degree Days (see SUEWS_DailyState.f95)
145  REAL(KIND(1d0)), DIMENSION(3), INTENT(IN) :: SDD_id_prev ! Growing Degree Days (see SUEWS_DailyState.f95)
146  REAL(KIND(1d0)), DIMENSION(3), INTENT(OUT) :: SDD_id_next ! Growing Degree Days (see SUEWS_DailyState.f95)
147  REAL(KIND(1d0)), DIMENSION(3) :: LAI_id ! LAI for each veg surface [m2 m-2]
148  REAL(KIND(1d0)), DIMENSION(3), INTENT(IN) :: LAI_id_prev ! LAI for each veg surface [m2 m-2]
149  REAL(KIND(1d0)), DIMENSION(3), INTENT(OUT) :: LAI_id_next ! LAI for each veg surface [m2 m-2]
150  REAL(KIND(1d0)), DIMENSION(12) :: HDD_id ! Heating Degree Days (see SUEWS_DailyState.f95)
151  REAL(KIND(1d0)), DIMENSION(12), INTENT(IN) :: HDD_id_prev ! Heating Degree Days (see SUEWS_DailyState.f95)
152  REAL(KIND(1d0)), DIMENSION(12), INTENT(OUT) :: HDD_id_next ! Heating Degree Days (see SUEWS_DailyState.f95)
153  REAL(KIND(1d0)), DIMENSION(9), INTENT(OUT) :: WUDay_id ! Water use related array
154  ! --------------------------------------------------------------------------------
155  ! ------------- Key to daily arrays ----------------------------------------------
156  ! TS, 27 Dec 2018: updated the annotation for 2018b and WRF-SUEWS coupling
157  !
158  ! HDD_id:
159  ! first half used for update through the day
160  ! HDD_id(1) ---- Heating [degC]: used for accumulation during calculation
161  ! HDD_id(2) ---- Cooling [degC]: used for accumulation during calculation
162  ! HDD_id(3) ---- Daily mean temp [degC]: used for accumulation during calculation
163  ! HDD_id(4) ---- 5-day running mean temp [degC]: used for actual calculation
164  ! HDD_id(5) ---- Daily precip total [mm]
165  ! HDD_id(6) ---- Days since rain [d]
166  ! second half used for storage of the first half for the prevous day
167  ! HDD_id(6+1) ---- Heating [degC]: used for accumulation during calculation
168  ! HDD_id(6+2) ---- Cooling [degC]: used for accumulation during calculation
169  ! HDD_id(6+3) ---- Daily mean temp [degC]: used for accumulation during calculation
170  ! HDD_id(6+4) ---- 5-day running mean temp [degC]: used for actual calculation
171  ! HDD_id(6+5) ---- Daily precip total [mm]
172  ! HDD_id(6+6) ---- Days since rain [d]
173  !
174  ! GDD_id:
175  ! GDD_id(1) ---- Growing [degC]
176  ! GDD_id(2) ---- Senescence [degC]
177  ! GDD_id(3) ---- Daily min temp [degC]
178  ! GDD_id(4) ---- Daily max temp [degC]
179  ! GDD_id(5) ---- Daytime hours [h]
180  !
181  ! LAI_id:
182  ! LAI_id(1:3) -- LAI for each veg surface [m2 m-2]
183  !
184  ! WUDay_id:
185  ! WUDay_id(1) - Daily water use total for Irr EveTr (automatic+manual) [mm]
186  ! WUDay_id(2) - Automatic irrigation for Irr EveTr [mm]
187  ! WUDay_id(3) - Manual irrigation for Irr EveTr [mm]
188  ! WUDay_id(4) - Daily water use total for Irr DecTr (automatic+manual) [mm]
189  ! WUDay_id(5) - Automatic irrigation for Irr DecTr [mm]
190  ! WUDay_id(6) - Manual irrigation for Irr DecTr [mm]
191  ! WUDay_id(7) - Daily water use total for Irr Grass (automatic+manual) [mm]
192  ! WUDay_id(8) - Automatic irrigation for Irr Grass [mm]
193  ! WUDay_id(9) - Manual irrigation for Irr Grass [mm]
194  ! --------------------------------------------------------------------------------
195 
196  ! REAL(KIND(1d0)), DIMENSION(nsurf), INTENT(INOUT)::SnowDens
197  INTEGER, DIMENSION(3), INTENT(in)::DayofWeek_id
198 
199  REAL(KIND(1d0))::Tmin_id
200  REAL(KIND(1d0)), INTENT(IN)::Tmin_id_prev
201  REAL(KIND(1d0)), INTENT(out)::Tmin_id_next
202  REAL(KIND(1d0))::Tmax_id
203  REAL(KIND(1d0)), INTENT(in)::Tmax_id_prev
204  REAL(KIND(1d0)), INTENT(out)::Tmax_id_next
205  REAL(KIND(1d0))::lenDay_id
206  REAL(KIND(1d0)), INTENT(IN)::lenDay_id_prev
207  REAL(KIND(1d0)), INTENT(out)::lenDay_id_next
208 
209  !Daily water use for EveTr, DecTr, Grass [mm] (see SUEWS_DailyState.f95)
210  REAL(KIND(1d0)), INTENT(OUT)::deltaLAI
211  ! REAL(KIND(1d0)), DIMENSION(nvegsurf),INTENT(IN):: LAI_id_prev !LAI for each veg surface [m2 m-2]
212 
213  REAL(KIND(1d0)):: DecidCap_id
214  REAL(KIND(1d0)), INTENT(IN):: DecidCap_id_prev
215  REAL(KIND(1d0)), INTENT(OUT):: DecidCap_id_next
216  REAL(KIND(1d0)):: albDecTr_id
217  REAL(KIND(1d0)), INTENT(IN):: albDecTr_id_prev
218  REAL(KIND(1d0)), INTENT(OUT):: albDecTr_id_next
219  REAL(KIND(1d0)):: albEveTr_id
220  REAL(KIND(1d0)), INTENT(IN):: albEveTr_id_prev
221  REAL(KIND(1d0)), INTENT(OUT):: albEveTr_id_next
222  REAL(KIND(1d0)):: albGrass_id
223  REAL(KIND(1d0)), INTENT(IN):: albGrass_id_prev
224  REAL(KIND(1d0)), INTENT(OUT):: albGrass_id_next
225  REAL(KIND(1d0)):: porosity_id
226  REAL(KIND(1d0)), INTENT(INOUT):: porosity_id_prev
227  REAL(KIND(1d0)), INTENT(INOUT):: porosity_id_next
228  REAL(KIND(1d0)), DIMENSION(6, nsurf)::StoreDrainPrm
229  REAL(KIND(1d0)), DIMENSION(6, nsurf), INTENT(in)::StoreDrainPrm_prev
230  REAL(KIND(1d0)), DIMENSION(6, nsurf), INTENT(out)::StoreDrainPrm_next
231 
232  LOGICAL :: first_tstep_Q ! if this is the first tstep of a day
233  LOGICAL :: last_tstep_Q ! if this is the last tstep of a day
234  TYPE(datetime) :: time_now, time_prev, time_next
235 
236  ! transfer values
237  lai_id = lai_id_prev
238  gdd_id = gdd_id_prev
239  sdd_id = sdd_id_prev
240  tmin_id = tmin_id_prev
241  tmax_id = tmax_id_prev
242  lenday_id = lenday_id_prev
243  storedrainprm = storedrainprm_prev
244  decidcap_id = decidcap_id_prev
245  albdectr_id = albdectr_id_prev
246  albevetr_id = albevetr_id_prev
247  albgrass_id = albgrass_id_prev
248  porosity_id = porosity_id_prev
249  hdd_id = hdd_id_prev
250 
251  ! get timestamps
252  time_now = datetime(year=iy) + timedelta(days=id - 1, hours=it, minutes=imin, seconds=isec)
253  time_prev = time_now - timedelta(seconds=tstep_prev)
254  time_next = time_now + timedelta(seconds=tstep)
255 
256  ! test if time at now is the first/last tstep of today
257  first_tstep_q = time_now%getDay() /= time_prev%getDay()
258  last_tstep_q = time_now%getDay() /= time_next%getDay()
259 
260  ! --------------------------------------------------------------------------------
261  ! On first timestep of each day, define whether the day each a workday or weekend
262  IF (first_tstep_q) THEN
264  it, imin, &!input
265  hdd_id)!inout
266 
267  ! reset certain GDD columns
268  tmin_id = temp_c !Daily min T in column 3
269  tmax_id = temp_c !Daily max T in column 4
270  lenday_id = 0 !Cumulate daytime hours
271  ENDIF
272 
273  ! --------------------------------------------------------------------------------
274  ! regular update at all timesteps of a day
275  CALL update_dailystate_day( &
276  avkdn, &!input
277  temp_c, &
278  precip, &
279  basethdd, &
280  nsh_real, &
281  tmin_id, tmax_id, lenday_id, &!inout
282  hdd_id)
283 
284  ! Update snow density, albedo surface fraction
285  ! IF (snowUse == 1) CALL SnowUpdate( &
286  ! nsurf, tstep, Temp_C, tau_a, tau_f, tau_r, &!input
287  ! SnowDensMax, SnowDensMin, SnowAlbMax, SnowAlbMin, SnowPack, &
288  ! SnowAlb, SnowDens)!inout
289 
290  ! --------------------------------------------------------------------------------
291  ! On last timestep, perform the daily calculations -------------------------------
292  ! Daily values not correct until end of each day,
293  ! so main program should use values from the previous day
294  IF (last_tstep_q) THEN
295  CALL update_dailystate_end( &
296  id, it, imin, tstep, dt_since_start, &!input
297  tmin_id, tmax_id, lenday_id, &
298  laitype, ie_end, ie_start, laicalcyes, &
299  waterusemethod, dayofweek_id, &
300  albmax_dectr, albmax_evetr, albmax_grass, albmin_dectr, albmin_evetr, albmin_grass, &
301  baset, basete, capmax_dec, capmin_dec, daywat, daywatper, faut, gddfull, &
302  ie_a, ie_m, laimax, laimin, laipower, lat, pormax_dec, pormin_dec, sddfull, lai_obs, &
303  gdd_id, sdd_id, & !inout
304  hdd_id, &
305  lai_id, &
306  decidcap_id, &
307  albdectr_id, &
308  albevetr_id, &
309  albgrass_id, &
310  porosity_id, &
311  storedrainprm, &
312  wuday_id, deltalai)!output
313  ENDIF !End of section done only at the end of each day (i.e. only once per day)
314 
315  ! translate values back
316  lai_id_next = lai_id
317  gdd_id_next = gdd_id
318  sdd_id_next = sdd_id
319  tmin_id_next = tmin_id
320  tmax_id_next = tmax_id
321  lenday_id_next = lenday_id
322  storedrainprm_next = storedrainprm
323  decidcap_id_next = decidcap_id
324  albdectr_id_next = albdectr_id
325  albevetr_id_next = albevetr_id
326  albgrass_id_next = albgrass_id
327  porosity_id_next = porosity_id
328  hdd_id_next = hdd_id
329  ! PRINT*, 'after_DailyState', iy,id,it,imin
330  ! PRINT*, 'HDD(id)', HDD(id,:)
331  ! PRINT*, 'HDD_id', HDD_id
332 
333  ! RETURN
334 
335  END SUBROUTINE suews_cal_dailystate
336 
337  SUBROUTINE update_dailystate_end( &
338  id, it, imin, tstep, dt_since_start, &!input
339  Tmin_id, Tmax_id, lenDay_id, &
340  LAIType, Ie_end, Ie_start, LAICalcYes, &
341  WaterUseMethod, DayofWeek_id, &
342  AlbMax_DecTr, AlbMax_EveTr, AlbMax_Grass, AlbMin_DecTr, AlbMin_EveTr, AlbMin_Grass, &
343  BaseT, BaseTe, CapMax_dec, CapMin_dec, DayWat, DayWatPer, Faut, GDDFull, &
344  Ie_a, Ie_m, LAIMax, LAIMin, LAIPower, lat, PorMax_dec, PorMin_dec, SDDFull, LAI_obs, &
345  GDD_id, SDD_id, & !inout
346  HDD_id, &
347  LAI_id, &
348  DecidCap_id, &
349  albDecTr_id, &
350  albEveTr_id, &
351  albGrass_id, &
352  porosity_id, &
353  StoreDrainPrm, &
354  WUDay_id, deltaLAI)!output
355  IMPLICIT NONE
356 
357  INTEGER, INTENT(IN)::id
358  INTEGER, INTENT(IN)::it
359  INTEGER, INTENT(IN)::imin
360  INTEGER, INTENT(IN)::tstep
361  INTEGER, INTENT(IN)::dt_since_start
362  INTEGER, INTENT(IN)::LAIType(nvegsurf)
363  INTEGER, INTENT(IN)::Ie_end
364  INTEGER, INTENT(IN)::Ie_start
365  INTEGER, INTENT(IN)::LAICalcYes
366  INTEGER, INTENT(IN)::WaterUseMethod
367  INTEGER, INTENT(in)::DayofWeek_id(3)
368 
369  REAL(KIND(1d0)), INTENT(IN)::AlbMax_DecTr
370  REAL(KIND(1d0)), INTENT(IN)::AlbMax_EveTr
371  REAL(KIND(1d0)), INTENT(IN)::AlbMax_Grass
372  REAL(KIND(1d0)), INTENT(IN)::AlbMin_DecTr
373  REAL(KIND(1d0)), INTENT(IN)::AlbMin_EveTr
374  REAL(KIND(1d0)), INTENT(IN)::AlbMin_Grass
375  REAL(KIND(1d0)), INTENT(IN)::BaseT(nvegsurf)
376  REAL(KIND(1d0)), INTENT(IN)::BaseTe(nvegsurf)
377  REAL(KIND(1d0)), INTENT(IN)::CapMax_dec
378  REAL(KIND(1d0)), INTENT(IN)::CapMin_dec
379  REAL(KIND(1d0)), INTENT(IN)::DayWat(7)
380  REAL(KIND(1d0)), INTENT(IN)::DayWatPer(7)
381  REAL(KIND(1d0)), INTENT(IN)::Faut
382  REAL(KIND(1d0)), INTENT(IN)::GDDFull(nvegsurf)
383  REAL(KIND(1d0)), INTENT(IN)::Ie_a(3)
384  REAL(KIND(1d0)), INTENT(IN)::Ie_m(3)
385  REAL(KIND(1d0)), INTENT(IN)::LAIMax(nvegsurf)
386  REAL(KIND(1d0)), INTENT(IN)::LAIMin(nvegsurf)
387  REAL(KIND(1d0)), INTENT(IN)::LAIPower(4, nvegsurf)
388  REAL(KIND(1d0)), INTENT(IN)::lat
389  REAL(KIND(1d0)), INTENT(IN)::PorMax_dec
390  REAL(KIND(1d0)), INTENT(IN)::PorMin_dec
391  REAL(KIND(1d0)), INTENT(IN)::SDDFull(nvegsurf)
392  REAL(KIND(1d0)), INTENT(IN)::LAI_obs
393  REAL(KIND(1d0)), INTENT(IN)::Tmin_id
394  REAL(KIND(1d0)), INTENT(IN)::Tmax_id
395  REAL(KIND(1d0)), INTENT(IN)::lenDay_id
396 
397  REAL(KIND(1d0)), DIMENSION(3), INTENT(INOUT) ::GDD_id ! Growing Degree Days (see SUEWS_DailyState.f95)
398  REAL(KIND(1d0)), DIMENSION(3), INTENT(INOUT) ::SDD_id ! Senescence Degree Days (see SUEWS_DailyState.f95)
399  REAL(KIND(1d0)), DIMENSION(12), INTENT(INOUT) ::HDD_id
400  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(INOUT)::LAI_id ! LAI for each veg surface [m2 m-2]
401 
402  ! REAL(KIND(1d0)),DIMENSION(6),INTENT(INOUT)::HDD_id_use ! HDD of previous day
403  REAL(KIND(1d0)), DIMENSION(nvegsurf)::LAI_id_in ! LAI of previous day
404 
405  REAL(KIND(1d0)), DIMENSION(9), INTENT(OUT):: WUDay_id
406  REAL(KIND(1d0)), INTENT(OUT)::deltaLAI
407 
408  REAL(KIND(1d0)), INTENT(INOUT):: DecidCap_id
409  REAL(KIND(1d0)), INTENT(INOUT):: albDecTr_id
410  REAL(KIND(1d0)), INTENT(INOUT):: albEveTr_id
411  REAL(KIND(1d0)), INTENT(INOUT):: albGrass_id
412  REAL(KIND(1d0)), INTENT(INOUT):: porosity_id
413 
414  REAL(KIND(1d0)), DIMENSION(6, nsurf), INTENT(inout)::StoreDrainPrm
415 
416  ! CALL update_HDD(&
417  ! id,it,imin,tstep,& !input
418  ! HDD) !inout
419 
420  CALL update_hdd( &
421  dt_since_start, it, imin, tstep, & !input
422  hdd_id)!inout
423 
424  ! Calculate modelled daily water use ------------------------------------------
425  ! CALL update_WaterUse(&
426  ! id,WaterUseMethod,DayofWeek_id,lat,Faut,HDD_id,&!input
427  ! Ie_a,Ie_m,Ie_start,Ie_end,DayWatPer,DayWat,&
428  ! WUDay) !inout
429 
430  CALL update_wateruse( &
431  id, waterusemethod, dayofweek_id, lat, faut, hdd_id, &!input
432  ie_a, ie_m, ie_start, ie_end, daywatper, daywat, &
433  wuday_id) !output
434 
435  ! PRINT*, ''
436  ! PRINT*, 'WUDay(id)',WUDay(id,:)
437  ! PRINT*, 'WUDay_id',WUDay_id
438 
439  !------------------------------------------------------------------------------
440  ! Calculation of LAI from growing degree days
441  ! This was revised and checked on 16 Feb 2014 by LJ
442  !------------------------------------------------------------------------------
443  ! save initial LAI_id
444  lai_id_in = lai_id
445 
446  ! CALL update_GDDLAI( &
447  ! id, LAICalcYes, & !input
448  ! lat, LAI_obs, &
449  ! BaseT, BaseTe, &
450  ! GDDFull, SDDFull, &
451  ! LAIMin, LAIMax, LAIPower, LAIType, &
452  ! LAI_id_in, &
453  ! GDD_id, &!inout
454  ! LAI_id) !output
455 
456  CALL update_gddlai_x( &
457  id, laicalcyes, & !input
458  lat, lai_obs, &
459  tmin_id, tmax_id, lenday_id, &
460  baset, basete, &
461  gddfull, sddfull, &
462  laimin, laimax, laipower, laitype, &
463  lai_id_in, &
464  gdd_id, sdd_id, &!inout
465  lai_id) !output
466 
467  CALL update_veg( &
468  laimax, laimin, &!input
469  albmax_dectr, albmax_evetr, albmax_grass, &
470  albmin_dectr, albmin_evetr, albmin_grass, &
471  capmax_dec, capmin_dec, &
472  pormax_dec, pormin_dec, &
473  lai_id, lai_id_in, &
474  decidcap_id, &!inout
475  albdectr_id, &
476  albevetr_id, &
477  albgrass_id, &
478  porosity_id, &
479  storedrainprm, &
480  deltalai)!output
481 
482  ! PRINT*, 'DecidCap',DecidCap(id),DecidCap_id
483  ! PRINT*, 'albDecTr',albDecTr(id),albDecTr_id
484  ! PRINT*, 'albEveTr',albEveTr(id),albEveTr_id
485  ! PRINT*, 'albGrass',albGrass(id),albGrass_id
486  ! PRINT*, 'porosity',porosity(id),porosity_id
487 
488  END SUBROUTINE update_dailystate_end
489 
490  SUBROUTINE update_dailystate_day( &
491  avkdn, &!input
492  Temp_C, &
493  Precip, &
494  BaseTHDD, &
495  nsh_real, &
496  Tmin_id, Tmax_id, lenDay_id, &!inout
497  HDD_id)!inout
498  ! use time, only: id, id_prev_t
499  IMPLICIT NONE
500 
501  ! INTEGER,INTENT(IN)::id
502  REAL(KIND(1d0)), INTENT(IN)::avkdn
503  REAL(KIND(1d0)), INTENT(IN)::Temp_C
504  REAL(KIND(1d0)), INTENT(IN)::Precip
505  REAL(KIND(1d0)), INTENT(IN)::BaseTHDD
506  REAL(KIND(1d0)), INTENT(IN)::nsh_real
507  REAL(KIND(1d0)), INTENT(INOUT)::Tmin_id
508  REAL(KIND(1d0)), INTENT(INOUT)::Tmax_id
509  REAL(KIND(1d0)), INTENT(INOUT)::lenDay_id
510  ! REAL(KIND(1d0)), INTENT(out)::Tmin_id_next
511  ! REAL(KIND(1d0)), INTENT(out)::Tmax_id_next
512  ! REAL(KIND(1d0)), INTENT(out)::lenDay_id_next
513 
514  ! REAL(KIND(1d0))::tstepcount
515  ! REAL(KIND(1d0)),DIMENSION(-4:366,6),INTENT(INOUT):: HDD
516  ! REAL(KIND(1d0)), DIMENSION(5), INTENT(INOUT):: GDD_id !Growing Degree Days (see SUEWS_DailyState.f95)
517  REAL(KIND(1d0)), DIMENSION(12), INTENT(INOUT):: HDD_id !Heating Degree Days (see SUEWS_DailyState.f95)
518  ! REAL(KIND(1d0)),DIMENSION(5),INTENT(OUT):: GDD_id_prev !Growing Degree Days (see SUEWS_DailyState.f95)
519 
520  INTEGER::gamma1
521  INTEGER::gamma2
522 
523  ! Daily min and max temp (these get updated through the day) ---------------------
524  tmin_id = min(temp_c, tmin_id) !Daily min T in column 3
525  tmax_id = max(temp_c, tmax_id) !Daily max T in column 4
526  IF (avkdn > 10) THEN
527  lenday_id = lenday_id + 1/nsh_real !Cumulate daytime hours !Divide by nsh (HCW 01 Dec 2014)
528  ENDIF
529 
530  ! Calculations related to heating and cooling degree days (HDD) ------------------
531  ! See Sailor & Vasireddy (2006) EMS Eq 1,2 (theirs is hourly timestep)
532  gamma1 = merge(1, 0, (basethdd - temp_c) >= 0)
533  gamma2 = merge(1, 0, (temp_c - basethdd) >= 0)
534 
535  ! HDD(id,1)=HDD(id,1) + gamma1*(BaseTHDD-Temp_C) !Heating
536  ! HDD(id,2)=HDD(id,2) + gamma2*(Temp_C-BaseTHDD) !Cooling
537  ! HDD(id,3)=HDD(id,3) + Temp_C !Will become daily average temperature
538  ! ! 4 ------------------------------------! !5-day running mean
539  ! HDD(id,5)=HDD(id,5) + Precip !Daily precip total
540  ! 6 ------------------------------------! !Days since rain
541 
542  hdd_id(1) = hdd_id(1) + gamma1*(basethdd - temp_c) !Heating
543  hdd_id(2) = hdd_id(2) + gamma2*(temp_c - basethdd) !Cooling
544  hdd_id(3) = hdd_id(3) + temp_c !Will become daily average temperature
545  ! 4 ------------------------------------! !5-day running mean
546  hdd_id(5) = hdd_id(5) + precip !Daily precip total
547  ! 6 ------------------------------------! !Days since rain
548 
549  END SUBROUTINE update_dailystate_day
550 
551  SUBROUTINE update_veg( &
552  LAImax, LAIMin, &!input
553  AlbMax_DecTr, AlbMax_EveTr, AlbMax_Grass, &
554  AlbMin_DecTr, AlbMin_EveTr, AlbMin_Grass, &
555  CapMax_dec, CapMin_dec, &
556  PorMax_dec, PorMin_dec, &
557  LAI_id, LAI_id_prev, &
558  DecidCap_id, &!inout
559  albDecTr_id, &
560  albEveTr_id, &
561  albGrass_id, &
562  porosity_id, &
563  StoreDrainPrm, &
564  deltaLAI)!output
566  IMPLICIT NONE
567 
568  ! INTEGER,INTENT(IN)::id
569  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN)::LAImax
570  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN)::LAIMin
571 
572  REAL(KIND(1d0)), INTENT(IN)::AlbMax_DecTr
573  REAL(KIND(1d0)), INTENT(IN)::AlbMax_EveTr
574  REAL(KIND(1d0)), INTENT(IN)::AlbMax_Grass
575  REAL(KIND(1d0)), INTENT(IN)::AlbMin_DecTr
576  REAL(KIND(1d0)), INTENT(IN)::AlbMin_EveTr
577  REAL(KIND(1d0)), INTENT(IN)::AlbMin_Grass
578  REAL(KIND(1d0)), INTENT(IN)::CapMax_dec
579  REAL(KIND(1d0)), INTENT(IN)::CapMin_dec
580  REAL(KIND(1d0)), INTENT(IN)::PorMax_dec
581  REAL(KIND(1d0)), INTENT(IN)::PorMin_dec
582  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN)::LAI_id, LAI_id_prev
583 
584  REAL(KIND(1d0)), INTENT(INOUT)::DecidCap_id
585  REAL(KIND(1d0)), INTENT(INOUT)::albDecTr_id
586  REAL(KIND(1d0)), INTENT(INOUT)::albEveTr_id
587  REAL(KIND(1d0)), INTENT(INOUT)::albGrass_id
588  REAL(KIND(1d0)), INTENT(INOUT)::porosity_id
589 
590  REAL(KIND(1d0)), DIMENSION(6, nsurf), INTENT(inout)::StoreDrainPrm
591 
592  REAL(KIND(1d0)), INTENT(OUT)::deltaLAI
593 
594  INTEGER::iv
595 
596  REAL(KIND(1d0))::albChangeDecTr
597  REAL(KIND(1d0))::albChangeEveTr
598  REAL(KIND(1d0))::albChangeGrass
599  REAL(KIND(1d0))::CapChange
600 
601  REAL(KIND(1d0))::deltaLAIEveTr
602  REAL(KIND(1d0))::deltaLAIGrass
603  REAL(KIND(1d0))::porChange
604  !::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
605  ! Calculate the development of vegetation cover
606  ! Albedo changes with LAI for each vegetation type
607  ! Storage capacity and porosity are updated based on DecTr LAI only (seasonal variation in Grass and EveTr assumed small)
608  ! If only LUMPS is used, set deciduous capacities to 0
609  ! QUESTION: Assume porosity Change based on GO99- Heisler?
610  deltalai = 0
611  deltalaievetr = 0
612  deltalaigrass = 0
613  capchange = 0
614  porchange = 0
615  albchangedectr = 0
616  albchangeevetr = 0
617  albchangegrass = 0
618 
619  iv = ivdecid
620  IF ((lai_id(iv) - lai_id_prev(iv)) /= 0) THEN
621  deltalai = (lai_id(iv) - lai_id_prev(iv))/(laimax(iv) - laimin(iv))
622  albchangedectr = (albmax_dectr - albmin_dectr)*deltalai
623  capchange = (capmin_dec - capmax_dec)*deltalai
624  porchange = (pormin_dec - pormax_dec)*deltalai
625  ENDIF
626 
627  iv = ivconif
628  IF ((lai_id(iv) - lai_id_prev(iv)) /= 0) THEN
629  deltalaievetr = (lai_id(iv) - lai_id_prev(iv))/(laimax(iv) - laimin(iv))
630  albchangeevetr = (albmax_evetr - albmin_evetr)*deltalaievetr !!N.B. Currently uses deltaLAI for deciduous trees only!!
631  ENDIF
632 
633  iv = ivgrass
634  IF ((lai_id(iv) - lai_id_prev(iv)) /= 0) THEN
635  deltalaigrass = (lai_id(iv) - lai_id_prev(iv))/(laimax(iv) - laimin(iv))
636  albchangegrass = (albmax_grass - albmin_grass)*deltalaigrass !!N.B. Currently uses deltaLAI for deciduous trees only!!
637  ENDIF
638 
639  iv = ivdecid
640 
641  !write(*,*) deltaLAI, deltaLAIEveTr, deltaLAIGrass
642 
643  decidcap_id = decidcap_id - capchange
644  storedrainprm(6, decidsurf) = decidcap_id !Change current storage capacity of deciduous trees
645  porosity_id = porosity_id + porchange !- changed to + by HCW 20 Aug 2015 (porosity greatest when LAI smallest)
646 
647  ! update albedo values while limiting these to valid ranges
648  albdectr_id = min(max(albdectr_id + albchangedectr, albmin_dectr), albmax_dectr)
649  albevetr_id = min(max(albevetr_id + albchangeevetr, albmin_evetr), albmax_evetr)
650  albgrass_id = min(max(albgrass_id + albchangegrass, albmin_grass), albmax_grass)
651  ! albDecTr_id = albDecTr_id + albChangeDecTr
652  ! albEveTr_id = albEveTr_id + albChangeEveTr
653  ! albGrass_id = albGrass_id + albChangeGrass
654 
655  END SUBROUTINE update_veg
656 
657  SUBROUTINE update_gddlai( &
658  id, LAICalcYes, & !input
659  lat, LAI_obs, &
660  BaseT, BaseTe, &
661  GDDFull, SDDFull, &
662  LAIMin, LAIMax, LAIPower, LAIType, &
663  LAI_id_prev, &
664  GDD_id, &!inout
665  LAI_id_next) !output
666  IMPLICIT NONE
667 
668  !------------------------------------------------------------------------------
669  ! Calculation of LAI from growing degree days
670  ! This was revised and checked on 16 Feb 2014 by LJ
671  !------------------------------------------------------------------------------
672 
673  INTEGER, INTENT(IN)::id
674  INTEGER, INTENT(IN)::LAICalcYes
675 
676  REAL(KIND(1d0)), INTENT(IN)::lat
677  REAL(KIND(1d0)), INTENT(IN)::LAI_obs
678 
679  ! --- Vegetation phenology ---------------------------------------------------------------------
680  ! Parameters provided in input information for each vegetation surface (SUEWS_Veg.txt)
681  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) :: BaseT !Base temperature for growing degree days [degC]
682  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) :: BaseTe !Base temperature for senescence degree days [degC]
683  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) :: GDDFull !Growing degree days needed for full capacity [degC]
684  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) :: SDDFull !Senescence degree days needed to initiate leaf off [degC]
685  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) :: LAIMin !Min LAI [m2 m-2]
686  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) :: LAIMax !Max LAI [m2 m-2]
687  REAL(KIND(1d0)), DIMENSION(4, nvegsurf), INTENT(IN):: LAIPower !Coeffs for LAI equation: 1,2 - leaf growth; 3,4 - leaf off
688  !! N.B. currently DecTr only, although input provided for all veg types
689  INTEGER, DIMENSION(nvegsurf), INTENT(IN):: LAIType !LAI equation to use: original (0) or new (1)
690 
691  REAL(KIND(1d0)), DIMENSION(5), INTENT(INOUT) :: GDD_id !Growing Degree Days (see SUEWS_DailyState.f95)
692  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(OUT):: LAI_id_next !LAI for each veg surface [m2 m-2]
693  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN)::LAI_id_prev ! LAI of previous day
694 
695  REAL(KIND(1d0)):: no !Switches and checks for GDD
696  REAL(KIND(1d0))::yes !Switches and checks for GDD
697  REAL(KIND(1d0))::indHelp !Switches and checks for GDD
698  REAL(KIND(1d0)), DIMENSION(5)::GDD_id_prev ! GDD of previous day
699 
700  INTEGER:: critDays
701  INTEGER::iv
702 
703  ! translate values of previous day to local variables
704  gdd_id_prev = gdd_id
705  ! LAI_id_prev = LAI_id_next
706 
707  critdays = 50 !Critical limit for GDD when GDD or SDD is set to zero
708 
709  ! Loop through vegetation types (iv)
710  DO iv = 1, nvegsurf
711  ! Calculate GDD for each day from the minimum and maximum air temperature
712  yes = ((gdd_id_prev(3) + gdd_id_prev(4))/2 - baset(iv)) !Leaf on
713  no = ((gdd_id_prev(3) + gdd_id_prev(4))/2 - basete(iv)) !Leaf off
714 
715  indhelp = 0 !Help switch to allow GDD to go to zero in sprint-time !! QUESTION: What does this mean? HCW
716 
717  IF (yes < 0) THEN !GDD cannot be negative
718  indhelp = yes !Amount of negative GDD
719  yes = 0
720  ENDIF
721 
722  IF (no > 0) no = 0 !SDD cannot be positive
723 
724  ! Calculate cumulative growing and senescence degree days
725  gdd_id(1) = gdd_id_prev(1) + yes
726  gdd_id(2) = gdd_id_prev(2) + no
727 
728  ! Possibility for cold spring
729  IF (gdd_id(2) <= sddfull(iv) .AND. indhelp < 0) THEN
730  gdd_id(1) = 0
731  ENDIF
732 
733  IF (gdd_id(1) >= gddfull(iv)) THEN !Start senescence
734  gdd_id(1) = gddfull(iv) !Leaves should not grow so delete yes from earlier
735  IF (gdd_id(2) < -critdays) gdd_id(1) = 0
736  ENDIF
737 
738  IF (gdd_id(2) <= sddfull(iv)) THEN !After senescence now start growing leaves
739  gdd_id(2) = sddfull(iv) !Leaves off so add back earlier
740  IF (gdd_id(1) > critdays) gdd_id(2) = 0
741  ENDIF
742 
743  ! With these limits SDD, GDD is set to zero
744  IF (gdd_id(2) < -critdays .AND. gdd_id(2) > sddfull(iv)) gdd_id(1) = 0
745  IF (gdd_id(1) > critdays .AND. gdd_id(1) < gddfull(iv)) gdd_id(2) = 0
746 
747  ! Now calculate LAI itself
748  IF (lat >= 0) THEN !Northern hemispere
749  !If SDD is not zero by mid May, this is forced
750  IF (id == 140 .AND. gdd_id(2) /= 0) gdd_id(2) = 0
751  ! Set SDD to zero in summer time
752  IF (gdd_id(1) > critdays .AND. id < 170) gdd_id(2) = 0
753  ! Set GDD zero in winter time
754  IF (gdd_id(2) < -critdays .AND. id > 170) gdd_id(1) = 0
755 
756  IF (laitype(iv) < 0.5) THEN !Original LAI type
757  IF (gdd_id(1) > 0 .AND. gdd_id(1) < gddfull(iv)) THEN !Leaves can still grow
758  lai_id_next(iv) = (lai_id_prev(iv)**laipower(1, iv)*gdd_id(1)*laipower(2, iv)) + lai_id_prev(iv)
759  ELSEIF (gdd_id(2) < 0 .AND. gdd_id(2) > sddfull(iv)) THEN !Start senescence
760  lai_id_next(iv) = (lai_id_prev(iv)**laipower(3, iv)*gdd_id(2)*laipower(4, iv)) + lai_id_prev(iv)
761  ELSE
762  lai_id_next(iv) = lai_id_prev(iv)
763  ENDIF
764  ELSEIF (laitype(iv) >= 0.5) THEN
765  IF (gdd_id(1) > 0 .AND. gdd_id(1) < gddfull(iv)) THEN !Leaves can still grow
766  lai_id_next(iv) = (lai_id_prev(iv)**laipower(1, iv)*gdd_id(1)*laipower(2, iv)) + lai_id_prev(iv)
767  !! Use day length to start senescence at high latitudes (N hemisphere)
768  ELSEIF (gdd_id(5) <= 12 .AND. gdd_id(2) > sddfull(iv)) THEN !Start senescence
769  lai_id_next(iv) = (lai_id_prev(iv)*laipower(3, iv)*(1 - gdd_id(2))*laipower(4, iv)) + lai_id_prev(iv)
770  ELSE
771  lai_id_next(iv) = lai_id_prev(iv)
772  ENDIF
773  ENDIF
774 
775  ELSEIF (lat < 0) THEN !Southern hemisphere !! N.B. not identical to N hemisphere - return to later
776  !If SDD is not zero by late Oct, this is forced
777  IF (id == 300 .AND. gdd_id(2) /= 0) gdd_id(2) = 0
778  ! Set SDD to zero in summer time
779  IF (gdd_id(1) > critdays .AND. id > 250) gdd_id(2) = 0
780  ! Set GDD zero in winter time
781  IF (gdd_id(2) < -critdays .AND. id < 250) gdd_id(1) = 0
782 
783  IF (laitype(iv) < 0.5) THEN !Original LAI type
784  IF (gdd_id(1) > 0 .AND. gdd_id(1) < gddfull(iv)) THEN
785  lai_id_next(iv) = (lai_id_prev(iv)**laipower(1, iv)*gdd_id(1)*laipower(2, iv)) + lai_id_prev(iv)
786  ELSEIF (gdd_id(2) < 0 .AND. gdd_id(2) > sddfull(iv)) THEN
787  lai_id_next(iv) = (lai_id_prev(iv)**laipower(3, iv)*gdd_id(2)*laipower(4, iv)) + lai_id_prev(iv)
788  ELSE
789  lai_id_next(iv) = lai_id_prev(iv)
790  ENDIF
791  ELSE
792  IF (gdd_id(1) > 0 .AND. gdd_id(1) < gddfull(iv)) THEN
793  lai_id_next(iv) = (lai_id_prev(iv)**laipower(1, iv)*gdd_id(1)*laipower(2, iv)) + lai_id_prev(iv)
794  !! Day length not used to start senescence in S hemisphere (not much land)
795  ELSEIF (gdd_id(2) < 0 .AND. gdd_id(2) > sddfull(iv)) THEN
796  lai_id_next(iv) = (lai_id_prev(iv)*laipower(3, iv)*(1 - gdd_id(2))*laipower(4, iv)) + lai_id_prev(iv)
797  ELSE
798  lai_id_next(iv) = lai_id_prev(iv)
799  ENDIF
800  ENDIF
801  ENDIF !N or S hemisphere
802 
803  ! Check LAI within limits; if not set to limiting value
804  IF (lai_id_next(iv) > laimax(iv)) THEN
805  lai_id_next(iv) = laimax(iv)
806  ELSEIF (lai_id_next(iv) < laimin(iv)) THEN
807  lai_id_next(iv) = laimin(iv)
808  ENDIF
809 
810  ENDDO !End of loop over veg surfaces
811 
812  IF (laicalcyes == 0) THEN ! moved to SUEWS_cal_DailyState, TS 18 Sep 2017
813  ! LAI(id-1,:)=LAI_obs ! check -- this is going to be a problem as it is not for each vegetation class
814  lai_id_next = lai_obs
815  ENDIF
816  !------------------------------------------------------------------------------
817 
818  END SUBROUTINE update_gddlai
819 
820  SUBROUTINE update_gddlai_x( &
821  id, LAICalcYes, & !input
822  lat, LAI_obs, &
823  Tmin_id_prev, Tmax_id_prev, lenDay_id_prev, &
824  BaseT, BaseTe, &
825  GDDFull, SDDFull, &
826  LAIMin, LAIMax, LAIPower, LAIType, &
827  LAI_id_prev, &
828  GDD_id, SDD_id, &!inout
829  LAI_id_next) !output
830  IMPLICIT NONE
831 
832  !------------------------------------------------------------------------------
833  ! Calculation of LAI from growing degree days
834  ! This was revised and checked on 16 Feb 2014 by LJ
835  !------------------------------------------------------------------------------
836 
837  INTEGER, INTENT(IN)::id
838  INTEGER, INTENT(IN)::LAICalcYes
839 
840  REAL(KIND(1d0)), INTENT(IN)::lat
841  REAL(KIND(1d0)), INTENT(IN)::LAI_obs
842  REAL(KIND(1d0)), INTENT(IN)::Tmin_id_prev
843  REAL(KIND(1d0)), INTENT(IN)::Tmax_id_prev
844  REAL(KIND(1d0)), INTENT(IN)::lenDay_id_prev
845 
846  ! --- Vegetation phenology ---------------------------------------------------------------------
847  ! Parameters provided in input information for each vegetation surface (SUEWS_Veg.txt)
848  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) :: BaseT !Base temperature for growing degree days [degC]
849  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) :: BaseTe !Base temperature for senescence degree days [degC]
850  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) :: GDDFull !Growing degree days needed for full capacity [degC]
851  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) :: SDDFull !Senescence degree days needed to initiate leaf off [degC]
852  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) :: LAIMin !Min LAI [m2 m-2]
853  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN) :: LAIMax !Max LAI [m2 m-2]
854  REAL(KIND(1d0)), DIMENSION(4, nvegsurf), INTENT(IN):: LAIPower !Coeffs for LAI equation: 1,2 - leaf growth; 3,4 - leaf off
855  !! N.B. currently DecTr only, although input provided for all veg types
856  INTEGER, DIMENSION(nvegsurf), INTENT(IN):: LAIType !LAI equation to use: original (0) or new (1)
857 
858  REAL(KIND(1d0)), DIMENSION(3), INTENT(INOUT) :: GDD_id !Growing Degree Days (see SUEWS_DailyState.f95)
859  REAL(KIND(1d0)), DIMENSION(3), INTENT(INOUT) :: SDD_id !Senescence Degree Days (see SUEWS_DailyState.f95)
860  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(OUT):: LAI_id_next !LAI for each veg surface [m2 m-2]
861  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN)::LAI_id_prev ! LAI of previous day
862 
863  REAL(KIND(1d0)):: no !Switches and checks for GDD
864  REAL(KIND(1d0))::yes !Switches and checks for GDD
865  REAL(KIND(1d0))::indHelp !Switches and checks for GDD
866  REAL(KIND(1d0)), DIMENSION(3)::GDD_id_prev ! GDD of previous day
867  REAL(KIND(1d0)), DIMENSION(3)::SDD_id_prev ! SDD of previous day
868 
869  INTEGER:: critDays
870  INTEGER::iv
871 
872  ! translate values of previous day to local variables
873  gdd_id_prev = gdd_id
874  sdd_id_prev = sdd_id
875  ! LAI_id_prev = LAI_id_next
876 
877  critdays = 50 !Critical limit for GDD when GDD or SDD is set to zero
878 
879  ! Loop through vegetation types (iv)
880  DO iv = 1, nvegsurf
881  ! Calculate GDD for each day from the minimum and maximum air temperature
882  yes = ((tmin_id_prev + tmax_id_prev)/2 - baset(iv)) !Leaf on
883  no = ((tmin_id_prev + tmax_id_prev)/2 - basete(iv)) !Leaf off
884 
885  indhelp = 0 !Help switch to allow GDD to go to zero in sprint-time !! QUESTION: What does this mean? HCW
886 
887  IF (yes < 0) THEN !GDD cannot be negative
888  indhelp = yes !Amount of negative GDD
889  yes = 0
890  ENDIF
891 
892  IF (no > 0) no = 0 !SDD cannot be positive
893 
894  ! Calculate cumulative growing and senescence degree days
895  gdd_id(iv) = gdd_id_prev(iv) + yes
896  sdd_id(iv) = sdd_id_prev(iv) + no
897 
898  ! Possibility for cold spring
899  IF (sdd_id(iv) <= sddfull(iv) .AND. indhelp < 0) THEN
900  gdd_id(iv) = 0
901  ENDIF
902 
903  IF (gdd_id(iv) >= gddfull(iv)) THEN !Start senescence
904  gdd_id(iv) = gddfull(iv) !Leaves should not grow so delete yes from earlier
905  IF (sdd_id(iv) < -critdays) gdd_id(iv) = 0
906  ENDIF
907 
908  IF (sdd_id(iv) <= sddfull(iv)) THEN !After senescence now start growing leaves
909  sdd_id(iv) = sddfull(iv) !Leaves off so add back earlier
910  IF (gdd_id(iv) > critdays) sdd_id(iv) = 0
911  ENDIF
912 
913  ! With these limits SDD, GDD is set to zero
914  IF (sdd_id(iv) < -critdays .AND. sdd_id(iv) > sddfull(iv)) gdd_id(iv) = 0
915  IF (gdd_id(iv) > critdays .AND. gdd_id(iv) < gddfull(iv)) sdd_id(iv) = 0
916 
917  ! Now calculate LAI itself
918  IF (lat >= 0) THEN !Northern hemispere
919  !If SDD is not zero by mid May, this is forced
920  IF (id == 140 .AND. sdd_id(iv) /= 0) sdd_id(iv) = 0
921  ! Set SDD to zero in summer time
922  IF (gdd_id(iv) > critdays .AND. id < 170) sdd_id(iv) = 0
923  ! Set GDD zero in winter time
924  IF (sdd_id(iv) < -critdays .AND. id > 170) gdd_id(iv) = 0
925 
926  IF (laitype(iv) < 0.5) THEN !Original LAI type
927  IF (gdd_id(iv) > 0 .AND. gdd_id(iv) < gddfull(iv)) THEN !Leaves can still grow
928  lai_id_next(iv) = (lai_id_prev(iv)**laipower(1, iv)*gdd_id(iv)*laipower(2, iv)) + lai_id_prev(iv)
929  ELSEIF (sdd_id(iv) < 0 .AND. sdd_id(iv) > sddfull(iv)) THEN !Start senescence
930  lai_id_next(iv) = (lai_id_prev(iv)**laipower(3, iv)*sdd_id(iv)*laipower(4, iv)) + lai_id_prev(iv)
931  ELSE
932  lai_id_next(iv) = lai_id_prev(iv)
933  ENDIF
934  ELSEIF (laitype(iv) >= 0.5) THEN
935  IF (gdd_id(iv) > 0 .AND. gdd_id(iv) < gddfull(iv)) THEN !Leaves can still grow
936  lai_id_next(iv) = (lai_id_prev(iv)**laipower(1, iv)*gdd_id(iv)*laipower(2, iv)) + lai_id_prev(iv)
937  !! Use day length to start senescence at high latitudes (N hemisphere)
938  ELSEIF (lenday_id_prev <= 12 .AND. sdd_id(iv) > sddfull(iv)) THEN !Start senescence
939  lai_id_next(iv) = (lai_id_prev(iv)*laipower(3, iv)*(1 - sdd_id(iv))*laipower(4, iv)) + lai_id_prev(iv)
940  ELSE
941  lai_id_next(iv) = lai_id_prev(iv)
942  ENDIF
943  ENDIF
944 
945  ELSEIF (lat < 0) THEN !Southern hemisphere !! N.B. not identical to N hemisphere - return to later
946  !If SDD is not zero by late Oct, this is forced
947  IF (id == 300 .AND. sdd_id(iv) /= 0) sdd_id(iv) = 0
948  ! Set SDD to zero in summer time
949  IF (gdd_id(iv) > critdays .AND. id > 250) sdd_id(iv) = 0
950  ! Set GDD zero in winter time
951  IF (sdd_id(iv) < -critdays .AND. id < 250) gdd_id(iv) = 0
952 
953  IF (laitype(iv) < 0.5) THEN !Original LAI type
954  IF (gdd_id(iv) > 0 .AND. gdd_id(iv) < gddfull(iv)) THEN
955  lai_id_next(iv) = (lai_id_prev(iv)**laipower(1, iv)*gdd_id(iv)*laipower(2, iv)) + lai_id_prev(iv)
956  ELSEIF (sdd_id(iv) < 0 .AND. sdd_id(iv) > sddfull(iv)) THEN
957  lai_id_next(iv) = (lai_id_prev(iv)**laipower(3, iv)*sdd_id(iv)*laipower(4, iv)) + lai_id_prev(iv)
958  ELSE
959  lai_id_next(iv) = lai_id_prev(iv)
960  ENDIF
961  ELSE
962  IF (gdd_id(iv) > 0 .AND. gdd_id(iv) < gddfull(iv)) THEN
963  lai_id_next(iv) = (lai_id_prev(iv)**laipower(1, iv)*gdd_id(iv)*laipower(2, iv)) + lai_id_prev(iv)
964  !! Day length not used to start senescence in S hemisphere (not much land)
965  ELSEIF (sdd_id(iv) < 0 .AND. sdd_id(iv) > sddfull(iv)) THEN
966  lai_id_next(iv) = (lai_id_prev(iv)*laipower(3, iv)*(1 - sdd_id(iv))*laipower(4, iv)) + lai_id_prev(iv)
967  ELSE
968  lai_id_next(iv) = lai_id_prev(iv)
969  ENDIF
970  ENDIF
971  ENDIF !N or S hemisphere
972 
973  ! Check LAI within limits; if not set to limiting value
974  IF (lai_id_next(iv) > laimax(iv)) THEN
975  lai_id_next(iv) = laimax(iv)
976  ELSEIF (lai_id_next(iv) < laimin(iv)) THEN
977  lai_id_next(iv) = laimin(iv)
978  ENDIF
979 
980  ENDDO !End of loop over veg surfaces
981 
982  IF (laicalcyes == 0) THEN ! moved to SUEWS_cal_DailyState, TS 18 Sep 2017
983  ! LAI(id-1,:)=LAI_obs ! check -- this is going to be a problem as it is not for each vegetation class
984  lai_id_next = lai_obs
985  ENDIF
986  !------------------------------------------------------------------------------
987 
988  END SUBROUTINE update_gddlai_x
989 
990  SUBROUTINE update_wateruse( &
991  id, WaterUseMethod, DayofWeek_id, lat, Faut, HDD_id, &!input
992  Ie_a, Ie_m, Ie_start, Ie_end, DayWatPer, DayWat, &
993  WUDay_id) !output
995  IMPLICIT NONE
996 
997  INTEGER, INTENT(IN) :: id
998  INTEGER, INTENT(IN) :: WaterUseMethod
999  INTEGER, INTENT(IN)::Ie_start !Starting time of water use (DOY)
1000  INTEGER, INTENT(IN)::Ie_end !Ending time of water use (DOY)
1001  INTEGER, DIMENSION(3), INTENT(IN)::DayofWeek_id
1002 
1003  REAL(KIND(1d0)), INTENT(IN)::lat
1004  REAL(KIND(1d0)), INTENT(IN)::Faut !Fraction of irrigated area using automatic irrigation
1005 
1006  REAL(KIND(1d0)), DIMENSION(12), INTENT(IN)::HDD_id
1007  REAL(KIND(1d0)), DIMENSION(3), INTENT(IN)::Ie_a
1008  REAL(KIND(1d0)), DIMENSION(3), INTENT(IN)::Ie_m !Coefficients for automatic and manual irrigation models
1009  REAL(KIND(1d0)), DIMENSION(7), INTENT(IN)::DayWatPer !% of houses following daily water
1010  REAL(KIND(1d0)), DIMENSION(7), INTENT(IN)::DayWat !Days of watering allowed
1011 
1012  REAL(KIND(1d0)), DIMENSION(9), INTENT(OUT):: WUDay_id !Daily water use for EveTr, DecTr, Grass [mm] (see SUEWS_DailyState.f95)
1013 
1014  INTEGER::wd !Water use calculation is done when calc = 1
1015  INTEGER::calc !Water use calculation is done when calc = 1
1016 
1017  REAL(KIND(1d0))::temp_avg
1018  REAL(KIND(1d0))::days_since_rain
1019 
1020  ! transfer HDD values
1021  temp_avg = hdd_id(9)
1022  days_since_rain = hdd_id(12)
1023 
1024  ! initialise WUDay_id
1025  wuday_id = 0
1026 
1027  IF (waterusemethod == 0) THEN !If water use is to be modelled (rather than observed)
1028 
1029  wd = dayofweek_id(1)
1030 
1031  IF (daywat(wd) == 1.0) THEN !1 indicates watering permitted on this day
1032  calc = 0
1033  IF (lat >= 0) THEN !Northern Hemisphere
1034  IF (id >= ie_start - 1 .AND. id <= ie_end + 1) calc = 1 !Day between irrigation period
1035  ELSE !Southern Hemisphere
1036  calc = 1
1037  IF (id >= ie_end .AND. id <= ie_start) calc = 0 !Day between irrigation period
1038  ENDIF
1039 
1040  IF (calc == 1) THEN
1041  ! Model daily water use based on days_since_rain (days since rain) and temp_avg (average temp)
1042  ! WUDay is the amount of water [mm] per day, applied to each of the irrigated areas
1043  ! N.B. These are the same for each vegetation type at the moment
1044 
1045  ! ---- Automatic irrigation (evergreen trees) ----
1046  wuday_id(2) = faut*(ie_a(1) + ie_a(2)*temp_avg + ie_a(3)*days_since_rain)*daywatper(wd)
1047  IF (wuday_id(2) < 0) wuday_id(2) = 0 !If modelled WU is negative -> 0
1048 
1049  ! ---- Manual irrigation (evergreen trees) ----
1050  wuday_id(3) = (1 - faut)*(ie_m(1) + ie_m(2)*temp_avg + ie_m(3)*days_since_rain)*daywatper(wd)
1051  IF (wuday_id(3) < 0) wuday_id(3) = 0 !If modelled WU is negative -> 0
1052 
1053  ! ---- Total evergreen trees water use (automatic + manual) ----
1054  wuday_id(1) = (wuday_id(2) + wuday_id(3))
1055 
1056  ! ---- Automatic irrigation (deciduous trees) ----
1057  wuday_id(5) = faut*(ie_a(1) + ie_a(2)*temp_avg + ie_a(3)*days_since_rain)*daywatper(wd)
1058  IF (wuday_id(5) < 0) wuday_id(5) = 0 !If modelled WU is negative -> 0
1059 
1060  ! ---- Manual irrigation (deciduous trees) ----
1061  wuday_id(6) = (1 - faut)*(ie_m(1) + ie_m(2)*temp_avg + ie_m(3)*days_since_rain)*daywatper(wd)
1062  IF (wuday_id(6) < 0) wuday_id(6) = 0 !If modelled WU is negative -> 0
1063 
1064  ! ---- Total deciduous trees water use (automatic + manual) ----
1065  wuday_id(4) = (wuday_id(5) + wuday_id(6))
1066 
1067  ! ---- Automatic irrigation (grass) ----
1068  wuday_id(8) = faut*(ie_a(1) + ie_a(2)*temp_avg + ie_a(3)*days_since_rain)*daywatper(wd)
1069  IF (wuday_id(8) < 0) wuday_id(8) = 0 !If modelled WU is negative -> 0
1070 
1071  ! ---- Manual irrigation (grass) ----
1072  wuday_id(9) = (1 - faut)*(ie_m(1) + ie_m(2)*temp_avg + ie_m(3)*days_since_rain)*daywatper(wd)
1073  IF (wuday_id(9) < 0) wuday_id(9) = 0 !If modelled WU is negative -> 0
1074 
1075  ! ---- Total grass water use (automatic + manual) ----
1076  wuday_id(7) = (wuday_id(8) + wuday_id(9))
1077 
1078  ELSE !If no irrigation on this day
1079  wuday_id(1) = 0
1080  wuday_id(2) = 0
1081  wuday_id(3) = 0
1082  wuday_id(4) = 0
1083  wuday_id(5) = 0
1084  wuday_id(6) = 0
1085  wuday_id(7) = 0
1086  wuday_id(8) = 0
1087  wuday_id(9) = 0
1088  ENDIF
1089  ENDIF
1090  ENDIF
1091 
1092  END SUBROUTINE update_wateruse
1093 
1094  SUBROUTINE update_hdd( &
1095  dt_since_start, it, imin, tstep, & !input
1096  HDD_id)!inout
1097  IMPLICIT NONE
1098  INTEGER, INTENT(IN)::dt_since_start, it, imin, tstep
1099 
1100  REAL(KIND(1d0)), DIMENSION(12), INTENT(INOUT):: HDD_id
1101  ! REAL(KIND(1d0)),DIMENSION(6),INTENT(OUT):: HDD_id_use
1102 
1103  INTEGER:: days_prev
1104  REAL(KIND(1d0))::tstepcount
1105 
1106  ! count of timesteps performed during day `id`
1107  tstepcount = (it*60 + imin)*60/tstep*1.
1108  ! Heating degree days (HDD) -------------
1109  hdd_id(1) = hdd_id(1)/tstepcount !Heating
1110  hdd_id(2) = hdd_id(2)/tstepcount !Cooling
1111  hdd_id(3) = hdd_id(3)/tstepcount !Average temp
1112 
1113  ! Calculate a quasi-5-day-running-mean temp
1114  days_prev = min(4, & ! dt_since_start >= 4 days
1115  floor(dt_since_start/(24*60*60)*1.)) ! dt_since_start < 4 days
1116  hdd_id(4) = (hdd_id(4)*days_prev + hdd_id(3))/(days_prev + 1)
1117 
1118  ! Calculate number of days since rain
1119  IF (hdd_id(5) > 0) THEN !Rain occurred
1120  hdd_id(6) = 0
1121  ELSE
1122  hdd_id(6) = hdd_id(6) + 1 !Days since rain
1123  ENDIF
1124 
1125  ! save updated HDD_id(1:6) values to the last-half part (i.e., HDD_id(7:12))
1126  hdd_id(6 + 1:6 + 6) = hdd_id(1:6)
1127 
1128  END SUBROUTINE update_hdd
1129 
1130  SUBROUTINE update_dailystate_start( &
1131  it, imin, &!input
1132  HDD_id)!output
1133  IMPLICIT NONE
1134  INTEGER, INTENT(IN) :: it
1135  INTEGER, INTENT(IN) ::imin
1136 
1137  REAL(KIND(1d0)), DIMENSION(6), INTENT(INOUT) ::HDD_id
1138  REAL(KIND(1d0))::HDD_id_mav, HDD_id_daysSR
1139 
1140  ! reset HDD_id to ZERO except for:
1141  ! 5-day moving average
1142  hdd_id_mav = hdd_id(4)
1143  ! Days Since Rain
1144  hdd_id_dayssr = hdd_id(6)
1145  IF (it == 0 .AND. imin == 0) THEN
1146  hdd_id = 0
1147  hdd_id(4) = hdd_id_mav
1148  hdd_id(6) = hdd_id_dayssr
1149  END IF
1150 
1151  END SUBROUTINE update_dailystate_start
1152 
1153  SUBROUTINE suews_update_dailystate( &
1154  id, datetimeline, &!input
1155  Gridiv, NumberOfGrids, &
1156  DailyStateLine, &
1157  dataOutDailyState)!inout
1159  IMPLICIT NONE
1160 
1161  ! INTEGER,INTENT(IN) ::iy
1162  INTEGER, INTENT(IN) ::id
1163  ! INTEGER,INTENT(IN) ::it
1164  ! INTEGER,INTENT(IN) ::imin
1165 
1166  REAL(KIND(1d0)), DIMENSION(5), INTENT(IN)::datetimeline
1167 
1168  INTEGER, INTENT(IN)::Gridiv
1169  INTEGER, INTENT(IN)::NumberOfGrids
1170  REAL(KIND(1d0)), DIMENSION(ncolumnsDataOutDailyState - 5), INTENT(IN) :: DailyStateLine
1171  REAL(KIND(1d0)), DIMENSION(ndays, ncolumnsDataOutDailyState, NumberOfGrids), INTENT(INOUT):: dataOutDailyState
1172 
1173  ! write out to dataOutDailyState
1174  dataoutdailystate(id, 1:5, gridiv) = datetimeline
1175  ! DailyStateLine will be -999 unless realistic values are calculated at the last timestep of each day
1176  dataoutdailystate(id, 6:ncolumnsdataoutdailystate, gridiv) = dailystateline
1177 
1178  END SUBROUTINE suews_update_dailystate
1179 
1180  ! transfer results to a one-line output for SUEWS_cal_DailyState
1181  SUBROUTINE update_dailystateline( &
1182  it, imin, nsh_real, &!input
1183  GDD_id, HDD_id, LAI_id, &
1184  SDD_id, &
1185  Tmin_id, Tmax_id, lenday_id, &
1186  DecidCap_id, &
1187  albDecTr_id, &
1188  albEveTr_id, &
1189  albGrass_id, &
1190  porosity_id, &
1191  WUDay_id, &
1192  deltaLAI, VegPhenLumps, &
1193  SnowAlb, SnowDens, &
1194  a1, a2, a3, &
1195  DailyStateLine)!out
1197  IMPLICIT NONE
1198 
1199  ! INTEGER,INTENT(IN) ::iy
1200  ! INTEGER,INTENT(IN) ::id
1201  INTEGER, INTENT(IN) ::it
1202  INTEGER, INTENT(IN) ::imin
1203  REAL(KIND(1d0)), INTENT(IN) ::nsh_real
1204 
1205  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN):: GDD_id !Growing Degree Days (see SUEWS_DailyState.f95)
1206  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN):: SDD_id !Growing Degree Days (see SUEWS_DailyState.f95)
1207  REAL(KIND(1d0)), DIMENSION(6), INTENT(IN):: HDD_id !Heating Degree Days (see SUEWS_DailyState.f95)
1208  REAL(KIND(1d0)), DIMENSION(nvegsurf), INTENT(IN):: LAI_id !LAI for each veg surface [m2 m-2]
1209 
1210  REAL(KIND(1d0)), INTENT(IN) ::DecidCap_id
1211  REAL(KIND(1d0)), INTENT(IN) ::albDecTr_id
1212  REAL(KIND(1d0)), INTENT(IN) ::albEveTr_id
1213  REAL(KIND(1d0)), INTENT(IN) ::albGrass_id
1214  REAL(KIND(1d0)), INTENT(IN) ::porosity_id
1215  REAL(KIND(1d0)), INTENT(IN) ::Tmin_id
1216  REAL(KIND(1d0)), INTENT(IN) ::Tmax_id
1217  REAL(KIND(1d0)), INTENT(IN) ::lenday_id
1218  REAL(KIND(1d0)), DIMENSION(9), INTENT(IN):: WUDay_id !Daily water use for EveTr, DecTr, Grass [mm] (see SUEWS_DailyState.f95)
1219 
1220  REAL(KIND(1d0)), INTENT(IN) ::deltaLAI
1221  REAL(KIND(1d0)), INTENT(IN) ::VegPhenLumps
1222  REAL(KIND(1d0)), INTENT(IN) ::SnowAlb
1223  REAL(KIND(1d0)), DIMENSION(7), INTENT(IN)::SnowDens
1224  REAL(KIND(1d0)), INTENT(IN) ::a1
1225  REAL(KIND(1d0)), INTENT(IN) ::a2
1226  REAL(KIND(1d0)), INTENT(IN) ::a3
1227 
1228  REAL(KIND(1d0)), DIMENSION(ncolumnsDataOutDailyState - 5), INTENT(OUT) :: DailyStateLine
1229 
1230  ! initialise DailyStateLine
1231  dailystateline = -999
1232  IF (it == 23 .AND. imin == (nsh_real - 1)/nsh_real*60) THEN
1233  ! Write actual data only at the last timesstep of each day
1234  ! DailyStateLine(1:2) = [iy,id]
1235  ! DailyStateLine(1:6) = HDD_id
1236  ! DailyStateLine(6 + 1:6 + 5) = GDD_id
1237  ! DailyStateLine(11 + 1:11 + 3) = LAI_id
1238  ! DailyStateLine(14 + 1:14 + 5) = [DecidCap_id, Porosity_id, AlbEveTr_id, AlbDecTr_id, AlbGrass_id]
1239  ! DailyStateLine(19 + 1:19 + 9) = WUDay_id(1:9)
1240  ! DailyStateLine(28 + 1) = deltaLAI
1241  ! DailyStateLine(29 + 1) = VegPhenLumps
1242  ! DailyStateLine(30 + 1:30 + 8) = [SnowAlb, SnowDens(1:7)]
1243  ! DailyStateLine(38 + 1:38 + 3) = [a1, a2, a3]
1244  dailystateline = [hdd_id, gdd_id, sdd_id, tmin_id, tmax_id, lenday_id, lai_id, decidcap_id, porosity_id, &
1245  albevetr_id, albdectr_id, albgrass_id, wuday_id, deltalai, vegphenlumps, snowalb, snowdens, &
1246  a1, a2, a3]
1247 
1248  END IF
1249 
1250  END SUBROUTINE update_dailystateline
1251 
1252 END MODULE dailystate_module
subroutine update_gddlai(id, LAICalcYes, lat, LAI_obs, BaseT, BaseTe, GDDFull, SDDFull, LAIMin, LAIMax, LAIPower, LAIType, LAI_id_prev, GDD_id, LAI_id_next)
integer, parameter ivgrass
subroutine suews_cal_dailystate(iy, id, it, imin, isec, tstep, tstep_prev, dt_since_start, DayofWeek_id, Tmin_id_prev, Tmax_id_prev, lenDay_id_prev, WaterUseMethod, Ie_start, Ie_end, LAICalcYes, LAIType, nsh_real, avkdn, Temp_C, Precip, BaseTHDD, lat, Faut, LAI_obs, AlbMax_DecTr, AlbMax_EveTr, AlbMax_Grass, AlbMin_DecTr, AlbMin_EveTr, AlbMin_Grass, CapMax_dec, CapMin_dec, PorMax_dec, PorMin_dec, Ie_a, Ie_m, DayWatPer, DayWat, BaseT, BaseTe, GDDFull, SDDFull, LAIMin, LAIMax, LAIPower, DecidCap_id_prev, StoreDrainPrm_prev, LAI_id_prev, GDD_id_prev, SDD_id_prev, albDecTr_id_prev, albEveTr_id_prev, albGrass_id_prev, porosity_id_prev, HDD_id_prev, HDD_id_next, Tmin_id_next, Tmax_id_next, lenDay_id_next, albDecTr_id_next, albEveTr_id_next, albGrass_id_next, porosity_id_next, DecidCap_id_next, StoreDrainPrm_next, LAI_id_next, GDD_id_next, SDD_id_next, deltaLAI, WUDay_id)
integer, parameter ncolumnsdataoutdailystate
subroutine update_dailystate_day(avkdn, Temp_C, Precip, BaseTHDD, nsh_real, Tmin_id, Tmax_id, lenDay_id, HDD_id)
subroutine update_gddlai_x(id, LAICalcYes, lat, LAI_obs, Tmin_id_prev, Tmax_id_prev, lenDay_id_prev, BaseT, BaseTe, GDDFull, SDDFull, LAIMin, LAIMax, LAIPower, LAIType, LAI_id_prev, GDD_id, SDD_id, LAI_id_next)
subroutine suews_update_dailystate(id, datetimeline, Gridiv, NumberOfGrids, DailyStateLine, dataOutDailyState)
integer, parameter nsurf
integer, parameter ndays
subroutine update_dailystateline(it, imin, nsh_real, GDD_id, HDD_id, LAI_id, SDD_id, Tmin_id, Tmax_id, lenday_id, DecidCap_id, albDecTr_id, albEveTr_id, albGrass_id, porosity_id, WUDay_id, deltaLAI, VegPhenLumps, SnowAlb, SnowDens, a1, a2, a3, DailyStateLine)
subroutine update_veg(LAImax, LAIMin, AlbMax_DecTr, AlbMax_EveTr, AlbMax_Grass, AlbMin_DecTr, AlbMin_EveTr, AlbMin_Grass, CapMax_dec, CapMin_dec, PorMax_dec, PorMin_dec, LAI_id, LAI_id_prev, DecidCap_id, albDecTr_id, albEveTr_id, albGrass_id, porosity_id, StoreDrainPrm, deltaLAI)
integer, parameter ivconif
subroutine update_hdd(dt_since_start, it, imin, tstep, HDD_id)
integer, parameter nvegsurf
subroutine update_dailystate_start(it, imin, HDD_id)
subroutine update_wateruse(id, WaterUseMethod, DayofWeek_id, lat, Faut, HDD_id, Ie_a, Ie_m, Ie_start, Ie_end, DayWatPer, DayWat, WUDay_id)
subroutine update_dailystate_end(id, it, imin, tstep, dt_since_start, Tmin_id, Tmax_id, lenDay_id, LAIType, Ie_end, Ie_start, LAICalcYes, WaterUseMethod, DayofWeek_id, AlbMax_DecTr, AlbMax_EveTr, AlbMax_Grass, AlbMin_DecTr, AlbMin_EveTr, AlbMin_Grass, BaseT, BaseTe, CapMax_dec, CapMin_dec, DayWat, DayWatPer, Faut, GDDFull, Ie_a, Ie_m, LAIMax, LAIMin, LAIPower, lat, PorMax_dec, PorMin_dec, SDDFull, LAI_obs, GDD_id, SDD_id, HDD_id, LAI_id, DecidCap_id, albDecTr_id, albEveTr_id, albGrass_id, porosity_id, StoreDrainPrm, WUDay_id, deltaLAI)
integer, parameter decidsurf
integer, parameter ivdecid