SUEWS API Site
Documentation of SUEWS source code
suews_ctrl_driver.f95
Go to the documentation of this file.
1!========================================================================================
2! SUEWS driver subroutines
3! TS 31 Aug 2017: initial version
4! TS 02 Oct 2017: added as the generic wrapper
5! TS 03 Oct 2017: added
7 ! only the following immutable objects are imported:
8 ! 1. functions/subroutines
9 ! 2. constant variables
10
11 USE meteo, ONLY: qsatf, rh2qa, qa2rh
15 USE anohm_module, ONLY: anohm
18 USE estm_module, ONLY: estm, estm_ext
21 USE waterdist_module, ONLY: &
27 USE ctrl_output, ONLY: varlistall
31 USE rsl_module, ONLY: rslprofile
33 USE co2_module, ONLY: co2_biogen
34 USE allocatearray, ONLY: &
42 USE moist, ONLY: avcp, avdens, lv_j_kg
46
47 IMPLICIT NONE
48
49CONTAINS
50 ! ===================MAIN CALCULATION WRAPPER FOR ENERGY AND WATER FLUX===========
51 SUBROUTINE suews_cal_main( &
52 AerodynamicResistanceMethod, AH_MIN, AHProf_24hr, AH_SLOPE_Cooling, & ! input&inout in alphabetical order
53 AH_SLOPE_Heating, &
54 alb, AlbMax_DecTr, AlbMax_EveTr, AlbMax_Grass, &
55 AlbMin_DecTr, AlbMin_EveTr, AlbMin_Grass, &
56 alpha_bioCO2, alpha_enh_bioCO2, alt, kdown, avRh, avU1, BaseT, BaseTe, &
57 BaseTMethod, &
58 BaseT_HC, beta_bioCO2, beta_enh_bioCO2, bldgH, CapMax_dec, CapMin_dec, &
59 chAnOHM, CO2PointSource, cpAnOHM, CRWmax, CRWmin, DayWat, DayWatPer, &
60 DecTreeH, DiagMethod, Diagnose, DiagQN, DiagQS, DRAINRT, &
61 dt_since_start, dqndt, qn_av, dqnsdt, qn_s_av, &
62 EF_umolCO2perJ, emis, EmissionsMethod, EnEF_v_Jkm, endDLS, EveTreeH, FAIBldg, &
63 FAIDecTree, FAIEveTree, Faut, FcEF_v_kgkm, fcld_obs, FlowChange, &
64 FrFossilFuel_Heat, FrFossilFuel_NonHeat, G1, G2, G3, G4, G5, G6, GDD_id, &
65 GDDFull, Gridiv, gsModel, H_maintain, HDD_id, HumActivity_24hr, &
66 IceFrac, id, Ie_a, Ie_end, Ie_m, Ie_start, imin, &
67 InternalWaterUse_h, &
68 IrrFracPaved, IrrFracBldgs, &
69 IrrFracEveTr, IrrFracDecTr, IrrFracGrass, &
70 IrrFracBSoil, IrrFracWater, &
71 isec, it, EvapMethod, &
72 iy, kkAnOHM, Kmax, LAI_id, LAICalcYes, LAIMax, LAIMin, LAI_obs, &
73 LAIPower, LAIType, lat, lenDay_id, ldown_obs, lng, MaxConductance, MaxFCMetab, MaxQFMetab, &
74 SnowWater, MetForcingData_grid, MinFCMetab, MinQFMetab, min_res_bioCO2, &
75 NARP_EMIS_SNOW, NARP_TRANS_SITE, NetRadiationMethod, &
76 nlayer, &
77 n_vegetation_region_urban, &
78 n_stream_sw_urban, n_stream_lw_urban, &
79 sw_dn_direct_frac, air_ext_sw, air_ssa_sw, &
80 veg_ssa_sw, air_ext_lw, air_ssa_lw, veg_ssa_lw, &
81 veg_fsd_const, veg_contact_fraction_const, &
82 ground_albedo_dir_mult_fact, use_sw_direct_albedo, & !input
83 height, building_frac, veg_frac, building_scale, veg_scale, & !input: SPARTACUS
84 alb_roof, emis_roof, alb_wall, emis_wall, &
85 roof_albedo_dir_mult_fact, wall_specular_frac, &
86 OHM_coef, OHMIncQF, OHM_threshSW, &
87 OHM_threshWD, PipeCapacity, PopDensDaytime, &
88 PopDensNighttime, PopProf_24hr, PorMax_dec, PorMin_dec, &
89 Precip, PrecipLimit, PrecipLimitAlb, Press_hPa, &
90 QF0_BEU, Qf_A, Qf_B, Qf_C, &
91 qn1_obs, qs_obs, qf_obs, &
92 RadMeltFact, RAINCOVER, RainMaxRes, resp_a, resp_b, &
93 RoughLenHeatMethod, RoughLenMomMethod, RunoffToWater, S1, S2, &
94 SatHydraulicConduct, SDDFull, SDD_id, SMDMethod, SnowAlb, SnowAlbMax, &
95 SnowAlbMin, SnowPackLimit, SnowDens, SnowDensMax, SnowDensMin, SnowfallCum, SnowFrac, &
96 SnowLimBldg, SnowLimPaved, snowFrac_obs, SnowPack, SnowProf_24hr, SnowUse, SoilDepth, &
97 StabilityMethod, startDLS, &
98 soilstore_surf, SoilStoreCap_surf, state_surf, StateLimit_surf, WetThresh_surf, &
99 soilstore_roof, SoilStoreCap_roof, state_roof, StateLimit_roof, WetThresh_roof, &
100 soilstore_wall, SoilStoreCap_wall, state_wall, StateLimit_wall, WetThresh_wall, &
101 StorageHeatMethod, StoreDrainPrm, SurfaceArea, Tair_av, tau_a, tau_f, tau_r, &
102 Tmax_id, Tmin_id, &
103 BaseT_Cooling, BaseT_Heating, Temp_C, TempMeltFact, TH, &
104 theta_bioCO2, timezone, TL, TrafficRate, TrafficUnits, &
105 sfr_surf, &
106 tsfc_roof, tsfc_wall, tsfc_surf, &
107 temp_roof, temp_wall, temp_surf, &
108 tin_roof, tin_wall, tin_surf, &
109 k_roof, k_wall, k_surf, &
110 cp_roof, cp_wall, cp_surf, &
111 dz_roof, dz_wall, dz_surf, &
112 TraffProf_24hr, Ts5mindata_ir, tstep, tstep_prev, veg_type, &
113 WaterDist, WaterUseMethod, wu_m3, &
114 WUDay_id, DecidCap_id, albDecTr_id, albEveTr_id, albGrass_id, porosity_id, &
115 WUProfA_24hr, WUProfM_24hr, xsmd, Z, z0m_in, zdm_in, &
116 datetimeLine, dataOutLineSUEWS, dataOutLineSnow, dataOutLineESTM, dataoutLineRSL, & !output
117 dataOutLineBEERS, & !output
118 dataOutLineDebug, dataOutLineSPARTACUS, &
119 dataOutLineESTMExt, &
120 DailyStateLine) !output
121
122 IMPLICIT NONE
123
124 ! ########################################################################################
125 ! input variables
126 INTEGER, INTENT(IN) :: AerodynamicResistanceMethod !method to calculate RA [-]
127 INTEGER, INTENT(IN) :: BaseTMethod ! base t method [-]
128 INTEGER, INTENT(IN) :: Diagnose ! flag for printing diagnostic info during runtime [N/A]C
129 INTEGER, INTENT(IN) :: DiagQN ! flag for printing diagnostic info for QN module during runtime [N/A]
130 INTEGER, INTENT(IN) :: DiagQS ! flag for printing diagnostic info for QS module during runtime [N/A]
131 INTEGER, INTENT(IN) :: startDLS !start of daylight saving [DOY]
132 INTEGER, INTENT(IN) :: endDLS !end of daylight saving [DOY]
133 INTEGER, INTENT(IN) :: EmissionsMethod !method to calculate anthropogenic heat [-]
134 INTEGER, INTENT(IN) :: Gridiv ! grid id [-]
135 INTEGER, INTENT(IN) :: nlayer ! number of vertical layers in urban canyon [-]
136 INTEGER, INTENT(IN) :: gsModel !choice of gs parameterisation (1 = Ja11, 2 = Wa16) [-]
137 INTEGER, INTENT(IN) :: id ! day of year, 1-366 [-]
138 INTEGER, INTENT(IN) :: Ie_end !ending time of water use [DOY]
139 INTEGER, INTENT(IN) :: Ie_start !starting time of water use [DOY]
140 INTEGER, INTENT(IN) :: isec ! seconds, 0-59 [s]
141 INTEGER, INTENT(IN) :: imin !minutes, 0-59 [min]
142 INTEGER, INTENT(IN) :: it ! hour, 0-23 [h]
143 INTEGER, INTENT(IN) :: EvapMethod ! Evaporation calculated according to Rutter (1) or Shuttleworth (2) [-]
144 INTEGER, INTENT(IN) :: iy ! year [y]
145 INTEGER, INTENT(IN) :: LAICalcYes ! boolean to determine if calculate LAI [-]
146 INTEGER, INTENT(IN) :: NetRadiationMethod ! method for calculation of radiation fluxes [-]
147 INTEGER, INTENT(IN) :: OHMIncQF ! Determines whether the storage heat flux calculation uses Q* or ( Q* +QF) [-]
148 INTEGER, INTENT(IN) :: RoughLenHeatMethod ! method to calculate heat roughness length [-]
149 INTEGER, INTENT(IN) :: RoughLenMomMethod ! Determines how aerodynamic roughness length (z0m) and zero displacement height (zdm) are calculated [-]
150 INTEGER, INTENT(IN) :: SMDMethod ! Determines method for calculating soil moisture deficit [-]
151 INTEGER, INTENT(IN) :: SnowUse ! Determines whether the snow part of the model runs[-]
152 INTEGER, INTENT(IN) :: StabilityMethod !method to calculate atmospheric stability [-]
153 INTEGER, INTENT(IN) :: StorageHeatMethod !Determines method for calculating storage heat flux ΔQS [-]
154 INTEGER, INTENT(in) :: DiagMethod !Defines how near surface diagnostics are calculated
155 INTEGER, INTENT(IN) :: tstep !timestep [s]
156 INTEGER, INTENT(IN) :: tstep_prev ! tstep size of the previous step [s]
157 INTEGER, INTENT(in) :: dt_since_start ! time since simulation starts [s]
158 INTEGER, INTENT(IN) :: veg_type !Defines how vegetation is calculated for LUMPS [-]
159 INTEGER, INTENT(IN) :: WaterUseMethod !Defines how external water use is calculated[-]
160
161 REAL(KIND(1D0)), INTENT(IN) :: AlbMax_DecTr !maximum albedo for deciduous tree and shrub [-]
162 REAL(KIND(1D0)), INTENT(IN) :: AlbMax_EveTr !maximum albedo for evergreen tree and shrub [-]
163 REAL(KIND(1D0)), INTENT(IN) :: AlbMax_Grass !maximum albedo for grass [-]
164 REAL(KIND(1D0)), INTENT(IN) :: AlbMin_DecTr !minimum albedo for deciduous tree and shrub [-]
165 REAL(KIND(1D0)), INTENT(IN) :: AlbMin_EveTr !minimum albedo for evergreen tree and shrub [-]
166 REAL(KIND(1D0)), INTENT(IN) :: AlbMin_Grass !minimum albedo for grass [-]
167 REAL(KIND(1D0)), INTENT(IN) :: alt !solar altitude [deg]
168 REAL(KIND(1D0)), INTENT(IN) :: kdown !incominging shortwave radiation [W m-2]
169 REAL(KIND(1D0)), INTENT(IN) :: avRh !relative humidity [-]
170 REAL(KIND(1D0)), INTENT(IN) :: avU1 !average wind speed at 1m [W m-1]
171 REAL(KIND(1D0)), INTENT(IN) :: BaseT_HC !base temperature for heating degree dayb [degC]
172 REAL(KIND(1D0)), INTENT(IN) :: bldgH !average building height [m]
173 REAL(KIND(1D0)), INTENT(IN) :: CapMax_dec !maximum water storage capacity for upper surfaces (i.e. canopy)
174 REAL(KIND(1D0)), INTENT(IN) :: CapMin_dec !minimum water storage capacity for upper surfaces (i.e. canopy)
175 REAL(KIND(1D0)), INTENT(IN) :: CO2PointSource ! point source [kgC day-1]
176 REAL(KIND(1D0)), INTENT(IN) :: CRWmax !maximum water holding capacity of snow [mm]
177 REAL(KIND(1D0)), INTENT(IN) :: CRWmin !minimum water holding capacity of snow [mm]
178 REAL(KIND(1D0)), INTENT(IN) :: DecTreeH !average height of deciduous tree and shrub [-]
179 REAL(KIND(1D0)), INTENT(IN) :: DRAINRT !Drainage rate of the water bucket [mm hr-1]
180 REAL(KIND(1D0)), INTENT(IN) :: EF_umolCO2perJ !co2 emission factor [umol J-1]
181 REAL(KIND(1D0)), INTENT(IN) :: EnEF_v_Jkm ! energy emission factor [J K m-1]
182 REAL(KIND(1D0)), INTENT(IN) :: EveTreeH !height of evergreen tree [m]
183 REAL(KIND(1D0)), INTENT(IN) :: FAIBldg ! frontal area index for buildings [-]
184 REAL(KIND(1D0)), INTENT(IN) :: FAIDecTree ! frontal area index for deciduous tree [-]
185 REAL(KIND(1D0)), INTENT(IN) :: FAIEveTree ! frontal area index for evergreen tree [-]
186 REAL(KIND(1D0)), INTENT(IN) :: Faut !Fraction of irrigated area using automatic irrigation [-]
187 REAL(KIND(1D0)), INTENT(IN) :: fcld_obs !observed could fraction [-]
188 REAL(KIND(1D0)), INTENT(IN) :: FlowChange !Difference between the input and output flow in the water body [mm]
189 REAL(KIND(1D0)), INTENT(IN) :: FrFossilFuel_Heat ! fraction of fossil fuel heat [-]
190 REAL(KIND(1D0)), INTENT(IN) :: FrFossilFuel_NonHeat ! fraction of fossil fuel non heat [-]
191 REAL(KIND(1D0)), INTENT(IN) :: G1 !Fitted parameters related to surface res. calculations
192 REAL(KIND(1D0)), INTENT(IN) :: G2 !Fitted parameters related to surface res. calculations
193 REAL(KIND(1D0)), INTENT(IN) :: G3 !Fitted parameters related to surface res. calculations
194 REAL(KIND(1D0)), INTENT(IN) :: G4 !Fitted parameters related to surface res. calculations
195 REAL(KIND(1D0)), INTENT(IN) :: G5 !Fitted parameters related to surface res. calculations
196 REAL(KIND(1D0)), INTENT(IN) :: G6 !Fitted parameters related to surface res. calculations
197 REAL(KIND(1D0)), INTENT(IN) :: H_maintain ! ponding water depth to maintain [mm]
198 REAL(KIND(1D0)), INTENT(IN) :: InternalWaterUse_h !Internal water use [mm h-1]
199 REAL(KIND(1D0)), INTENT(IN) :: IrrFracPaved !fraction of paved which are irrigated [-]
200 REAL(KIND(1D0)), INTENT(IN) :: IrrFracBldgs !fraction of buildings (e.g., green roofs) which are irrigated [-]
201 REAL(KIND(1D0)), INTENT(IN) :: IrrFracDecTr !fraction of deciduous trees which are irrigated [-]
202 REAL(KIND(1D0)), INTENT(IN) :: IrrFracEveTr !fraction of evergreen trees which are irrigated [-]
203 REAL(KIND(1D0)), INTENT(IN) :: IrrFracGrass !fraction of grass which are irrigated [-]
204 REAL(KIND(1D0)), INTENT(IN) :: IrrFracBSoil !fraction of bare soil trees which are irrigated [-]
205 REAL(KIND(1D0)), INTENT(IN) :: IrrFracWater !fraction of water which are irrigated [-]
206 REAL(KIND(1D0)), INTENT(IN) :: Kmax !annual maximum hourly solar radiation [W m-2]
207 REAL(KIND(1D0)), INTENT(IN) :: LAI_obs !observed LAI [m2 m-2]
208 REAL(KIND(1D0)), INTENT(IN) :: lat !latitude [deg]
209 REAL(KIND(1D0)), INTENT(IN) :: ldown_obs !observed incoming longwave radiation [W m-2]
210 REAL(KIND(1D0)), INTENT(IN) :: lng !longitude [deg]
211 REAL(KIND(1D0)), INTENT(IN) :: MaxFCMetab ! maximum FC metabolism [umol m-2 s-1]
212 REAL(KIND(1D0)), INTENT(IN) :: MaxQFMetab ! maximum QF Metabolism [W m-2]
213 REAL(KIND(1D0)), INTENT(IN) :: MinFCMetab ! minimum QF metabolism [umol m-2 s-1]
214 REAL(KIND(1D0)), INTENT(IN) :: MinQFMetab ! minimum FC metabolism [W m-2]
215 REAL(KIND(1D0)), INTENT(IN) :: NARP_EMIS_SNOW ! snow emissivity in NARP model [-]
216 REAL(KIND(1D0)), INTENT(IN) :: NARP_TRANS_SITE !atmospheric transmissivity for NARP [-]
217 REAL(KIND(1D0)), INTENT(IN) :: PipeCapacity !capacity of pipes to transfer water [mm]
218 REAL(KIND(1D0)), INTENT(IN) :: PopDensNighttime ! nighttime population density (i.e. residents) [ha-1]
219 REAL(KIND(1D0)), INTENT(IN) :: PorMax_dec !full leaf-on summertime value used only for DecTr
220 REAL(KIND(1D0)), INTENT(IN) :: PorMin_dec !leaf-off wintertime value used only for DecTr
221 REAL(KIND(1D0)), INTENT(IN) :: Precip !rain data [mm]
222 REAL(KIND(1D0)), INTENT(IN) :: PrecipLimit !temperature limit when precipitation falls as snow [degC]
223 REAL(KIND(1D0)), INTENT(IN) :: PrecipLimitAlb !Limit for hourly precipitation when the ground is fully covered with snow [mm]
224 REAL(KIND(1D0)), INTENT(IN) :: Press_hPa !air pressure [hPa]
225 REAL(KIND(1D0)), INTENT(IN) :: qn1_obs !observed net all-wave radiation [W m-2]
226 REAL(KIND(1D0)), INTENT(IN) :: qs_obs !observed heat storage flux [W m-2]
227 REAL(KIND(1D0)), INTENT(IN) :: qf_obs !observed anthropogenic heat flux [W m-2]
228 REAL(KIND(1D0)), INTENT(IN) :: RadMeltFact !hourly radiation melt factor of snow [mm W-1 h-1]
229 REAL(KIND(1D0)), INTENT(IN) :: RAINCOVER !limit when surface totally covered with water for LUMPS [mm]
230 REAL(KIND(1D0)), INTENT(IN) :: RainMaxRes !maximum water bucket reservoir. Used for LUMPS surface wetness control. [mm]
231 REAL(KIND(1D0)), INTENT(IN) :: RunoffToWater !fraction of above-ground runoff flowing to water surface during flooding [-]
232 REAL(KIND(1D0)), INTENT(IN) :: S1 !a parameter related to soil moisture dependence [-]
233 REAL(KIND(1D0)), INTENT(IN) :: S2 !a parameter related to soil moisture dependence [mm]
234 REAL(KIND(1D0)), INTENT(IN) :: SnowAlbMax !effective surface albedo (middle of the day value) for summertime [-]
235 REAL(KIND(1D0)), INTENT(IN) :: SnowAlbMin !effective surface albedo (middle of the day value) for wintertime (not including snow) [-]
236 REAL(KIND(1D0)), INTENT(IN) :: SnowDensMax !maximum snow density [kg m-3]
237 REAL(KIND(1D0)), INTENT(IN) :: SnowDensMin !fresh snow density [kg m-3]
238 REAL(KIND(1D0)), INTENT(IN) :: SnowLimBldg !Limit of the snow water equivalent for snow removal from building roofs [mm]
239 REAL(KIND(1D0)), INTENT(IN) :: SnowLimPaved !limit of the snow water equivalent for snow removal from roads[mm]
240 REAL(KIND(1D0)), INTENT(IN) :: snowFrac_obs !observed snow fraction [-]
241 REAL(KIND(1D0)), INTENT(IN) :: SurfaceArea !area of the grid [ha]
242 REAL(KIND(1D0)), INTENT(IN) :: tau_a !time constant for snow albedo aging in cold snow [-]
243 REAL(KIND(1D0)), INTENT(IN) :: tau_f !time constant for snow albedo aging in melting snow [-]
244 REAL(KIND(1D0)), INTENT(IN) :: tau_r !time constant for snow density ageing [-]
245 REAL(KIND(1D0)), INTENT(IN) :: Temp_C !air temperature [degC]
246 REAL(KIND(1D0)), INTENT(IN) :: TempMeltFact !hourly temperature melt factor of snow [mm K-1 h-1]
247 REAL(KIND(1D0)), INTENT(IN) :: TH !upper air temperature limit [degC]
248 REAL(KIND(1D0)), INTENT(IN) :: timezone !time zone, for site relative to UTC (east is positive) [h]
249 REAL(KIND(1D0)), INTENT(IN) :: TL !lower air temperature limit [degC]
250 REAL(KIND(1D0)), INTENT(IN) :: TrafficUnits ! traffic units choice [-]
251 REAL(KIND(1D0)), INTENT(IN) :: wu_m3 ! external water input (e.g., irrigation) [m3]
252 REAL(KIND(1D0)), INTENT(IN) :: xsmd ! observed soil moisture; can be provided either as volumetric ([m3 m-3] when SMDMethod = 1) or gravimetric quantity ([kg kg-1] when SMDMethod = 2
253 REAL(KIND(1D0)), INTENT(IN) :: Z ! measurement height [m]
254 REAL(KIND(1D0)), INTENT(IN) :: z0m_in !roughness length for momentum [m]
255 REAL(KIND(1D0)), INTENT(IN) :: zdm_in !zero-plane displacement [m]
256
257 INTEGER, DIMENSION(NVEGSURF), INTENT(IN) :: LAIType !LAI calculation choice[-]
258
259 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: AH_MIN !minimum QF values [W m-2]
260 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: AH_SLOPE_Cooling ! cooling slope for the anthropogenic heat flux calculation [W m-2 K-1]
261 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: AH_SLOPE_Heating ! heating slope for the anthropogenic heat flux calculation [W m-2 K-1]
262 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: FcEF_v_kgkm ! CO2 Emission factor [kg km-1]
263 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: QF0_BEU ! Fraction of base value coming from buildings [-]
264 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: Qf_A ! Base value for QF [W m-2]
265 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: Qf_B ! Parameter related to heating degree days [W m-2 K-1 (Cap ha-1 )-1]
266 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: Qf_C ! Parameter related to cooling degree days [W m-2 K-1 (Cap ha-1 )-1]
267 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: PopDensDaytime ! Daytime population density [people ha-1] (i.e. workers)
268 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: BaseT_Cooling ! base temperature for cooling degree day [degC]
269 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: BaseT_Heating ! base temperatrue for heating degree day [degC]
270 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: TrafficRate ! Traffic rate [veh km m-2 s-1]
271 REAL(KIND(1D0)), DIMENSION(3), INTENT(IN) :: Ie_a !Coefficient for automatic irrigation model
272 REAL(KIND(1D0)), DIMENSION(3), INTENT(IN) :: Ie_m !Coefficients for manual irrigation models
273 REAL(KIND(1D0)), DIMENSION(3), INTENT(IN) :: MaxConductance !the maximum conductance of each vegetation or surface type. [mm s-1]
274 REAL(KIND(1D0)), DIMENSION(7), INTENT(IN) :: DayWat !Irrigation flag: 1 for on and 0 for off [-]
275 REAL(KIND(1D0)), DIMENSION(7), INTENT(IN) :: DayWatPer !Fraction of properties using irrigation for each day of a week [-]
276 REAL(KIND(1D0)), DIMENSION(nsurf + 1), INTENT(IN) :: OHM_threshSW !Temperature threshold determining whether summer/winter OHM coefficients are applied [degC]
277 REAL(KIND(1D0)), DIMENSION(nsurf + 1), INTENT(IN) :: OHM_threshWD !Soil moisture threshold determining whether wet/dry OHM coefficients are applied [-]
278 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: chAnOHM !Bulk transfer coefficient for this surface to use in AnOHM [-]
279 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: cpAnOHM !Volumetric heat capacity for this surface to use in AnOHM [J m-3]
280 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: emis !Effective surface emissivity[-]
281 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: kkAnOHM !Thermal conductivity for this surface to use in AnOHM [W m K-1]
282 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: SatHydraulicConduct !Hydraulic conductivity for saturated soil [mm s-1]
283 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: sfr_surf !surface cover fraction[-]
284 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: SnowPackLimit !Limit for the snow water equivalent when snow cover starts to be patchy [mm]
285 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: SoilDepth !Depth of soil beneath the surface [mm]
286 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: SoilStoreCap_surf !Capacity of soil store for each surface [mm]
287 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: StateLimit_surf !Upper limit to the surface state [mm]
288 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: WetThresh_surf ! !surface wetness threshold [mm], When State > WetThresh, RS=0 limit in SUEWS_evap [mm]
289 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: alpha_bioCO2 !The mean apparent ecosystem quantum. Represents the initial slope of the light-response curve [-]
290 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: alpha_enh_bioCO2 !Part of the alpha coefficient related to the fraction of vegetation[-]
291 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: BaseT !Base Temperature for initiating growing degree days (GDD) for leaf growth [degC]
292 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: BaseTe !Base temperature for initiating sensesance degree days (SDD) for leaf off [degC]
293 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: beta_bioCO2 !The light-saturated gross photosynthesis of the canopy [umol m-2 s-1 ]
294 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: beta_enh_bioCO2 !Part of the beta coefficient related to the fraction of vegetation [umol m-2 s-1 ]
295 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: GDDFull !the growing degree days (GDD) needed for full capacity of the leaf area index [degC]
296 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: LAIMax !full leaf-on summertime value [m2 m-2]
297 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: LAIMin !leaf-off wintertime value [m2 m-2]
298 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: min_res_bioCO2 !Minimum soil respiration rate (for cold-temperature limit) [umol m-2 s-1]
299 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: resp_a !Respiration coefficient a
300 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: resp_b !Respiration coefficient b - related to air temperature dependency
301 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: SDDFull !the sensesence degree days (SDD) needed to initiate leaf off [degC]
302 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(IN) :: SnowProf_24hr !Hourly profile values used in snow clearing [-]
303 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: theta_bioCO2 !The convexity of the curve at light saturation [-]
304 REAL(KIND(1D0)), DIMENSION(4, NVEGSURF), INTENT(IN) :: LAIPower !parameters required by LAI calculation
305 REAL(KIND(1D0)), DIMENSION(nsurf + 1, 4, 3), INTENT(IN) :: OHM_coef !Coefficients for OHM calculation
306 REAL(KIND(1D0)), DIMENSION(NSURF + 1, NSURF - 1), INTENT(IN) :: WaterDist !Fraction of water redistribution [-]
307 REAL(KIND(1D0)), DIMENSION(:), INTENT(IN) :: Ts5mindata_ir !surface temperature input data[degC]
308 REAL(KIND(1D0)), DIMENSION(:, :), INTENT(IN) :: MetForcingData_grid ! met forcing array of grid
309
310 ! diurnal profile values for 24hr
311 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(IN) :: AHProf_24hr !Hourly profile values used in energy use calculation [-]
312 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(IN) :: HumActivity_24hr !Hourly profile values used in human activity calculation[-]
313 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(IN) :: PopProf_24hr !Hourly profile values used in dynamic population estimation[-]
314 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(IN) :: TraffProf_24hr !Hourly profile values used in traffic activity calculation[-]
315 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(IN) :: WUProfA_24hr !Hourly profile values used in automatic irrigation[-]
316 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(IN) :: WUProfM_24hr !Hourly profile values used in manual irrigation[-]
317
318 ! ####################################################################################
319 ! ESTM_EXT
320 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: SoilStoreCap_roof !Capacity of soil store for roof [mm]
321 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: StateLimit_roof !Limit for state_id of roof [mm]
322 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: wetthresh_roof ! wetness threshold of roof[mm]
323 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(INOUT) :: soilstore_roof !Soil moisture of roof [mm]
324 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(INOUT) :: state_roof !wetness status of roof [mm]
325
326 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: SoilStoreCap_wall !Capacity of soil store for wall [mm]
327 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: StateLimit_wall !Limit for state_id of wall [mm]
328 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: wetthresh_wall ! wetness threshold of wall[mm]
329 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(INOUT) :: soilstore_wall !Soil moisture of wall [mm]
330 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(INOUT) :: state_wall !wetness status of wall [mm]
331
332 ! ########################################################################################
333
334 ! ########################################################################################
335 ! inout variables
336 ! OHM related:
337 REAL(KIND(1D0)), INTENT(INOUT) :: qn_av ! weighted average of net all-wave radiation [W m-2]
338 REAL(KIND(1D0)), INTENT(INOUT) :: dqndt ! rate of change of net radiation [W m-2 h-1]
339 REAL(KIND(1D0)), INTENT(INOUT) :: qn_s_av ! weighted average of qn over snow [W m-2]
340 REAL(KIND(1D0)), INTENT(INOUT) :: dqnsdt ! Rate of change of net radiation [W m-2 h-1]
341
342 ! snow related:
343 REAL(KIND(1D0)), INTENT(INOUT) :: SnowfallCum !cumulated snow falling [mm]
344 REAL(KIND(1D0)), INTENT(INOUT) :: SnowAlb !albedo of know [-]
345 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: IceFrac !fraction of ice in snowpack [-]
346 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: SnowWater ! snow water[mm]
347 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: SnowDens !snow density [kg m-3]
348 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: SnowFrac !snow fraction [-]
349 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: SnowPack !snow water equivalent on each land cover [mm]
350
351 ! water balance related:
352 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: soilstore_surf !soil moisture of each surface type [mm]
353 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: state_surf !wetness status of each surface type [mm]
354 REAL(KIND(1D0)), DIMENSION(6, NSURF), INTENT(INOUT) :: StoreDrainPrm !coefficients used in drainage calculation [-]
355
356 ! phenology related:
357 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: alb !albedo [-]
358 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(INOUT) :: GDD_id !Growing Degree Days [degC d]
359 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(INout) :: SDD_id !Senescence Degree Days[degC d]
360 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(INOUT) :: LAI_id !LAI for each veg surface [m2 m-2]
361 REAL(KIND(1D0)), INTENT(INout) :: Tmin_id !Daily minimum temperature [degC]
362 REAL(KIND(1D0)), INTENT(INout) :: Tmax_id !Daily maximum temperature [degC]
363 REAL(KIND(1D0)), INTENT(INout) :: lenDay_id !daytime length [h]
364 REAL(KIND(1D0)), INTENT(INOUT) :: DecidCap_id !Moisture storage capacity of deciduous trees [mm]
365 REAL(KIND(1D0)), INTENT(INOUT) :: albDecTr_id !Albedo of deciduous trees [-]
366 REAL(KIND(1D0)), INTENT(INOUT) :: albEveTr_id !Albedo of evergreen trees [-]
367 REAL(KIND(1D0)), INTENT(INOUT) :: albGrass_id !Albedo of grass [-]
368 REAL(KIND(1D0)), INTENT(INOUT) :: porosity_id !Porosity of deciduous trees [-]
369
370 ! anthropogenic heat related:
371 REAL(KIND(1D0)), DIMENSION(12), INTENT(INOUT) :: HDD_id !Heating Degree Days [degC d]
372
373 ! water use related:
374 REAL(KIND(1D0)), DIMENSION(9), INTENT(INOUT) :: WUDay_id !Daily water use for EveTr, DecTr, Grass [mm]
375
376 ! ESTM related:
377 REAL(KIND(1D0)), INTENT(INOUT) :: Tair_av !average air temperature [degC]
378
379 ! ESTM_ext related:
380 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(INOUT) :: temp_roof !interface temperature between depth layers in roof [degC]
381 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(INOUT) :: temp_wall !interface temperature between depth layers in wall [degC]
382 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(INOUT) :: temp_surf !interface temperature between depth layers [degC]
383
384 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(INOUT) :: tsfc_roof !roof surface temperature [degC]
385 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(INOUT) :: tsfc_wall !wall surface temperature [degC]
386 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(INOUT) :: tsfc_surf !surface temperature [degC]
387
388 ! SPARTACUS input variables
389 INTEGER, INTENT(IN) :: n_vegetation_region_urban !Number of regions used to describe vegetation [-]
390 INTEGER, INTENT(IN) :: n_stream_sw_urban ! shortwave diffuse streams per hemisphere [-]
391 INTEGER, INTENT(IN) :: n_stream_lw_urban ! LW streams per hemisphere [-]
392 REAL(KIND(1D0)), INTENT(IN) :: sw_dn_direct_frac
393 REAL(KIND(1D0)), INTENT(IN) :: air_ext_sw
394 REAL(KIND(1D0)), INTENT(IN) :: air_ssa_sw
395 REAL(KIND(1D0)), INTENT(IN) :: veg_ssa_sw
396 REAL(KIND(1D0)), INTENT(IN) :: air_ext_lw
397 REAL(KIND(1D0)), INTENT(IN) :: air_ssa_lw
398 REAL(KIND(1D0)), INTENT(IN) :: veg_ssa_lw
399 REAL(KIND(1D0)), INTENT(IN) :: veg_fsd_const
400 REAL(KIND(1D0)), INTENT(IN) :: veg_contact_fraction_const
401 REAL(KIND(1D0)), INTENT(IN) :: ground_albedo_dir_mult_fact
402
403 ! ########################################################################################
404
405 ! ########################################################################################
406 ! output variables
407 REAL(KIND(1D0)), DIMENSION(5), INTENT(OUT) :: datetimeLine !date & time
408 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutSUEWS - 5), INTENT(OUT) :: dataOutLineSUEWS
409 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutSnow - 5), INTENT(OUT) :: dataOutLineSnow
410 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutESTM - 5), INTENT(OUT) :: dataOutLineESTM
411 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutESTMExt - 5), INTENT(OUT) :: dataOutLineESTMExt
412 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutRSL - 5), INTENT(OUT) :: dataoutLineRSL
413 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutBEERS - 5), INTENT(OUT) :: dataOutLineBEERS
414 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutDebug - 5), INTENT(OUT) :: dataOutLineDebug
415 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutSPARTACUS - 5), INTENT(OUT) :: dataOutLineSPARTACUS
416 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutDailyState - 5), INTENT(OUT) :: DailyStateLine
417 ! ########################################################################################
418
419 ! ########################################################################################
420 ! local variables
421 REAL(KIND(1D0)) :: a1 !AnOHM coefficients of grid [-]
422 REAL(KIND(1D0)) :: a2 ! AnOHM coefficients of grid [h]
423 REAL(KIND(1D0)) :: a3 !AnOHM coefficients of grid [W m-2]
424 REAL(KIND(1D0)) :: AdditionalWater !!Additional water coming from other grids [mm] (these are expressed as depths over the whole surface)
425 REAL(KIND(1D0)) :: U10_ms !average wind speed at 10m [W m-1]
426 REAL(KIND(1D0)) :: azimuth !solar azimuth [angle]
427 REAL(KIND(1D0)) :: chSnow_per_interval ! change state_id of snow and surface per time interval [mm]
428
429 REAL(KIND(1D0)) :: dens_dry !Vap density or absolute humidity (kg m-3)
430 REAL(KIND(1D0)) :: deltaLAI !change in LAI [m2 m-2]
431 REAL(KIND(1D0)) :: drain_per_tstep ! total drainage for all surface type at each timestep [mm]
432 REAL(KIND(1D0)) :: Ea_hPa !vapor pressure [hPa]
433 REAL(KIND(1D0)) :: QE_LUMPS !turbulent latent heat flux by LUMPS model [W m-2]
434 REAL(KIND(1D0)) :: es_hPa !Saturation vapour pressure over water [hPa]
435 REAL(KIND(1D0)) :: ev_per_tstep ! evaporation at each time step [mm]
436 REAL(KIND(1D0)) :: wu_ext !external water use [mm]
437 REAL(KIND(1D0)) :: Fc !total co2 flux [umol m-2 s-1]
438 REAL(KIND(1D0)) :: Fc_anthro !anthropogenic co2 flux [umol m-2 s-1]
439 REAL(KIND(1D0)) :: Fc_biogen !biogenic CO2 flux [umol m-2 s-1]
440 REAL(KIND(1D0)) :: Fc_build ! anthropogenic co2 flux [umol m-2 s-1]
441 REAL(KIND(1D0)) :: fcld !estomated cloud fraction [-]
442 REAL(KIND(1D0)) :: Fc_metab ! co2 emission from metabolism component [umol m-2 s-1]
443 REAL(KIND(1D0)) :: Fc_photo !co2 flux from photosynthesis [umol m
444 REAL(KIND(1D0)) :: Fc_point ! co2 emission from point source [umol m-2 s-1]
445 REAL(KIND(1D0)) :: Fc_respi !co2 flux from respiration [umol m-2 s-1]
446 REAL(KIND(1D0)) :: Fc_traff ! co2 emission from traffic component [umol m-2 s-1]
447 REAL(KIND(1D0)) :: gfunc
448 REAL(KIND(1D0)) :: gsc !Surface Layer Conductance
449 REAL(KIND(1D0)) :: QH_LUMPS !turbulent sensible heat flux from LUMPS model [W m-2]
450 REAL(KIND(1D0)) :: wu_int !internal water use [mm]
451 REAL(KIND(1D0)) :: kclear !clear sky incoming shortwave radiation [W m-2]
452 REAL(KIND(1D0)) :: kup !outgoing shortwave radiation [W m-2]
453 REAL(KIND(1D0)) :: ldown !incoming longtwave radiation [W m-2]
454 REAL(KIND(1D0)) :: lup !outgoing longwave radiation [W m-2]
455 REAL(KIND(1D0)) :: L_mod !Obukhov length [m]
456 REAL(KIND(1D0)) :: mwh !snowmelt [mm]
457 REAL(KIND(1D0)) :: mwstore !overall met water [mm]
458 REAL(KIND(1D0)) :: NWstate_per_tstep ! state_id at each tinestep(excluding water body) [mm]
459 REAL(KIND(1D0)) :: FAI ! frontal area index [-]
460 REAL(KIND(1D0)) :: PAI ! plan area index [-]
461 REAL(KIND(1D0)) :: zL ! Stability scale [-]
462 REAL(KIND(1D0)) :: q2_gkg ! Air specific humidity at 2 m [g kg-1]
463 REAL(KIND(1D0)) :: qe !turbuent latent heat flux [W m-2]
464 REAL(KIND(1D0)) :: qf !anthropogenic heat flux [W m-2]
465 REAL(KIND(1D0)) :: QF_SAHP !total anthropogeic heat flux when EmissionMethod is not 0 [W m-2]
466 REAL(KIND(1D0)) :: qh !turbulent sensible heat flux [W m-2]
467 REAL(KIND(1D0)) :: qh_residual ! residual based sensible heat flux [W m-2]
468 REAL(KIND(1D0)) :: qh_resist !resistance bnased sensible heat flux [W m-2]
469 REAL(KIND(1D0)) :: Qm !Snowmelt-related heat [W m-2]
470 REAL(KIND(1D0)) :: QmFreez !heat related to freezing of surface store [W m-2]
471 REAL(KIND(1D0)) :: QmRain !melt heat for rain on snow [W m-2]
472 REAL(KIND(1D0)) :: qn !net all-wave radiation [W m-2]
473 REAL(KIND(1D0)) :: qn_snow !net all-wave radiation on snow surface [W m-2]
474 REAL(KIND(1D0)) :: qn_snowfree !net all-wave radiation on snow-free surface [W m-2]
475 REAL(KIND(1D0)) :: qs !heat storage flux [W m-2]
476 REAL(KIND(1D0)) :: RA_h ! aerodynamic resistance [s m-1]
477 REAL(KIND(1D0)) :: RS ! surface resistance [s m-1]
478 REAL(KIND(1D0)), DIMENSION(NSURF) :: rss_surf ! surface resistance adjusted by surface wetness state[s m-1]
479 REAL(KIND(1D0)) :: RH2 ! air relative humidity at 2m [-]
480 REAL(KIND(1D0)) :: runoffAGveg !Above ground runoff from vegetated surfaces for all surface area [mm]
481 REAL(KIND(1D0)) :: runoffAGimpervious !Above ground runoff from impervious surface for all surface area [mm]
482 REAL(KIND(1D0)) :: runoff_per_tstep !runoff water at each time step [mm]
483 REAL(KIND(1D0)) :: runoffPipes !runoff to pipes [mm]
484 REAL(KIND(1D0)) :: runoffSoil_per_tstep !Runoff to deep soil per timestep [mm] (for whole surface, excluding water body)
485 REAL(KIND(1D0)) :: runoffwaterbody !Above ground runoff from water body for all surface area [mm]
486 REAL(KIND(1D0)) :: smd !soil moisture deficit [mm]
487 REAL(KIND(1D0)) :: SoilState !Area-averaged soil moisture for whole surface [mm]
488 REAL(KIND(1D0)) :: state_per_tstep !state_id at each timestep [mm]
489 REAL(KIND(1D0)) :: surf_chang_per_tstep !change in state_id (exluding snowpack) per timestep [mm]
490 REAL(KIND(1D0)) :: swe !overall snow water equavalent[mm]
491 REAL(KIND(1D0)) :: t2_C !modelled 2 meter air temperature [degC]
492 REAL(KIND(1D0)) :: TSfc_C ! surface temperature [degC]
493 REAL(KIND(1D0)) :: TempVeg ! temporary vegetative surface fraction adjusted by rainfall [-]
494 REAL(KIND(1D0)) :: tot_chang_per_tstep !Change in surface state_id [mm]
495 REAL(KIND(1D0)) :: TStar !T*, temperature scale [-]
496 REAL(KIND(1D0)) :: tsurf !surface temperatue [degC]
497 REAL(KIND(1D0)) :: UStar !friction velocity [m s-1]
498 REAL(KIND(1D0)) :: VPD_Pa !vapour pressure deficit [Pa]
499 REAL(KIND(1D0)) :: z0m !Aerodynamic roughness length [m]
500 REAL(KIND(1D0)) :: zdm !zero-plane displacement [m]
501 REAL(KIND(1D0)) :: ZENITH_deg !solar zenith angle in degree [°]
502 REAL(KIND(1D0)) :: zH ! Mean building height [m]
503
504 REAL(KIND(1D0)), DIMENSION(2) :: SnowRemoval !snow removal [mm]
505 REAL(KIND(1D0)), DIMENSION(NSURF) :: wu_surf !external water use of each surface type [mm]
506 ! REAL(KIND(1D0)), DIMENSION(NSURF) :: FreezMelt !freezing of melt water[mm]
507 REAL(KIND(1D0)), DIMENSION(nsurf) :: kup_ind_snow !outgoing shortwave on snowpack [W m-2]
508 ! REAL(KIND(1D0)), DIMENSION(NSURF) :: mw_ind !melt water from sknowpack[mm]
509 ! REAL(KIND(1D0)), DIMENSION(NSURF) :: Qm_freezState !heat related to freezing of surface store [W m-2]
510 ! REAL(KIND(1D0)), DIMENSION(NSURF) :: Qm_melt !melt heat [W m-2]
511 ! REAL(KIND(1D0)), DIMENSION(NSURF) :: Qm_rain !melt heat for rain on snow [W m-2]
512 REAL(KIND(1D0)), DIMENSION(NSURF) :: qn_ind_snow !net all-wave radiation on snowpack [W m-2]
513 ! REAL(KIND(1D0)), DIMENSION(NSURF) :: rainOnSnow !rain water on snow event [mm]
514 REAL(KIND(1D0)), DIMENSION(NSURF) :: runoffSoil !Soil runoff from each soil sub-surface [mm]
515 REAL(KIND(1D0)), DIMENSION(NSURF) :: smd_nsurf !soil moisture deficit for each surface
516 ! REAL(KIND(1D0)), DIMENSION(NSURF) :: snowDepth !Snow depth [m]
517
518 REAL(KIND(1D0)), DIMENSION(nsurf) :: Tsurf_ind_snow !snowpack surface temperature [C]
519
520 ! INTEGER, DIMENSION(NSURF) :: snowCalcSwitch
521 INTEGER, DIMENSION(3) :: dayofWeek_id ! 1 - day of week; 2 - month; 3 - season
522 INTEGER :: DLS
523
524 REAL(KIND(1D0)) :: dq !Specific humidity deficit [g/kg]
525 REAL(KIND(1D0)) :: lvS_J_kg !latent heat of sublimation [J kg-1]
526 REAL(KIND(1D0)) :: psyc_hPa !psychometric constant [hPa]
527 REAL(KIND(1D0)) :: z0v !roughness for heat [m]
528 REAL(KIND(1D0)) :: z0vSnow !roughness for heat [m]
529 REAL(KIND(1D0)) :: RAsnow !Aerodynamic resistance for snow [s m-1]
530 REAL(KIND(1D0)) :: RB !boundary layer resistance shuttleworth
531 REAL(KIND(1D0)) :: runoff_per_interval !run-off at each time interval [mm]
532 REAL(KIND(1D0)) :: s_hPa !vapour pressure versus temperature slope [hPa K-1]
533 REAL(KIND(1D0)) :: sIce_hpa !satured curve on snow [hPa]
534 REAL(KIND(1D0)) :: SoilMoistCap !Maximum capacity of soil store [mm]
535 ! REAL(KIND(1D0)) :: veg_fr !vegetation fraction [-]
536 REAL(KIND(1D0)) :: VegPhenLumps
537 REAL(KIND(1D0)) :: VPd_hpa ! vapour pressure deficit [hPa]
538 REAL(KIND(1D0)) :: vsmd !Soil moisture deficit for vegetated surfaces only [mm]
539 REAL(KIND(1D0)) :: ZZD !Active measurement height[m]
540
541 REAL(KIND(1D0)), DIMENSION(NSURF) :: deltaQi ! storage heat flux of snow surfaces [W m-2]
542 REAL(KIND(1D0)), DIMENSION(NSURF) :: drain_surf !drainage of each surface type [mm]
543 ! REAL(KIND(1D0)), DIMENSION(NSURF) :: FreezState !freezing of state_id [mm]
544 ! REAL(KIND(1D0)), DIMENSION(NSURF) :: FreezStateVol !surface state_id [mm]
545 REAL(KIND(1D0)), DIMENSION(NSURF) :: tsurf_ind !snow-free surface temperature [degC]
546
547 ! TODO: TS 25 Oct 2017
548 ! the variables are not used currently as grid-to-grid connection is NOT set up.
549 ! set these variables as zero.
550 REAL(KIND(1D0)) :: addImpervious = 0
551 REAL(KIND(1D0)) :: addPipes = 0
552 REAL(KIND(1D0)) :: addVeg = 0
553 REAL(KIND(1D0)) :: addWaterBody = 0
554 REAL(KIND(1D0)), DIMENSION(NSURF) :: AddWater = 0
555 REAL(KIND(1D0)), DIMENSION(NSURF) :: frac_water2runoff = 0
556
557 ! values that are derived from tstep
558 INTEGER :: nsh ! number of timesteps per hour
559 REAL(KIND(1D0)) :: nsh_real ! nsh in type real [-]
560 REAL(KIND(1D0)) :: tstep_real ! tstep in type real
561 REAL(KIND(1D0)) :: dectime !decimal time [-]
562
563 ! values that are derived from sfr_surf (surface fractions)
564 REAL(KIND(1D0)) :: VegFraction ! fraction of vegetation [-]
565 REAL(KIND(1D0)) :: ImpervFraction !fractioin of impervious surface [-]
566 REAL(KIND(1D0)) :: PervFraction !fraction of pervious surfaces [-]
567 REAL(KIND(1D0)) :: NonWaterFraction !fraction of non-water [-]
568
569 ! snow related temporary values
570 REAL(KIND(1D0)) :: albedo_snow !snow albedo [-]
571
572 ! ########################################################################################
573 ! TS 19 Sep 2019
574 ! temporary variables to save values for inout varialbes
575 ! suffixes and denote values from last and to next tsteps, respectively
576 ! these variables are introduced to allow safe and robust iterations inccurred in this subroutine
577 ! so that these values won't updated in unexpectedly many times
578
579 ! OHM related:
580 REAL(KIND(1D0)) :: qn_av_prev, qn_av_next ! weighted average of net all-wave radiation [W m-2]
581 REAL(KIND(1D0)) :: dqndt_prev, dqndt_next ! Rate of change of net radiation [W m-2 h-1]
582 REAL(KIND(1D0)) :: qn_s_av_prev, qn_s_av_next ! weighted average of qn over snow [W m-2]
583 REAL(KIND(1D0)) :: dqnsdt_prev, dqnsdt_next ! Rate of change of net radiation [W m-2 h-1]
584
585 ! snow related:
586 REAL(KIND(1D0)) :: SnowfallCum_prev, SnowfallCum_next !cumulative snow depth [mm]
587 REAL(KIND(1D0)) :: SnowAlb_prev, SnowAlb_next !snow albedo [-]
588
589 REAL(KIND(1D0)), DIMENSION(NSURF) :: IceFrac_prev, IceFrac_next !fraction of ice in snowpack [-]
590 REAL(KIND(1D0)), DIMENSION(NSURF) :: SnowWater_prev, SnowWater_next ! snow water[mm]
591 REAL(KIND(1D0)), DIMENSION(NSURF) :: SnowDens_prev, SnowDens_next !snow density [kg m-3]
592 REAL(KIND(1D0)), DIMENSION(NSURF) :: SnowFrac_prev, SnowFrac_next !snow fraction [-]
593 REAL(KIND(1D0)), DIMENSION(NSURF) :: SnowPack_prev, SnowPack_next !snow water equivalent on each land cover [mm]
594
595 ! water balance related:
596 REAL(KIND(1D0)), DIMENSION(NSURF) :: soilstore_surf_prev, soilstore_surf_next !soil moisture of each surface type [mm]
597 REAL(KIND(1D0)), DIMENSION(nlayer) :: soilstore_roof_prev, soilstore_roof_next !soil moisture of roof [mm]
598 REAL(KIND(1D0)), DIMENSION(nlayer) :: soilstore_wall_prev, soilstore_wall_next !soil moisture of wall[mm]
599 REAL(KIND(1D0)), DIMENSION(NSURF) :: state_surf_prev, state_surf_next !wetness status of each surface type [mm]
600 REAL(KIND(1D0)), DIMENSION(nlayer) :: state_roof_prev, state_roof_next !wetness status of roof [mm]
601 REAL(KIND(1D0)), DIMENSION(nlayer) :: state_wall_prev, state_wall_next !wetness status of wall [mm]
602 REAL(KIND(1D0)), DIMENSION(NSURF) :: ev0_surf ! evapotranspiration from PM of each surface type [mm]
603 REAL(KIND(1D0)), DIMENSION(NSURF) :: ev_surf ! evapotranspiration of each surface type [mm]
604 REAL(KIND(1D0)), DIMENSION(nlayer) :: ev_roof ! evapotranspiration of each roof layer [mm]
605 REAL(KIND(1D0)), DIMENSION(nlayer) :: ev_wall ! evapotranspiration of each wall type [mm]
606 REAL(KIND(1D0)), DIMENSION(6, NSURF) :: StoreDrainPrm_prev, StoreDrainPrm_next !coefficients used in drainage calculation [-]
607
608 ! phenology related:
609 REAL(KIND(1D0)), DIMENSION(NSURF) :: alb_prev, alb_next !albedo [-]
610 REAL(KIND(1D0)), DIMENSION(nvegsurf) :: GDD_id_prev, GDD_id_next !Growing Degree Days [degC]
611 REAL(KIND(1D0)), DIMENSION(nvegsurf) :: LAI_id_prev, LAI_id_next !Senescence Degree Days[degC]
612 REAL(KIND(1D0)), DIMENSION(nvegsurf) :: SDD_id_prev, SDD_id_next !LAI for each veg surface [m2 m-2]
613
614 REAL(KIND(1D0)) :: DecidCap_id_prev, DecidCap_id_next !Moisture storage capacity of deciduous trees [mm]
615 REAL(KIND(1D0)) :: albDecTr_id_prev, albDecTr_id_next !Albedo of deciduous trees [-]
616 REAL(KIND(1D0)) :: albEveTr_id_prev, albEveTr_id_next !Albedo of evergreen trees [-]
617 REAL(KIND(1D0)) :: albGrass_id_prev, albGrass_id_next !Albedo of grass [-]
618 REAL(KIND(1D0)) :: porosity_id_prev, porosity_id_next !Porosity of deciduous trees [-]
619
620 REAL(KIND(1D0)) :: Tmin_id_prev, Tmin_id_next !Daily minimum temperature [degC]
621 REAL(KIND(1D0)) :: Tmax_id_prev, Tmax_id_next !Daily maximum temperature [degC]
622 REAL(KIND(1D0)) :: lenDay_id_prev, lenDay_id_next !daytime length [h]
623
624 ! anthropogenic heat related:
625 REAL(KIND(1D0)), DIMENSION(12) :: HDD_id_prev, HDD_id_next !Heating Degree Days [degC d]
626
627 ! water use related:
628 REAL(KIND(1D0)), DIMENSION(9) :: WUDay_id_prev, WUDay_id_next !Daily water use for EveTr, DecTr, Grass [mm]
629
630 REAL(KIND(1D0)) :: Tair_av_prev, Tair_av_next !average air temperature [degC]
631 ! ########################################################################################
632
633 ! Related to RSL wind profiles
634 INTEGER, PARAMETER :: nz = 90 ! number of levels 10 levels in canopy plus 20 (3 x Zh) above the canopy
635
636 ! flag for Tsurf convergence
637 LOGICAL :: flag_converge
638 REAL(KIND(1D0)) :: Ts_iter !average surface temperature of all surfaces [degC]
639 REAL(KIND(1D0)) :: dif_tsfc_iter
640 REAL(KIND(1D0)) :: QH_Init !initialised sensible heat flux [W m-2]
641 INTEGER :: i_iter
642
643 ! ########################################################################################
644 ! ! extended for ESTM_ext, TS 20 Jan 2022
645 !
646 ! input arrays: standard suews surfaces
647 REAL(KIND(1D0)), DIMENSION(nlayer) :: tsfc_out_roof, tsfc0_out_roof !surface temperature of roof[degC]
648 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tin_roof ! indoor temperature for roof [degC]
649 REAL(KIND(1D0)), DIMENSION(nlayer) :: sfr_roof !roof surface fraction [-]
650 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth) :: temp_in_roof ! temperature at inner interfaces of roof [degC]
651 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: k_roof ! thermal conductivity of roof [W m-1 K]
652 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: cp_roof ! Heat capacity of roof [J m-3 K-1]
653 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: dz_roof ! thickness of each layer in roof [m]
654 ! input arrays: standard suews surfaces
655 REAL(KIND(1D0)), DIMENSION(nlayer) :: tsfc_out_wall, tsfc0_out_wall !surface temperature of wall [degC]
656 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tin_wall ! indoor temperature for wall [degC]
657 REAL(KIND(1D0)), DIMENSION(nlayer) :: sfr_wall !wall surface fraction [-]
658 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth) :: temp_in_wall ! temperature at inner interfaces of wall [degC]
659 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: k_wall ! thermal conductivity of wall [W m-1 K]
660 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: cp_wall ! Heat capacity of wall [J m-3 K-1]
661 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: dz_wall ! thickness of each layer in wall [m]
662 ! input arrays: standard suews surfaces
663 REAL(KIND(1D0)), DIMENSION(nsurf) :: tsfc_out_surf, tsfc0_out_surf !surface temperature [degC]
664 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: tin_surf !deep bottom temperature for each surface [degC]
665 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth) :: temp_in_surf ! temperature at inner interfaces of of each surface [degC]
666 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(in) :: k_surf ! thermal conductivity of v [W m-1 K]
667 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(in) :: cp_surf ! Heat capacity of each surface [J m-3 K-1]
668 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(in) :: dz_surf ! thickness of each layer in each surface [m]
669
670 ! output arrays:
671
672 ! roof facets
673 ! aggregated heat storage of all roof facets
674 REAL(KIND(1D0)), DIMENSION(nlayer) :: QS_roof ! heat storage flux for roof component [W m-2]
675 !interface temperature between depth layers
676 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth) :: temp_out_roof !interface temperature between depth layers [degC]
677
678 ! energy fluxes of individual surfaces
679 REAL(KIND(1D0)), DIMENSION(nlayer) :: QG_roof ! heat flux used in ESTM_ext as forcing of roof surface [W m-2]
680 REAL(KIND(1D0)), DIMENSION(nlayer) :: QN_roof ! net all-wave radiation of roof surface [W m-2]
681 REAL(KIND(1D0)), DIMENSION(nlayer) :: qe_roof ! latent heat flux of roof surface [W m-2]
682 REAL(KIND(1D0)), DIMENSION(nlayer) :: qh_roof ! sensible heat flux of roof surface [W m-2]
683 REAL(KIND(1D0)), DIMENSION(nlayer) :: qh_resist_roof ! resist-based sensible heat flux of roof surface [W m-2]
684
685 ! wall facets
686 ! aggregated heat storage of all wall facets
687 REAL(KIND(1D0)), DIMENSION(nlayer) :: QS_wall ! heat storage flux for wall component [W m-2]
688 !interface temperature between depth layers
689 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth) :: temp_out_wall !interface temperature between depth layers [degC]
690
691 ! energy fluxes of individual surfaces
692 REAL(KIND(1D0)), DIMENSION(nlayer) :: QG_wall ! heat flux used in ESTM_ext as forcing of wall surface [W m-2]
693 REAL(KIND(1D0)), DIMENSION(nlayer) :: QN_wall ! net all-wave radiation of wall surface [W m-2]
694 REAL(KIND(1D0)), DIMENSION(nlayer) :: qe_wall ! latent heat flux of wall surface [W m-2]
695 REAL(KIND(1D0)), DIMENSION(nlayer) :: qh_wall ! sensible heat flux of wall surface [W m-2]
696 REAL(KIND(1D0)), DIMENSION(nlayer) :: qh_resist_wall ! resistance based sensible heat flux of wall surface [W m-2]
697
698 ! standard suews surfaces
699 !interface temperature between depth layers
700 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth) :: temp_out_surf !interface temperature between depth layers[degC]
701
702 ! energy fluxes of individual surfaces
703 REAL(KIND(1D0)), DIMENSION(nsurf) :: QG_surf ! heat flux used in ESTM_ext as forcing of individual surface [W m-2]
704 REAL(KIND(1D0)), DIMENSION(nsurf) :: QN_surf ! net all-wave radiation of individual surface [W m-2]
705 REAL(KIND(1D0)), DIMENSION(nsurf) :: qs_surf ! aggregated heat storage of of individual surface [W m-2]
706 REAL(KIND(1D0)), DIMENSION(nsurf) :: qe0_surf ! latent heat flux from PM of individual surface [W m-2]
707 REAL(KIND(1D0)), DIMENSION(nsurf) :: qe_surf ! latent heat flux of individual surface [W m-2]
708 REAL(KIND(1D0)), DIMENSION(nsurf) :: qh_surf ! sensinle heat flux of individual surface [W m-2]
709 REAL(KIND(1D0)), DIMENSION(nsurf) :: qh_resist_surf ! resistance based sensible heat flux of individual surface [W m-2]
710 ! surface temperature
711 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: tsfc_qh_surf ! latent heat flux of individual surface [W m-2]
712
713 ! iterator for surfaces
714 INTEGER :: i_surf !iterator for surfaces
715
716 ! used in iteration
717 INTEGER :: max_iter !maximum iteration
718 REAL(KIND(1D0)) :: ratio_iter
719
720 LOGICAL, INTENT(IN) :: use_sw_direct_albedo !boolean, Specify ground and roof albedos separately for direct solar radiation [-]
721
722 REAL(KIND(1D0)), DIMENSION(nlayer + 1), INTENT(IN) :: height ! height in spartacus [m]
723 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: building_frac !building fraction [-]
724 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: veg_frac !vegetation fraction [-]
725 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: building_scale ! diameter of buildings [[m]
726 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: veg_scale ! scale of tree crowns [m]
727 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: alb_roof !albedo of roof [-]
728 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: emis_roof ! emissivity of roof [-]
729 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: alb_wall !albedo of wall [-]
730 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: emis_wall ! emissivity of wall [-]
731 REAL(KIND(1D0)), DIMENSION(nspec, nlayer), INTENT(IN) :: roof_albedo_dir_mult_fact !Ratio of the direct and diffuse albedo of the roof[-]
732 REAL(KIND(1D0)), DIMENSION(nspec, nlayer), INTENT(IN) :: wall_specular_frac ! Fraction of wall reflection that is specular [-]
733
734 ! ####
735 ! set initial values for output arrays
736 swe = 0.
737 mwh = 0.
738 mwstore = 0.
739 chsnow_per_interval = 0.
740 snowremoval = 0.
741 qm = 0
742 qmfreez = 0
743 qmrain = 0
744
745 ! these output variables are used for debugging
746 qe0_surf = 0 ! QE from PM: only meaningful when snowuse=0
747 ev0_surf = 0 ! ev from PM: only meaningful when snowuse=0
748 ev_surf = 0 ! ev from water balance: only meaningful when snowuse=0
749
750 ! ####
751 ! force several snow related state variables to zero if snow module is off
752 IF (snowuse == 0) THEN
753 snowdens = 0.
754 snowfrac = 0.
755 snowwater = 0.
756 snowalb = 0.
757 icefrac = 0.
758 snowpack = 0.
759 END IF
760
761 ! ########################################################################################
762 ! save initial values of inout variables
763 qn_av_prev = qn_av
764 dqndt_prev = dqndt
765 qn_s_av_prev = qn_s_av
766 dqnsdt_prev = dqnsdt
767 snowfallcum_prev = snowfallcum
768 snowalb_prev = snowalb
769 icefrac_prev = icefrac
770 snowwater_prev = snowwater
771 snowdens_prev = snowdens
772 snowfrac_prev = merge(snowfrac_obs, snowfrac, netradiationmethod == 0)
773 snowpack_prev = snowpack
774 state_surf_prev = state_surf
775 soilstore_surf_prev = soilstore_surf
776 IF (storageheatmethod == 5) THEN
777 state_roof_prev = state_roof
778 state_wall_prev = state_wall
779 soilstore_roof_prev = soilstore_roof
780 soilstore_wall_prev = soilstore_wall
781 END IF
782 tair_av_prev = tair_av
783 lai_id_prev = lai_id
784 gdd_id_prev = gdd_id
785 sdd_id_prev = sdd_id
786 tmin_id_prev = tmin_id
787 tmax_id_prev = tmax_id
788 lenday_id_prev = lenday_id
789 storedrainprm_prev = storedrainprm
790 decidcap_id_prev = decidcap_id
791 porosity_id_prev = porosity_id
792 alb_prev = alb
793 albdectr_id_prev = albdectr_id
794 albevetr_id_prev = albevetr_id
795 albgrass_id_prev = albgrass_id
796 hdd_id_prev = hdd_id
797 wuday_id_prev = wuday_id
798
799 ! ESTM_ext related
800 ! save initial values of inout variables
801 IF (storageheatmethod == 5) THEN
802 temp_in_roof = temp_roof
803 temp_in_wall = temp_wall
804 temp_in_surf = temp_surf
805 END IF
806 ! initialise indoor/bottom boundary temperature arrays
807 ! tin_roof = 10.
808 ! tin_wall = 10.
809 ! tin_surf = 3.
810
811 ! initialise variables
812 qn_av_next = qn_av
813 dqndt_next = dqndt
814 qn_s_av_next = qn_s_av
815 dqnsdt_next = dqnsdt
816 snowfallcum_next = snowfallcum
817 snowalb_next = snowalb
818 icefrac_next = icefrac
819 snowwater_next = snowwater
820 snowdens_next = snowdens
821 snowfrac_next = snowfrac_prev
822 snowpack_next = snowpack
823 state_surf_next = state_surf
824 soilstore_surf_next = soilstore_surf
825
826 IF (storageheatmethod == 5) THEN
827
828 soilstore_roof_next = soilstore_roof
829 soilstore_wall_next = soilstore_wall
830 state_roof_next = state_roof
831 state_wall_next = state_wall
832
833 END IF
834
835 tair_av_next = tair_av
836 lai_id_next = lai_id
837 gdd_id_next = gdd_id
838 sdd_id_next = sdd_id
839 tmin_id_next = tmin_id
840 tmax_id_next = tmax_id
841 lenday_id_next = lenday_id
842 storedrainprm_next = storedrainprm
843 decidcap_id_next = decidcap_id
844 porosity_id_next = porosity_id
845 alb_next = alb
846 albdectr_id_next = albdectr_id
847 albevetr_id_next = albevetr_id
848 albgrass_id_next = albgrass_id
849 hdd_id_next = hdd_id
850 wuday_id_next = wuday_id
851
852 ! initialise output variables
853 dataoutlinesnow = -999.
854 dataoutlineestm = -999.
855 dataoutlineestmext = -999.
856 dataoutlinersl = -999.
857 dataoutlinebeers = -999.
858 dataoutlinedebug = -999.
859 dataoutlinespartacus = -999.
860 dailystateline = -999.
861
862 !########################################################################################
863 ! main calculation starts here
864 !########################################################################################
865
866 ! iteration is used below to get results converge
867 flag_converge = .false.
868 ts_iter = temp_c
869
870 tsfc_out_surf = tsfc_surf
871 tsfc0_out_surf = tsfc_surf
872 ! TODO: ESTM work: to allow heterogeneous surface temperatures
873 IF (storageheatmethod == 5 .OR. netradiationmethod > 1000) THEN
874 tsfc_out_roof = tsfc_roof
875 tsfc0_out_roof = tsfc_roof
876 tsfc_out_wall = tsfc_wall
877 tsfc0_out_wall = tsfc_wall
878 END IF
879 ! PRINT *, 'sfr_surf for this grid ', sfr_surf
880 ! PRINT *, 'before iteration Ts_iter = ', Ts_iter
881 ! L_mod_iter = 10
882 i_iter = 1
883 max_iter = 30
884 DO WHILE ((.NOT. flag_converge) .AND. i_iter < max_iter)
885 ! PRINT *, '=========================== '
886 ! PRINT *, 'Ts_iter of ', i_iter, ' is:', Ts_iter
887
888 ! calculate dectime
889 CALL suews_cal_dectime( &
890 id, it, imin, isec, & ! input
891 dectime) ! output
892
893 ! calculate tstep related VARIABLES
894 CALL suews_cal_tstep( &
895 tstep, & ! input
896 nsh, nsh_real, tstep_real) ! output
897
898 ! calculate surface fraction related VARIABLES
899 CALL suews_cal_surf( &
900 storageheatmethod, netradiationmethod, & !input
901 nlayer, sfr_surf, & !input
902 building_frac, building_scale, height, & !input
903 vegfraction, impervfraction, pervfraction, nonwaterfraction, & ! output
904 sfr_roof, sfr_wall) ! output
905
906 ! calculate dayofweek information
907 CALL suews_cal_weekday( &
908 iy, id, lat, & !input
909 dayofweek_id) !output
910
911 ! calculate dayofweek information
912 CALL suews_cal_dls( &
913 id, startdls, enddls, & !input
914 dls) !output
915
916 ! calculate mean air temperature of past 24 hours
917 tair_av_next = cal_tair_av(tair_av_prev, dt_since_start, tstep, temp_c)
918
919 !==============main calculation start=======================
920
921 !==============surface roughness calculation=======================
922 IF (diagnose == 1) WRITE (*, *) 'Calling SUEWS_cal_RoughnessParameters...'
923 IF (diagnose == 1) print *, 'z0m_in =', z0m_in
925 roughlenmommethod, sfr_surf, & !input
926 bldgh, evetreeh, dectreeh, &
927 porosity_id_prev, faibldg, faievetree, faidectree, &
928 z0m_in, zdm_in, z, &
929 fai, pai, & !output
930 zh, z0m, zdm, zzd)
931
932 !=================Calculate sun position=================
933 IF (diagnose == 1) WRITE (*, *) 'Calling NARP_cal_SunPosition...'
935 REAL(iy, KIND(1D0)), & !input:
936 dectime - tstep/2/86400, & ! sun position at middle of timestep before
937 timezone, lat, lng, alt, &
938 azimuth, zenith_deg) !output:
939
940 !=================Call the SUEWS_cal_DailyState routine to get surface characteristics ready=================
941 IF (diagnose == 1) WRITE (*, *) 'Calling SUEWS_cal_DailyState...'
943 iy, id, it, imin, isec, tstep, tstep_prev, dt_since_start, dayofweek_id, & !input
944 tmin_id_prev, tmax_id_prev, lenday_id_prev, &
945 basetmethod, &
946 waterusemethod, ie_start, ie_end, &
947 laicalcyes, laitype, &
948 nsh_real, kdown, temp_c, precip, baset_hc, &
949 baset_heating, baset_cooling, &
950 lat, faut, lai_obs, &
951 albmax_dectr, albmax_evetr, albmax_grass, &
952 albmin_dectr, albmin_evetr, albmin_grass, &
953 capmax_dec, capmin_dec, pormax_dec, pormin_dec, &
954 ie_a, ie_m, daywatper, daywat, &
955 baset, basete, gddfull, sddfull, laimin, laimax, laipower, &
956 decidcap_id_prev, storedrainprm_prev, lai_id_prev, gdd_id_prev, sdd_id_prev, &
957 albdectr_id_prev, albevetr_id_prev, albgrass_id_prev, porosity_id_prev, & !input
958 hdd_id_prev, & !input
959 state_surf_prev, soilstore_surf_prev, soilstorecap_surf, h_maintain, & !input
960 hdd_id_next, & !output
961 tmin_id_next, tmax_id_next, lenday_id_next, &
962 albdectr_id_next, albevetr_id_next, albgrass_id_next, porosity_id_next, & !output
963 decidcap_id_next, storedrainprm_next, lai_id_next, gdd_id_next, sdd_id_next, deltalai, wuday_id_next) !output
964
965 !=================Calculation of density and other water related parameters=================
966 IF (diagnose == 1) WRITE (*, *) 'Calling LUMPS_cal_AtmMoist...'
967 CALL cal_atmmoist( &
968 temp_c, press_hpa, avrh, dectime, & ! input:
969 lv_j_kg, lvs_j_kg, & ! output:
970 es_hpa, ea_hpa, vpd_hpa, vpd_pa, dq, dens_dry, avcp, avdens)
971
972 !======== Calculate soil moisture =========
973 IF (diagnose == 1) WRITE (*, *) 'Calling SUEWS_update_SoilMoist...'
975 nonwaterfraction, & !input
976 soilstorecap_surf, sfr_surf, soilstore_surf_prev, &
977 soilmoistcap, soilstate, & !output
978 vsmd, smd)
979
980 IF (diagnose == 1) WRITE (*, *) 'Calling SUEWS_cal_WaterUse...'
981 !=================Gives the external and internal water uses per timestep=================
982 CALL suews_cal_wateruse( &
983 nsh_real, & ! input:
984 wu_m3, surfacearea, sfr_surf, &
985 irrfracpaved, irrfracbldgs, &
986 irrfracevetr, irrfracdectr, irrfracgrass, &
987 irrfracbsoil, irrfracwater, &
988 dayofweek_id, wuprofa_24hr, wuprofm_24hr, &
989 internalwateruse_h, hdd_id_next, wuday_id_next, &
990 waterusemethod, nsh, it, imin, dls, &
991 wu_surf, wu_int, wu_ext) ! output:
992
993 ! ===================ANTHROPOGENIC HEAT AND CO2 FLUX======================
995 ah_min, ahprof_24hr, ah_slope_cooling, ah_slope_heating, co2pointsource, & ! input:
996 dayofweek_id, dls, ef_umolco2perj, emissionsmethod, enef_v_jkm, &
997 fcef_v_kgkm, frfossilfuel_heat, frfossilfuel_nonheat, hdd_id_next, humactivity_24hr, &
998 imin, it, maxfcmetab, maxqfmetab, minfcmetab, minqfmetab, &
999 popdensdaytime, popdensnighttime, popprof_24hr, qf, qf0_beu, qf_a, qf_b, qf_c, &
1000 qf_obs, qf_sahp, surfacearea, baset_cooling, baset_heating, &
1001 temp_c, trafficrate, trafficunits, traffprof_24hr, &
1002 fc_anthro, fc_build, fc_metab, fc_point, fc_traff) ! output:
1003
1004 ! ========================================================================
1005 ! N.B.: the following parts involves snow-related calculations.
1006 ! ===================NET ALLWAVE RADIATION================================
1007 ! if (kdown>0 .and. i_iter == 1) then
1008 ! print *, 'snowFrac_prev=', snowFrac_prev
1009 ! snowFrac_prev=-999
1010 ! print *, 'snowFrac_prev=', snowFrac_prev
1011 ! endif
1012 CALL suews_cal_qn( &
1013 storageheatmethod, netradiationmethod, snowuse, & !input
1014 tstep, nlayer, snowpack_prev, tau_a, tau_f, snowalbmax, snowalbmin, &
1015 diagnose, ldown_obs, fcld_obs, &
1016 dectime, zenith_deg, ts_iter, kdown, temp_c, avrh, ea_hpa, qn1_obs, &
1017 snowalb_prev, snowfrac_prev, diagqn, &
1018 narp_trans_site, narp_emis_snow, icefrac_prev, &
1019 sfr_surf, sfr_roof, sfr_wall, &
1020 tsfc_out_surf, tsfc_out_roof, tsfc_out_wall, &
1021 emis, alb_prev, albdectr_id_next, albevetr_id_next, albgrass_id_next, &
1022 lai_id, & !input
1023 n_vegetation_region_urban, &
1024 n_stream_sw_urban, n_stream_lw_urban, &
1025 sw_dn_direct_frac, air_ext_sw, air_ssa_sw, &
1026 veg_ssa_sw, air_ext_lw, air_ssa_lw, veg_ssa_lw, &
1027 veg_fsd_const, veg_contact_fraction_const, &
1028 ground_albedo_dir_mult_fact, use_sw_direct_albedo, & !input
1029 height, building_frac, veg_frac, building_scale, veg_scale, & !input: SPARTACUS
1030 alb_roof, emis_roof, alb_wall, emis_wall, &
1031 roof_albedo_dir_mult_fact, wall_specular_frac, &
1032 alb_next, ldown, fcld, & !output
1033 qn_surf, qn_roof, qn_wall, &
1034 qn, qn_snowfree, qn_snow, kclear, kup, lup, tsurf, &
1035 qn_ind_snow, kup_ind_snow, tsurf_ind_snow, tsurf_ind, &
1036 albedo_snow, snowalb_next, &
1037 dataoutlinespartacus)
1038
1039 ! IF (qn < -300) THEN
1040 ! PRINT *, 'qn=', qn
1041 ! PRINT *, 'snowFrac_prev=', snowFrac_prev
1042 ! END IF
1043
1044 ! PRINT *, 'Qn_surf after SUEWS_cal_Qn ', qn_surf
1045 ! PRINT *, 'qn_roof after SUEWS_cal_Qn ', qn_roof
1046 ! PRINT *, 'qn_wall after SUEWS_cal_Qn ', qn_wall
1047 ! PRINT *, ''
1048
1049 ! =================STORAGE HEAT FLUX=======================================
1050 IF (i_iter == 1) THEN
1051 qg_surf = 0.1*qn_surf
1052 qg_roof = 0.1*qn_roof
1053 qg_wall = 0.1*qn_wall
1054 ELSE
1055 qg_surf = qn_surf + qf - (qh_surf + qe_surf)
1056 qg_roof = qn_roof + qf - (qh_roof + qe_roof)
1057 qg_wall = qn_wall + qf - (qh_wall + qe_wall)
1058 END IF
1059
1060 ! PRINT *, 'Qg_surf before cal_qs', Qg_surf
1061 ! PRINT *, 'Qg_roof before cal_qs', Qg_roof
1062 ! PRINT *, 'Qg_wall before cal_qs', Qg_wall
1063 ! print *,''
1064
1065 ! PRINT *, 'tsfc_surf before cal_qs', tsfc_out_surf
1066 ! PRINT *, 'tsfc_out_roof before cal_qs', tsfc_out_roof
1067 ! PRINT *, 'tsfc_wall before cal_qs', tsfc_out_wall
1068 ! PRINT *, ''
1069
1070 CALL suews_cal_qs( &
1071 storageheatmethod, qs_obs, ohmincqf, gridiv, & !input
1072 id, tstep, dt_since_start, diagnose, &
1073 nlayer, &
1074 qg_surf, qg_roof, qg_wall, &
1075 tsfc_out_roof, tin_roof, temp_in_roof, k_roof, cp_roof, dz_roof, sfr_roof, & !input
1076 tsfc_out_wall, tin_wall, temp_in_wall, k_wall, cp_wall, dz_wall, sfr_wall, & !input
1077 tsfc_out_surf, tin_surf, temp_in_surf, k_surf, cp_surf, dz_surf, sfr_surf, & !input
1078 ohm_coef, ohm_threshsw, ohm_threshwd, &
1079 soilstore_surf_prev, soilstorecap_surf, state_surf_prev, snowuse, snowfrac_prev, diagqs, &
1080 hdd_id, metforcingdata_grid, ts5mindata_ir, qf, qn, &
1081 kdown, avu1, temp_c, zenith_deg, avrh, press_hpa, ldown, &
1082 bldgh, alb, emis, cpanohm, kkanohm, chanohm, emissionsmethod, &
1083 tair_av, qn_av_prev, dqndt_prev, qn_s_av_prev, dqnsdt_prev, &
1084 storedrainprm, &
1085 qn_snow, dataoutlineestm, qs, & !output
1086 qn_av_next, dqndt_next, qn_s_av_next, dqnsdt_next, &
1087 deltaqi, a1, a2, a3, &
1088 temp_out_roof, qs_roof, & !output
1089 temp_out_wall, qs_wall, & !output
1090 temp_out_surf, qs_surf) !output
1091
1092 ! update iteration variables
1093 ! temp_in_roof = temp_out_roof
1094 ! temp_in_wall = temp_out_wall
1095 ! temp_in_surf = temp_out_surf
1096 ! Ts_iter = DOT_PRODUCT(tsfc_out_surf, sfr_surf)
1097 ! PRINT *, 'QS_surf after cal_qs', QS_surf
1098 ! PRINT *, 'QS_roof after cal_qs', QS_roof
1099 ! PRINT *, 'QS_wall after cal_qs', QS_wall
1100
1101 ! PRINT *, ''
1102
1103 ! PRINT *, 'tsfc_surf after cal_qs', tsfc_out_surf
1104 ! PRINT *, 'tsfc_roof after cal_qs', tsfc_out_roof
1105 ! PRINT *, 'tsfc_wall after cal_qs', tsfc_out_wall
1106 ! PRINT *, ''
1107 ! print *,'tsfc_surf abs. diff.:',maxval(abs(tsfc_out_surf-tsfc0_out_surf)),maxloc(abs(tsfc_out_surf-tsfc0_out_surf))
1108 ! dif_tsfc_iter=maxval(abs(tsfc_out_surf-tsfc0_out_surf))
1109 ! print *,'tsfc_roof abs. diff.:',maxval(abs(tsfc_out_roof-tsfc0_out_roof)),maxloc(abs(tsfc_out_roof-tsfc0_out_roof))
1110 ! dif_tsfc_iter=max(maxval(abs(tsfc_out_roof-tsfc0_out_roof)),dif_tsfc_iter)
1111 ! print *,'tsfc_wall abs. diff.:',maxval(abs(tsfc_out_wall-tsfc0_out_wall)),maxloc(abs(tsfc_out_wall-tsfc0_out_wall))
1112 ! dif_tsfc_iter=max(maxval(abs(tsfc0_out_wall-tsfc_out_wall)),dif_tsfc_iter)
1113
1114 ! tsfc0_out_surf = tsfc_out_surf
1115 ! tsfc0_out_roof = tsfc_out_roof
1116 ! tsfc0_out_wall = tsfc_out_wall
1117
1118 !==================Energy related to snow melting/freezing processes=======
1119 IF (diagnose == 1) WRITE (*, *) 'Calling MeltHeat'
1120
1121 !==========================Turbulent Fluxes================================
1122 IF (diagnose == 1) WRITE (*, *) 'Calling LUMPS_cal_QHQE...'
1123 IF (i_iter == 1) THEN
1124 !Calculate QH and QE from LUMPS in the first iteration of each time step
1125 CALL lumps_cal_qhqe( &
1126 veg_type, & !input
1127 snowuse, qn, qf, qs, temp_c, vegfraction, avcp, press_hpa, lv_j_kg, &
1128 tstep_real, drainrt, nsh_real, &
1129 precip, rainmaxres, raincover, sfr_surf, lai_id_next, laimax, laimin, &
1130 qh_lumps, & !output
1131 qe_lumps, psyc_hpa, s_hpa, sice_hpa, tempveg, vegphenlumps)
1132
1133 ! use LUMPS QH to do stability correction
1134 qh_init = qh_lumps
1135 ELSE
1136 ! use SUEWS QH to do stability correction
1137 qh_init = qh
1138 END IF
1139
1140 !============= calculate water balance =============
1141 CALL suews_cal_water( &
1142 diagnose, & !input
1143 snowuse, nonwaterfraction, addpipes, addimpervious, addveg, addwaterbody, &
1144 state_surf_prev, sfr_surf, storedrainprm_next, waterdist, nsh_real, &
1145 drain_per_tstep, & !output
1146 drain_surf, frac_water2runoff, &
1147 additionalwater, runoffpipes, runoff_per_interval, &
1148 addwater)
1149 !============= calculate water balance end =============
1150
1151 !===============Resistance Calculations=======================
1152 CALL suews_cal_resistance( &
1153 stabilitymethod, & !input:
1154 diagnose, aerodynamicresistancemethod, roughlenheatmethod, snowuse, &
1155 id, it, gsmodel, smdmethod, &
1156 avdens, avcp, qh_init, zzd, z0m, zdm, &
1157 avu1, temp_c, vegfraction, kdown, &
1158 kmax, &
1159 g1, g2, g3, g4, &
1160 g5, g6, s1, s2, &
1161 th, tl, &
1162 dq, xsmd, vsmd, maxconductance, laimax, lai_id_next, snowfrac_prev, sfr_surf, &
1163 ustar, tstar, l_mod, & !output
1164 zl, gsc, rs, ra_h, rasnow, rb, z0v, z0vsnow)
1165
1166 !===================Resistance Calculations End=======================
1167
1168 !===================Calculate surface hydrology and related soil water=======================
1169 IF (snowuse == 1) THEN
1170
1171 ! ===================Calculate snow related hydrology=======================
1172 CALL suews_cal_snow( &
1173 diagnose, nlayer, & !input
1174 tstep, imin, it, evapmethod, dayofweek_id, crwmin, crwmax, &
1175 dectime, avdens, avcp, lv_j_kg, lvs_j_kg, avrh, press_hpa, temp_c, &
1176 rasnow, psyc_hpa, sice_hpa, tau_r, &
1177 radmeltfact, tempmeltfact, snowalbmax, preciplimit, preciplimitalb, &
1178 qn_ind_snow, kup_ind_snow, deltaqi, tsurf_ind_snow, &
1179 snowalb_next, &
1180 pervfraction, vegfraction, addimpervious, qn_snowfree, qf, qs, vpd_hpa, s_hpa, &
1181 rs, ra_h, rb, snowdensmax, snowdensmin, precip, pipecapacity, runofftowater, &
1182 addveg, snowlimpaved, snowlimbldg, &
1183 flowchange, drain_surf, wetthresh_surf, soilstorecap_surf, &
1184 tsurf_ind, sfr_surf, &
1185 addwater, frac_water2runoff, storedrainprm_next, snowpacklimit, snowprof_24hr, &
1186 snowpack_prev, snowfrac_prev, snowwater_prev, icefrac_prev, snowdens_prev, & ! input:
1187 snowfallcum_prev, state_surf_prev, soilstore_surf_prev, & ! input:
1188 qn_surf, qs_surf, &
1189 snowremoval, & ! snow specific output
1190 snowpack_next, snowfrac_next, snowwater_next, icefrac_next, snowdens_next, & ! output
1191 snowfallcum_next, state_surf_next, soilstore_surf_next, & ! general output:
1192 state_per_tstep, nwstate_per_tstep, &
1193 qe, qe_surf, qe_roof, qe_wall, &
1194 snowalb_next, &
1195 swe, chsnow_per_interval, ev_per_tstep, runoff_per_tstep, &
1196 surf_chang_per_tstep, runoffpipes, mwstore, runoffwaterbody, &
1197 runoffagveg, runoffagimpervious, rss_surf, &
1198 dataoutlinesnow)
1199 ! N.B.: snow-related calculations end here.
1200 !===================================================
1201 ELSE
1202 !======== Evaporation and surface state_id for snow-free conditions ========
1203 CALL suews_cal_qe( &
1204 diagnose, storageheatmethod, nlayer, & !input
1205 tstep, &
1206 evapmethod, &
1207 avdens, avcp, lv_j_kg, &
1208 psyc_hpa, &
1209 pervfraction, &
1210 addimpervious, &
1211 qf, vpd_hpa, s_hpa, rs, ra_h, rb, &
1212 precip, pipecapacity, runofftowater, &
1213 nonwaterfraction, wu_surf, addveg, addwaterbody, addwater, &
1214 flowchange, drain_surf, &
1215 frac_water2runoff, storedrainprm_next, &
1216 sfr_surf, statelimit_surf, soilstorecap_surf, wetthresh_surf, & ! input:
1217 state_surf_prev, soilstore_surf_prev, qn_surf, qs_surf, & ! input:
1218 sfr_roof, statelimit_roof, soilstorecap_roof, wetthresh_roof, & ! input:
1219 state_roof_prev, soilstore_roof_prev, qn_roof, qs_roof, & ! input:
1220 sfr_wall, statelimit_wall, soilstorecap_wall, wetthresh_wall, & ! input:
1221 state_wall_prev, soilstore_wall_prev, qn_wall, qs_wall, & ! input:
1222 state_surf_next, soilstore_surf_next, ev_surf, & ! general output:
1223 state_roof_next, soilstore_roof_next, ev_roof, & ! general output:
1224 state_wall_next, soilstore_wall_next, ev_wall, & ! general output:
1225 state_per_tstep, nwstate_per_tstep, &
1226 ev0_surf, qe0_surf, &
1227 qe, qe_surf, qe_roof, qe_wall, &
1228 ev_per_tstep, runoff_per_tstep, &
1229 surf_chang_per_tstep, runoffpipes, &
1230 runoffwaterbody, &
1231 runoffagveg, runoffagimpervious, rss_surf)
1232 !======== Evaporation and surface state_id end========
1233 END IF
1234 IF (diagnose == 1) print *, 'before SUEWS_cal_SoilState soilstore_id = ', soilstore_surf_next
1235
1236 !=== Horizontal movement between soil stores ===
1237 ! Now water is allowed to move horizontally between the soil stores
1238 IF (diagnose == 1) WRITE (*, *) 'Calling SUEWS_cal_HorizontalSoilWater...'
1240 sfr_surf, & ! input: ! surface fractions
1241 soilstorecap_surf, & !Capacity of soil store for each surface [mm]
1242 soildepth, & !Depth of sub-surface soil store for each surface [mm]
1243 sathydraulicconduct, & !Saturated hydraulic conductivity for each soil subsurface [mm s-1]
1244 surfacearea, & !Surface area of the study area [m2]
1245 nonwaterfraction, & ! sum of surface cover fractions for all except water surfaces
1246 tstep_real, & !tstep cast as a real for use in calculations
1247 soilstore_surf_next, & ! inout:!Soil moisture of each surface type [mm]
1248 runoffsoil, & !Soil runoff from each soil sub-surface [mm]
1249 runoffsoil_per_tstep & ! output:!Runoff to deep soil per timestep [mm] (for whole surface, excluding water body)
1250 )
1251
1252 !========== Calculate soil moisture ============
1253 IF (diagnose == 1) WRITE (*, *) 'Calling SUEWS_cal_SoilState...'
1254 CALL suews_cal_soilstate( &
1255 smdmethod, xsmd, nonwaterfraction, soilmoistcap, & !input
1256 soilstorecap_surf, surf_chang_per_tstep, &
1257 soilstore_surf_next, soilstore_surf_prev, sfr_surf, &
1258 smd, smd_nsurf, tot_chang_per_tstep, soilstate) !output
1259
1260 !============ Sensible heat flux ===============
1261 IF (diagnose == 1) WRITE (*, *) 'Calling SUEWS_cal_QH...'
1262 CALL suews_cal_qh( &
1263 1, nlayer, storageheatmethod, & !input
1264 qn, qf, qmrain, qe, qs, qmfreez, qm, avdens, avcp, &
1265 sfr_surf, sfr_roof, sfr_wall, &
1266 tsfc_out_surf, tsfc_out_roof, tsfc_out_wall, &
1267 temp_c, &
1268 ra_h, &
1269 qh, qh_residual, qh_resist, & !output
1270 qh_resist_surf, qh_resist_roof, qh_resist_wall)
1271 ! PRINT *, 'qn_surf after SUEWS_cal_QH', qn_surf
1272 ! PRINT *, 'qs_surf after SUEWS_cal_QH', qs_surf
1273 ! PRINT *, 'qe_surf after SUEWS_cal_QH', qe_surf
1274 ! PRINT *, 'qh_surf after SUEWS_cal_QH (resist)', qh_surf
1275 ! PRINT *, 'qh_roof after SUEWS_cal_QH (resist)', qh_roof
1276 ! PRINT *, 'qh_wall after SUEWS_cal_QH (resist)', qh_wall
1277 ! PRINT *, ''
1278
1279 ! PRINT *, 'tsfc_surf after SUEWS_cal_QH (resist)', tsfc_out_surf
1280 ! PRINT *, 'tsfc_roof after SUEWS_cal_QH (resist)', tsfc_out_roof
1281 ! PRINT *, 'tsfc_wall after SUEWS_cal_QH (resist)', tsfc_out_wall
1282 ! PRINT *, ''
1283 ! PRINT *, ' qh_residual: ', qh_residual, ' qh_resist: ', qh_resist
1284 ! PRINT *, ' dif_qh: ', ABS(qh_residual - qh_resist)
1285 !============ Sensible heat flux end ===============
1286
1287 ! residual heat flux
1288 ! PRINT *, 'residual surf: ', qn_surf + qf - qs_surf - qe_surf - qh_surf
1289 ! PRINT *, 'residual roof: ', qn_roof + qf - qs_roof - qe_roof - qh_roof
1290 ! PRINT *, 'residual wall: ', qn_wall + qf - qs_wall - qe_wall - qh_wall
1291
1292 !============ Sensible heat flux end===============
1293
1294 !============ calculate surface temperature ===============
1295 tsfc_c = cal_tsfc(qh, avdens, avcp, ra_h, temp_c)
1296
1297 !============= calculate surface specific QH and Tsfc ===============
1298 ! note: tsfc has an upper limit of temp_c+50 to avoid numerical errors
1299 tsfc0_out_surf = min(tsfc_out_surf, temp_c + 50)
1300 tsfc0_out_roof = min(tsfc_out_roof, temp_c + 50)
1301 tsfc0_out_wall = min(tsfc_out_wall, temp_c + 50)
1302
1303 qh_surf = qn_surf + qf - qs_surf - qe_surf
1304 qh_roof = qn_roof + qf - qs_roof - qe_roof
1305 qh_wall = qn_wall + qf - qs_wall - qe_wall
1306 IF (diagnose == 1) THEN
1307 print *, 'qn_surf before QH back env.:', qn_surf
1308 print *, 'qf before QH back env.:', qf
1309 print *, 'qs_surf before QH back env.:', qs_surf
1310 print *, 'qe_surf before QH back env.:', qe_surf
1311 print *, 'qh_surf before QH back env.:', qh_surf
1312
1313 print *, 'qn_roof before QH back env.:', qn_roof
1314 print *, 'qs_roof before QH back env.:', qs_roof
1315 print *, 'qe_roof before QH back env.:', qe_roof
1316 print *, 'qh_roof before QH back env.:', qh_roof
1317
1318 END IF
1319 DO i_surf = 1, nsurf
1320 ! TSfc_QH_surf(i_surf) = cal_tsfc(qh_surf(i_surf), avdens, avcp, RA_h, temp_c)
1321 tsfc_out_surf(i_surf) = cal_tsfc(qh_surf(i_surf), avdens, avcp, ra_h, temp_c)
1322 ! if ( i_surf==1 ) then
1323 ! tsfc_out_surf(i_surf) = cal_tsfc(qh_surf(i_surf), avdens, avcp, RA_h, temp_c)
1324 ! else
1325 ! tsfc_out_surf(i_surf)=tsfc0_out_surf(i_surf)
1326 ! end if
1327 ! restrict calculated heat storage to a sensible range
1328 ! tsfc_out_surf(i_surf) = MAX(MIN(tsfc_out_surf(i_surf), 100.0), -100.0)
1329 END DO
1330
1331 DO i_surf = 1, nlayer
1332 tsfc_out_roof(i_surf) = cal_tsfc(qh_roof(i_surf), avdens, avcp, ra_h, temp_c)
1333 tsfc_out_wall(i_surf) = cal_tsfc(qh_wall(i_surf), avdens, avcp, ra_h, temp_c)
1334 END DO
1335
1336 IF (diagnose == 1) print *, 'tsfc_surf after QH back env.:', tsfc_out_surf
1337 ! print *,'tsfc_roof after QH back env.:',tsfc_out_roof
1338 IF (diagnose == 1) print *, &
1339 'tsfc_surf abs. diff.:', maxval(abs(tsfc_out_surf - tsfc0_out_surf)), maxloc(abs(tsfc_out_surf - tsfc0_out_surf))
1340 dif_tsfc_iter = maxval(abs(tsfc_out_surf - tsfc0_out_surf))
1341 IF (storageheatmethod == 5) THEN
1342 IF (diagnose == 1) print *, &
1343 'tsfc_roof abs. diff.:', maxval(abs(tsfc_out_roof - tsfc0_out_roof)), maxloc(abs(tsfc_out_roof - tsfc0_out_roof))
1344 dif_tsfc_iter = max(maxval(abs(tsfc_out_roof - tsfc0_out_roof)), dif_tsfc_iter)
1345 IF (diagnose == 1) print *, &
1346 'tsfc_wall abs. diff.:', maxval(abs(tsfc_out_wall - tsfc0_out_wall)), maxloc(abs(tsfc_out_wall - tsfc0_out_wall))
1347 dif_tsfc_iter = max(maxval(abs(tsfc0_out_wall - tsfc_out_wall)), dif_tsfc_iter)
1348 END IF
1349
1350 ! ====test===
1351 ! see if this converges better
1352 ratio_iter = .4
1353 tsfc_out_surf = (tsfc0_out_surf*(1 - ratio_iter) + tsfc_out_surf*ratio_iter)
1354 tsfc_out_roof = (tsfc0_out_roof*(1 - ratio_iter) + tsfc_out_roof*ratio_iter)
1355 tsfc_out_wall = (tsfc0_out_wall*(1 - ratio_iter) + tsfc_out_wall*ratio_iter)
1356 ! =======test end=======
1357
1358 ! PRINT *, 'tsfc_surf after qh_cal', TSfc_QH_surf
1359
1360 !============ surface-level diagonostics end ===============
1361
1362 ! force quit do-while, i.e., skip iteration and use NARP for Tsurf calculation
1363 ! if (NetRadiationMethod < 10 .or. NetRadiationMethod > 100) exit
1364
1365 ! Test if sensible heat fluxes converge in iterations
1366 ! if (abs(QH - QH_Init) > 0.1) then
1367 ! IF (ABS(Ts_iter - TSfc_C) > 0.1) THEN
1368 ! flag_converge = .FALSE.
1369 ! ELSE
1370 ! flag_converge = .TRUE.
1371 ! PRINT *, 'Iteration done in', i_iter, ' iterations'
1372 ! PRINT *, ' Ts_iter: ', Ts_iter, ' TSfc_C: ', TSfc_C
1373 ! END IF
1374 ! IF (MINVAL(ABS(TSfc_QH_surf - tsfc_surf)) > 0.1) THEN
1375 ! IF (ABS(qh_residual - qh_resist) > .2) THEN
1376 IF (dif_tsfc_iter > .1) THEN
1377 flag_converge = .false.
1378 ELSE
1379 flag_converge = .true.
1380 ! PRINT *, 'Iteration done in', i_iter, ' iterations'
1381 ! PRINT *, ' qh_residual: ', qh_residual, ' qh_resist: ', qh_resist
1382 ! PRINT *, ' dif_qh: ', ABS(qh_residual - qh_resist)
1383 ! PRINT *, ' abs. dif_tsfc: ', dif_tsfc_iter
1384
1385 END IF
1386
1387 i_iter = i_iter + 1
1388 ! force quit do-while loop if not convergent after 100 iterations
1389 IF (diagnose == 1 .AND. i_iter == max_iter) THEN
1390 ! PRINT *, 'Iteration did not converge in', i_iter, ' iterations'
1391 ! PRINT *, ' qh_residual: ', qh_residual, ' qh_resist: ', qh_resist
1392 ! PRINT *, ' dif_qh: ', ABS(qh_residual - qh_resist)
1393 ! PRINT *, ' Ts_iter: ', Ts_iter, ' TSfc_C: ', TSfc_C
1394 ! PRINT *, ' abs. dif_tsfc: ', dif_tsfc_iter
1395 ! exit
1396 END IF
1397
1398 ! Ts_iter = TSfc_C
1399 ! l_mod_iter = l_mod
1400 ! PRINT *, '========================='
1401 ! PRINT *, ''
1402 !==============main calculation end=======================
1403 END DO ! end iteration for tsurf calculations
1404
1405 !==============================================================
1406 ! Calculate diagnostics: these variables are decoupled from the main SUEWS calculation
1407
1408 !============ roughness sub-layer diagonostics ===============
1409 IF (diagnose == 1) WRITE (*, *) 'Calling RSLProfile...'
1410 CALL rslprofile( &
1411 diagmethod, &
1412 zh, z0m, zdm, z0v, &
1413 l_mod, sfr_surf, fai, pai, &
1414 stabilitymethod, ra_h, &
1415 avcp, lv_j_kg, avdens, &
1416 avu1, temp_c, avrh, press_hpa, z, qh, qe, & ! input
1417 t2_c, q2_gkg, u10_ms, rh2, & !output
1418 dataoutlinersl) ! output
1419
1420 ! ============ BIOGENIC CO2 FLUX =======================
1421 CALL suews_cal_biogenco2( &
1422 alpha_bioco2, alpha_enh_bioco2, kdown, avrh, beta_bioco2, beta_enh_bioco2, & ! input:
1423 dectime, diagnose, emissionsmethod, fc_anthro, g1, g2, g3, g4, &
1424 g5, g6, gfunc, gsmodel, id, it, kmax, lai_id_next, laimin, &
1425 laimax, maxconductance, min_res_bioco2, press_hpa, resp_a, &
1426 resp_b, s1, s2, sfr_surf, smdmethod, snowfrac, t2_c, temp_c, theta_bioco2, th, tl, vsmd, xsmd, &
1427 fc, fc_biogen, fc_photo, fc_respi) ! output:
1428
1429 ! calculations of diagnostics end
1430 !==============================================================
1431
1432 !==============================================================
1433 ! update inout variables with new values
1434 qn_av = qn_av_next
1435 dqndt = dqndt_next
1436 qn_s_av = qn_s_av_next
1437 dqnsdt = dqnsdt_next
1438 snowfallcum = snowfallcum_next
1439 snowalb = snowalb_next
1440 icefrac = icefrac_next
1441 snowwater = snowwater_next
1442 snowdens = snowdens_next
1443 snowfrac = snowfrac_next
1444 snowpack = snowpack_next
1445
1446 soilstore_surf = soilstore_surf_next
1447 state_surf = state_surf_next
1448 alb = alb_next
1449 gdd_id = gdd_id_next
1450 sdd_id = sdd_id_next
1451 lai_id = lai_id_next
1452 decidcap_id = decidcap_id_next
1453 albdectr_id = albdectr_id_next
1454 albevetr_id = albevetr_id_next
1455 albgrass_id = albgrass_id_next
1456 porosity_id = porosity_id_next
1457 storedrainprm = storedrainprm_next
1458 tair_av = tair_av_next
1459 tmin_id = tmin_id_next
1460 tmax_id = tmax_id_next
1461 lenday_id = lenday_id_next
1462 hdd_id = hdd_id_next
1463 wuday_id = wuday_id_next
1464
1465 IF (storageheatmethod == 5) THEN
1466 ! ESTM_ext related
1467 temp_roof = temp_out_roof
1468 temp_wall = temp_out_wall
1469 temp_surf = temp_out_surf
1470 tsfc_roof = tsfc_out_roof
1471 tsfc_wall = tsfc_out_wall
1472 tsfc_surf = tsfc_out_surf
1473
1474 soilstore_roof = soilstore_roof_next
1475 state_roof = state_roof_next
1476 soilstore_wall = soilstore_wall_next
1477 state_wall = state_wall_next
1478 END IF
1479
1480 !==============use SOLWEIG to get localised radiation flux==================
1481 ! if (sfr_surf(BldgSurf) > 0) then
1482 ! CALL SOLWEIG_cal_main(id, it, dectime, 0.8d0, FAI, avkdn, ldown, Temp_C, avRh, Press_hPa, TSfc_C, &
1483 ! lat, ZENITH_deg, azimuth, 1.d0, alb(1), alb(2), emis(1), emis(2), bldgH, dataOutLineSOLWEIG)
1484 ! else
1485 ! dataOutLineSOLWEIG = set_nan(dataOutLineSOLWEIG)
1486 ! endif
1487
1488 !==============use BEERS to get localised radiation flux==================
1489 ! TS 14 Jan 2021: BEERS is a modified version of SOLWEIG
1490 IF (sfr_surf(bldgsurf) > 0) THEN
1491 pai = sfr_surf(2)/sum(sfr_surf(1:2))
1492 CALL beers_cal_main(iy, id, dectime, pai, fai, kdown, ldown, temp_c, avrh, &
1493 press_hpa, tsfc_c, lat, lng, alt, timezone, zenith_deg, azimuth, &
1494 alb(1), alb(2), emis(1), emis(2), &
1495 dataoutlinebeers) ! output
1496 ! CALL SOLWEIG_cal_main(id, it, dectime, 0.8d0, FAI, avkdn, ldown, Temp_C, avRh, Press_hPa, TSfc_C, &
1497 ! lat, ZENITH_deg, azimuth, 1.d0, alb(1), alb(2), emis(1), emis(2), bldgH, dataOutLineSOLWEIG)
1498 ELSE
1499 dataoutlinebeers = set_nan(dataoutlinebeers)
1500 END IF
1501
1502 !==============translation of output variables into output array===========
1504 additionalwater, alb, kdown, u10_ms, azimuth, & !input
1505 chsnow_per_interval, dectime, &
1506 drain_per_tstep, qe_lumps, ev_per_tstep, wu_ext, fc, fc_build, fcld, &
1507 fc_metab, fc_photo, fc_respi, fc_point, fc_traff, flowchange, &
1508 qh_lumps, id, imin, wu_int, it, iy, &
1509 kup, lai_id, ldown, l_mod, lup, mwh, &
1510 mwstore, &
1511 nsh_real, nwstate_per_tstep, precip, q2_gkg, &
1512 qe, qf, qh, qh_resist, qm, qmfreez, &
1513 qmrain, qn, qn_snow, qn_snowfree, qs, ra_h, &
1514 rs, rh2, runoffagimpervious, runoffagveg, &
1515 runoff_per_tstep, runoffpipes, runoffsoil_per_tstep, &
1516 runoffwaterbody, sfr_surf, smd, smd_nsurf, snowalb, snowremoval, &
1517 state_surf_next, state_per_tstep, surf_chang_per_tstep, swe, t2_c, tsfc_c, &
1518 tot_chang_per_tstep, tsurf, ustar, &
1519 wu_surf, &
1520 z0m, zdm, zenith_deg, &
1521 datetimeline, dataoutlinesuews) !output
1522
1524 iy, id, it, imin, dectime, nlayer, & !input
1525 tsfc_out_surf, qs_surf, &
1526 tsfc_out_roof, &
1527 qn_roof, &
1528 qs_roof, &
1529 qe_roof, &
1530 qh_roof, &
1531 state_roof, &
1532 soilstore_roof, &
1533 tsfc_out_wall, &
1534 qn_wall, &
1535 qs_wall, &
1536 qe_wall, &
1537 qh_wall, &
1538 state_wall, &
1539 soilstore_wall, &
1540 datetimeline, dataoutlineestmext) !output
1541
1542 ! daily state_id:
1543 CALL update_dailystateline( &
1544 it, imin, nsh_real, & !input
1545 gdd_id, hdd_id, lai_id, &
1546 sdd_id, &
1547 tmin_id, tmax_id, lenday_id, &
1548 decidcap_id, &
1549 albdectr_id, &
1550 albevetr_id, &
1551 albgrass_id, &
1552 porosity_id, &
1553 wuday_id, &
1554 deltalai, vegphenlumps, &
1555 snowalb, snowdens, &
1556 a1, a2, a3, &
1557 dailystateline) !out
1558
1559 !==============translation end ================
1560
1561 dataoutlinedebug = &
1562 [tsfc0_out_surf, &
1563 qn_surf, qs_surf, qe0_surf, qe_surf, qh_surf, & ! energy balance
1564 wu_surf, ev0_surf, ev_surf, drain_surf, state_surf_prev, state_surf_next, soilstore_surf_prev, soilstore_surf_next, & ! water balance
1565 rs, ra_h, rb, rasnow, rss_surf, & ! for debugging QE
1566 vpd_hpa, lv_j_kg, avdens, avcp, s_hpa, psyc_hpa, & ! for debugging QE
1567 i_iter*1d0, dqndt]
1568
1569 END SUBROUTINE suews_cal_main
1570 ! ================================================================================
1571
1572 ! ===================ANTHROPOGENIC HEAT + CO2 FLUX================================
1574 AH_MIN, AHProf_24hr, AH_SLOPE_Cooling, AH_SLOPE_Heating, CO2PointSource, & ! input:
1575 dayofWeek_id, DLS, EF_umolCO2perJ, EmissionsMethod, EnEF_v_Jkm, &
1576 FcEF_v_kgkm, FrFossilFuel_Heat, FrFossilFuel_NonHeat, HDD_id, HumActivity_24hr, &
1577 imin, it, MaxFCMetab, MaxQFMetab, MinFCMetab, MinQFMetab, &
1578 PopDensDaytime, PopDensNighttime, PopProf_24hr, QF, QF0_BEU, Qf_A, Qf_B, Qf_C, &
1579 QF_obs, QF_SAHP, SurfaceArea, BaseT_Cooling, BaseT_Heating, &
1580 Temp_C, TrafficRate, TrafficUnits, TraffProf_24hr, &
1581 Fc_anthro, Fc_build, Fc_metab, Fc_point, Fc_traff) ! output:
1582
1583 IMPLICIT NONE
1584
1585 ! INTEGER, INTENT(in)::Diagnose
1586 INTEGER, INTENT(in) :: DLS ! daylighting savings
1587 INTEGER, INTENT(in) :: EmissionsMethod !0 - Use values in met forcing file, or default QF;1 - Method according to Loridan et al. (2011) : SAHP; 2 - Method according to Jarvi et al. (2011) : SAHP_2
1588 ! INTEGER, INTENT(in) :: id
1589 INTEGER, INTENT(in) :: it ! hour [H]
1590 INTEGER, INTENT(in) :: imin ! minutes [M]
1591 ! INTEGER, INTENT(in) :: nsh
1592 INTEGER, DIMENSION(3), INTENT(in) :: dayofWeek_id ! 1 - day of week; 2 - month; 3 - season
1593
1594 REAL(KIND(1D0)), DIMENSION(6, 2), INTENT(in) :: HDD_id ! Heating Degree Days (see SUEWS_DailyState.f95)
1595
1596 REAL(KIND(1D0)), DIMENSION(2), INTENT(in) :: AH_MIN ! miniumum anthropogenic heat flux [W m-2]
1597 REAL(KIND(1D0)), DIMENSION(2), INTENT(in) :: AH_SLOPE_Heating ! heating slope for the anthropogenic heat flux calculation [W m-2 K-1]
1598 REAL(KIND(1D0)), DIMENSION(2), INTENT(in) :: AH_SLOPE_Cooling ! cooling slope for the anthropogenic heat flux calculation [W m-2 K-1]
1599 REAL(KIND(1D0)), DIMENSION(2), INTENT(in) :: FcEF_v_kgkm ! CO2 Emission factor [kg km-1]
1600 ! REAL(KIND(1d0)), DIMENSION(2), INTENT(in)::NumCapita
1601 REAL(KIND(1D0)), DIMENSION(2), INTENT(in) :: PopDensDaytime ! Daytime population density [people ha-1] (i.e. workers)
1602 REAL(KIND(1D0)), DIMENSION(2), INTENT(in) :: QF0_BEU ! Fraction of base value coming from buildings [-]
1603 REAL(KIND(1D0)), DIMENSION(2), INTENT(in) :: Qf_A ! Base value for QF [W m-2]
1604 REAL(KIND(1D0)), DIMENSION(2), INTENT(in) :: Qf_B ! Parameter related to heating degree days [W m-2 K-1 (Cap ha-1 )-1]
1605 REAL(KIND(1D0)), DIMENSION(2), INTENT(in) :: Qf_C ! Parameter related to cooling degree days [W m-2 K-1 (Cap ha-1 )-1]
1606 REAL(KIND(1D0)), DIMENSION(2), INTENT(in) :: BaseT_Heating ! base temperatrue for heating degree day [degC]
1607 REAL(KIND(1D0)), DIMENSION(2), INTENT(in) :: BaseT_Cooling ! base temperature for cooling degree day [degC]
1608 REAL(KIND(1D0)), DIMENSION(2), INTENT(in) :: TrafficRate ! Traffic rate [veh km m-2 s-1]
1609
1610 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(in) :: AHProf_24hr ! diurnal profile of anthropogenic heat flux (AVERAGE of the multipliers is equal to 1) [-]
1611 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(in) :: HumActivity_24hr ! diurnal profile of human activity [-]
1612 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(in) :: TraffProf_24hr ! diurnal profile of traffic activity calculation[-]
1613 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(in) :: PopProf_24hr ! diurnal profile of population [-]
1614
1615 REAL(KIND(1D0)), INTENT(in) :: CO2PointSource ! point source [kgC day-1]
1616 REAL(KIND(1D0)), INTENT(in) :: EF_umolCO2perJ !co2 emission factor [umol J-1]
1617 REAL(KIND(1D0)), INTENT(in) :: EnEF_v_Jkm ! energy emission factor [J K m-1]
1618 REAL(KIND(1D0)), INTENT(in) :: FrFossilFuel_Heat ! fraction of fossil fuel heat [-]
1619 REAL(KIND(1D0)), INTENT(in) :: FrFossilFuel_NonHeat ! fraction of fossil fuel non heat [-]
1620 REAL(KIND(1D0)), INTENT(in) :: MaxFCMetab ! maximum FC metabolism [umol m-2 s-1]
1621 REAL(KIND(1D0)), INTENT(in) :: MaxQFMetab ! maximum QF Metabolism [W m-2]
1622 REAL(KIND(1D0)), INTENT(in) :: MinFCMetab ! minimum QF metabolism [umol m-2 s-1]
1623 REAL(KIND(1D0)), INTENT(in) :: MinQFMetab ! minimum FC metabolism [W m-2]
1624 REAL(KIND(1D0)), INTENT(in) :: PopDensNighttime ! nighttime population density [ha-1] (i.e. residents)
1625 REAL(KIND(1D0)), INTENT(in) :: QF_obs ! observed anthropogenic heat flux from met forcing file when EmissionMethod=0 [W m-2]
1626 REAL(KIND(1D0)), INTENT(in) :: Temp_C ! air temperature [degC]
1627 REAL(KIND(1D0)), INTENT(in) :: TrafficUnits ! traffic units choice [-]
1628
1629 ! REAL(KIND(1d0)), DIMENSION(nsurf), INTENT(in)::sfr_surf
1630 ! REAL(KIND(1d0)), DIMENSION(nsurf), INTENT(in)::SnowFrac
1631 REAL(KIND(1D0)), INTENT(IN) :: SurfaceArea !surface area [m-2]
1632
1633 REAL(KIND(1D0)), INTENT(out) :: Fc_anthro ! anthropogenic co2 flux [umol m-2 s-1]
1634 REAL(KIND(1D0)), INTENT(out) :: Fc_build ! co2 emission from building component [umol m-2 s-1]
1635 REAL(KIND(1D0)), INTENT(out) :: Fc_metab ! co2 emission from metabolism component [umol m-2 s-1]
1636 REAL(KIND(1D0)), INTENT(out) :: Fc_point ! co2 emission from point source [umol m-2 s-1]
1637 REAL(KIND(1D0)), INTENT(out) :: Fc_traff ! co2 emission from traffic component [umol m-2 s-1]
1638 REAL(KIND(1D0)), INTENT(out) :: QF ! anthropogeic heat flux when EmissionMethod = 0 [W m-2]
1639 REAL(KIND(1D0)), INTENT(out) :: QF_SAHP !total anthropogeic heat flux when EmissionMethod is not 0 [W m-2]
1640
1641 INTEGER, PARAMETER :: notUsedI = -999
1642 REAL(KIND(1D0)), PARAMETER :: notUsed = -999
1643
1644 IF (emissionsmethod == 0) THEN ! use observed qf
1645 qf = qf_obs
1646 ELSEIF ((emissionsmethod > 0 .AND. emissionsmethod <= 6) .OR. emissionsmethod >= 11) THEN
1648 co2pointsource, emissionsmethod, &
1649 it, imin, dls, dayofweek_id, &
1650 ef_umolco2perj, fcef_v_kgkm, enef_v_jkm, trafficunits, &
1651 frfossilfuel_heat, frfossilfuel_nonheat, &
1652 minfcmetab, maxfcmetab, minqfmetab, maxqfmetab, &
1653 popdensdaytime, popdensnighttime, &
1654 temp_c, hdd_id, qf_a, qf_b, qf_c, &
1655 ah_min, ah_slope_heating, ah_slope_cooling, &
1656 baset_heating, baset_cooling, &
1657 trafficrate, &
1658 qf0_beu, qf_sahp, &
1659 fc_anthro, fc_metab, fc_traff, fc_build, fc_point, &
1660 ahprof_24hr, humactivity_24hr, traffprof_24hr, popprof_24hr, surfacearea)
1661
1662 ELSE
1663 CALL errorhint(73, 'RunControl.nml:EmissionsMethod unusable', notused, notused, emissionsmethod)
1664 END IF
1665
1666 IF (emissionsmethod >= 1) qf = qf_sahp
1667
1668 IF (emissionsmethod >= 0 .AND. emissionsmethod <= 6) THEN
1669 fc_anthro = 0
1670 fc_metab = 0
1671 fc_traff = 0
1672 fc_build = 0
1673 fc_point = 0
1674 END IF
1675
1676 END SUBROUTINE suews_cal_anthropogenicemission
1677 ! ================================================================================
1678
1679 !==============BIOGENIC CO2 flux==================================================
1681 alpha_bioCO2, alpha_enh_bioCO2, avkdn, avRh, beta_bioCO2, beta_enh_bioCO2, & ! input:
1682 dectime, Diagnose, EmissionsMethod, Fc_anthro, G1, G2, G3, G4, &
1683 G5, G6, gfunc, gsmodel, id, it, Kmax, LAI_id, LAIMin, &
1684 LAIMax, MaxConductance, min_res_bioCO2, Press_hPa, resp_a, &
1685 resp_b, S1, S2, sfr_surf, SMDMethod, SnowFrac, t2_C, Temp_C, theta_bioCO2, TH, TL, vsmd, xsmd, &
1686 Fc, Fc_biogen, Fc_photo, Fc_respi) ! output:
1687
1688 IMPLICIT NONE
1689
1690 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(in) :: alpha_bioCO2 !The mean apparent ecosystem quantum. Represents the initial slope of the light-response curve [-]
1691 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(in) :: alpha_enh_bioCO2 !part of the alpha coefficient related to the fraction of vegetation [-]
1692 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(in) :: beta_bioCO2 !The light-saturated gross photosynthesis of the canopy [umol m-2 s-1 ]
1693 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(in) :: beta_enh_bioCO2 !Part of the beta coefficient related to the fraction of vegetation [umol m-2 s-1 ]
1694 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(in) :: LAI_id !=LAI(id-1,:), LAI for each veg surface [m2 m-2]
1695 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(in) :: LAIMin !Min LAI [m2 m-2]
1696 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(in) :: LAIMax !Max LAI [m2 m-2]
1697 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(in) :: min_res_bioCO2 !minimum soil respiration rate (for cold-temperature limit) [umol m-2 s-1]
1698 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(in) :: resp_a !Respiration coefficient a
1699 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(in) :: resp_b !Respiration coefficient b - related to air temperature dependency
1700 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(in) :: theta_bioCO2 !The convexity of the curve at light saturation [-]
1701
1702 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: sfr_surf ! surface fraction [-]
1703 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SnowFrac !surface fraction of snow cover [-]
1704
1705 REAL(KIND(1D0)), DIMENSION(3), INTENT(in) :: MaxConductance !max conductance [mm s-1]
1706
1707 ! INTEGER, INTENT(in) :: BSoilSurf
1708 ! INTEGER, INTENT(in) :: ConifSurf
1709 ! INTEGER, INTENT(in) :: DecidSurf
1710 INTEGER, INTENT(in) :: Diagnose
1711 INTEGER, INTENT(in) :: EmissionsMethod
1712 ! INTEGER, INTENT(in) :: GrassSurf
1713 INTEGER, INTENT(in) :: gsmodel !choice of gs parameterisation (1 = Ja11, 2 = Wa16)
1714 INTEGER, INTENT(in) :: id !day of year [-]
1715 INTEGER, INTENT(in) :: it ! hour [H]
1716 ! INTEGER, INTENT(in) :: ivConif
1717 ! INTEGER, INTENT(in) :: ivDecid
1718 ! INTEGER, INTENT(in) :: ivGrass
1719 ! INTEGER, INTENT(in) :: nsurf
1720 ! INTEGER, INTENT(in) :: NVegSurf
1721 INTEGER, INTENT(in) :: SMDMethod !Method of measured soil moisture [-]
1722
1723 REAL(KIND(1D0)), INTENT(in) :: avkdn !Average downwelling shortwave radiation [W m-2]
1724 REAL(KIND(1D0)), INTENT(in) :: avRh !average relative humidity (%) [-]
1725 REAL(KIND(1D0)), INTENT(in) :: dectime !decimal time [-]
1726 REAL(KIND(1D0)), INTENT(in) :: Fc_anthro !anthropogenic co2 flux [umol m-2 s-1]
1727 REAL(KIND(1D0)), INTENT(in) :: G1 !Fitted parameters related to surface res. calculations
1728 REAL(KIND(1D0)), INTENT(in) :: G2 !Fitted parameters related to surface res. calculations
1729 REAL(KIND(1D0)), INTENT(in) :: G3 !Fitted parameters related to surface res. calculations
1730 REAL(KIND(1D0)), INTENT(in) :: G4 !Fitted parameters related to surface res. calculations
1731 REAL(KIND(1D0)), INTENT(in) :: G5 !Fitted parameters related to surface res. calculations
1732 REAL(KIND(1D0)), INTENT(in) :: G6 !Fitted parameters related to surface res. calculations
1733 REAL(KIND(1D0)), INTENT(in) :: gfunc
1734 REAL(KIND(1D0)), INTENT(in) :: Kmax !annual maximum hourly solar radiation [W m-2]
1735 REAL(KIND(1D0)), INTENT(in) :: Press_hPa !air pressure [hPa]
1736 REAL(KIND(1D0)), INTENT(in) :: S1 !a parameter related to soil moisture dependence [-]
1737 REAL(KIND(1D0)), INTENT(in) :: S2 !a parameter related to soil moisture dependence [mm]
1738 REAL(KIND(1D0)), INTENT(in) :: t2_C !modelled 2 meter air temperature [degC]
1739 REAL(KIND(1D0)), INTENT(in) :: Temp_C ! measured air temperature [degC]
1740 REAL(KIND(1D0)), INTENT(in) :: TH !Maximum temperature limit [degC]
1741 REAL(KIND(1D0)), INTENT(in) :: TL !Minimum temperature limit [degC]
1742 REAL(KIND(1D0)), INTENT(in) :: vsmd !Soil moisture deficit for vegetated surfaces only [mm]
1743 REAL(KIND(1D0)), INTENT(in) :: xsmd !Measured soil moisture deficit [mm]
1744
1745 REAL(KIND(1D0)), INTENT(out) :: Fc_biogen !biogenic CO2 flux [umol m-2 s-1]
1746 REAL(KIND(1D0)), INTENT(out) :: Fc_photo !co2 flux from photosynthesis [umol m-2 s-1]
1747 REAL(KIND(1D0)), INTENT(out) :: Fc_respi !co2 flux from respiration [umol m-2 s-1]
1748 REAL(KIND(1D0)), INTENT(out) :: Fc !total co2 flux [umol m-2 s-1]
1749
1750 REAL(KIND(1D0)) :: gfunc2 !gdq*gtemp*gs*gq for photosynthesis calculations (With modelled 2 meter temperature)
1751 REAL(KIND(1D0)) :: dq !Specific humidity deficit [g/kg]
1752 REAL(KIND(1D0)) :: t2 !air temperature at 2m [degC]
1753 REAL(KIND(1D0)) :: dummy1 !Latent heat of vaporization in [J kg-1]
1754 REAL(KIND(1D0)) :: dummy2 !Latent heat of sublimation in J/kg
1755 REAL(KIND(1D0)) :: dummy3 !Saturation vapour pressure over water[hPa]
1756 REAL(KIND(1D0)) :: dummy4 !Vapour pressure of water[hpa]
1757 REAL(KIND(1D0)) :: dummy5 !vapour pressure deficit[hpa]
1758 REAL(KIND(1D0)) :: dummy6 !vapour pressure deficit[pa]
1759 REAL(KIND(1D0)) :: dummy7 !Vap density or absolute humidity [kg m-3]
1760 REAL(KIND(1D0)) :: dummy8 !specific heat capacity [J kg-1 K-1]
1761 REAL(KIND(1D0)) :: dummy9 !Air density [kg m-3]
1762 REAL(KIND(1D0)) :: dummy10 !Surface Layer Conductance [mm s-1]
1763 REAL(KIND(1D0)) :: dummy11 !Surface resistance [s m-1]
1764
1765 IF (emissionsmethod >= 11) THEN
1766
1767 IF (gsmodel == 3 .OR. gsmodel == 4) THEN ! With modelled 2 meter temperature
1768 ! Call LUMPS_cal_AtmMoist for dq and SurfaceResistance for gfunc with 2 meter temperature
1769 ! If modelled 2 meter temperature is too different from measured air temperature then
1770 ! use temp_c
1771 IF (abs(temp_c - t2_c) > 5) THEN
1772 t2 = temp_c
1773 ELSE
1774 t2 = t2_c
1775 END IF
1776
1777 CALL cal_atmmoist( &
1778 t2, press_hpa, avrh, dectime, & ! input:
1779 dummy1, dummy2, & ! output:
1780 dummy3, dummy4, dummy5, dummy6, dq, dummy7, dummy8, dummy9)
1781
1782 CALL surfaceresistance( &
1783 id, it, & ! input:
1784 smdmethod, snowfrac, sfr_surf, avkdn, t2, dq, xsmd, vsmd, maxconductance, &
1785 laimax, lai_id, gsmodel, kmax, &
1786 g1, g2, g3, g4, g5, g6, th, tl, s1, s2, &
1787 gfunc2, dummy10, dummy11) ! output:
1788 END IF
1789
1790 ! Calculate CO2 fluxes from biogenic components
1791 IF (diagnose == 1) WRITE (*, *) 'Calling CO2_biogen...'
1792 CALL co2_biogen( &
1793 alpha_bioco2, alpha_enh_bioco2, avkdn, beta_bioco2, beta_enh_bioco2, bsoilsurf, & ! input:
1794 conifsurf, decidsurf, dectime, emissionsmethod, gfunc, gfunc2, grasssurf, gsmodel, &
1795 id, it, ivconif, ivdecid, ivgrass, lai_id, laimin, laimax, min_res_bioco2, nsurf, &
1796 nvegsurf, resp_a, resp_b, sfr_surf, snowfrac, t2, temp_c, theta_bioco2, &
1797 fc_biogen, fc_photo, fc_respi) ! output:
1798 END IF
1799
1800 IF (emissionsmethod >= 0 .AND. emissionsmethod <= 6) THEN
1801 fc_biogen = 0
1802 fc_photo = 0
1803 fc_respi = 0
1804 END IF
1805
1806 fc = fc_anthro + fc_biogen
1807
1808 END SUBROUTINE suews_cal_biogenco2
1809 !========================================================================
1810
1811 !=============net all-wave radiation=====================================
1812 SUBROUTINE suews_cal_qn( &
1813 storageheatmethod, NetRadiationMethod, SnowUse, & !input
1814 tstep, nlayer, SnowPack_prev, tau_a, tau_f, SnowAlbMax, SnowAlbMin, &
1815 Diagnose, ldown_obs, fcld_obs, &
1816 dectime, ZENITH_deg, Tsurf_0, kdown, Tair_C, avRH, ea_hPa, qn1_obs, &
1817 SnowAlb_prev, snowFrac_prev, DiagQN, &
1818 NARP_TRANS_SITE, NARP_EMIS_SNOW, IceFrac, &
1819 sfr_surf, sfr_roof, sfr_wall, &
1820 tsfc_surf, tsfc_roof, tsfc_wall, &
1821 emis, alb_prev, albDecTr_id, albEveTr_id, albGrass_id, &
1822 LAI_id, & !input
1823 n_vegetation_region_urban, &
1824 n_stream_sw_urban, n_stream_lw_urban, & !input: SPARTACUS
1825 sw_dn_direct_frac, air_ext_sw, air_ssa_sw, &
1826 veg_ssa_sw, air_ext_lw, air_ssa_lw, veg_ssa_lw, &
1827 veg_fsd_const, veg_contact_fraction_const, &
1828 ground_albedo_dir_mult_fact, use_sw_direct_albedo, & !input: SPARTACUS
1829 height, building_frac, veg_frac, building_scale, veg_scale, & !input: SPARTACUS
1830 alb_roof, emis_roof, alb_wall, emis_wall, &
1831 roof_albedo_dir_mult_fact, wall_specular_frac, &
1832 alb_next, ldown, fcld, & !output
1833 qn_surf, qn_roof, qn_wall, &
1834 qn, qn_snowfree, qn_snow, kclear, kup, lup, tsurf, &
1835 qn_ind_snow, kup_ind_snow, Tsurf_ind_snow, Tsurf_ind, &
1836 albedo_snow, SnowAlb_next, &
1837 dataOutLineSPARTACUS)
1838 USE narp_module, ONLY: radmethod, narp
1839 USE spartacus_module, ONLY: spartacus
1840
1841 IMPLICIT NONE
1842 ! INTEGER,PARAMETER ::nsurf = 7 ! number of surface types
1843 ! INTEGER,PARAMETER ::ConifSurf = 3 !New surface classes: Grass = 5th/7 surfaces
1844 ! INTEGER,PARAMETER ::DecidSurf = 4 !New surface classes: Grass = 5th/7 surfaces
1845 ! INTEGER,PARAMETER ::GrassSurf = 5
1846
1847 INTEGER, INTENT(in) :: storageheatmethod !Determines method for calculating storage heat flux ΔQS
1848 INTEGER, INTENT(in) :: NetRadiationMethod !Determines method for calculation of radiation fluxes
1849 INTEGER, INTENT(in) :: SnowUse !Determines whether the snow part of the model runs; 0-Snow calculations are not performed.1-Snow calculations are performed.
1850 INTEGER, INTENT(in) :: Diagnose
1851 INTEGER, INTENT(in) :: DiagQN
1852 INTEGER, INTENT(in) :: tstep !timestep [s]
1853 INTEGER, INTENT(in) :: nlayer !number of vertical levels in urban canopy [-]
1854
1855 ! REAL(KIND(1D0)), INTENT(in) :: snowFrac_obs
1856 REAL(KIND(1D0)), INTENT(in) :: ldown_obs !observed incoming longwave radiation [W m-2]
1857 REAL(KIND(1D0)), INTENT(in) :: fcld_obs !observed cloud fraction [-]
1858 REAL(KIND(1D0)), INTENT(in) :: dectime !decimal time [-]
1859 REAL(KIND(1D0)), INTENT(in) :: ZENITH_deg !solar zenith angle in degree [°]
1860 REAL(KIND(1D0)), INTENT(in) :: Tsurf_0
1861 REAL(KIND(1D0)), INTENT(in) :: kdown !incoming shortwave radiation [W m-2]
1862 REAL(KIND(1D0)), INTENT(in) :: Tair_C !Air temperature in degree C [degC]
1863 REAL(KIND(1D0)), INTENT(in) :: avRH !average relative humidity (%) in each layer [-]
1864 REAL(KIND(1D0)), INTENT(in) :: ea_hPa !vapor pressure [hPa]
1865 REAL(KIND(1D0)), INTENT(in) :: qn1_obs !observed net wall-wave radiation [W m-2]
1866 REAL(KIND(1D0)), INTENT(in) :: SnowAlb_prev ! snow albedo at previous timestep [-]
1867 REAL(KIND(1D0)), INTENT(in) :: NARP_EMIS_SNOW ! snow emissivity in NARP model [-]
1868 REAL(KIND(1D0)), INTENT(in) :: NARP_TRANS_SITE !Atmospheric transmissivity for NARP [-]
1869 REAL(KIND(1D0)), INTENT(in) :: tau_a, tau_f, SnowAlbMax, SnowAlbMin !tau_a=Time constant for snow albedo aging in cold snow [-], tau_f=Time constant for snow albedo aging in melting snow [-], SnowAlbMax=maxmimum snow albedo, SnowAlbMin=minimum snow albedo
1870
1871 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(in) :: LAI_id !LAI for day of year [m2 m-3]
1872
1873 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: IceFrac !fraction of ice in snowpack [-]
1874 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: sfr_surf !fraction of each surfaces [-]
1875 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: tsfc_surf ! surface temperature [degC]
1876 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: sfr_roof ! surface fraction of roofs at each surfaces [-]
1877 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tsfc_roof ! roof surface temperature [degC]
1878 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: sfr_wall ! surface fraction of walls at each surfaces [-]
1879 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tsfc_wall ! wall surface temperature [degC]
1880
1881 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: emis ! Effective surface emissivity. [-]
1882 REAL(KIND(1D0)), DIMENSION(nsurf) :: alb ! surface albedo [-]
1883 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: alb_prev ! input surface albedo [-]
1884 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: alb_next ! output surface albedo [-]
1885 REAL(KIND(1D0)), INTENT(in) :: albDecTr_id !!albedo for deciduous trees on day of year [-]
1886 ! REAL(KIND(1d0)), INTENT(in) ::DecidCap_id
1887 REAL(KIND(1D0)), INTENT(in) :: albEveTr_id !albedo for evergreen trees and shrubs on day of year [-]
1888 REAL(KIND(1D0)), INTENT(in) :: albGrass_id !albedo for grass on day of year [-]
1889
1890 ! REAL(KIND(1d0)), DIMENSION(6, nsurf), INTENT(inout)::StoreDrainPrm
1891
1892 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SnowPack_prev !initial snow water equivalent on each land cover [mm]
1893 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: snowFrac_prev !initial snow fraction [-]
1894 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: snowFrac_next
1895 REAL(KIND(1D0)), DIMENSION(nsurf) :: SnowFrac ! snow fractions of each surface [-]
1896
1897 REAL(KIND(1D0)), INTENT(out) :: ldown ! output incoming longwave radiation [W m-2]
1898 REAL(KIND(1D0)), INTENT(out) :: fcld ! estimated cloud fraction [-](used only for emissivity estimate)
1899 REAL(KIND(1D0)), INTENT(out) :: qn ! output net all-wave radiation [W m-2]
1900 REAL(KIND(1D0)), INTENT(out) :: qn_snowfree !output net all-wave radiation for snow free surface [W m-2]
1901 REAL(KIND(1D0)), INTENT(out) :: qn_snow ! output net all-wave radiation for snowpack [W m-2]
1902 REAL(KIND(1D0)), INTENT(out) :: kclear !output clear sky incoming shortwave radiation [W m-2]
1903 REAL(KIND(1D0)), INTENT(out) :: kup !output outgoing shortwave radiation [W m-2]
1904 REAL(KIND(1D0)), INTENT(out) :: lup !output outgoing longwave radiation [W m-2]
1905 REAL(KIND(1D0)), INTENT(out) :: tsurf !output surface temperature [degC]
1906 REAL(KIND(1D0)), INTENT(out) :: albedo_snow !estimated albedo of snow [-]
1907 REAL(KIND(1D0)), INTENT(out) :: SnowAlb_next !output snow albedo [-]
1908 REAL(KIND(1D0)) :: albedo_snowfree !estimated albedo for snow-free surface [-]
1909 REAL(KIND(1D0)) :: SnowAlb ! updated snow albedo [-]
1910
1911 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: qn_surf !net all-wave radiation on each surface [W m-2]
1912 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: qn_ind_snow !net all-wave radiation on snowpack [W m-2]
1913 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: kup_ind_snow !outgoing shortwave on snowpack [W m-2]
1914 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: Tsurf_ind_snow !snowpack surface temperature [C]
1915 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: tsurf_ind !snow-free surface temperature [C]
1916
1917 REAL(KIND(1D0)), DIMENSION(nsurf) :: lup_ind !outgoing longwave radiation from observation [W m-2]
1918 REAL(KIND(1D0)), DIMENSION(nsurf) :: kup_ind !outgoing shortwave radiation from observation [W m-2]
1919 REAL(KIND(1D0)), DIMENSION(nsurf) :: qn1_ind !net all-wave radiation from observation [W m-2]
1920
1921 REAL(KIND(1D0)), PARAMETER :: NAN = -999
1922 INTEGER :: NetRadiationMethod_use
1923 INTEGER :: AlbedoChoice, ldown_option
1924
1925 ! SPARTACUS output variables
1926 ! REAL(KIND(1D0)), INTENT(OUT) :: alb_spc, emis_spc, lw_emission_spc, lw_up_spc, sw_up_spc, qn_spc
1927 ! REAL(KIND(1D0)), INTENT(OUT) :: top_net_lw_spc, ground_net_lw_spc, top_dn_lw_spc
1928 ! REAL(KIND(1D0)), DIMENSION(15), INTENT(OUT) :: clear_air_abs_lw_spc, wall_net_lw_spc, roof_net_lw_spc, &
1929 ! roof_in_lw_spc
1930 ! REAL(KIND(1D0)), INTENT(OUT) :: top_dn_dir_sw_spc, top_net_sw_spc, ground_dn_dir_sw_spc, ground_net_sw_spc
1931 ! REAL(KIND(1D0)), DIMENSION(15), INTENT(OUT) :: clear_air_abs_sw_spc, wall_net_sw_spc, roof_net_sw_spc, &
1932 ! roof_in_sw_spc
1933
1934 ! SPARTACUS input variables
1935 INTEGER, INTENT(IN) :: n_vegetation_region_urban, &
1936 n_stream_sw_urban, n_stream_lw_urban
1937 REAL(KIND(1D0)), INTENT(IN) :: sw_dn_direct_frac, air_ext_sw, air_ssa_sw, &
1938 veg_ssa_sw, air_ext_lw, air_ssa_lw, veg_ssa_lw, &
1939 veg_fsd_const, veg_contact_fraction_const, &
1940 ground_albedo_dir_mult_fact
1941 LOGICAL, INTENT(IN) :: use_sw_direct_albedo !boolean, Specify ground and roof albedos separately for direct solar radiation [-]
1942
1943 REAL(KIND(1D0)), DIMENSION(nlayer + 1), INTENT(IN) :: height ! height in spartacus [m]
1944 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: building_frac ! building fraction [-]
1945 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: veg_frac !vegetation fraction [-]
1946 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: building_scale ! diameter of buildings [[m]. The only L method for buildings is Eq. 19 Hogan et al. 2018.
1947 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: veg_scale ! scale of tree crowns [m]. Using the default use_symmetric_vegetation_scale_urban=.TRUE. so that Eq. 20 Hogan et al. 2018 is used for L.
1948 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: alb_roof !albedo of roof [-]
1949 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: emis_roof ! emissivity of roof [-]
1950 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: alb_wall !albedo of wall [-]
1951 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: emis_wall ! emissivity of wall [-]
1952 REAL(KIND(1D0)), DIMENSION(nspec, nlayer), INTENT(IN) :: roof_albedo_dir_mult_fact !Ratio of the direct and diffuse albedo of the roof [-]
1953 REAL(KIND(1D0)), DIMENSION(nspec, nlayer), INTENT(IN) :: wall_specular_frac ! Fraction of wall reflection that is specular [-]
1954 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: qn_wall ! net all-wave radiation on the wall [W m-2]
1955 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: qn_roof ! net all-wave radiation on the roof [W m-2]
1956
1957 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutSPARTACUS - 5), INTENT(OUT) :: dataOutLineSPARTACUS
1958
1959 ! translate values
1960 alb = alb_prev
1961
1962 ! update snow albedo
1963 snowalb = update_snow_albedo( &
1964 tstep, snowpack_prev, snowalb_prev, tair_c, &
1965 tau_a, tau_f, snowalbmax, snowalbmin)
1966
1967 CALL radmethod( &
1968 netradiationmethod, & !input
1969 snowuse, & !input
1970 netradiationmethod_use, albedochoice, ldown_option) !output
1971
1972 snowfrac = snowfrac_prev
1973 IF (netradiationmethod_use > 0) THEN
1974
1975 ! IF (SnowUse==0) SnowFrac=snowFrac_obs
1976 IF (snowuse == 0) snowfrac = 0
1977
1978 IF (ldown_option == 2) THEN !observed cloud fraction provided as forcing
1979 fcld = fcld_obs
1980 END IF
1981
1982 !write(*,*) DecidCap(id), id, it, imin, 'Calc - near start'
1983
1984 ! Update variables that change daily and represent seasonal variability
1985 alb(decidsurf) = albdectr_id !Change deciduous albedo
1986 ! StoreDrainPrm(6, DecidSurf) = DecidCap_id !Change current storage capacity of deciduous trees
1987 ! Change EveTr and Grass albedo too
1988 alb(conifsurf) = albevetr_id
1989 alb(grasssurf) = albgrass_id
1990
1991 IF (diagnose == 1) WRITE (*, *) 'Calling NARP...'
1992 IF (diagqn == 1) WRITE (*, *) 'NetRadiationMethodX:', netradiationmethod_use
1993 IF (diagqn == 1) WRITE (*, *) 'AlbedoChoice:', albedochoice
1994
1995 ! TODO: TS 14 Feb 2022, ESTM development:
1996 ! here we use uniform `tsurf_0` for all land covers, which should be distinguished in future developments
1997
1998 CALL narp( &
1999 storageheatmethod, & !input:
2000 nsurf, sfr_surf, tsfc_surf, snowfrac, alb, emis, icefrac, & !
2001 narp_trans_site, narp_emis_snow, &
2002 dectime, zenith_deg, tsurf_0, kdown, tair_c, avrh, ea_hpa, qn1_obs, ldown_obs, &
2003 snowalb, &
2004 albedochoice, ldown_option, netradiationmethod_use, diagqn, &
2005 qn_surf, & ! output:
2006 qn, qn_snowfree, qn_snow, kclear, kup, ldown, lup, fcld, tsurf, & ! output:
2007 qn_ind_snow, kup_ind_snow, tsurf_ind_snow, tsurf_ind, albedo_snowfree, albedo_snow)
2008
2009 IF (diagqn == 1) WRITE (*, *) 'Calling SPARTACUS:'
2010 IF (netradiationmethod > 1000) THEN
2011 ! TODO: TS 14 Feb 2022, ESTM development: introduce facet surface temperatures
2012 CALL spartacus( &
2013 diagqn, & !input:
2014 sfr_surf, zenith_deg, nlayer, & !input:
2015 tsfc_surf, tsfc_roof, tsfc_wall, &
2016 kdown, ldown, tair_c, alb, emis, lai_id, &
2017 n_vegetation_region_urban, &
2018 n_stream_sw_urban, n_stream_lw_urban, &
2019 sw_dn_direct_frac, air_ext_sw, air_ssa_sw, &
2020 veg_ssa_sw, air_ext_lw, air_ssa_lw, veg_ssa_lw, &
2021 veg_fsd_const, veg_contact_fraction_const, &
2022 ground_albedo_dir_mult_fact, use_sw_direct_albedo, &
2023 height, building_frac, veg_frac, sfr_roof, sfr_wall, &
2024 building_scale, veg_scale, & !input:
2025 alb_roof, emis_roof, alb_wall, emis_wall, &
2026 roof_albedo_dir_mult_fact, wall_specular_frac, &
2027 qn, kup, lup, qn_roof, qn_wall, qn_surf, & !output:
2028 dataoutlinespartacus)
2029 ELSE
2030 qn_roof = qn_surf(bldgsurf)
2031 qn_wall = qn_surf(bldgsurf)
2032 END IF
2033
2034 ELSE ! NetRadiationMethod==0
2035 ! SnowFrac = snowFrac_obs
2036 qn = qn1_obs
2037 qn_snowfree = qn1_obs
2038 qn_snow = qn1_obs
2039 ldown = nan
2040 lup = nan
2041 kup = nan
2042 tsurf = nan
2043 lup_ind = nan
2044 kup_ind = nan
2045 tsurf_ind = nan
2046 qn1_ind = nan
2047 fcld = nan
2048 qn_surf = qn
2049 qn_roof = qn_surf(bldgsurf)
2050 qn_wall = qn_surf(bldgsurf)
2051 END IF
2052 ! snowFrac_next = SnowFrac
2053
2054 IF (ldown_option == 1) THEN
2055 fcld = nan
2056 END IF
2057
2058 ! translate values
2059 alb_next = alb
2060 snowalb_next = snowalb
2061
2062 END SUBROUTINE suews_cal_qn
2063 !========================================================================
2064
2065 !=============storage heat flux=========================================
2066 SUBROUTINE suews_cal_qs( &
2067 StorageHeatMethod, qs_obs, OHMIncQF, Gridiv, & !input
2068 id, tstep, dt_since_start, Diagnose, &
2069 nlayer, &
2070 QG_surf, QG_roof, QG_wall, &
2071 tsfc_roof, tin_roof, temp_in_roof, k_roof, cp_roof, dz_roof, sfr_roof, & !input
2072 tsfc_wall, tin_wall, temp_in_wall, k_wall, cp_wall, dz_wall, sfr_wall, & !input
2073 tsfc_surf, tin_surf, temp_in_surf, k_surf, cp_surf, dz_surf, sfr_surf, & !input
2074 OHM_coef, OHM_threshSW, OHM_threshWD, &
2075 soilstore_id, SoilStoreCap, state_id, SnowUse, SnowFrac, DiagQS, &
2076 HDD_id, MetForcingData_grid, Ts5mindata_ir, qf, qn, &
2077 avkdn, avu1, temp_c, zenith_deg, avrh, press_hpa, ldown, &
2078 bldgh, alb, emis, cpAnOHM, kkAnOHM, chAnOHM, EmissionsMethod, &
2079 Tair_av, qn_av_prev, dqndt_prev, qn_s_av_prev, dqnsdt_prev, &
2080 StoreDrainPrm, &
2081 qn_S, dataOutLineESTM, qs, & !output
2082 qn_av_next, dqndt_next, qn_s_av_next, dqnsdt_next, &
2083 deltaQi, a1, a2, a3, &
2084 temp_out_roof, QS_roof, & !output
2085 temp_out_wall, QS_wall, & !output
2086 temp_out_surf, QS_surf) !output
2087
2088 IMPLICIT NONE
2089
2090 INTEGER, INTENT(in) :: StorageHeatMethod !heat storage calculation option [-]
2091 INTEGER, INTENT(in) :: OHMIncQF !Determines whether the storage heat flux calculation uses Q* or ( Q* +QF)
2092 INTEGER, INTENT(in) :: Gridiv ! grid id [-]
2093 INTEGER, INTENT(in) :: id ! day of year [-]
2094 INTEGER, INTENT(in) :: tstep ! time step [s]
2095 INTEGER, INTENT(in) :: dt_since_start ! time since simulation starts [s]
2096 INTEGER, INTENT(in) :: Diagnose
2097 ! INTEGER, INTENT(in) ::nsh ! number of timesteps in one hour
2098 INTEGER, INTENT(in) :: SnowUse ! option for snow related calculations [-]
2099 INTEGER, INTENT(in) :: DiagQS ! diagnostic option [-]
2100 INTEGER, INTENT(in) :: EmissionsMethod ! AnthropHeat option [-]
2101 INTEGER, INTENT(in) :: nlayer ! number of vertical levels in urban canopy [-]
2102
2103 REAL(KIND(1D0)), INTENT(in) :: OHM_coef(nsurf + 1, 4, 3) ! OHM coefficients [-]
2104 REAL(KIND(1D0)), INTENT(in) :: OHM_threshSW(nsurf + 1) ! Temperature threshold determining whether summer/winter OHM coefficients are applied [degC]
2105 REAL(KIND(1D0)), INTENT(in) :: OHM_threshWD(nsurf + 1) ! Soil moisture threshold determining whether wet/dry OHM coefficients are applied [-]
2106 REAL(KIND(1D0)), INTENT(in) :: soilstore_id(nsurf) ! soil moisture on day of year
2107 REAL(KIND(1D0)), INTENT(in) :: SoilStoreCap(nsurf) ! capacity of soil store [J m-3 K-1]
2108 REAL(KIND(1D0)), INTENT(in) :: state_id(nsurf) ! wetness status [mm]
2109
2110 REAL(KIND(1D0)), DIMENSION(12), INTENT(in) :: HDD_id ! Heating degree day of the day of year
2111 REAL(KIND(1D0)), INTENT(in) :: qf ! anthropogenic heat lufx [W m-2]
2112 REAL(KIND(1D0)), INTENT(in) :: qn ! net all-wave radiative flux [W m-2]
2113 REAL(KIND(1D0)), INTENT(in) :: qs_obs ! observed heat storage flux [W m-2]
2114 REAL(KIND(1D0)), INTENT(in) :: avkdn, avu1, temp_c, zenith_deg, avrh, press_hpa, ldown
2115 REAL(KIND(1D0)), INTENT(in) :: bldgh ! mean building height [m]
2116
2117 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: alb ! albedo [-]
2118 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: emis ! emissivity [-]
2119 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: cpAnOHM ! heat capacity [J m-3 K-1]
2120 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: kkAnOHM ! thermal conductivity [W m-1 K-1]
2121 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: chAnOHM ! bulk transfer coef [J m-3 K-1]
2122 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SnowFrac ! snow fractions of each surface [-]
2123
2124 REAL(KIND(1D0)), DIMENSION(:, :), INTENT(in) :: MetForcingData_grid
2125
2126 REAL(KIND(1D0)), DIMENSION(:), INTENT(in) :: Ts5mindata_ir !surface temperature input data [degC]
2127
2128 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: QG_surf ! ground heat flux [W m-2]
2129 REAL(KIND(1D0)), INTENT(in) :: Tair_av ! mean air temperature of past 24hr [degC]
2130 REAL(KIND(1D0)), INTENT(in) :: qn_av_prev ! weighted average of qn [W m-2]
2131 REAL(KIND(1D0)), INTENT(out) :: qn_av_next ! weighted average of qn for previous 60 mins [W m-2]
2132 REAL(KIND(1D0)), INTENT(in) :: dqndt_prev ! Rate of change of net radiation at t-1 [W m-2 h-1]
2133 REAL(KIND(1D0)), INTENT(out) :: dqndt_next ! Rate of change of net radiation at t+1 [W m-2 h-1]
2134 REAL(KIND(1D0)), INTENT(in) :: qn_s_av_prev ! weighted average of qn over snow for previous 60mins [W m-2]
2135 REAL(KIND(1D0)), INTENT(out) :: qn_s_av_next ! weighted average of qn over snow for next 60mins [W m-2]
2136 REAL(KIND(1D0)), INTENT(in) :: dqnsdt_prev ! Rate of change of net radiation [W m-2 h-1] at t-1
2137 REAL(KIND(1D0)), INTENT(out) :: dqnsdt_next ! Rate of change of net radiation [W m-2 h-1] at t+1
2138 ! REAL(KIND(1d0)),DIMENSION(nsh),INTENT(inout) ::qn1_store_grid
2139 ! REAL(KIND(1d0)),DIMENSION(nsh),INTENT(inout) ::qn1_S_store_grid !< stored qn1 [W m-2]
2140
2141 ! REAL(KIND(1d0)),DIMENSION(2*nsh+1),INTENT(inout)::qn1_av_store_grid
2142 ! REAL(KIND(1d0)),DIMENSION(2*nsh+1),INTENT(inout)::qn1_S_av_store_grid !< average net radiation over previous hour [W m-2]
2143 REAL(KIND(1D0)), DIMENSION(6, nsurf), INTENT(in) :: StoreDrainPrm !Coefficients used in drainage calculation [-]
2144
2145 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: deltaQi ! storage heat flux of snow surfaces [W m-2]
2146
2147 REAL(KIND(1D0)), DIMENSION(27), INTENT(out) :: dataOutLineESTM !data output from ESTM
2148 REAL(KIND(1D0)), INTENT(out) :: qn_S ! net all-wave radiation over snow [W m-2]
2149 REAL(KIND(1D0)), INTENT(out) :: qs ! storage heat flux [W m-2]
2150 REAL(KIND(1D0)), INTENT(out) :: a1
2151 REAL(KIND(1D0)), INTENT(out) :: a2
2152 REAL(KIND(1D0)), INTENT(out) :: a3
2153
2154 ! extended for ESTM_ext
2155 ! input arrays: standard suews surfaces
2156 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: qg_roof ! conductive heat flux through roof [W m-2]
2157 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tin_roof ! indoor/deep bottom temperature for roof [degC]
2158 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: sfr_roof ! surface fraction of roof [-]
2159 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: temp_in_roof ! temperature at inner interfaces of roof [degC]
2160 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: k_roof ! thermal conductivity of roof [W m-1 K]
2161 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: cp_roof ! Heat capacity of roof [J m-3 K-1]
2162 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: dz_roof ! thickness of each layer in roof [m]
2163 ! input arrays: standard suews surfaces
2164 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: qg_wall ! conductive heat flux through wall [W m-2]
2165 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tin_wall ! indoor/deep bottom temperature for wall [degC]
2166 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: sfr_wall ! surface fraction of wall [-]
2167 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: temp_in_wall ! temperature at inner interfaces of wall [degC]
2168 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: k_wall ! thermal conductivity of wall [W m-1 K]
2169 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: cp_wall ! Heat capacity of wall [J m-3 K-1]
2170 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: dz_wall ! thickness of each layer in wall [m]
2171 ! input arrays: standard suews surfaces
2172 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: tin_surf !deep bottom temperature for each surface [degC]
2173 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: sfr_surf ! fraction of each surface [-]
2174 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(in) :: temp_in_surf ! temperature at inner interfaces of of each surface [degC]
2175 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(in) :: k_surf ! thermal conductivity of v [W m-1 K]
2176 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(in) :: cp_surf ! Heat capacity of each surface [J m-3 K-1]
2177 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(in) :: dz_surf ! thickness of each layer in each surface [m]
2178 ! output arrays
2179 ! roof facets
2180 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tsfc_roof ! roof surface temperature [degC]
2181 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: QS_roof ! heat storage flux for roof component [W m-2]
2182 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(out) :: temp_out_roof !interface temperature between depth layers [degC]
2183 ! wall facets
2184 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tsfc_wall ! wall surface temperature [degC]
2185 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: QS_wall ! heat storage flux for wall component [W m-2]
2186 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(out) :: temp_out_wall !interface temperature between depth layers [degC]
2187 ! standard suews surfaces
2188 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: tsfc_surf ! each surface temperature [degC]
2189 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: QS_surf ! heat storage flux for each surface component [W m-2]
2190 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(out) :: temp_out_surf !interface temperature between depth layers [degC]
2191
2192 ! internal use arrays
2193 REAL(KIND(1D0)) :: Tair_mav_5d ! Tair_mav_5d=HDD(id-1,4) HDD at the begining of today (id-1)
2194 REAL(KIND(1D0)) :: qn_use ! qn used in OHM calculations [W m-2]
2195
2196 REAL(KIND(1D0)) :: moist_surf(nsurf)
2197
2198 ! initialise output variables
2199 deltaqi = 0
2200 !SnowFrac = 0
2201 !qn1_S = 0
2202 dataoutlineestm = -999
2203 qs = -999
2204 a1 = -999
2205 a2 = -999
2206 a3 = -999
2207
2208 ! calculate qn if qf should be included
2209 IF (ohmincqf == 1) THEN
2210 qn_use = qf + qn
2211 ELSEIF (ohmincqf == 0) THEN
2212 qn_use = qn
2213 END IF
2214
2215 IF (storageheatmethod == 0) THEN !Use observed QS
2216 qs = qs_obs
2217
2218 ELSEIF (storageheatmethod == 1) THEN !Use OHM to calculate QS
2219 tair_mav_5d = hdd_id(10)
2220 IF (diagnose == 1) WRITE (*, *) 'Calling OHM...'
2221 CALL ohm(qn_use, qn_av_prev, dqndt_prev, qn_av_next, dqndt_next, &
2222 qn_s, qn_s_av_prev, dqnsdt_prev, qn_s_av_next, dqnsdt_next, &
2223 tstep, dt_since_start, &
2224 sfr_surf, nsurf, &
2225 tair_mav_5d, &
2226 ohm_coef, &
2227 ohm_threshsw, ohm_threshwd, &
2228 soilstore_id, soilstorecap, state_id, &
2230 snowuse, snowfrac, &
2231 diagqs, &
2232 a1, a2, a3, qs, deltaqi)
2233 qs_surf = qs
2234 qs_roof = qs
2235 qs_wall = qs
2236
2237 ! use AnOHM to calculate QS, TS 14 Mar 2016
2238 ELSEIF (storageheatmethod == 3) THEN
2239 IF (diagnose == 1) WRITE (*, *) 'Calling AnOHM...'
2240 ! CALL AnOHM(qn1_use,qn1_store_grid,qn1_av_store_grid,qf,&
2241 ! MetForcingData_grid,state_id/StoreDrainPrm(6,:),&
2242 ! alb, emis, cpAnOHM, kkAnOHM, chAnOHM,&
2243 ! sfr_surf,nsurf,nsh,EmissionsMethod,id,Gridiv,&
2244 ! a1,a2,a3,qs,deltaQi)
2245 moist_surf = state_id/storedrainprm(6, :)
2246 CALL anohm( &
2247 tstep, dt_since_start, &
2248 qn_use, qn_av_prev, dqndt_prev, qf, &
2249 metforcingdata_grid, moist_surf, &
2250 alb, emis, cpanohm, kkanohm, chanohm, & ! input
2251 sfr_surf, nsurf, emissionsmethod, id, gridiv, &
2252 qn_av_next, dqndt_next, &
2253 a1, a2, a3, qs, deltaqi) ! output
2254 qs_surf = qs
2255 qs_roof = qs
2256 qs_wall = qs
2257
2258 ! !Calculate QS using ESTM
2259 ELSEIF (storageheatmethod == 4 .OR. storageheatmethod == 14) THEN
2260 ! !CALL ESTM(QSestm,iMB)
2261 IF (diagnose == 1) WRITE (*, *) 'Calling ESTM...'
2262 CALL estm( &
2263 gridiv, & !input
2264 tstep, &
2265 avkdn, avu1, temp_c, zenith_deg, avrh, press_hpa, ldown, &
2266 bldgh, ts5mindata_ir, &
2267 tair_av, &
2268 dataoutlineestm, qs) !output
2269 ! CALL ESTM(QSestm,Gridiv,ir) ! iMB corrected to Gridiv, TS 09 Jun 2016
2270 ! QS=QSestm ! Use ESTM qs
2271 ELSEIF (storageheatmethod == 5) THEN
2272 ! !CALL ESTM(QSestm,iMB)
2273 IF (diagnose == 1) WRITE (*, *) 'Calling extended ESTM...'
2274 ! facets: seven suews standard facets + extra for buildings [roof, wall] (can be extended for heterogeneous buildings)
2275 !
2276 ! ASSOCIATE (v => dz_roof(1, 1:ndepth))
2277 ! PRINT *, 'dz_roof in cal_qs', v, SIZE(v)
2278 ! END ASSOCIATE
2279 ! ASSOCIATE (v => dz_wall(1, 1:ndepth))
2280 ! PRINT *, 'dz_wall in cal_qs', v, SIZE(v)
2281 ! END ASSOCIATE
2282 CALL estm_ext( &
2283 tstep, & !input
2284 nlayer, &
2285 qg_surf, qg_roof, qg_wall, &
2286 tsfc_roof, tin_roof, temp_in_roof, k_roof, cp_roof, dz_roof, sfr_roof, & !input
2287 tsfc_wall, tin_wall, temp_in_wall, k_wall, cp_wall, dz_wall, sfr_wall, & !input
2288 tsfc_surf, tin_surf, temp_in_surf, k_surf, cp_surf, dz_surf, sfr_surf, & !input
2289 temp_out_roof, qs_roof, & !output
2290 temp_out_wall, qs_wall, & !output
2291 temp_out_surf, qs_surf, & !output
2292 qs) !output
2293
2294 ! TODO: add deltaQi to output for snow heat storage
2295
2296 ! PRINT *, 'QS after ESTM_ext', QS
2297 ! PRINT *, 'QS_roof after ESTM_ext', QS_roof
2298 ! PRINT *, 'QS_wall after ESTM_ext', QS_wall
2299 ! PRINT *, 'QS_surf after ESTM_ext', QS_surf
2300 ! PRINT *, '------------------------------------'
2301 ! PRINT *, ''
2302 END IF
2303
2304 END SUBROUTINE suews_cal_qs
2305 !=======================================================================
2306
2307 !==========================drainage and runoff================================
2308 SUBROUTINE suews_cal_water( &
2309 Diagnose, & !input
2310 SnowUse, NonWaterFraction, addPipes, addImpervious, addVeg, addWaterBody, &
2311 state_id, sfr_surf, StoreDrainPrm, WaterDist, nsh_real, &
2312 drain_per_tstep, & !output
2313 drain, frac_water2runoff, &
2314 AdditionalWater, runoffPipes, runoff_per_interval, &
2315 AddWater)
2316
2317 IMPLICIT NONE
2318 ! INTEGER,PARAMETER :: nsurf=7! number of surface types
2319 ! INTEGER,PARAMETER ::WaterSurf = 7
2320 INTEGER, INTENT(in) :: Diagnose
2321 INTEGER, INTENT(in) :: SnowUse !!Snow part used (1) or not used (0) [-]
2322
2323 REAL(KIND(1D0)), INTENT(in) :: NonWaterFraction !the surface fraction of non-water [-]
2324 REAL(KIND(1D0)), INTENT(in) :: addPipes !additional water in pipes [mm]
2325 REAL(KIND(1D0)), INTENT(in) :: addImpervious !water from impervious surfaces of other grids [mm] for whole surface area
2326 REAL(KIND(1D0)), INTENT(in) :: addVeg !Water from vegetated surfaces of other grids [mm] for whole surface area
2327 REAL(KIND(1D0)), INTENT(in) :: addWaterBody ! water from water body of other grids [mm] for whole surface area
2328 REAL(KIND(1D0)), INTENT(in) :: nsh_real !nsh cast as a real for use in calculations
2329
2330 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: state_id !wetness states of each surface [mm]
2331 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: soilstore_id
2332 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: sfr_surf !Surface fractions [-]
2333 REAL(KIND(1D0)), DIMENSION(6, nsurf), INTENT(in) :: StoreDrainPrm ! drain storage capacity [mm]
2334 REAL(KIND(1D0)), DIMENSION(nsurf + 1, nsurf - 1), INTENT(in) :: WaterDist !Within-grid water distribution to other surfaces and runoff/soil store [-]
2335
2336 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: drain !drainage of each surface type [mm]
2337 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: frac_water2runoff !Fraction of water going to runoff/sub-surface soil (WGWaterDist) [-]
2338 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: AddWater !water from other surfaces (WGWaterDist in SUEWS_ReDistributeWater.f95) [mm]
2339 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: stateOld
2340 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: soilstoreOld
2341
2342 REAL(KIND(1D0)), INTENT(out) :: drain_per_tstep ! total drainage for all surface type at each timestep [mm]
2343 REAL(KIND(1D0)), INTENT(out) :: AdditionalWater !Additional water coming from other grids [mm] (these are expressed as depths over the whole surface)
2344 REAL(KIND(1D0)), INTENT(out) :: runoffPipes !run-off in pipes [mm]
2345 REAL(KIND(1D0)), INTENT(out) :: runoff_per_interval !run-off at each time interval [mm]
2346 INTEGER :: is
2347
2348 ! Retain previous surface state_id and soil moisture state_id
2349 ! stateOld = state_id !state_id of each surface [mm] for the previous timestep
2350 ! soilstoreOld = soilstore_id !Soil moisture of each surface [mm] for the previous timestep
2351
2352 !============= Grid-to-grid runoff =============
2353 ! Calculate additional water coming from other grids
2354 ! i.e. the variables addImpervious, addVeg, addWaterBody, addPipes
2355 !call RunoffFromGrid(GridFromFrac) !!Need to code between-grid water transfer
2356
2357 ! Sum water coming from other grids (these are expressed as depths over the whole surface)
2358 additionalwater = addpipes + addimpervious + addveg + addwaterbody ![mm]
2359
2360 ! Initialise runoff in pipes
2361 runoffpipes = addpipes !Water flowing in pipes from other grids. QUESTION: No need for scaling?
2362 !! CHECK p_i
2363 runoff_per_interval = addpipes !pipe plor added to total runoff.
2364
2365 !================== Drainage ===================
2366 ! Calculate drainage for each soil subsurface (excluding water body)
2367 IF (diagnose == 1) WRITE (*, *) 'Calling Drainage...'
2368
2369 IF (nonwaterfraction /= 0) THEN !Soil states only calculated if soil exists. LJ June 2017
2370 DO is = 1, nsurf - 1
2371
2372 CALL drainage( &
2373 is, & ! input:
2374 state_id(is), &
2375 storedrainprm(6, is), &
2376 storedrainprm(2, is), &
2377 storedrainprm(3, is), &
2378 storedrainprm(4, is), &
2379 nsh_real, &
2380 drain(is)) ! output
2381
2382 ! !HCW added and changed to StoreDrainPrm(6,is) here 20 Feb 2015
2383 ! drain_per_tstep=drain_per_tstep+(drain(is)*sfr_surf(is)/NonWaterFraction) !No water body included
2384 END DO
2385 drain_per_tstep = dot_product(drain(1:nsurf - 1), sfr_surf(1:nsurf - 1))/nonwaterfraction !No water body included
2386 ELSE
2387 drain(1:nsurf - 1) = 0
2388 drain_per_tstep = 0
2389 END IF
2390
2391 drain(watersurf) = 0 ! Set drainage from water body to zero
2392
2393 ! Distribute water within grid, according to WithinGridWaterDist matrix (Cols 1-7)
2394 IF (diagnose == 1) WRITE (*, *) 'Calling ReDistributeWater...'
2395 ! CALL ReDistributeWater
2396 !Calculates AddWater(is)
2397 CALL redistributewater( &
2398 snowuse, waterdist, sfr_surf, drain, & ! input:
2399 frac_water2runoff, addwater) ! output
2400
2401 END SUBROUTINE suews_cal_water
2402 !=======================================================================
2403
2404 !===============initialize sensible heat flux============================
2405 SUBROUTINE suews_init_qh( &
2406 avdens, avcp, h_mod, qn1, dectime, & !input
2407 H_init) !output
2408
2409 IMPLICIT NONE
2410 ! REAL(KIND(1d0)), INTENT(in)::qh_obs
2411 REAL(KIND(1D0)), INTENT(in) :: avdens !air density [kg m-3]
2412 REAL(KIND(1D0)), INTENT(in) :: avcp ! air heat capacity [J kg-1 K-1]
2413 REAL(KIND(1D0)), INTENT(in) :: h_mod !volumetric air heat capacity [J m-3 K-1]
2414 REAL(KIND(1D0)), INTENT(in) :: qn1 !net all-wave radiation [W m-2]
2415 REAL(KIND(1D0)), INTENT(in) :: dectime !local time (days), not daylight savings
2416 REAL(KIND(1D0)), INTENT(out) :: H_init !initial QH [W m-2]
2417
2418 REAL(KIND(1D0)), PARAMETER :: NAN = -999
2419 INTEGER, PARAMETER :: notUsedI = -999
2420
2421 ! Calculate kinematic heat flux (w'T') from sensible heat flux [W m-2] from observed data (if available) or LUMPS
2422 ! IF (qh_obs /= NAN) THEN !if(qh_obs/=NAN) qh=qh_obs !Commented out by HCW 04 Mar 2015
2423 ! H_init = qh_obs/(avdens*avcp) !Use observed value
2424 ! ELSE
2425 IF (h_mod /= nan) THEN
2426 h_init = h_mod/(avdens*avcp) !Use LUMPS value
2427 ELSE
2428 h_init = (qn1*0.2)/(avdens*avcp) !If LUMPS has had a problem, we still need a value
2429 CALL errorhint(38, 'LUMPS unable to calculate realistic value for H_mod.', h_mod, dectime, notusedi)
2430 END IF
2431 ! ENDIF
2432
2433 END SUBROUTINE suews_init_qh
2434 !========================================================================
2435 SUBROUTINE suews_cal_snow( &
2436 Diagnose, nlayer, & !input
2437 tstep, imin, it, EvapMethod, dayofWeek_id, CRWmin, CRWmax, &
2438 dectime, avdens, avcp, lv_J_kg, lvS_J_kg, avRh, Press_hPa, Temp_C, &
2439 RAsnow, psyc_hPa, sIce_hPa, tau_r, &
2440 RadMeltFact, TempMeltFact, SnowAlbMax, PrecipLimit, PrecipLimitAlb, &
2441 qn_ind_snow, kup_ind_snow, deltaQi, Tsurf_ind_snow, &
2442 SnowAlb_in, &
2443 PervFraction, vegfraction, addimpervious, qn_snowfree, qf, qs, vpd_hPa, s_hPa, &
2444 RS, RA, RB, SnowDensMax, SnowDensMin, precip, PipeCapacity, RunoffToWater, &
2445 addVeg, SnowLimPaved, SnowLimBldg, &
2446 FlowChange, drain, WetThresh_surf, SoilStoreCap, &
2447 Tsurf_ind, sfr_surf, &
2448 AddWater, addwaterrunoff, StoreDrainPrm, SnowPackLimit, SnowProf_24hr, &
2449 SnowPack_in, SnowFrac_in, SnowWater_in, iceFrac_in, SnowDens_in, & ! input:
2450 SnowfallCum_in, state_id_in, soilstore_id_in, & ! input:
2451 qn_surf, qs_surf, &
2452 SnowRemoval, & ! snow specific output:
2453 SnowPack_out, SnowFrac_out, SnowWater_out, iceFrac_out, SnowDens_out, & ! output
2454 SnowfallCum_out, state_id_out, soilstore_id_out, & ! general output:
2455 state_per_tstep, NWstate_per_tstep, &
2456 qe, qe_surf, qe_roof, qe_wall, &
2457 SnowAlb_out, &
2458 swe, chSnow_per_tstep, ev_per_tstep, runoff_per_tstep, &
2459 surf_chang_per_tstep, runoffPipes, mwstore, runoffwaterbody, &
2460 runoffAGveg, runoffAGimpervious, rss_surf, &
2461 dataOutLineSnow)
2462
2463 IMPLICIT NONE
2464
2465 INTEGER, INTENT(in) :: Diagnose
2466 INTEGER, INTENT(in) :: nlayer !number of vertical levels in urban canopy [-]
2467 INTEGER, INTENT(in) :: tstep !timestep [s]
2468 INTEGER, INTENT(in) :: imin ! minutes [min]
2469 INTEGER, INTENT(in) :: it ! hour [H]
2470 INTEGER, INTENT(in) :: EvapMethod !Evaporation calculated according to Rutter (1) or Shuttleworth (2)
2471
2472 INTEGER, DIMENSION(nsurf) :: snowCalcSwitch
2473 INTEGER, DIMENSION(3), INTENT(in) :: dayofWeek_id ! 1 - day of week; 2 - month; 3 - season
2474
2475 REAL(KIND(1D0)), INTENT(in) :: CRWmin !minimum water holding capacity of snow [mm]
2476 REAL(KIND(1D0)), INTENT(in) :: CRWmax !maximum water holding capacity of snow [mm]
2477 REAL(KIND(1D0)), INTENT(in) :: dectime !decimal time [-]
2478 REAL(KIND(1D0)), INTENT(in) :: lvS_J_kg !latent heat of sublimation [J kg-1]
2479 REAL(KIND(1D0)), INTENT(in) :: lv_j_kg !Latent heat of vapourisation per timestep [J kg-1]
2480 REAL(KIND(1D0)), INTENT(in) :: avdens !air density [kg m-3]
2481 REAL(KIND(1D0)), INTENT(in) :: avRh !relative humidity [-]
2482 REAL(KIND(1D0)), INTENT(in) :: Press_hPa !air pressure [hPa]
2483 REAL(KIND(1D0)), INTENT(in) :: Temp_C !air temperature [degC]
2484 REAL(KIND(1D0)), INTENT(in) :: RAsnow !aerodynamic resistance of snow [s m-1]
2485 REAL(KIND(1D0)), INTENT(in) :: psyc_hPa !psychometric constant [hPa]
2486 REAL(KIND(1D0)), INTENT(in) :: avcp !air heat capacity [J kg-1 K-1]
2487 REAL(KIND(1D0)), INTENT(in) :: sIce_hPa !satured curve on snow [hPa]
2488 REAL(KIND(1D0)), INTENT(in) :: PervFraction !sum of surface cover fractions for impervious surfaces [-]
2489 REAL(KIND(1D0)), INTENT(in) :: vegfraction ! fraction of vegetation [-]
2490 REAL(KIND(1D0)), INTENT(in) :: addimpervious !Water from impervious surfaces of other grids for whole surface area [mm]
2491 REAL(KIND(1D0)), INTENT(in) :: qn_snowfree ! net all-wave radiation for snow-free surface [W m-2]
2492 REAL(KIND(1D0)), INTENT(in) :: qf !anthropogenic heat flux [W m-2]
2493 REAL(KIND(1D0)), INTENT(in) :: qs !heat storage flux [W m-2]
2494 REAL(KIND(1D0)), INTENT(in) :: vpd_hPa ! vapour pressure deficit [hPa]
2495 REAL(KIND(1D0)), INTENT(in) :: s_hPa !vapour pressure versus temperature slope [hPa K-1]
2496 REAL(KIND(1D0)), INTENT(in) :: RS !surface resistance [s m-1]
2497 REAL(KIND(1D0)), INTENT(in) :: RA !aerodynamic resistance [s m-1]
2498 REAL(KIND(1D0)), INTENT(in) :: RB !boundary layer resistance [s m-1]
2499 REAL(KIND(1D0)), INTENT(in) :: SnowDensMax !Fresh snow density [kg m-3]
2500 REAL(KIND(1D0)), INTENT(in) :: SnowDensMin !Fresh snow density [kg m-3]
2501 REAL(KIND(1D0)), INTENT(in) :: precip !rain data [mm]
2502 REAL(KIND(1D0)), INTENT(in) :: PipeCapacity !Capacity of pipes to transfer water [mm]
2503 REAL(KIND(1D0)), INTENT(in) :: RunoffToWater !Fraction of surface runoff going to water body [-]
2504 ! REAL(KIND(1D0)), INTENT(in) :: NonWaterFraction
2505 ! REAL(KIND(1d0)), INTENT(in)::wu_EveTr!Water use for evergreen trees/shrubs [mm]
2506 ! REAL(KIND(1d0)), INTENT(in)::wu_DecTr!Water use for deciduous trees/shrubs [mm]
2507 ! REAL(KIND(1d0)), INTENT(in)::wu_Grass!Water use for grass [mm]
2508 REAL(KIND(1D0)), INTENT(in) :: addVeg !Water from vegetated surfaces of other grids [mm] for whole surface area
2509 ! REAL(KIND(1D0)), INTENT(in) :: addWaterBody !Water from water surface of other grids [mm] for whole surface area
2510 REAL(KIND(1D0)), INTENT(in) :: SnowLimPaved !snow limit for paved [mm]
2511 REAL(KIND(1D0)), INTENT(in) :: SnowLimBldg !snow limit for building [mm]
2512 ! REAL(KIND(1D0)), INTENT(in) :: SurfaceArea
2513 REAL(KIND(1D0)), INTENT(in) :: FlowChange !Difference between the input and output flow in the water body [mm]
2514
2515 REAL(KIND(1D0)), INTENT(in) :: tau_r !time constant for snow density ageing [-]
2516
2517 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: WU_nsurf
2518 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: drain !water flowing intyo drainage [mm]
2519 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: WetThresh_surf !surface wetness threshold [mm]
2520 REAL(KIND(1D0)), DIMENSION(nsurf) :: mw_ind !melt water from sknowpack[mm]
2521 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SoilStoreCap !Capacity of soil store [mm]
2522 REAL(KIND(1D0)), DIMENSION(nsurf) :: rainonsnow !rain water on snow event [mm]
2523 REAL(KIND(1D0)), DIMENSION(nsurf) :: freezmelt !freezing of melt water[mm]
2524 REAL(KIND(1D0)), DIMENSION(nsurf) :: freezstate !freezing of state_id [mm]
2525 REAL(KIND(1D0)), DIMENSION(nsurf) :: freezstatevol !surface state_id [mm]
2526 REAL(KIND(1D0)), DIMENSION(nsurf) :: Qm_Melt !melt heat [W m-2]
2527 REAL(KIND(1D0)), DIMENSION(nsurf) :: Qm_rain !melt heat for rain on snow [W m-2]
2528 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: Tsurf_ind !snow-free surface temperature [degC]
2529 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: sfr_surf !surface fraction ratio [-]
2530 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SnowPackLimit !Limit for the snow water equivalent when snow cover starts to be patchy [mm]
2531 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: StateLimit !Limit for state_id of each surface type [mm] (specified in input files)
2532 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: AddWater !addition water from other surfaces [mm]
2533 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: addwaterrunoff !Fraction of water going to runoff/sub-surface soil (WGWaterDist) [-]
2534 REAL(KIND(1D0)), DIMENSION(6, nsurf), INTENT(in) :: StoreDrainPrm !Coefficients used in drainage calculation [-]
2535 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(in) :: SnowProf_24hr !Hourly profile values used in snow clearing [-]
2536
2537 ! Total water transported to each grid for grid-to-grid connectivity
2538 ! REAL(KIND(1D0)), INTENT(in) :: runoff_per_interval_in
2539 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: state_id_in ! wetness status of each surface type from previous timestep [mm]
2540 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: soilstore_id_in !soil moisture of each surface type from previous timestep[mm]
2541 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SnowPack_in ! snowpack from previous timestep[mm]
2542 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SnowFrac_in ! snow fraction from previous timestep[-]
2543 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SnowWater_in ! snow water from previous timestep[mm]
2544 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: iceFrac_in ! ice fraction from previous timestep [-]
2545 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SnowDens_in ! snow density from previous timestep[kg m-3]
2546
2547 ! output:
2548 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: state_id_out ! wetness status of each surface type at next timestep [mm]
2549 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: soilstore_id_out !soil moisture of each surface type at next timestep[mm]
2550 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: SnowPack_out ! snowpack at next timestep[mm]
2551 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: SnowFrac_out ! snow fraction at next timestep[-]
2552 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: SnowWater_out ! snow water at nexts timestep[mm]
2553 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: iceFrac_out ! ice fraction at next timestep [-]
2554 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: SnowDens_out ! snow density at next timestep[kg m-3]
2555
2556 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: runoffSnow_surf !Initialize for runoff caused by snowmelting
2557 REAL(KIND(1D0)), DIMENSION(nsurf) :: runoff_surf ! runoff for each surface [-]
2558 REAL(KIND(1D0)), DIMENSION(nsurf) :: chang !Change in state_id [mm]
2559 REAL(KIND(1D0)), DIMENSION(nsurf) :: ChangSnow_surf !change in SnowPack (mm)
2560 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: snowDepth
2561 REAL(KIND(1D0)), DIMENSION(nsurf) :: SnowToSurf !the water flowing into snow free area [mm]
2562 REAL(KIND(1D0)), DIMENSION(nsurf) :: ev_snow !Evaporation of now [mm]
2563 REAL(KIND(1D0)), DIMENSION(2), INTENT(out) :: SnowRemoval !snow removal [mm]
2564 REAL(KIND(1D0)), DIMENSION(nsurf) :: ev_surf !evaporation of each surface type [mm]
2565 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: rss_surf !redefined surface resistance for wet surfaces [s m-1]
2566
2567 ! REAL(KIND(1D0)) :: p_mm !Inputs to surface water balance
2568 ! REAL(KIND(1d0)),INTENT(out)::rss
2569 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: qn_surf ! net all-wave radiation of individual surface [W m-2]
2570 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: qs_surf ! heat storage flux of individual surface [W m-2]
2571 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: qe_surf ! latent heat flux of individual surface [W m-2]
2572 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: qe_roof ! latent heat flux of roof [W m-2]
2573 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: qe_wall ! latent heat flux of wall [W m-2]
2574 REAL(KIND(1D0)), INTENT(out) :: state_per_tstep !state_id at each timestep [mm]
2575 REAL(KIND(1D0)), INTENT(out) :: NWstate_per_tstep ! state_id at each tinestep(excluding water body) [mm]
2576 REAL(KIND(1D0)), INTENT(out) :: qe !latent heat flux [W m-2]
2577 REAL(KIND(1D0)), INTENT(out) :: swe !overall snow water equavalent[mm]
2578 REAL(KIND(1D0)), INTENT(out) :: chSnow_per_tstep ! change state_id of snow and surface per time interval [mm]
2579 REAL(KIND(1D0)), INTENT(out) :: ev_per_tstep ! evaporation at each time step [mm]
2580 REAL(KIND(1D0)) :: qe_per_tstep !latent heat flux at each timestep[W m-2]
2581 REAL(KIND(1D0)), INTENT(out) :: runoff_per_tstep !runoff water at each time step [mm]
2582 REAL(KIND(1D0)), INTENT(out) :: surf_chang_per_tstep !change in state_id (exluding snowpack) per timestep [mm]
2583 REAL(KIND(1D0)), INTENT(out) :: runoffPipes !runoff to pipes [mm]
2584 REAL(KIND(1D0)), INTENT(out) :: mwstore !overall met water [mm]
2585 REAL(KIND(1D0)), INTENT(out) :: runoffwaterbody !Above ground runoff from water surface for all surface area [mm]
2586 ! REAL(KIND(1D0)) :: runoffWaterBody_m3
2587 ! REAL(KIND(1D0)) :: runoffPipes_m3
2588 REAL(KIND(1D0)), INTENT(out) :: runoffAGveg !Above ground runoff from vegetated surfaces for all surface area [mm]
2589 REAL(KIND(1D0)), INTENT(out) :: runoffAGimpervious !Above ground runoff from impervious surface for all surface area [mm]
2590
2591 ! local:
2592 INTEGER :: is ! surface type [-]
2593
2594 ! REAL(KIND(1D0)) :: runoff_per_interval
2595 REAL(KIND(1D0)), DIMENSION(nsurf) :: state_id_surf ! wetness status of each surface type [mm]
2596 REAL(KIND(1D0)), DIMENSION(nsurf) :: soilstore_id !soil moisture of each surface type[mm]
2597 REAL(KIND(1D0)), DIMENSION(nsurf) :: SnowPack ! snowpack [mm]
2598 REAL(KIND(1D0)), DIMENSION(nsurf) :: SnowFrac !snow fraction [-]
2599 REAL(KIND(1D0)), DIMENSION(nsurf) :: SnowWater ! water in snow [mm]
2600 REAL(KIND(1D0)), DIMENSION(nsurf) :: iceFrac !ice fraction [-]
2601 REAL(KIND(1D0)), DIMENSION(nsurf) :: SnowDens !snow density [kg m-3]
2602 REAL(KIND(1D0)), DIMENSION(nsurf) :: qn_e_surf !net available energy for evaporation for each surfaces [W m-2]
2603
2604 REAL(KIND(1D0)), DIMENSION(2) :: SurplusEvap !surface evaporation in 5 min timestep [mm]
2605 REAL(KIND(1D0)) :: surplusWaterBody !Extra runoff that goes to water body [mm] as specified by RunoffToWater
2606 REAL(KIND(1D0)) :: pin !Rain per time interval [mm]
2607 ! REAL(KIND(1d0))::sae
2608 ! REAL(KIND(1d0))::vdrc
2609 ! REAL(KIND(1d0))::sp
2610 ! REAL(KIND(1d0))::numPM
2611 REAL(KIND(1D0)) :: qn_e !net available energy for evaporation [W m-2]
2612 REAL(KIND(1D0)) :: tlv !Latent heat of vapourisation per timestep [J kg-1 s-1]
2613 ! REAL(KIND(1D0)) :: runoffAGimpervious_m3
2614 ! REAL(KIND(1D0)) :: runoffAGveg_m3
2615 REAL(KIND(1D0)) :: nsh_real !timestep in a hour [-]
2616 ! REAL(KIND(1D0)) :: tstep_real
2617 REAL(KIND(1D0)) :: ev_tot !total evaporation for all surfaces [mm]
2618 REAL(KIND(1D0)) :: qe_tot ! total latent heat flux for all surfaces [W m-2]
2619 REAL(KIND(1D0)) :: surf_chang_tot !total change in state_id(excluding snowpack) for all surfaces [mm]
2620 REAL(KIND(1D0)) :: runoff_tot !total runoff for all surfaces [mm]
2621 REAL(KIND(1D0)) :: chSnow_tot !total change state_id of snow and surface [mm]
2622
2623 REAL(KIND(1D0)), DIMENSION(7) :: capStore_surf ! current storage capacity [mm]
2624
2625 REAL(KIND(1D0)), DIMENSION(nsurf) :: Qm_freezState
2626 REAL(KIND(1D0)) :: mwh
2627 REAL(KIND(1D0)) :: fwh
2628 REAL(KIND(1D0)) :: Qm
2629 REAL(KIND(1D0)) :: QmFreez
2630 REAL(KIND(1D0)) :: QmRain
2631 REAL(KIND(1D0)), DIMENSION(nsurf) :: SnowDepth
2632
2633 REAL(KIND(1D0)), INTENT(in) :: RadMeltFact
2634 REAL(KIND(1D0)), INTENT(in) :: TempMeltFact
2635 REAL(KIND(1D0)), INTENT(in) :: SnowAlbMax
2636 REAL(KIND(1D0)), INTENT(in) :: PrecipLimit
2637 REAL(KIND(1D0)), INTENT(in) :: PrecipLimitAlb
2638
2639 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: qn_ind_snow
2640 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: kup_ind_snow
2641 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: deltaQi
2642 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: Tsurf_ind_snow
2643
2644 REAL(KIND(1D0)), INTENT(in) :: SnowfallCum_in
2645 REAL(KIND(1D0)), INTENT(out) :: SnowfallCum_out
2646 REAL(KIND(1D0)) :: SnowfallCum
2647
2648 REAL(KIND(1D0)), INTENT(in) :: SnowAlb_in
2649 REAL(KIND(1D0)), INTENT(out) :: SnowAlb_out
2650 REAL(KIND(1D0)) :: SnowAlb
2651 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutSnow - 5), INTENT(out) :: dataOutLineSnow
2652
2653 ! runoff_per_interval = runoff_per_interval_in
2654 state_id_surf = state_id_in
2655 soilstore_id = soilstore_id_in
2656
2657 ! tstep_real = tstep*1.D0
2658 nsh_real = 3600/tstep*1.d0
2659
2660 capstore_surf = 0 !initialise capStore
2661
2662 tlv = lv_j_kg/tstep*1.d0 !Latent heat of vapourisation per timestep
2663
2664 pin = max(0., precip) !Initiate rain data [mm]
2665
2666 ! Initialize the output variables
2667 qe_surf = 0
2668
2669 ev_per_tstep = 0
2670 qe_per_tstep = 0
2671 surf_chang_per_tstep = 0
2672 runoff_per_tstep = 0
2673 state_per_tstep = 0
2674 nwstate_per_tstep = 0
2675 chsnow_per_tstep = 0
2676 qe = 0
2677
2678 runoffagveg = 0
2679 runoffagimpervious = 0
2680 surpluswaterbody = 0
2681 runoff_surf = 0
2682 chang = 0
2683 surplusevap = 0
2684
2685 ! force these facets to be totally dry
2686 ! TODO: need to consider their hydrologic dynamics
2687 qe_roof = 0
2688 qe_wall = 0
2689
2690 ! net available energy for evaporation
2691 qn_e_surf = qn_surf + qf - qs_surf ! qn1 changed to qn1_snowfree, lj in May 2013
2692
2693 IF (diagnose == 1) WRITE (*, *) 'Calling SUEWS_cal_snow...'
2694 ! IF (SnowUse == 1) THEN ! snow calculation
2695 ! net available energy for evaporation
2696 qn_e = qn_snowfree + qf - qs ! qn1 changed to qn1_snowfree, lj in May 2013
2697
2698 snowpack = snowpack_in
2699 snowfrac = snowfrac_in
2700 snowwater = snowwater_in
2701 icefrac = icefrac_in
2702 snowdens = snowdens_in
2703 snowfallcum = snowfallcum_in
2704 snowalb = snowalb_in
2705
2706 ! update snow density
2707 snowdens = update_snow_dens( &
2708 tstep, snowfrac, snowdens, &
2709 tau_r, snowdensmax, snowdensmin)
2710
2711 ! Calculate snow-related energy budgets
2712 CALL meltheat( &
2713 lvs_j_kg, lv_j_kg, tstep*1d0, radmeltfact, tempmeltfact, & !input
2714 snowalbmax, snowdensmin, temp_c, precip, preciplimit, preciplimitalb, &
2715 nsh_real, sfr_surf, tsurf_ind, state_id_in, qn_ind_snow, &
2716 snowwater, deltaqi, &
2717 snowpack, snowfrac, snowalb, snowdens, snowfallcum, & !inout
2718 mwh, fwh, qm, qmfreez, qmrain, snowcalcswitch, & !output
2719 qm_melt, qm_freezstate, qm_rain, freezmelt, freezstate, freezstatevol, &
2720 rainonsnow, snowdepth, mw_ind)
2721
2722 DO is = 1, nsurf !For each surface in turn
2723 qe_tot = 0
2724 ev_tot = 0
2725 swe = 0
2726 ev_snow = 0
2727 runoff_tot = 0
2728 surf_chang_tot = 0
2729 chsnow_tot = 0
2730 snowremoval = 0
2731 runoffpipes = 0
2732 mwstore = 0
2733 runoffwaterbody = 0
2734 IF (sfr_surf(is) > 0) THEN
2735 ! IF (Diagnose == 1) WRITE (*, *) 'Calling SnowCalc...'
2736
2737 CALL snowcalc( &
2738 tstep, imin, it, dectime, is, & !input
2739 snowcalcswitch, &
2740 evapmethod, crwmin, crwmax, nsh_real, lvs_j_kg, avdens, &
2741 avrh, press_hpa, temp_c, rasnow, psyc_hpa, avcp, sice_hpa, &
2742 pervfraction, vegfraction, addimpervious, &
2743 vpd_hpa, qn_e, s_hpa, rs, ra, rb, tlv, snowdensmin, snowprof_24hr, precip, &
2744 pipecapacity, runofftowater, &
2745 addveg, snowlimpaved, snowlimbldg, flowchange, drain, &
2746 wetthresh_surf, state_id_in, mw_ind, soilstorecap, rainonsnow, &
2747 freezmelt, freezstate, freezstatevol, &
2748 qm_melt, qm_rain, tsurf_ind, sfr_surf, dayofweek_id, storedrainprm, snowpacklimit, &
2749 addwater, addwaterrunoff, &
2750 soilstore_id, snowpack, surplusevap, & !inout
2751 snowfrac, snowwater, icefrac, snowdens, &
2752 runoffagimpervious, runoffagveg, surpluswaterbody, &
2753 ev_tot, qe_tot, runoff_tot, surf_chang_tot, chsnow_tot, & ! output
2754 rss_surf, &
2755 runoff_surf, chang, changsnow_surf, snowtosurf, state_id_surf, ev_snow, &
2756 snowremoval, swe, &
2757 runoffpipes, mwstore, runoffwaterbody)
2758
2759 ELSE
2760 snowfrac(is) = 0
2761 snowdens(is) = 0
2762 snowpack(is) = 0
2763 END IF
2764 !Actual updates here as xx_tstep variables not taken as input to snowcalc
2765 ev_per_tstep = ev_per_tstep + ev_tot
2766 qe_per_tstep = qe_per_tstep + qe_tot
2767 runoff_per_tstep = runoff_per_tstep + runoff_tot
2768 surf_chang_per_tstep = surf_chang_per_tstep + surf_chang_tot
2769 chsnow_per_tstep = chsnow_per_tstep + chsnow_tot
2770
2771 !Store ev_tot for each surface
2772 ev_surf(is) = ev_tot
2773
2774 END DO
2775
2776 qe = qe_per_tstep
2777
2778 ! Calculate volume of water that will move between grids
2779 ! Volume [m3] = Depth relative to whole area [mm] / 1000 [mm m-1] * SurfaceArea [m2]
2780 ! Need to use these volumes when converting back to addImpervious, AddVeg and AddWater
2781 ! runoffAGimpervious_m3 = runoffAGimpervious/1000*SurfaceArea
2782 ! runoffAGveg_m3 = runoffAGveg/1000*SurfaceArea
2783 ! runoffWaterBody_m3 = runoffWaterBody/1000*SurfaceArea
2784 ! runoffPipes_m3 = runoffPipes/1000*SurfaceArea
2785
2786 state_id_out = state_id_surf
2787 soilstore_id_out = soilstore_id
2788
2789 snowwater_out = snowwater
2790 icefrac_out = icefrac
2791
2792 snowalb_out = snowalb
2793 snowdens_out = snowdens
2794 snowpack_out = snowpack
2795 snowfrac_out = snowfrac
2796 snowfallcum_out = snowfallcum
2797
2798 ! pack output into one line
2799 dataoutlinesnow = [ &
2800 snowpack_out(1:nsurf), mw_ind(1:nsurf), qm_melt(1:nsurf), & !26
2801 qm_rain(1:nsurf), qm_freezstate(1:nsurf), snowfrac_out(1:(nsurf - 1)), & !46
2802 rainonsnow(1:nsurf), & !53
2803 qn_ind_snow(1:nsurf), kup_ind_snow(1:nsurf), freezmelt(1:nsurf), & !74
2804 snowwater(1:nsurf), snowdens_out(1:nsurf), & !88
2805 snowdepth(1:nsurf), tsurf_ind_snow(1:nsurf), &
2806 snowalb_out]
2807
2808 END SUBROUTINE suews_cal_snow
2809
2810 !================latent heat flux and surface wetness===================
2811 ! TODO: optimise the structure of this function
2812 SUBROUTINE suews_cal_qe( &
2813 Diagnose, storageheatmethod, nlayer, & !input
2814 tstep, &
2815 EvapMethod, &
2816 avdens, avcp, lv_J_kg, &
2817 psyc_hPa, &
2818 PervFraction, &
2819 addimpervious, &
2820 qf, vpd_hPa, s_hPa, RS, RA_h, RB, &
2821 precip, PipeCapacity, RunoffToWater, &
2822 NonWaterFraction, WU_surf, addVeg, addWaterBody, AddWater_surf, &
2823 FlowChange, drain_surf, &
2824 frac_water2runoff_surf, StoreDrainPrm, &
2825 sfr_surf, StateLimit_surf, SoilStoreCap_surf, WetThresh_surf, & ! input:
2826 state_surf_in, soilstore_surf_in, qn_surf, qs_surf, & ! input:
2827 sfr_roof, StateLimit_roof, SoilStoreCap_roof, WetThresh_roof, & ! input:
2828 state_roof_in, soilstore_roof_in, qn_roof, qs_roof, & ! input:
2829 sfr_wall, StateLimit_wall, SoilStoreCap_wall, WetThresh_wall, & ! input:
2830 state_wall_in, soilstore_wall_in, qn_wall, qs_wall, & ! input:
2831 state_surf_out, soilstore_surf_out, ev_surf, & ! general output:
2832 state_roof_out, soilstore_roof_out, ev_roof, & ! general output:
2833 state_wall_out, soilstore_wall_out, ev_wall, & ! general output:
2834 state_grid, NWstate_grid, &
2835 ev0_surf, qe0_surf, &
2836 qe, qe_surf, qe_roof, qe_wall, &
2837 ev_grid, runoff_grid, &
2838 surf_chang_grid, runoffPipes_grid, &
2839 runoffWaterBody_grid, &
2840 runoffAGveg_grid, runoffAGimpervious_grid, rss_surf)
2841
2842 IMPLICIT NONE
2843
2844 INTEGER, INTENT(in) :: Diagnose
2845 INTEGER, INTENT(in) :: storageheatmethod !Determines method for calculating storage heat flux ΔQS [-]
2846 INTEGER, INTENT(in) :: nlayer !number of vertical levels in urban canopy [-]
2847 INTEGER, INTENT(in) :: tstep !timesteps [s]
2848 ! INTEGER, INTENT(in) :: imin
2849 ! INTEGER, INTENT(in) :: it
2850 INTEGER, INTENT(in) :: EvapMethod !Evaporation calculated according to Rutter (1) or Shuttleworth (2)
2851
2852 REAL(KIND(1D0)), INTENT(in) :: lv_j_kg !Latent heat of vapourisation [J kg-1]
2853 REAL(KIND(1D0)), INTENT(in) :: avdens !air density [kg m-3]
2854 REAL(KIND(1D0)), INTENT(in) :: psyc_hPa !Psychometric constant [hPa]
2855 REAL(KIND(1D0)), INTENT(in) :: avcp ! air heat capacity [J kg-1 K-1]
2856
2857 REAL(KIND(1D0)), INTENT(in) :: PervFraction ! sum of surface cover fractions for impervious surfaces [-]
2858 ! REAL(KIND(1D0)), INTENT(in) :: vegfraction
2859 REAL(KIND(1D0)), INTENT(in) :: addimpervious !Water from impervious surfaces of other grids for whole surface area [mm]
2860
2861 REAL(KIND(1D0)), INTENT(in) :: qf ! athropogenic heat flux [W m-2]
2862
2863 REAL(KIND(1D0)), INTENT(in) :: vpd_hPa ! vapour pressure deficit [hPa]
2864 REAL(KIND(1D0)), INTENT(in) :: s_hPa !vapour pressure versus temperature slope [hPa K-1]
2865 REAL(KIND(1D0)), INTENT(in) :: RS !surface resistance [s m-1]
2866 REAL(KIND(1D0)), INTENT(in) :: RA_h !aerodynamic resistance [s m-1]
2867 REAL(KIND(1D0)), INTENT(in) :: RB !boundary layer resistance [s m-1]
2868 ! REAL(KIND(1D0)), INTENT(in) :: snowdensmin
2869 REAL(KIND(1D0)), INTENT(in) :: precip !rain data [mm]
2870 REAL(KIND(1D0)), INTENT(in) :: PipeCapacity !Capacity of pipes to transfer water [mm]
2871 REAL(KIND(1D0)), INTENT(in) :: RunoffToWater !Fraction of surface runoff going to water body [-]
2872 REAL(KIND(1D0)), INTENT(in) :: NonWaterFraction !Fraction of non-water surface [-]
2873 ! REAL(KIND(1d0)), INTENT(in)::wu_EveTr!Water use for evergreen trees/shrubs [mm]
2874 ! REAL(KIND(1d0)), INTENT(in)::wu_DecTr!Water use for deciduous trees/shrubs [mm]
2875 ! REAL(KIND(1d0)), INTENT(in)::wu_Grass!Water use for grass [mm]
2876 REAL(KIND(1D0)), INTENT(in) :: addVeg !Water from vegetated surfaces of other grids [mm] for whole surface area
2877 REAL(KIND(1D0)), INTENT(in) :: addWaterBody !Water from water surface of other grids [mm] for whole surface area
2878 ! REAL(KIND(1D0)), INTENT(in) :: SnowLimPaved
2879 ! REAL(KIND(1D0)), INTENT(in) :: SnowLimBldg
2880 ! REAL(KIND(1D0)), INTENT(in) :: SurfaceArea
2881 REAL(KIND(1D0)), INTENT(in) :: FlowChange !Difference between the input and output flow in the water body [mm]
2882
2883 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: WU_surf !external water use of each surface type [mm]
2884 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: drain_surf !Drainage of each surface type [mm]
2885
2886 ! input for generic suews surfaces
2887 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: sfr_surf !surface fraction [-]
2888 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: StateLimit_surf !Limit for state_id of each surface type [mm] (specified in input files)
2889 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: WetThresh_surf !surface wetness threshold [mm], When State > WetThresh, RS=0 limit in SUEWS_evap [mm]
2890 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SoilStoreCap_surf !Capacity of soil store for each surface [mm]
2891 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: state_surf_in !wetness status of each surface type from previous timestep [mm]
2892 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: soilstore_surf_in !initial water store in soil of each surface type [mm]
2893 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: qn_surf ! latent heat flux of individual surface [W m-2]
2894 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: qs_surf ! latent heat flux of individual surface [W m-2]
2895
2896 ! input for generic roof facets
2897 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: sfr_roof !surface fraction ratio of roof [-]
2898 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: StateLimit_roof !Limit for state_id of roof [mm]
2899 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: WetThresh_roof ! wetness threshold of roof[mm]
2900 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: SoilStoreCap_roof !Capacity of soil store for roof [mm]
2901 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: state_roof_in !wetness status of roof from previous timestep[mm]
2902 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: soilstore_roof_in !Soil moisture of roof [mm]
2903 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: qn_roof !net all-wave radiation for roof [W m-2]
2904 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: qs_roof !heat storage flux for roof [W m-2]
2905
2906 ! input for generic wall facets
2907 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: sfr_wall !surface fraction ratio of wall [-]
2908 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: StateLimit_wall ! upper limit for state_id of wall [mm]
2909 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: WetThresh_wall ! wetness threshold of roof[mm]
2910 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: SoilStoreCap_wall !Capacity of soil store for wall [mm]
2911 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: state_wall_in !wetness status of wall from previous timestep[mm]
2912 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: soilstore_wall_in !Soil moisture of wall [mm]
2913 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: qn_wall !net all-wave radiation for wall [W m-2]
2914 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: qs_wall !heat storage flux for wall [W m-2]
2915
2916 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SnowPackLimit
2917 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: AddWater_surf !Water from other surfaces (WGWaterDist in SUEWS_ReDistributeWater.f95) [mm]
2918 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: frac_water2runoff_surf !Fraction of water going to runoff/sub-surface soil (WGWaterDist) [-]
2919 REAL(KIND(1D0)), DIMENSION(6, nsurf), INTENT(in) :: StoreDrainPrm !Coefficients used in drainage calculation [-]
2920 ! REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(in) :: SnowProf_24hr
2921
2922 ! Total water transported to each grid for grid-to-grid connectivity
2923 ! REAL(KIND(1D0)), INTENT(in) :: runoff_per_interval_in
2924 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SnowPack_in
2925 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SnowFrac_in
2926 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SnowWater_in
2927 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: iceFrac_in
2928 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SnowDens_in
2929
2930 ! output:
2931 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: state_surf_out !wetness status of each surface type [mm]
2932 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: soilstore_surf_out !soil moisture of each surface type [mm]
2933 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: state_roof_out !Wetness status of roof [mm]
2934 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: soilstore_roof_out !soil moisture of roof [mm]
2935 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: state_wall_out !wetness status of wall [mm]
2936 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: soilstore_wall_out !soil moisture of wall [mm]
2937 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: SnowPack_out
2938 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: SnowFrac_out
2939 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: SnowWater_out
2940 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: iceFrac_out
2941 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: SnowDens_out
2942
2943 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: runoffSnow_surf !Initialize for runoff caused by snowmelting
2944 REAL(KIND(1D0)), DIMENSION(nsurf) :: runoff_surf !runoff from each surface type [mm]
2945 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: chang !Change in state_id [mm]
2946 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: ChangSnow_surf
2947 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: snowDepth
2948 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: SnowToSurf
2949 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: ev_snow
2950 ! REAL(KIND(1D0)), DIMENSION(2), INTENT(out) :: SnowRemoval
2951 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: qe0_surf !evaporation of each surface type by PM [mm]
2952 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: ev0_surf !evaporation of each surface type by PM [mm]
2953 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: ev_surf !evaporation of each surface type [mm]
2954 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: rss_surf !Redefined surface resistance for wet surfaces [s m-1]
2955
2956 ! REAL(KIND(1D0)) :: p_mm !Inputs to surface water balance
2957 ! REAL(KIND(1d0)),INTENT(out)::rss
2958 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: qe_surf ! latent heat flux on ground surface [W m-2]
2959 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: qe_roof ! latent heat flux on roof [W m-2]
2960 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: qe_wall ! latent heat flux on wall [W m-2]
2961 REAL(KIND(1D0)), DIMENSION(nlayer) :: ev_roof ! evaporation of roof [mm]
2962 REAL(KIND(1D0)), DIMENSION(nlayer) :: rss_roof ! redefined surface resistance for wet roof [s m-1]
2963 REAL(KIND(1D0)), DIMENSION(nlayer) :: runoff_roof !runoff from roof [mm]
2964 ! REAL(KIND(1D0)) :: qe_roof_total !turbulent latent heat flux on the roof [W m-2]
2965 REAL(KIND(1D0)), DIMENSION(nlayer) :: ev_wall ! evaporation of wall [mm]
2966 REAL(KIND(1D0)), DIMENSION(nlayer) :: rss_wall ! redefined surface resistance for wet wall [s m-1]
2967 REAL(KIND(1D0)), DIMENSION(nlayer) :: runoff_wall !runoff from wall [mm]
2968 ! REAL(KIND(1D0)) :: qe_wall_total !turbulent latent heat flux on the wall [W m-2]
2969 REAL(KIND(1D0)), INTENT(out) :: state_grid !total state_id (including water body) [mm]
2970 REAL(KIND(1D0)), INTENT(out) :: NWstate_grid !total state_id (excluding water body) [mm]
2971 REAL(KIND(1D0)), INTENT(out) :: qe ! aggregated latent heat flux of all surfaces [W m-2]
2972 ! REAL(KIND(1D0)), INTENT(out) :: swe
2973 ! REAL(KIND(1D0)) :: ev
2974 ! REAL(KIND(1D0)), INTENT(out) :: chSnow_per_interval
2975 REAL(KIND(1D0)), INTENT(out) :: ev_grid ! total evaporation for all surfaces [mm]
2976 ! REAL(KIND(1D0)) :: qe_grid ! total latent heat flux [W m-2] for all surfaces [W m-2]
2977 REAL(KIND(1D0)), INTENT(out) :: runoff_grid ! total runoff for all surfaces [mm]
2978 REAL(KIND(1D0)), INTENT(out) :: surf_chang_grid ! total change in surface state_id for all surfaces [mm]
2979 REAL(KIND(1D0)), INTENT(out) :: runoffPipes_grid ! !Runoff in pipes for all surface area [mm]
2980 ! REAL(KIND(1D0)), INTENT(out) :: mwstore
2981 REAL(KIND(1D0)), INTENT(out) :: runoffWaterBody_grid !Above ground runoff from water surface for all surface area [mm]
2982 ! REAL(KIND(1D0)) :: runoffWaterBody_m3
2983 ! REAL(KIND(1D0)) :: runoffPipes_m3
2984 REAL(KIND(1D0)), INTENT(out) :: runoffAGveg_grid !Above ground runoff from vegetated surfaces for all surface area [mm]
2985 REAL(KIND(1D0)), INTENT(out) :: runoffAGimpervious_grid !Above ground runoff from impervious surface for all surface area [mm]
2986
2987 ! local:
2988 ! INTEGER :: is
2989
2990 ! REAL(KIND(1D0)) :: runoff_per_interval
2991 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: state_id_out
2992 REAL(KIND(1D0)), DIMENSION(nsurf) :: soilstore_id !Soil moisture of each surface type [mm]
2993 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: SnowPack
2994 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: SnowFrac
2995 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: SnowWater
2996 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: iceFrac
2997 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: SnowDens
2998 REAL(KIND(1D0)), DIMENSION(nsurf) :: qn_e_surf !net available energy for evaporation for each surface[W m-2]
2999 REAL(KIND(1D0)), DIMENSION(nlayer) :: qn_e_roof !net available energy for evaporation for roof[W m-2]
3000 REAL(KIND(1D0)), DIMENSION(nlayer) :: qn_e_wall !net available energy for evaporation for wall[W m-2]
3001
3002 REAL(KIND(1D0)) :: pin !Rain per time interval
3003 REAL(KIND(1D0)) :: tlv !Latent heat of vapourisation per timestep [J kg-1 s-1]
3004 REAL(KIND(1D0)) :: nsh_real !timesteps per hour
3005 REAL(KIND(1D0)) :: state_building !aggregated surface water of building facets [mm]
3006 REAL(KIND(1D0)) :: soilstore_building !aggregated soilstore of building facets[mm]
3007 REAL(KIND(1D0)) :: capStore_builing ! aggregated storage capacity of building facets[mm]
3008 REAL(KIND(1D0)) :: runoff_building !aggregated Runoff of building facets [mm]
3009 REAL(KIND(1D0)) :: qe_building !aggregated qe of building facets[W m-2]
3010
3011 REAL(KIND(1D0)), DIMENSION(7) :: capStore_surf ! current storage capacity [mm]
3012
3013 ! runoff_per_interval = runoff_per_interval_in
3014 state_surf_out = state_surf_in
3015 soilstore_id = soilstore_surf_in
3016
3017 nsh_real = 3600/tstep*1.d0
3018
3019 tlv = lv_j_kg/tstep*1.d0 !Latent heat of vapourisation per timestep
3020
3021 pin = max(0., precip) !Initiate rain data [mm]
3022
3023 ! force these facets to be totally dry
3024 ! TODO: need to consider their hydrologic dynamics
3025 qe_roof = 0
3026 qe_wall = 0
3027 qe0_surf = 0
3028
3029 IF (diagnose == 1) WRITE (*, *) 'Calling evap_SUEWS and SoilStore...'
3030 ! == calculate QE ==
3031 ! --- general suews surfaces ---
3032 ! net available energy for evaporation
3033 qn_e_surf = qn_surf + qf - qs_surf ! qn1 changed to qn1_snowfree, lj in May 2013
3034
3035 ! soil store capacity
3036 capstore_surf = storedrainprm(6, :)
3037 CALL cal_evap_multi( &
3038 evapmethod, & !input
3039 sfr_surf, state_surf_in, wetthresh_surf, capstore_surf, & !input
3040 vpd_hpa, avdens, avcp, qn_e_surf, s_hpa, psyc_hpa, rs, ra_h, rb, tlv, &
3041 rss_surf, ev0_surf, qe0_surf) !output
3042
3043 IF (storageheatmethod == 5) THEN
3044 ! --- roofs ---
3045 ! net available energy for evaporation
3046 qn_e_roof = qn_roof + qf - qs_roof ! qn1 changed to qn1_snowfree, lj in May 2013
3047 CALL cal_evap_multi( &
3048 evapmethod, & !input
3049 sfr_roof, state_roof_in, wetthresh_roof, statelimit_roof, & !input
3050 vpd_hpa, avdens, avcp, qn_e_roof, s_hpa, psyc_hpa, rs, ra_h, rb, tlv, &
3051 rss_roof, ev_roof, qe_roof) !output
3052
3053 ! --- walls ---
3054 ! net available energy for evaporation
3055 qn_e_wall = qn_wall + qf - qs_wall ! qn1 changed to qn1_snowfree, lj in May 2013
3056 CALL cal_evap_multi( &
3057 evapmethod, & !input
3058 sfr_wall, state_wall_in, wetthresh_wall, statelimit_wall, & !input
3059 vpd_hpa, avdens, avcp, qn_e_wall, s_hpa, psyc_hpa, rs, ra_h, rb, tlv, &
3060 rss_wall, ev_wall, qe_wall) !output
3061
3062 ! == calculate water balance ==
3063 ! --- building facets: roofs and walls ---
3065 pin, nsh_real, nlayer, &
3066 sfr_roof, statelimit_roof, soilstorecap_roof, wetthresh_roof, & ! input:
3067 ev_roof, state_roof_in, soilstore_roof_in, & ! input:
3068 sfr_wall, statelimit_wall, soilstorecap_wall, wetthresh_wall, & ! input:
3069 ev_wall, state_wall_in, soilstore_wall_in, & ! input:
3070 ev_roof, state_roof_out, soilstore_roof_out, runoff_roof, & ! general output:
3071 ev_wall, state_wall_out, soilstore_wall_out, runoff_wall, & ! general output:
3072 state_building, soilstore_building, runoff_building, capstore_builing)
3073
3074 ! update QE based on the water balance
3075 qe_roof = tlv*ev_roof
3076 qe_wall = tlv*ev_wall
3077 qe_building = (dot_product(qe_roof, sfr_roof) + dot_product(qe_wall, sfr_wall))/sfr_surf(bldgsurf)
3078 END IF
3079 ! --- general suews surfaces ---
3081 pin, nsh_real, &
3082 pipecapacity, runofftowater, & ! input:
3083 addimpervious, addveg, addwaterbody, flowchange, &
3084 soilstorecap_surf, statelimit_surf, &
3085 pervfraction, &
3086 sfr_surf, drain_surf, addwater_surf, frac_water2runoff_surf, wu_surf, &
3087 ev0_surf, state_surf_in, soilstore_surf_in, &
3088 ev_surf, state_surf_out, soilstore_surf_out, & ! output:
3089 runoff_surf, &
3090 runoffagimpervious_grid, runoffagveg_grid, runoffpipes_grid, runoffwaterbody_grid & ! output:
3091 )
3092
3093 ! update QE based on the water balance
3094 qe_surf = tlv*ev_surf
3095
3096 ! --- update building related ---
3097 IF (storageheatmethod == 5) THEN
3098 ! update building specific values
3099 qe_surf(bldgsurf) = qe_building
3100 state_surf_out(bldgsurf) = state_building
3101 soilstore_surf_out(bldgsurf) = soilstore_building/capstore_builing*capstore_surf(bldgsurf)
3102 runoff_surf(bldgsurf) = runoff_building
3103 END IF
3104
3105 ! aggregate all surface water fluxes/amounts
3106 qe = dot_product(qe_surf, sfr_surf)
3107
3108 ! Sum change from different surfaces to find total change to surface state_id
3109 surf_chang_grid = dot_product(state_surf_out - state_surf_in, sfr_surf)
3110
3111 ! Sum evaporation from different surfaces to find total evaporation [mm]
3112 ev_grid = dot_product(ev_surf, sfr_surf)
3113
3114 ! Sum runoff from different surfaces to find total runoff
3115 runoff_grid = dot_product(runoff_surf, sfr_surf)
3116
3117 ! Calculate total state_id (including water body)
3118 state_grid = dot_product(state_surf_out, sfr_surf)
3119
3120 IF (nonwaterfraction /= 0) THEN
3121 nwstate_grid = dot_product(state_surf_out(1:nsurf - 1), sfr_surf(1:nsurf - 1))/nonwaterfraction
3122 END IF
3123 ! Calculate volume of water that will move between grids
3124 ! Volume [m3] = Depth relative to whole area [mm] / 1000 [mm m-1] * SurfaceArea [m2]
3125 ! Need to use these volumes when converting back to addImpervious, AddVeg and AddWater
3126 ! runoffAGimpervious_m3 = runoffAGimpervious/1000*SurfaceArea
3127 ! runoffAGveg_m3 = runoffAGveg/1000*SurfaceArea
3128 ! runoffWaterBody_m3 = runoffWaterBody/1000*SurfaceArea
3129 ! runoffPipes_m3 = runoffPipes/1000*SurfaceArea
3130
3131 ! state_id_out = state_id_out
3132 ! soilstore_id_out = soilstore_id
3133 IF (storageheatmethod == 5) THEN
3134 IF (diagnose == 1) print *, 'in SUEWS_cal_QE soilstore_building = ', soilstore_building
3135 IF (diagnose == 1) print *, 'in SUEWS_cal_QE capStore_builing = ', capstore_builing
3136 IF (diagnose == 1) print *, 'in SUEWS_cal_QE capStore_surf(BldgSurf) = ', capstore_surf(bldgsurf)
3137 END IF
3138 IF (diagnose == 1) print *, 'in SUEWS_cal_QE soilstore_id = ', soilstore_surf_out
3139
3140 END SUBROUTINE suews_cal_qe
3141 !========================================================================
3142
3143 !===============sensible heat flux======================================
3144 SUBROUTINE suews_cal_qh( &
3145 QHMethod, nlayer, storageheatmethod, & !input
3146 qn, qf, QmRain, qe, qs, QmFreez, qm, avdens, avcp, &
3147 sfr_surf, sfr_roof, sfr_wall, &
3148 tsfc_surf, tsfc_roof, tsfc_wall, &
3149 Temp_C, &
3150 RA, &
3151 qh, qh_residual, qh_resist, & !output
3152 qh_resist_surf, qh_resist_roof, qh_resist_wall)
3153 IMPLICIT NONE
3154
3155 INTEGER, INTENT(in) :: QHMethod ! option for QH calculation: 1, residual; 2, resistance-based
3156 INTEGER, INTENT(in) :: storageheatmethod !Determines method for calculating storage heat flux ΔQS [-]
3157 INTEGER, INTENT(in) :: nlayer !number of vertical levels in urban canopy [-]
3158
3159 REAL(KIND(1D0)), INTENT(in) :: qn !net all-wave radiation [W m-2]
3160 REAL(KIND(1D0)), INTENT(in) :: qf ! anthropogenic heat flux [W m-2]
3161 REAL(KIND(1D0)), INTENT(in) :: QmRain !melt heat for rain on snow [W m-2]
3162 REAL(KIND(1D0)), INTENT(in) :: qe !latent heat flux [W m-2]
3163 REAL(KIND(1D0)), INTENT(in) :: qs !heat storage flux [W m-2]
3164 REAL(KIND(1D0)), INTENT(in) :: QmFreez !heat related to freezing of surface store [W m-2]
3165 REAL(KIND(1D0)), INTENT(in) :: qm !Snowmelt-related heat [W m-2]
3166 REAL(KIND(1D0)), INTENT(in) :: avdens !air density [kg m-3]
3167 REAL(KIND(1D0)), INTENT(in) :: avcp !air heat capacity [J kg-1 K-1]
3168 ! REAL(KIND(1D0)), INTENT(in) :: tsurf
3169 REAL(KIND(1D0)), INTENT(in) :: Temp_C !air temperature [degC]
3170 REAL(KIND(1D0)), INTENT(in) :: RA !aerodynamic resistance [s m-1]
3171
3172 REAL(KIND(1D0)), INTENT(out) :: qh ! turtbulent sensible heat flux [W m-2]
3173 REAL(KIND(1D0)), INTENT(out) :: qh_resist !resistance bnased sensible heat flux [W m-2]
3174 REAL(KIND(1D0)), INTENT(out) :: qh_residual ! residual based sensible heat flux [W m-2]
3175 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: tsfc_surf !surface temperature [degC]
3176 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: sfr_surf !surface fraction ratio [-]
3177 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: qh_resist_surf !resistance-based sensible heat flux [W m-2]
3178 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: sfr_roof !surface fraction of roof [-]
3179 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tsfc_roof !roof surface temperature [degC]
3180 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: qh_resist_roof !resistance-based sensible heat flux of roof [W m-2]
3181 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: sfr_wall !surface fraction of wall [-]
3182 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tsfc_wall !wall surface temperature[degC]
3183 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: qh_resist_wall !resistance-based sensible heat flux of wall [W m-2]
3184
3185 REAL(KIND(1D0)), PARAMETER :: NAN = -999
3186 INTEGER :: is
3187
3188 ! Calculate sensible heat flux as a residual (Modified by LJ in Nov 2012)
3189 qh_residual = (qn + qf + qmrain) - (qe + qs + qm + qmfreez) !qh=(qn1+qf+QmRain+QmFreez)-(qeOut+qs+Qm)
3190
3191 ! ! Calculate QH using resistance method (for testing HCW 06 Jul 2016)
3192 ! Aerodynamic-Resistance-based method
3193 DO is = 1, nsurf
3194 IF (ra /= 0) THEN
3195 qh_resist_surf(is) = avdens*avcp*(tsfc_surf(is) - temp_c)/ra
3196 ELSE
3197 qh_resist_surf(is) = nan
3198 END IF
3199 END DO
3200 IF (storageheatmethod == 5) THEN
3201 DO is = 1, nlayer
3202 IF (ra /= 0) THEN
3203 qh_resist_roof(is) = avdens*avcp*(tsfc_roof(is) - temp_c)/ra
3204 qh_resist_wall(is) = avdens*avcp*(tsfc_wall(is) - temp_c)/ra
3205 ELSE
3206 qh_resist_surf(is) = nan
3207 END IF
3208 END DO
3209
3210 ! IF (RA /= 0) THEN
3211 ! qh_resist = avdens*avcp*(tsurf - Temp_C)/RA
3212 ! ELSE
3213 ! qh_resist = NAN
3214 ! END IF
3215 ! aggregate QH of roof and wall
3216 qh_resist_surf(bldgsurf) = (dot_product(qh_resist_roof, sfr_roof) + dot_product(qh_resist_wall, sfr_wall))/2.
3217 END IF
3218
3219 qh_resist = dot_product(qh_resist_surf, sfr_surf)
3220
3221 ! choose output QH
3222 SELECT CASE (qhmethod)
3223 CASE (1)
3224 qh = qh_residual
3225 CASE (2)
3226 qh = qh_resist
3227 END SELECT
3228
3229 END SUBROUTINE suews_cal_qh
3230 !========================================================================
3231
3232 !===============Resistance Calculations=======================
3234 StabilityMethod, & !input:
3235 Diagnose, AerodynamicResistanceMethod, RoughLenHeatMethod, SnowUse, &
3236 id, it, gsModel, SMDMethod, &
3237 avdens, avcp, QH_init, zzd, z0m, zdm, &
3238 avU1, Temp_C, VegFraction, &
3239 avkdn, Kmax, G1, G2, G3, G4, G5, G6, S1, S2, TH, TL, dq, &
3240 xsmd, vsmd, MaxConductance, LAIMax, LAI_id, SnowFrac, sfr_surf, &
3241 UStar, TStar, L_mod, & !output
3242 zL, gsc, RS, RA, RASnow, RB, z0v, z0vSnow)
3243
3244 IMPLICIT NONE
3245
3246 INTEGER, INTENT(in) :: StabilityMethod !method to calculate atmospheric stability [-]
3247 INTEGER, INTENT(in) :: Diagnose
3248 INTEGER, INTENT(in) :: AerodynamicResistanceMethod !method to calculate RA [-]
3249 INTEGER, INTENT(in) :: RoughLenHeatMethod !method to calculate heat roughness length [-]
3250 INTEGER, INTENT(in) :: SnowUse !!Snow part used (1) or not used (0) [-]
3251 INTEGER, INTENT(in) :: id ! day of the year [-]
3252 INTEGER, INTENT(in) :: it !hour [h]
3253 INTEGER, INTENT(in) :: gsModel !Choice of gs parameterisation (1 = Ja11, 2 = Wa16)
3254 INTEGER, INTENT(in) :: SMDMethod !Method of measured soil moisture
3255
3256 ! REAL(KIND(1d0)), INTENT(in)::qh_obs
3257 REAL(KIND(1D0)), INTENT(in) :: avdens !air density [kg m-3]
3258 REAL(KIND(1D0)), INTENT(in) :: avcp !air heat capacity [J kg-1 K-1]
3259 REAL(KIND(1D0)), INTENT(in) :: QH_init !initial sensible heat flux [W m-2]
3260 REAL(KIND(1D0)), INTENT(in) :: zzd !Active measurement height (meas. height-displac. height) [m]
3261 REAL(KIND(1D0)), INTENT(in) :: z0m !Aerodynamic roughness length [m]
3262 REAL(KIND(1D0)), INTENT(in) :: zdm !Displacement height [m]
3263 REAL(KIND(1D0)), INTENT(in) :: avU1 !Average wind speed [m s-1]
3264 REAL(KIND(1D0)), INTENT(in) :: Temp_C !Air temperature [degC]
3265 REAL(KIND(1D0)), INTENT(in) :: VegFraction !Fraction of vegetation [-]
3266 REAL(KIND(1D0)), INTENT(in) :: avkdn !Average downwelling shortwave radiation [W m-2]
3267 REAL(KIND(1D0)), INTENT(in) :: Kmax !Annual maximum hourly solar radiation [W m-2]
3268 REAL(KIND(1D0)), INTENT(in) :: G1 !Fitted parameters related to surface res. calculations
3269 REAL(KIND(1D0)), INTENT(in) :: G2 !Fitted parameters related to surface res. calculations
3270 REAL(KIND(1D0)), INTENT(in) :: G3 !Fitted parameters related to surface res. calculations
3271 REAL(KIND(1D0)), INTENT(in) :: G4 !Fitted parameters related to surface res. calculations
3272 REAL(KIND(1D0)), INTENT(in) :: G5 !Fitted parameters related to surface res. calculations
3273 REAL(KIND(1D0)), INTENT(in) :: G6 !Fitted parameters related to surface res. calculations
3274 REAL(KIND(1D0)), INTENT(in) :: S1 !a parameter related to soil moisture dependence [-]
3275 REAL(KIND(1D0)), INTENT(in) :: S2 !a parameter related to soil moisture dependence [mm]
3276 REAL(KIND(1D0)), INTENT(in) :: TH !Maximum temperature limit [degC]
3277 REAL(KIND(1D0)), INTENT(in) :: TL !Minimum temperature limit [degC]
3278 REAL(KIND(1D0)), INTENT(in) :: dq !Specific humidity deficit
3279 REAL(KIND(1D0)), INTENT(in) :: xsmd !Measured soil moisture deficit
3280 REAL(KIND(1D0)), INTENT(in) :: vsmd !Soil moisture deficit for vegetated surfaces only[mm]
3281
3282 REAL(KIND(1D0)), DIMENSION(3), INTENT(in) :: MaxConductance !the maximum conductance of each vegetation or surface type. [mm s-1]
3283 REAL(KIND(1D0)), DIMENSION(3), INTENT(in) :: LAIMax !Max LAI [m2 m-2]
3284 REAL(KIND(1D0)), DIMENSION(3), INTENT(in) :: LAI_id !=LAI_id(id-1,:), LAI for each veg surface [m2 m-2]
3285
3286 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: SnowFrac !Surface fraction of snow cover [-]
3287 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: sfr_surf !Surface fractions [-]
3288
3289 REAL(KIND(1D0)), INTENT(out) :: TStar !T* temperature scale
3290 REAL(KIND(1D0)), INTENT(out) :: UStar !friction velocity [m s-1]
3291 REAL(KIND(1D0)), INTENT(out) :: zL !stability scale
3292 REAL(KIND(1D0)), INTENT(out) :: gsc !Surface Layer Conductance
3293 REAL(KIND(1D0)), INTENT(out) :: RS !surface resistance [s m-1]
3294 REAL(KIND(1D0)), INTENT(out) :: RA !Aerodynamic resistance [s m-1]
3295 REAL(KIND(1D0)), INTENT(out) :: z0v !roughness for heat [m]
3296 REAL(KIND(1D0)), INTENT(out) :: RASnow !Aerodynamic resistance for snow [s m-1]
3297 REAL(KIND(1D0)), INTENT(out) :: z0vSnow !roughness for heat [m]
3298 REAL(KIND(1D0)), INTENT(out) :: RB !boundary layer resistance shuttleworth
3299 REAL(KIND(1D0)), INTENT(out) :: L_mod !Obukhov length [m]
3300 REAL(KIND(1D0)) :: gfunc !gdq*gtemp*gs*gq for photosynthesis calculations
3301 ! REAL(KIND(1d0)) ::H_init !Kinematic sensible heat flux [K m s-1] used to calculate friction velocity
3302
3303 ! Get first estimate of sensible heat flux. Modified by HCW 26 Feb 2015
3304 ! CALL SUEWS_init_QH( &
3305 ! avdens, avcp, QH_init, qn1, dectime, &
3306 ! H_init)
3307 rasnow = 0.0
3308
3309 IF (diagnose == 1) WRITE (*, *) 'Calling STAB_lumps...'
3310 !u* and Obukhov length out
3311 CALL cal_stab( &
3312 stabilitymethod, & ! input
3313 zzd, & !Active measurement height (meas. height-displac. height)
3314 z0m, & !Aerodynamic roughness length
3315 zdm, & !zero-plane displacement
3316 avu1, & !Average wind speed
3317 temp_c, & !Air temperature
3318 qh_init, & !sensible heat flux
3319 avdens, & ! air density
3320 avcp, & ! heat capacity of air
3321 l_mod, & ! output: !Obukhov length
3322 tstar, & !T*, temperature scale
3323 ustar, & !Friction velocity
3324 zl) !Stability scale
3325
3326 IF (diagnose == 1) WRITE (*, *) 'Calling AerodynamicResistance...'
3327 CALL aerodynamicresistance( &
3328 zzd, & ! input:
3329 z0m, &
3330 avu1, &
3331 l_mod, &
3332 ustar, &
3333 vegfraction, &
3334 aerodynamicresistancemethod, &
3335 stabilitymethod, &
3336 roughlenheatmethod, &
3337 ra, z0v) ! output:
3338
3339 IF (snowuse == 1) THEN
3340 IF (diagnose == 1) WRITE (*, *) 'Calling AerodynamicResistance for snow...'
3341 CALL aerodynamicresistance( &
3342 zzd, & ! input:
3343 z0m, &
3344 avu1, &
3345 l_mod, &
3346 ustar, &
3347 vegfraction, &
3348 aerodynamicresistancemethod, &
3349 stabilitymethod, &
3350 3, &
3351 rasnow, z0vsnow) ! output:
3352 END IF
3353
3354 IF (diagnose == 1) WRITE (*, *) 'Calling SurfaceResistance...'
3355 ! CALL SurfaceResistance(id,it) !qsc and surface resistance out
3356 CALL surfaceresistance( &
3357 id, it, & ! input:
3358 smdmethod, snowfrac, sfr_surf, avkdn, temp_c, dq, xsmd, vsmd, maxconductance, &
3359 laimax, lai_id, gsmodel, kmax, &
3360 g1, g2, g3, g4, g5, g6, th, tl, s1, s2, &
3361 gfunc, gsc, rs) ! output:
3362
3363 IF (diagnose == 1) WRITE (*, *) 'Calling BoundaryLayerResistance...'
3365 zzd, & ! input: !Active measurement height (meas. height- zero-plane displacement)
3366 z0m, & !Aerodynamic roughness length
3367 avu1, & !Average wind speed
3368 ustar, & ! input/output:
3369 rb) ! output:
3370
3371 END SUBROUTINE suews_cal_resistance
3372 !========================================================================
3373
3374 !==============Update output arrays=========================
3376 AdditionalWater, alb, avkdn, avU10_ms, azimuth, & !input
3377 chSnow_per_interval, dectime, &
3378 drain_per_tstep, E_mod, ev_per_tstep, ext_wu, Fc, Fc_build, fcld, &
3379 Fc_metab, Fc_photo, Fc_respi, Fc_point, Fc_traff, FlowChange, &
3380 h_mod, id, imin, int_wu, it, iy, &
3381 kup, LAI_id, ldown, l_mod, lup, mwh, &
3382 MwStore, &
3383 nsh_real, NWstate_per_tstep, Precip, q2_gkg, &
3384 qeOut, qf, qh, qh_resist, Qm, QmFreez, &
3385 QmRain, qn, qn_snow, qn_snowfree, qs, RA, &
3386 resistsurf, RH2, runoffAGimpervious, runoffAGveg, &
3387 runoff_per_tstep, runoffPipes, runoffSoil_per_tstep, &
3388 runoffWaterBody, sfr_surf, smd, smd_nsurf, SnowAlb, SnowRemoval, &
3389 state_id, state_per_tstep, surf_chang_per_tstep, swe, t2_C, tskin_C, &
3390 tot_chang_per_tstep, tsurf, UStar, &
3391 wu_nsurf, &
3392 z0m, zdm, zenith_deg, &
3393 datetimeLine, dataOutLineSUEWS) !output
3394 IMPLICIT NONE
3395
3396 REAL(KIND(1D0)), PARAMETER :: NAN = -999
3397 INTEGER, INTENT(in) :: iy ! year [YYYY]
3398 INTEGER, INTENT(in) :: id ! day of the year [DOY]
3399 INTEGER, INTENT(in) :: it ! hour [H]
3400 INTEGER, INTENT(in) :: imin ! minutes [M]
3401 REAL(KIND(1D0)), INTENT(in) :: AdditionalWater !Additional water coming from other grids [mm]
3402 REAL(KIND(1D0)), INTENT(in) :: alb(nsurf) !albedo of each surfaces [-]
3403 REAL(KIND(1D0)), INTENT(in) :: avkdn !Average downwelling shortwave radiation [W m-2]
3404 REAL(KIND(1D0)), INTENT(in) :: avU10_ms !average wind speed at 10m [W m-1]
3405 REAL(KIND(1D0)), INTENT(in) :: azimuth !solar azimuth [°]
3406 REAL(KIND(1D0)), INTENT(in) :: chSnow_per_interval ! change state_id of snow and surface per time interval [mm]
3407 REAL(KIND(1D0)), INTENT(in) :: dectime !decimal time [-]
3408 REAL(KIND(1D0)), INTENT(in) :: drain_per_tstep ! total dr ainage at each timestep [mm]
3409 REAL(KIND(1D0)), INTENT(in) :: E_mod
3410 REAL(KIND(1D0)), INTENT(in) :: ev_per_tstep ! evaporation at each time step [mm]
3411 REAL(KIND(1D0)), INTENT(in) :: ext_wu !external water use
3412 REAL(KIND(1D0)), INTENT(in) :: Fc !co2 emission [umol m-2 s-1]
3413 REAL(KIND(1D0)), INTENT(in) :: Fc_build ! co2 emission from building component [umol m-2 s-1]
3414 REAL(KIND(1D0)), INTENT(in) :: Fc_metab ! co2 emission from metabolism component [umol m-2 s-1]
3415 REAL(KIND(1D0)), INTENT(in) :: Fc_photo !co2 flux from photosynthesis [umol m-2 s-1]
3416 REAL(KIND(1D0)), INTENT(in) :: Fc_respi !co2 flux from respiration [umol m-2 s-1]
3417 REAL(KIND(1D0)), INTENT(in) :: Fc_point ! co2 emission from point source [umol m-2 s-1]
3418 REAL(KIND(1D0)), INTENT(in) :: Fc_traff !co2 flux from traffic [umol m-2 s-1]
3419 REAL(KIND(1D0)), INTENT(in) :: fcld !cloud fraction [-]
3420 REAL(KIND(1D0)), INTENT(in) :: FlowChange !Difference between the input and output flow in the water body [mm]
3421 REAL(KIND(1D0)), INTENT(in) :: h_mod !volumetric air heat capacity [J m-3 K-1]
3422 REAL(KIND(1D0)), INTENT(in) :: int_wu !internal water use [mm]
3423 REAL(KIND(1D0)), INTENT(in) :: kup !outgoing shortwave radiation [W m-2]
3424 REAL(KIND(1D0)), INTENT(in) :: l_mod !Obukhov length [m]
3425 REAL(KIND(1D0)), INTENT(in) :: LAI_id(nvegsurf) !leaf area index [m2 m-2]
3426 REAL(KIND(1D0)), INTENT(in) :: ldown !incoming longwave radiation [W m-2]
3427 REAL(KIND(1D0)), INTENT(in) :: lup !outgoing longwave radiation [W m-2]
3428 REAL(KIND(1D0)), INTENT(in) :: mwh !snowmelt [mm]
3429 REAL(KIND(1D0)), INTENT(in) :: MwStore !overall met water [mm]
3430 REAL(KIND(1D0)), INTENT(in) :: nsh_real !timestep in a hour [-]
3431 REAL(KIND(1D0)), INTENT(in) :: NWstate_per_tstep ! state_id at each tinestep(excluding water body) [mm]
3432 REAL(KIND(1D0)), INTENT(in) :: Precip !rain data [mm]
3433 REAL(KIND(1D0)), INTENT(in) :: q2_gkg ! Air specific humidity at 2 m [g kg-1]
3434 REAL(KIND(1D0)), INTENT(in) :: qeOut !latent heat flux [W -2]
3435 REAL(KIND(1D0)), INTENT(in) :: qf !anthropogenic heat flux [W m-2]
3436 REAL(KIND(1D0)), INTENT(in) :: qh !turbulent sensible heat flux [W m-2]
3437 REAL(KIND(1D0)), INTENT(in) :: qh_resist ! resistance-based turbulent sensible heat flux [W m-2]
3438 REAL(KIND(1D0)), INTENT(in) :: Qm !snowmelt-related heat [W m-2]
3439 REAL(KIND(1D0)), INTENT(in) :: QmFreez !heat related to freezing of surface store
3440 REAL(KIND(1D0)), INTENT(in) :: QmRain !melt heat for rain on snow [W m-2]
3441 REAL(KIND(1D0)), INTENT(in) :: qn !net all-wave radiation [W m-2]
3442 REAL(KIND(1D0)), INTENT(in) :: qn_snow !net all-wave radiation on snow surface [W m-2]
3443 REAL(KIND(1D0)), INTENT(in) :: qn_snowfree !net all-wave radiation on snow-free surface [W m-2]
3444 REAL(KIND(1D0)), INTENT(in) :: qs !heat storage flux [W m-2]
3445 REAL(KIND(1D0)), INTENT(in) :: RA !aerodynamic resistance [s m-1]
3446 REAL(KIND(1D0)), INTENT(in) :: resistsurf !surface resistance [s m-1]
3447 REAL(KIND(1D0)), INTENT(in) :: RH2 ! air relative humidity at 2m [-]
3448 REAL(KIND(1D0)), INTENT(in) :: runoff_per_tstep !runoff water at each time step [mm]
3449 REAL(KIND(1D0)), INTENT(in) :: runoffAGimpervious !Above ground runoff from impervious surface for all surface area [mm]
3450 REAL(KIND(1D0)), INTENT(in) :: runoffAGveg !Above ground runoff from vegetated surfaces for all surface area [mm]
3451 REAL(KIND(1D0)), INTENT(in) :: runoffPipes !runoff to pipes [mm]
3452 REAL(KIND(1D0)), INTENT(in) :: runoffSoil_per_tstep !Runoff to deep soil per timestep [mm] (for whole surface, excluding water body)
3453 REAL(KIND(1D0)), INTENT(in) :: runoffWaterBody !Above ground runoff from water body for all surface area [mm]
3454 REAL(KIND(1D0)), INTENT(in) :: sfr_surf(nsurf) !surface fraction [-]
3455 REAL(KIND(1D0)), INTENT(in) :: smd !soil moisture deficit [mm]
3456 REAL(KIND(1D0)), INTENT(in) :: smd_nsurf(nsurf) !smd for each surface [mm]
3457 REAL(KIND(1D0)), INTENT(in) :: SnowAlb !snow alebdo [-]
3458 REAL(KIND(1D0)), INTENT(in) :: SnowRemoval(2) !snow removal [mm]
3459 REAL(KIND(1D0)), INTENT(in) :: state_id(nsurf) ! wetness status of each surface type [mm]
3460 REAL(KIND(1D0)), INTENT(in) :: state_per_tstep !state_id at each timestep [mm]
3461 REAL(KIND(1D0)), INTENT(in) :: surf_chang_per_tstep !change in state_id (exluding snowpack) per timestep [mm]
3462 REAL(KIND(1D0)), INTENT(in) :: swe !overall snow water equavalent[mm]
3463 REAL(KIND(1D0)), INTENT(in) :: t2_C !modelled 2 meter air temperature [degC]
3464 REAL(KIND(1D0)), INTENT(in) :: tskin_C ! skin temperature [degC]
3465 REAL(KIND(1D0)), INTENT(in) :: tot_chang_per_tstep !Change in surface state_id [mm]
3466 REAL(KIND(1D0)), INTENT(in) :: tsurf !surface temperatue [degC]
3467 REAL(KIND(1D0)), INTENT(in) :: UStar !friction velocity [m s-1]
3468 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: wu_nsurf !water use of each surfaces [mm]
3469
3470 REAL(KIND(1D0)), INTENT(in) :: z0m !Aerodynamic roughness length [m]
3471 REAL(KIND(1D0)), INTENT(in) :: zdm !zero-plane displacement [m]
3472 REAL(KIND(1D0)), INTENT(in) :: zenith_deg !solar zenith angle in degree [°]
3473
3474 REAL(KIND(1D0)), DIMENSION(5), INTENT(OUT) :: datetimeLine !date & time
3475 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutSUEWS - 5), INTENT(out) :: dataOutLineSUEWS
3476 ! REAL(KIND(1d0)),DIMENSION(ncolumnsDataOutSnow-5),INTENT(out) :: dataOutLineSnow
3477 ! REAL(KIND(1d0)),DIMENSION(ncolumnsDataOutESTM-5),INTENT(out) :: dataOutLineESTM
3478 ! INTEGER:: is
3479 REAL(KIND(1D0)) :: LAI_wt !area weighted LAI [m2 m-2]
3480 REAL(KIND(1D0)) :: RH2_pct ! RH2 in percentage [-]
3481
3482 ! the variables below with '_x' endings stand for 'exported' values
3483 REAL(KIND(1D0)) :: ResistSurf_x !output surface resistance [s m-1]
3484 REAL(KIND(1D0)) :: surf_chang_per_tstep_x !output change in state_id (exluding snowpack) per timestep [mm]
3485 REAL(KIND(1D0)) :: l_mod_x !output Obukhov length [m]
3486 REAL(KIND(1D0)) :: bulkalbedo !output area-weighted albedo [-]
3487 REAL(KIND(1D0)) :: smd_nsurf_x(nsurf) !output soil moisture deficit for each surface [mm]
3488 REAL(KIND(1D0)) :: state_x(nsurf) !output wetness status of each surfaces[mm]
3489 REAL(KIND(1D0)) :: wu_DecTr !water use for deciduous tree and shrubs [mm]
3490 REAL(KIND(1D0)) :: wu_EveTr !water use of evergreen tree and shrubs [mm]
3491 REAL(KIND(1D0)) :: wu_Grass !water use for grass [mm]
3492
3493 !=====================================================================
3494 !====================== Prepare data for output ======================
3495 ! values outside of reasonable range are set as NAN-like numbers. TS 10 Jun 2018
3496
3497 ! Remove non-existing surface type from surface and soil outputs ! Added back in with NANs by HCW 24 Aug 2016
3498 state_x = unpack(spread(nan, dim=1, ncopies=SIZE(sfr_surf)), mask=(sfr_surf < 0.00001), field=state_id)
3499 smd_nsurf_x = unpack(spread(nan, dim=1, ncopies=SIZE(sfr_surf)), mask=(sfr_surf < 0.00001), field=smd_nsurf)
3500
3501 resistsurf_x = min(9999., resistsurf)
3502
3503 surf_chang_per_tstep_x = merge(surf_chang_per_tstep, 0.d0, abs(surf_chang_per_tstep) > 1e-6)
3504
3505 l_mod_x = max(min(9999., l_mod), -9999.)
3506
3507 ! Calculate areally-weighted LAI
3508 ! IF(iy == (iy_prev_t +1) .AND. (id-1) == 0) THEN !Check for start of next year and avoid using LAI(id-1) as this is at the start of the year
3509 ! LAI_wt=DOT_PRODUCT(LAI(id_prev_t,:),sfr_surf(1+2:nvegsurf+2))
3510 ! ELSE
3511 ! LAI_wt=DOT_PRODUCT(LAI(id-1,:),sfr_surf(1+2:nvegsurf+2))
3512 ! ENDIF
3513
3514 lai_wt = dot_product(lai_id(:), sfr_surf(1 + 2:nvegsurf + 2))
3515
3516 ! Calculate areally-weighted albedo
3517 bulkalbedo = dot_product(alb, sfr_surf)
3518
3519 ! convert RH2 to a percentage form
3520 rh2_pct = rh2*100.0
3521
3522 ! translate water use to vegetated surfaces
3523 wu_dectr = wu_nsurf(3)
3524 wu_evetr = wu_nsurf(4)
3525 wu_grass = wu_nsurf(5)
3526
3527 !====================== update output line ==============================
3528 ! date & time:
3529 datetimeline = [ &
3530 REAL(iy, KIND(1D0)), REAL(id, KIND(1D0)), &
3531 REAL(it, KIND(1D0)), REAL(imin, KIND(1D0)), dectime]
3532 !Define the overall output matrix to be printed out step by step
3533 dataoutlinesuews = [ &
3534 avkdn, kup, ldown, lup, tsurf, &
3535 qn, qf, qs, qh, qeout, &
3536 h_mod, e_mod, qh_resist, &
3537 precip, ext_wu, ev_per_tstep, runoff_per_tstep, tot_chang_per_tstep, &
3538 surf_chang_per_tstep_x, state_per_tstep, nwstate_per_tstep, drain_per_tstep, smd, &
3539 flowchange/nsh_real, additionalwater, &
3540 runoffsoil_per_tstep, runoffpipes, runoffagimpervious, runoffagveg, runoffwaterbody, &
3541 int_wu, wu_evetr, wu_dectr, wu_grass, &
3542 smd_nsurf_x(1:nsurf - 1), &
3543 state_x(1:nsurf), &
3544 zenith_deg, azimuth, bulkalbedo, fcld, &
3545 lai_wt, z0m, zdm, &
3546 ustar, l_mod, ra, resistsurf, &
3547 fc, &
3548 fc_photo, fc_respi, fc_metab, fc_traff, fc_build, fc_point, &
3549 qn_snowfree, qn_snow, snowalb, &
3550 qm, qmfreez, qmrain, swe, mwh, mwstore, chsnow_per_interval, &
3551 snowremoval(1:2), &
3552 tskin_c, t2_c, q2_gkg, avu10_ms, rh2_pct & ! surface-level diagonostics
3553 ]
3554 ! set invalid values to NAN
3555 ! dataOutLineSUEWS = set_nan(dataOutLineSUEWS)
3556
3557 !====================update output line end==============================
3558
3559 END SUBROUTINE suews_update_outputline
3560 !========================================================================
3561
3562 !==============Update output arrays=========================
3564 iy, id, it, imin, dectime, nlayer, & !input
3565 tsfc_out_surf, qs_surf, &
3566 tsfc_out_roof, &
3567 Qn_roof, &
3568 QS_roof, &
3569 QE_roof, &
3570 QH_roof, &
3571 state_roof, &
3572 soilstore_roof, &
3573 tsfc_out_wall, &
3574 Qn_wall, &
3575 QS_wall, &
3576 QE_wall, &
3577 QH_wall, &
3578 state_wall, &
3579 soilstore_wall, &
3580 datetimeLine, dataOutLineESTMExt) !output
3581 IMPLICIT NONE
3582
3583 REAL(KIND(1D0)), PARAMETER :: NAN = -999
3584 INTEGER, PARAMETER :: n_fill = 15
3585
3586 INTEGER, INTENT(in) :: iy ! year [YYYY]
3587 INTEGER, INTENT(in) :: id ! day of the year [DOY]
3588 INTEGER, INTENT(in) :: it ! hour [H]
3589 INTEGER, INTENT(in) :: imin ! minutes [M]
3590
3591 INTEGER, INTENT(in) :: nlayer ! number of vertical levels in urban canopy [-]
3592 REAL(KIND(1D0)), INTENT(in) :: dectime !decimal time [-]
3593
3594 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: tsfc_out_surf !surface temperature [degC]
3595 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: qs_surf !heat storage flux of each surface type [W m-2]
3596 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tsfc_out_roof !roof surface temperature [degC]
3597 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: Qn_roof !net all-wave radiation of the roof [W m-2]
3598 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: QS_roof !heat storage flux of the roof [W m-2]
3599 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: QE_roof !latent heat flux of the roof [W m-2]
3600 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: QH_roof !sensible heat flux of the roof [W m-2]
3601 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: state_roof !wetness state of the roof [mm]
3602 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: soilstore_roof !soil moisture of roof [mm]
3603 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tsfc_out_wall !wall surface temperature [degC]
3604 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: Qn_wall !net all-wave radiation of the wall [W m-2]
3605 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: QS_wall !heat storage flux of the wall [W m-2]
3606 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: QE_wall !latent heat flux of the wall [W m-2]
3607 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: QH_wall !sensible heat flux of the wall [W m-2]
3608 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: state_wall !wetness state of the wall [mm]
3609 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: soilstore_wall !soil moisture of wall [mm]
3610
3611 REAL(KIND(1D0)), DIMENSION(5), INTENT(OUT) :: datetimeLine !date & time
3612 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutESTMExt - 5), INTENT(out) :: dataOutLineESTMExt
3613 ! REAL(KIND(1d0)),DIMENSION(ncolumnsDataOutSnow-5),INTENT(out) :: dataOutLineSnow
3614 ! REAL(KIND(1d0)),DIMENSION(ncolumnsDataOutESTM-5),INTENT(out) :: dataOutLineESTM
3615 ! INTEGER:: is
3616 REAL(KIND(1D0)) :: LAI_wt !area weighted LAI [m2 m-2]
3617 REAL(KIND(1D0)) :: RH2_pct ! RH2 in percentage [-]
3618
3619 ! the variables below with '_x' endings stand for 'exported' values
3620 REAL(KIND(1D0)) :: ResistSurf_x !output surface resistance [s m-1]
3621 REAL(KIND(1D0)) :: surf_chang_per_tstep_x !output change in state_id (exluding snowpack) per timestep [mm]
3622 REAL(KIND(1D0)) :: l_mod_x !output Obukhov length [m]
3623 REAL(KIND(1D0)) :: bulkalbedo !output area-weighted albedo [-]
3624 REAL(KIND(1D0)) :: smd_nsurf_x(nsurf) !output soil moisture deficit for each surface [mm]
3625 REAL(KIND(1D0)) :: state_x(nsurf) !output wetness status of each surfaces[mm]
3626 REAL(KIND(1D0)) :: wu_DecTr !water use for deciduous tree and shrubs [mm]
3627 REAL(KIND(1D0)) :: wu_EveTr !water use of evergreen tree and shrubs [mm]
3628 REAL(KIND(1D0)) :: wu_Grass !water use for grass [mm]
3629
3630 ! date & time:
3631 datetimeline = [ &
3632 REAL(iy, KIND(1D0)), REAL(id, KIND(1D0)), &
3633 REAL(it, KIND(1D0)), REAL(imin, KIND(1D0)), dectime]
3634 !Define the overall output matrix to be printed out step by step
3635 dataoutlineestmext = [ &
3636 tsfc_out_surf, qs_surf, & !output
3637 fill_result(tsfc_out_roof, n_fill), &
3638 fill_result(qn_roof, n_fill), &
3639 fill_result(qs_roof, n_fill), &
3640 fill_result(qe_roof, n_fill), &
3641 fill_result(qh_roof, n_fill), &
3642 fill_result(state_roof, n_fill), &
3643 fill_result(soilstore_roof, n_fill), &
3644 fill_result(tsfc_out_wall, n_fill), &
3645 fill_result(qn_wall, n_fill), &
3646 fill_result(qs_wall, n_fill), &
3647 fill_result(qe_wall, n_fill), &
3648 fill_result(qh_wall, n_fill), &
3649 fill_result(state_wall, n_fill), &
3650 fill_result(soilstore_wall, n_fill) &
3651 ]
3652 ! set invalid values to NAN
3653 ! dataOutLineSUEWS = set_nan(dataOutLineSUEWS)
3654
3655 !====================update output line end==============================
3656
3657 END SUBROUTINE estmext_update_outputline
3658 !========================================================================
3659
3660 FUNCTION fill_result(res_valid, n_fill) RESULT(res_filled)
3661 IMPLICIT NONE
3662 REAL(kind(1d0)), DIMENSION(:), INTENT(IN) :: res_valid
3663 INTEGER, INTENT(IN) :: n_fill
3664 REAL(kind(1d0)), DIMENSION(n_fill) :: res_filled
3665
3666 REAL(kind(1d0)), PARAMETER :: nan = -999
3667
3668 res_filled = reshape(res_valid, [n_fill], pad=[nan])
3669 END FUNCTION fill_result
3670
3671 !==============Update output arrays=========================
3673 SnowUse, storageheatmethod, & !input
3674 ReadLinesMetdata, NumberOfGrids, &
3675 ir, gridiv, &
3676 datetimeLine, dataOutLineSUEWS, dataOutLineSnow, dataOutLineESTM, dataoutLineRSL, dataOutLineBEERS, &
3677 dataoutlineDebug, dataoutlineSPARTACUS, dataOutLineESTMExt, & !input
3678 dataOutSUEWS, dataOutSnow, dataOutESTM, dataOutRSL, dataOutBEERS, dataOutDebug, dataOutSPARTACUS, &
3679 dataOutESTMExt) !inout
3680 IMPLICIT NONE
3681
3682 INTEGER, INTENT(in) :: ReadLinesMetdata
3683 INTEGER, INTENT(in) :: NumberOfGrids
3684 INTEGER, INTENT(in) :: Gridiv
3685 INTEGER, INTENT(in) :: SnowUse
3686 INTEGER, INTENT(in) :: storageheatmethod
3687 INTEGER, INTENT(in) :: ir
3688
3689 REAL(KIND(1D0)), DIMENSION(5), INTENT(in) :: datetimeLine
3690 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutSUEWS - 5), INTENT(in) :: dataOutLineSUEWS
3691 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutESTM - 5), INTENT(in) :: dataOutLineESTM
3692 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutESTMExt - 5), INTENT(in) :: dataOutLineESTMExt
3693 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutSnow - 5), INTENT(in) :: dataOutLineSnow
3694 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutRSL - 5), INTENT(in) :: dataoutLineRSL
3695 REAL(KIND(1D0)), DIMENSION(ncolumnsdataOutBEERS - 5), INTENT(in) :: dataOutLineBEERS
3696 REAL(KIND(1D0)), DIMENSION(ncolumnsdataOutDebug - 5), INTENT(in) :: dataOutLineDebug
3697 REAL(KIND(1D0)), DIMENSION(ncolumnsdataOutSPARTACUS - 5), INTENT(in) :: dataOutLineSPARTACUS
3698
3699 REAL(KIND(1D0)), INTENT(inout) :: dataOutSUEWS(ReadLinesMetdata, ncolumnsDataOutSUEWS, NumberOfGrids)
3700 REAL(KIND(1D0)), INTENT(inout) :: dataOutSnow(ReadLinesMetdata, ncolumnsDataOutSnow, NumberOfGrids)
3701 REAL(KIND(1D0)), INTENT(inout) :: dataOutESTM(ReadLinesMetdata, ncolumnsDataOutESTM, NumberOfGrids)
3702 REAL(KIND(1D0)), INTENT(inout) :: dataOutESTMExt(ReadLinesMetdata, ncolumnsDataOutESTMExt, NumberOfGrids)
3703 REAL(KIND(1D0)), INTENT(inout) :: dataOutRSL(ReadLinesMetdata, ncolumnsDataOutRSL, NumberOfGrids)
3704 REAL(KIND(1D0)), INTENT(inout) :: dataOutBEERS(ReadLinesMetdata, ncolumnsdataOutBEERS, NumberOfGrids)
3705 REAL(KIND(1D0)), INTENT(inout) :: dataOutDebug(ReadLinesMetdata, ncolumnsDataOutDebug, NumberOfGrids)
3706 REAL(KIND(1D0)), INTENT(inout) :: dataOutSPARTACUS(ReadLinesMetdata, ncolumnsDataOutSPARTACUS, NumberOfGrids)
3707
3708 !====================== update output arrays ==============================
3709 !Define the overall output matrix to be printed out step by step
3710 dataoutsuews(ir, 1:ncolumnsdataoutsuews, gridiv) = [datetimeline, (dataoutlinesuews)]
3711 ! dataOutSUEWS(ir, 1:ncolumnsDataOutSUEWS, Gridiv) = [datetimeLine, set_nan(dataOutLineSUEWS)]
3712 dataoutrsl(ir, 1:ncolumnsdataoutrsl, gridiv) = [datetimeline, (dataoutlinersl)]
3713 dataoutdebug(ir, 1:ncolumnsdataoutdebug, gridiv) = [datetimeline, (dataoutlinedebug)]
3714 dataoutspartacus(ir, 1:ncolumnsdataoutspartacus, gridiv) = [datetimeline, (dataoutlinespartacus)]
3715 ! dataOutRSL(ir, 1:ncolumnsDataOutRSL, Gridiv) = [datetimeLine, set_nan(dataoutLineRSL)]
3716 dataoutbeers(ir, 1:ncolumnsdataoutbeers, gridiv) = [datetimeline, set_nan(dataoutlinebeers)]
3717 ! ! set invalid values to NAN
3718 ! dataOutSUEWS(ir,6:ncolumnsDataOutSUEWS,Gridiv)=set_nan(dataOutSUEWS(ir,6:ncolumnsDataOutSUEWS,Gridiv))
3719
3720 IF (snowuse == 1) THEN
3721 dataoutsnow(ir, 1:ncolumnsdataoutsnow, gridiv) = [datetimeline, set_nan(dataoutlinesnow)]
3722 END IF
3723
3724 IF (storageheatmethod == 4) THEN
3725 dataoutestm(ir, 1:ncolumnsdataoutestm, gridiv) = [datetimeline, set_nan(dataoutlineestm)]
3726 END IF
3727
3728 IF (storageheatmethod == 5) THEN
3729 dataoutestmext(ir, 1:ncolumnsdataoutestmext, gridiv) = [datetimeline, set_nan(dataoutlineestmext)]
3730 END IF
3731
3732 !====================update output arrays end==============================
3733
3734 END SUBROUTINE suews_update_output
3735
3736 ! !========================================================================
3737 ! SUBROUTINE SUEWS_cal_Diagnostics( &
3738 ! dectime, &!input
3739 ! avU1, Temp_C, avRH, Press_hPa, &
3740 ! qh, qe, &
3741 ! VegFraction, zMeas, z0m, zdm, RA, avdens, avcp, lv_J_kg, tstep_real, &
3742 ! RoughLenHeatMethod, StabilityMethod, &
3743 ! avU10_ms, t2_C, q2_gkg, tskin_C, RH2)!output
3744 ! ! TS 03 Aug 2018: added limit on q2 by restricting RH2_max to 100%
3745 ! ! TS 31 Jul 2018: removed dependence on surface variables (Tsurf, qsat)
3746 ! ! TS 26 Jul 2018: improved the calculation logic
3747 ! ! TS 05 Sep 2017: improved interface
3748 ! ! TS 20 May 2017: calculate surface-level diagonostics
3749 ! IMPLICIT NONE
3750 ! REAL(KIND(1d0)), INTENT(in) ::dectime
3751 ! REAL(KIND(1d0)), INTENT(in) ::avU1, Temp_C, avRH
3752 ! REAL(KIND(1d0)), INTENT(in) ::qh
3753 ! REAL(KIND(1d0)), INTENT(in) ::Press_hPa, qe
3754 ! REAL(KIND(1d0)), INTENT(in) :: VegFraction, z0m, RA, avdens, avcp, lv_J_kg, tstep_real
3755 ! REAL(KIND(1d0)), INTENT(in) :: zMeas! height for measurement
3756 ! REAL(KIND(1d0)), INTENT(in) :: zdm ! displacement height
3757
3758 ! ! INTEGER,INTENT(in) :: opt ! 0 for momentum, 1 for temperature, 2 for humidity
3759 ! INTEGER, INTENT(in) :: RoughLenHeatMethod, StabilityMethod
3760
3761 ! REAL(KIND(1d0)), INTENT(out):: avU10_ms, t2_C, q2_gkg, tskin_C, RH2
3762 ! REAL(KIND(1d0))::qa_gkg
3763 ! REAL(KIND(1d0)), PARAMETER::k = 0.4
3764
3765 ! ! wind speed:
3766 ! CALL diagSfc( &
3767 ! 0, &
3768 ! zMeas, avU1, 0d0, 10d0, avU10_ms, &
3769 ! VegFraction, &
3770 ! z0m, zdm, avdens, avcp, lv_J_kg, &
3771 ! avU1, Temp_C, qh, &
3772 ! RoughLenHeatMethod, StabilityMethod, tstep_real, dectime)
3773
3774 ! ! temperature at 2 m agl:
3775 ! CALL diagSfc( &
3776 ! 1, &
3777 ! zMeas, Temp_C, qh, 2d0, t2_C, &
3778 ! VegFraction, &
3779 ! z0m, zdm, avdens, avcp, lv_J_kg, &
3780 ! avU1, Temp_C, qh, &
3781 ! RoughLenHeatMethod, StabilityMethod, tstep_real, dectime)
3782
3783 ! ! skin temperature:
3784 ! tskin_C = qh/(avdens*avcp)*RA + temp_C
3785
3786 ! ! humidity:
3787 ! qa_gkg = RH2qa(avRH/100, Press_hPa, Temp_c)
3788 ! CALL diagSfc( &
3789 ! 2, &
3790 ! zMeas, qa_gkg, qe, 2d0, q2_gkg, &
3791 ! VegFraction, &
3792 ! z0m, zdm, avdens, avcp, lv_J_kg, &
3793 ! avU1, Temp_C, qh, &
3794 ! RoughLenHeatMethod, StabilityMethod, tstep_real, dectime)
3795 ! ! re-examine if the diagnostic RH2 > 100% ?
3796 ! RH2 = qa2RH(q2_gkg, Press_hPa, Temp_c)
3797 ! IF (RH2 > 1) THEN
3798 ! ! if so, limit RH2 to 100%
3799 ! RH2 = 1d0
3800 ! ! and adjust the diagnostic q2_gkg
3801 ! q2_gkg = RH2qa(RH2, Press_hPa, Temp_c)
3802 ! END IF
3803
3804 ! END SUBROUTINE SUEWS_cal_Diagnostics
3805
3806 ! calculate several surface fraction related parameters
3807 SUBROUTINE suews_cal_surf( &
3808 StorageHeatMethod, NetRadiationMethod, & !input
3809 nlayer, sfr_surf, & !input
3810 building_frac, building_scale, height, & !input
3811 vegfraction, ImpervFraction, PervFraction, NonWaterFraction, & ! output
3812 sfr_roof, sfr_wall) ! output
3813 IMPLICIT NONE
3814
3815 INTEGER, INTENT(IN) :: StorageHeatMethod ! method for storage heat calculations [-]
3816 INTEGER, INTENT(IN) :: NetRadiationMethod ! method for net radiation calculations [-]
3817 INTEGER, INTENT(IN) :: nlayer !number of vertical layers[-]
3818 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: sfr_surf !surface fraction [-]
3819 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: building_frac !cumulative surface fraction of buildings across vertical layers [-]
3820 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: building_scale !building scales of each vertical layer [m]
3821 REAL(KIND(1D0)), DIMENSION(nlayer + 1), INTENT(IN) :: height !building height of each layer[-]
3822 REAL(KIND(1D0)), INTENT(OUT) :: VegFraction ! fraction of vegetation [-]
3823 REAL(KIND(1D0)), INTENT(OUT) :: ImpervFraction !fractioin of impervious surface [-]
3824 REAL(KIND(1D0)), INTENT(OUT) :: PervFraction !fraction of pervious surfaces [-]
3825 REAL(KIND(1D0)), INTENT(OUT) :: NonWaterFraction !fraction of non-water [-]
3826 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(OUT) :: sfr_roof !fraction of roof facets [-]
3827 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(OUT) :: sfr_wall !fraction of wall facets [-]
3828
3829 ! REAL(KIND(1D0)), DIMENSION(nlayer) :: sfr_roof ! individual building fraction at each layer
3830 REAL(KIND(1D0)), DIMENSION(nlayer) :: dz_ind ! individual net building height at each layer
3831 ! REAL(KIND(1D0)), DIMENSION(nlayer) :: sfr_wall ! individual net building height at each layer
3832 REAL(KIND(1D0)), DIMENSION(nlayer) :: perimeter_ind ! individual building perimeter at each layer
3833
3834 vegfraction = sfr_surf(conifsurf) + sfr_surf(decidsurf) + sfr_surf(grasssurf)
3835 impervfraction = sfr_surf(pavsurf) + sfr_surf(bldgsurf)
3836 pervfraction = 1 - impervfraction
3837 nonwaterfraction = 1 - sfr_surf(watersurf)
3838
3839 IF (storageheatmethod == 5 .OR. netradiationmethod > 1000) THEN
3840 ! get individual building fractions of each layer
3841 ! NB.: sum(sfr_roof) = building_frac(1)
3842 sfr_roof = 0.
3843 IF (nlayer > 1) sfr_roof(1:nlayer - 1) = building_frac(1:nlayer - 1) - building_frac(2:nlayer)
3844 sfr_roof(nlayer) = building_frac(nlayer)
3845
3846 ! get individual net building height of each layer
3847 dz_ind = 0.
3848 dz_ind(1:nlayer) = height(2:nlayer + 1) - height(1:nlayer)
3849
3850 ! get individual building perimeter of each layer
3851 ! this is from eq. 8 in SS documentation:
3852 ! https://github.com/ecmwf/spartacus-surface/blob/master/doc/spartacus_surface_documentation.pdf
3853 perimeter_ind = 0.
3854 perimeter_ind(1:nlayer) = 4.*building_frac(1:nlayer)/building_scale(1:nlayer)
3855
3856 ! sfr_wall stands for individual wall area
3857 ! get individual wall area at each layer
3858 sfr_wall = 0.
3859 ! this is from eq. 1 in SS documentation:
3860 ! https://github.com/ecmwf/spartacus-surface/blob/master/doc/spartacus_surface_documentation.pdf
3861 sfr_wall(1:nlayer) = perimeter_ind(1:nlayer)*dz_ind(1:nlayer)
3862 END IF
3863
3864 END SUBROUTINE suews_cal_surf
3865
3866 ! SUBROUTINE diagSfc( &
3867 ! opt, &
3868 ! zMeas, xMeas, xFlux, zDiag, xDiag, &
3869 ! VegFraction, &
3870 ! z0m, zd, avdens, avcp, lv_J_kg, &
3871 ! avU1, Temp_C, qh, &
3872 ! RoughLenHeatMethod, StabilityMethod, tstep_real, dectime)
3873 ! ! TS 31 Jul 2018: removed dependence on surface variables (Tsurf, qsat)
3874 ! ! TS 26 Jul 2018: improved the calculation logic
3875 ! ! TS 05 Sep 2017: improved interface
3876 ! ! TS 20 May 2017: calculate surface-level diagonostics
3877
3878 ! IMPLICIT NONE
3879 ! REAL(KIND(1d0)), INTENT(in) :: dectime
3880 ! REAL(KIND(1d0)), INTENT(in) :: qh ! sensible heat flux
3881 ! REAL(KIND(1d0)), INTENT(in) :: z0m, avdens, avcp, lv_J_kg, tstep_real
3882 ! REAL(KIND(1d0)), INTENT(in) :: avU1, Temp_C ! atmospheric level variables
3883 ! REAL(KIND(1d0)), INTENT(in) :: zDiag ! height for diagonostics
3884 ! REAL(KIND(1d0)), INTENT(in) :: zMeas! height for measurement
3885 ! REAL(KIND(1d0)), INTENT(in) :: zd ! displacement height
3886 ! REAL(KIND(1d0)), INTENT(in) :: xMeas ! measurement at height
3887 ! REAL(KIND(1d0)), INTENT(in) :: xFlux!
3888 ! REAL(KIND(1d0)), INTENT(in) :: VegFraction ! vegetation fraction
3889
3890 ! INTEGER, INTENT(in) :: opt ! 0 for momentum, 1 for temperature, 2 for humidity
3891 ! INTEGER, INTENT(in) :: RoughLenHeatMethod, StabilityMethod
3892
3893 ! REAL(KIND(1d0)), INTENT(out):: xDiag
3894
3895 ! REAL(KIND(1d0)) :: L_mod
3896 ! REAL(KIND(1d0)) :: psimz0, psihzDiag, psihzMeas, psihz0, psimzDiag ! stability correction functions
3897 ! REAL(KIND(1d0)) :: z0h ! Roughness length for heat
3898 ! REAL(KIND(1d0)) :: zDiagzd! height for diagnositcs
3899 ! REAL(KIND(1d0)) :: zMeaszd
3900 ! REAL(KIND(1d0)) :: tlv, H_kms, TStar, zL, UStar
3901 ! REAL(KIND(1d0)), PARAMETER :: muu = 1.46e-5 !molecular viscosity
3902 ! REAL(KIND(1d0)), PARAMETER :: nan = -999
3903 ! REAL(KIND(1d0)), PARAMETER :: zdm = 0 ! assuming Displacement height is ZERO
3904 ! REAL(KIND(1d0)), PARAMETER::k = 0.4
3905
3906 ! tlv = lv_J_kg/tstep_real !Latent heat of vapourisation per timestep
3907 ! zDiagzd = zDiag + z0m ! height at hgtX assuming Displacement height is ZERO; set lower limit as z0 to prevent arithmetic error, zd=0
3908
3909 ! ! get !Kinematic sensible heat flux [K m s-1] used to calculate friction velocity
3910 ! CALL SUEWS_init_QH( &
3911 ! avdens, avcp, qh, 0d0, dectime, & ! use qh as qh_obs to initialise H_init
3912 ! H_kms)!output
3913
3914 ! ! redo the calculation for stability correction
3915 ! CALL cal_Stab( &
3916 ! ! input
3917 ! StabilityMethod, &
3918 ! dectime, & !Decimal time
3919 ! zDiagzd, & !Active measurement height (meas. height-displac. height)
3920 ! z0m, & !Aerodynamic roughness length
3921 ! zdm, & !Displacement height
3922 ! avU1, & !Average wind speed
3923 ! Temp_C, & !Air temperature
3924 ! H_kms, & !Kinematic sensible heat flux [K m s-1] used to calculate friction velocity
3925 ! ! output:
3926 ! L_MOD, & !Obukhov length
3927 ! TStar, & !T*
3928 ! UStar, & !Friction velocity
3929 ! zL)!Stability scale
3930
3931 ! !***************************************************************
3932 ! ! log-law based stability corrections:
3933 ! ! Roughness length for heat
3934 ! z0h = cal_z0V(RoughLenHeatMethod, z0m, VegFraction, UStar)
3935
3936 ! ! stability correction functions
3937 ! ! momentum:
3938 ! psimzDiag = stab_psi_mom(StabilityMethod, zDiagzd/L_mod)
3939 ! ! psimz2=stab_fn_mom(StabilityMethod,z2zd/L_mod,z2zd/L_mod)
3940 ! psimz0 = stab_psi_mom(StabilityMethod, z0m/L_mod)
3941
3942 ! ! heat and vapor: assuming both are the same
3943 ! ! psihz2=stab_fn_heat(StabilityMethod,z2zd/L_mod,z2zd/L_mod)
3944 ! psihz0 = stab_psi_heat(StabilityMethod, z0h/L_mod)
3945
3946 ! !***************************************************************
3947 ! SELECT CASE (opt)
3948 ! CASE (0) ! wind (momentum) at hgtX=10 m
3949 ! zDiagzd = zDiag + z0m! set lower limit as z0h to prevent arithmetic error, zd=0
3950
3951 ! ! stability correction functions
3952 ! ! momentum:
3953 ! psimzDiag = stab_psi_mom(StabilityMethod, zDiagzd/L_mod)
3954 ! psimz0 = stab_psi_mom(StabilityMethod, z0m/L_mod)
3955 ! xDiag = UStar/k*(LOG(zDiagzd/z0m) - psimzDiag + psimz0) ! Brutsaert (2005), p51, eq.2.54
3956
3957 ! CASE (1) ! temperature at hgtX=2 m
3958 ! zMeaszd = zMeas - zd
3959 ! zDiagzd = zDiag + z0h! set lower limit as z0h to prevent arithmetic error, zd=0
3960
3961 ! ! heat and vapor: assuming both are the same
3962 ! psihzMeas = stab_psi_heat(StabilityMethod, zMeaszd/L_mod)
3963 ! psihzDiag = stab_psi_heat(StabilityMethod, zDiagzd/L_mod)
3964 ! ! psihz0=stab_fn_heat(StabilityMethod,z0h/L_mod,z0h/L_mod)
3965 ! xDiag = xMeas + xFlux/(k*UStar*avdens*avcp)*(LOG(zMeaszd/zDiagzd) - (psihzMeas - psihzDiag)) ! Brutsaert (2005), p51, eq.2.55
3966 ! ! IF ( ABS((LOG(z2zd/z0h)-psihz2+psihz0))>10 ) THEN
3967 ! ! PRINT*, '#####################################'
3968 ! ! PRINT*, 'xSurf',xSurf
3969 ! ! PRINT*, 'xFlux',xFlux
3970 ! ! PRINT*, 'k*us*avdens*avcp',k*us*avdens*avcp
3971 ! ! PRINT*, 'k',k
3972 ! ! PRINT*, 'us',us
3973 ! ! PRINT*, 'avdens',avdens
3974 ! ! PRINT*, 'avcp',avcp
3975 ! ! PRINT*, 'xFlux/X',xFlux/(k*us*avdens*avcp)
3976 ! ! PRINT*, 'stab',(LOG(z2zd/z0h)-psihz2+psihz0)
3977 ! ! PRINT*, 'LOG(z2zd/z0h)',LOG(z2zd/z0h)
3978 ! ! PRINT*, 'z2zd',z2zd,'L_mod',L_mod,'z0h',z0h
3979 ! ! PRINT*, 'z2zd/L_mod',z2zd/L_mod
3980 ! ! PRINT*, 'psihz2',psihz2
3981 ! ! PRINT*, 'psihz0',psihz0
3982 ! ! PRINT*, 'psihz2-psihz0',psihz2-psihz0
3983 ! ! PRINT*, 'xDiag',xDiag
3984 ! ! PRINT*, '*************************************'
3985 ! ! END IF
3986
3987 ! CASE (2) ! humidity at hgtX=2 m
3988 ! zMeaszd = zMeas - zd
3989 ! zDiagzd = zDiag + z0h! set lower limit as z0h to prevent arithmetic error, zd=0
3990
3991 ! ! heat and vapor: assuming both are the same
3992 ! psihzMeas = stab_psi_heat(StabilityMethod, zMeaszd/L_mod)
3993 ! psihzDiag = stab_psi_heat(StabilityMethod, zDiagzd/L_mod)
3994 ! ! psihz0=stab_fn_heat(StabilityMethod,z0h/L_mod,z0h/L_mod)
3995
3996 ! xDiag = xMeas + xFlux/(k*UStar*avdens*tlv)*(LOG(zMeaszd/zDiagzd) - (psihzMeas - psihzDiag)) ! Brutsaert (2005), p51, eq.2.56
3997
3998 ! END SELECT
3999
4000 ! END SUBROUTINE diagSfc
4001
4002 !===============set variable of invalid value to NAN=====================
4003 ELEMENTAL FUNCTION set_nan(x) RESULT(xx)
4004 IMPLICIT NONE
4005 REAL(kind(1d0)), PARAMETER :: pnan = 30000 ! 30000 to prevent water_state being filtered out as it can be large
4006 REAL(kind(1d0)), PARAMETER :: pzero = 1e-8 ! to prevent inconsistency caused by positive or negative zero
4007 REAL(kind(1d0)), PARAMETER :: nan = -999
4008 REAL(kind(1d0)), INTENT(in) :: x
4009 REAL(kind(1d0)) :: xx
4010
4011 IF (abs(x) > pnan) THEN
4012 xx = nan
4013 ELSEIF (abs(x) < pzero) THEN
4014 xx = 0
4015 ELSE
4016 xx = x
4017 END IF
4018
4019 END FUNCTION set_nan
4020 !========================================================================
4021
4022 !===============the functions below are only for test in f2py conversion===
4023 FUNCTION square(x) RESULT(xx)
4024 IMPLICIT NONE
4025 REAL(kind(1d0)), PARAMETER :: pnan = 9999
4026 REAL(kind(1d0)), PARAMETER :: nan = -999
4027 REAL(kind(1d0)), INTENT(in) :: x
4028 REAL(kind(1d0)) :: xx
4029
4030 xx = x**2 + nan/pnan
4031 xx = x**2
4032
4033 END FUNCTION square
4034
4035 FUNCTION square_real(x) RESULT(xx)
4036 IMPLICIT NONE
4037 REAL, PARAMETER :: pnan = 9999
4038 REAL, PARAMETER :: nan = -999
4039 REAL, INTENT(in) :: x
4040 REAL :: xx
4041
4042 xx = x**2 + nan/pnan
4043 xx = x**2
4044
4045 END FUNCTION square_real
4046
4047 SUBROUTINE output_name_n(i, name, group, aggreg, outlevel)
4048 ! used by f2py module to handle output names
4049 IMPLICIT NONE
4050 ! the dimension is potentially incorrect,
4051 ! which should be consistent with that in output module
4052 INTEGER, INTENT(in) :: i
4053 CHARACTER(len=15), INTENT(out) :: name, group, aggreg
4054 INTEGER, INTENT(out) :: outlevel
4055
4056 INTEGER :: nVar
4057 nvar = SIZE(varlistall, dim=1)
4058 IF (i < nvar .AND. i > 0) THEN
4059 name = trim(varlistall(i)%header)
4060 group = trim(varlistall(i)%group)
4061 aggreg = trim(varlistall(i)%aggreg)
4062 outlevel = varlistall(i)%level
4063 ELSE
4064 name = ''
4065 group = ''
4066 aggreg = ''
4067 outlevel = 0
4068 END IF
4069
4070 END SUBROUTINE output_name_n
4071
4072 SUBROUTINE output_size(nVar)
4073 ! used by f2py module to get size of the output list
4074 IMPLICIT NONE
4075 ! the dimension is potentially incorrect,
4076 ! which should be consistent with that in output module
4077 INTEGER, INTENT(out) :: nVar
4078
4079 nvar = SIZE(varlistall, dim=1)
4080
4081 END SUBROUTINE output_size
4082
4084 MetForcingBlock, len_sim, &
4085 AerodynamicResistanceMethod, AH_MIN, AHProf_24hr, AH_SLOPE_Cooling, & ! input&inout in alphabetical order
4086 AH_SLOPE_Heating, &
4087 alb, AlbMax_DecTr, AlbMax_EveTr, AlbMax_Grass, &
4088 AlbMin_DecTr, AlbMin_EveTr, AlbMin_Grass, &
4089 alpha_bioCO2, alpha_enh_bioCO2, alt, BaseT, BaseTe, &
4090 BaseTMethod, &
4091 BaseT_HC, beta_bioCO2, beta_enh_bioCO2, bldgH, CapMax_dec, CapMin_dec, &
4092 chAnOHM, CO2PointSource, cpAnOHM, CRWmax, CRWmin, DayWat, DayWatPer, &
4093 DecTreeH, DiagMethod, Diagnose, DiagQN, DiagQS, DRAINRT, &
4094 dt_since_start, dqndt, qn_av, dqnsdt, qn_s_av, &
4095 EF_umolCO2perJ, emis, EmissionsMethod, EnEF_v_Jkm, endDLS, EveTreeH, FAIBldg, &
4096 FAIDecTree, FAIEveTree, Faut, FcEF_v_kgkm, FlowChange, &
4097 FrFossilFuel_Heat, FrFossilFuel_NonHeat, G1, G2, G3, G4, G5, G6, GDD_id, &
4098 GDDFull, Gridiv, gsModel, H_maintain, HDD_id, HumActivity_24hr, &
4099 IceFrac, Ie_a, Ie_end, Ie_m, Ie_start, &
4100 InternalWaterUse_h, &
4101 IrrFracPaved, IrrFracBldgs, &
4102 IrrFracEveTr, IrrFracDecTr, IrrFracGrass, &
4103 IrrFracBSoil, IrrFracWater, &
4104 EvapMethod, &
4105 kkAnOHM, Kmax, LAI_id, LAICalcYes, LAIMax, LAIMin, &
4106 LAIPower, LAIType, lat, lng, MaxConductance, MaxFCMetab, MaxQFMetab, &
4107 SnowWater, MinFCMetab, MinQFMetab, min_res_bioCO2, &
4108 NARP_EMIS_SNOW, NARP_TRANS_SITE, NetRadiationMethod, &
4109 OHM_coef, OHMIncQF, OHM_threshSW, &
4110 OHM_threshWD, PipeCapacity, PopDensDaytime, &
4111 PopDensNighttime, PopProf_24hr, PorMax_dec, PorMin_dec, &
4112 PrecipLimit, PrecipLimitAlb, &
4113 QF0_BEU, Qf_A, Qf_B, Qf_C, &
4114 nlayer, &
4115 n_vegetation_region_urban, &
4116 n_stream_sw_urban, n_stream_lw_urban, &
4117 sw_dn_direct_frac, air_ext_sw, air_ssa_sw, &
4118 veg_ssa_sw, air_ext_lw, air_ssa_lw, veg_ssa_lw, &
4119 veg_fsd_const, veg_contact_fraction_const, &
4120 ground_albedo_dir_mult_fact, use_sw_direct_albedo, & !input
4121 height, building_frac, veg_frac, building_scale, veg_scale, & !input: SPARTACUS
4122 alb_roof, emis_roof, alb_wall, emis_wall, &
4123 roof_albedo_dir_mult_fact, wall_specular_frac, &
4124 RadMeltFact, RAINCOVER, RainMaxRes, resp_a, resp_b, &
4125 RoughLenHeatMethod, RoughLenMomMethod, RunoffToWater, S1, S2, &
4126 SatHydraulicConduct, SDDFull, SDD_id, SMDMethod, SnowAlb, SnowAlbMax, &
4127 SnowAlbMin, SnowPackLimit, SnowDens, SnowDensMax, SnowDensMin, SnowfallCum, SnowFrac, &
4128 SnowLimBldg, SnowLimPaved, SnowPack, SnowProf_24hr, SnowUse, SoilDepth, &
4129 StabilityMethod, startDLS, &
4130 soilstore_surf, SoilStoreCap_surf, state_surf, StateLimit_surf, WetThresh_surf, &
4131 soilstore_roof, SoilStoreCap_roof, state_roof, StateLimit_roof, WetThresh_roof, &
4132 soilstore_wall, SoilStoreCap_wall, state_wall, StateLimit_wall, WetThresh_wall, &
4133 StorageHeatMethod, StoreDrainPrm, SurfaceArea, Tair_av, tau_a, tau_f, tau_r, &
4134 BaseT_Cooling, BaseT_Heating, TempMeltFact, TH, &
4135 theta_bioCO2, timezone, TL, TrafficRate, TrafficUnits, &
4136 sfr_surf, &
4137 tsfc_roof, tsfc_wall, tsfc_surf, &
4138 temp_roof, temp_wall, temp_surf, &
4139 tin_roof, tin_wall, tin_surf, &
4140 k_wall, k_roof, k_surf, &
4141 cp_wall, cp_roof, cp_surf, &
4142 dz_wall, dz_roof, dz_surf, &
4143 Tmin_id, Tmax_id, lenday_id, &
4144 TraffProf_24hr, Ts5mindata_ir, tstep, tstep_prev, veg_type, &
4145 WaterDist, WaterUseMethod, &
4146 WUDay_id, DecidCap_id, albDecTr_id, albEveTr_id, albGrass_id, porosity_id, &
4147 WUProfA_24hr, WUProfM_24hr, Z, z0m_in, zdm_in, &
4148 dataOutBlockSUEWS, dataOutBlockSnow, dataOutBlockESTM, dataOutBlockRSL, dataOutBlockBEERS, & !output
4149 dataOutBlockDebug, dataOutBlockSPARTACUS, dataOutBlockESTMExt, &
4150 DailyStateBlock)
4151
4152 IMPLICIT NONE
4153 ! input:
4154 ! met forcing block
4155 REAL(KIND(1D0)), DIMENSION(len_sim, 24), INTENT(IN) :: MetForcingBlock
4156 INTEGER, INTENT(IN) :: len_sim
4157 ! input variables
4158 INTEGER, INTENT(IN) :: nlayer ! number of vertical layers in urban canyon
4159 INTEGER, INTENT(IN) :: AerodynamicResistanceMethod !method to calculate RA [-]
4160 INTEGER, INTENT(IN) :: BaseTMethod ! base t method [-]
4161 INTEGER, INTENT(IN) :: Diagnose
4162 INTEGER, INTENT(IN) :: DiagQN
4163 INTEGER, INTENT(IN) :: DiagQS
4164 INTEGER, INTENT(IN) :: startDLS !start of daylight saving [DOY]
4165 INTEGER, INTENT(IN) :: endDLS !end of daylight saving [DOY]
4166 INTEGER, INTENT(IN) :: EmissionsMethod !method to calculate anthropogenic heat [-]
4167 INTEGER, INTENT(IN) :: Gridiv ! grid id [-]
4168 INTEGER, INTENT(IN) :: gsModel !choice of gs parameterisation (1 = Ja11, 2 = Wa16)
4169 INTEGER, INTENT(IN) :: Ie_end !ending time of water use [DOY]
4170 INTEGER, INTENT(IN) :: Ie_start !starting time of water use [DOY]
4171 INTEGER, INTENT(IN) :: EvapMethod !Evaporation calculated according to Rutter (1) or Shuttleworth (2) [-]
4172 INTEGER, INTENT(IN) :: LAICalcYes !boolean to determine if calculate LAI [-]
4173 INTEGER, INTENT(in) :: DiagMethod !Defines how near surface diagnostics are calculated [-]
4174 INTEGER, INTENT(IN) :: NetRadiationMethod ! method for calculation of radiation fluxes [-]
4175 INTEGER, INTENT(IN) :: OHMIncQF !Determines whether the storage heat flux calculation uses Q* or ( Q* +QF) [-]
4176 INTEGER, INTENT(IN) :: RoughLenHeatMethod !method to calculate heat roughness length [-]
4177 INTEGER, INTENT(IN) :: RoughLenMomMethod !Determines how aerodynamic roughness length (z0m) and zero displacement height (zdm) are calculated [-]
4178 INTEGER, INTENT(IN) :: SMDMethod !Determines method for calculating soil moisture deficit [-]
4179 INTEGER, INTENT(IN) :: SnowUse !Determines whether the snow part of the model runs[-]
4180 INTEGER, INTENT(IN) :: StabilityMethod !method to calculate atmospheric stability [-]
4181 INTEGER, INTENT(IN) :: StorageHeatMethod !Determines method for calculating storage heat flux ΔQS [-]
4182 INTEGER, INTENT(IN) :: tstep !timestep [s]
4183 INTEGER, INTENT(IN) :: tstep_prev ! tstep size of the previous step
4184 ! dt_since_start is intentionally made as inout to keep naming consistency with the embedded subroutine
4185 INTEGER, INTENT(inout) :: dt_since_start ! time since simulation starts [s]
4186 INTEGER, INTENT(IN) :: veg_type !Defines how vegetation is calculated for LUMPS [-]
4187 INTEGER, INTENT(IN) :: WaterUseMethod !Defines how external water use is calculated[-]
4188
4189 INTEGER, DIMENSION(NVEGSURF), INTENT(IN) :: LAIType !LAI calculation choice[-]
4190
4191 REAL(KIND(1D0)), INTENT(IN) :: AlbMax_DecTr !maximum albedo for deciduous tree and shrub [-]
4192 REAL(KIND(1D0)), INTENT(IN) :: AlbMax_EveTr !maximum albedo for evergreen tree and shrub [-]
4193 REAL(KIND(1D0)), INTENT(IN) :: AlbMax_Grass !maximum albedo for grass [-]
4194 REAL(KIND(1D0)), INTENT(IN) :: AlbMin_DecTr !minimum albedo for deciduous tree and shrub [-]
4195 REAL(KIND(1D0)), INTENT(IN) :: AlbMin_EveTr !minimum albedo for evergreen tree and shrub [-]
4196 REAL(KIND(1D0)), INTENT(IN) :: AlbMin_Grass !minimum albedo for grass [-]
4197 REAL(KIND(1D0)), INTENT(IN) :: alt !solar altitude [deg]
4198 ! REAL(KIND(1D0)),INTENT(IN)::avkdn
4199 ! REAL(KIND(1D0)),INTENT(IN)::avRh
4200 ! REAL(KIND(1D0)),INTENT(IN)::avU1
4201 REAL(KIND(1D0)), INTENT(IN) :: BaseT_HC !base temperature for heating degree dayb [degC]
4202 REAL(KIND(1D0)), INTENT(IN) :: bldgH !average building height [m]
4203 REAL(KIND(1D0)), INTENT(IN) :: CapMax_dec !maximum water storage capacity for upper surfaces (i.e. canopy)
4204 REAL(KIND(1D0)), INTENT(IN) :: CapMin_dec !minimum water storage capacity for upper surfaces (i.e. canopy)
4205 REAL(KIND(1D0)), INTENT(IN) :: CO2PointSource ! point source [kgC day-1]
4206 REAL(KIND(1D0)), INTENT(IN) :: CRWmax !maximum water holding capacity of snow [mm]
4207 REAL(KIND(1D0)), INTENT(IN) :: CRWmin !minimum water holding capacity of snow [mm]
4208 REAL(KIND(1D0)), INTENT(IN) :: DecTreeH !average height of deciduous tree and shrub [-]
4209 REAL(KIND(1D0)), INTENT(IN) :: DRAINRT !Drainage rate of the water bucket [mm hr-1]
4210 REAL(KIND(1D0)), INTENT(IN) :: EF_umolCO2perJ !co2 emission factor [umol J-1]
4211 REAL(KIND(1D0)), INTENT(IN) :: EnEF_v_Jkm ! energy emission factor [J K m-1]
4212 REAL(KIND(1D0)), INTENT(IN) :: EveTreeH !height of evergreen tree [m]
4213 REAL(KIND(1D0)), INTENT(IN) :: FAIBldg ! frontal area index for buildings [-]
4214 REAL(KIND(1D0)), INTENT(IN) :: FAIDecTree ! frontal area index for deciduous tree [-]
4215 REAL(KIND(1D0)), INTENT(IN) :: FAIEveTree ! frontal area index for evergreen tree [-]
4216 REAL(KIND(1D0)), INTENT(IN) :: Faut !Fraction of irrigated area using automatic irrigation [-]
4217 ! REAL(KIND(1D0)),INTENT(IN)::fcld_obs
4218 REAL(KIND(1D0)), INTENT(IN) :: FlowChange !Difference between the input and output flow in the water body [mm]
4219 REAL(KIND(1D0)), INTENT(IN) :: FrFossilFuel_Heat ! fraction of fossil fuel heat [-]
4220 REAL(KIND(1D0)), INTENT(IN) :: FrFossilFuel_NonHeat ! fraction of fossil fuel non heat [-]
4221 REAL(KIND(1D0)), INTENT(IN) :: G1 !Fitted parameters related to surface res. calculations
4222 REAL(KIND(1D0)), INTENT(IN) :: G2 !Fitted parameters related to surface res. calculations
4223 REAL(KIND(1D0)), INTENT(IN) :: G3 !Fitted parameters related to surface res. calculations
4224 REAL(KIND(1D0)), INTENT(IN) :: G4 !Fitted parameters related to surface res. calculations
4225 REAL(KIND(1D0)), INTENT(IN) :: G5 !Fitted parameters related to surface res. calculations
4226 REAL(KIND(1D0)), INTENT(IN) :: G6 !Fitted parameters related to surface res. calculations
4227 REAL(KIND(1D0)), INTENT(IN) :: H_maintain ! ponding water depth to maintain [mm]
4228 REAL(KIND(1D0)), INTENT(IN) :: InternalWaterUse_h !Internal water use [mm h-1
4229 REAL(KIND(1D0)), INTENT(IN) :: IrrFracPaved !fraction of paved which are irrigated [-]
4230 REAL(KIND(1D0)), INTENT(IN) :: IrrFracBldgs !fraction of buildings (e.g., green roofs) which are irrigated [-]
4231 REAL(KIND(1D0)), INTENT(IN) :: IrrFracEveTr !fraction of evergreen trees which are irrigated [-]
4232 REAL(KIND(1D0)), INTENT(IN) :: IrrFracDecTr !fraction of deciduous trees which are irrigated [-]
4233 REAL(KIND(1D0)), INTENT(IN) :: IrrFracGrass !fraction of grass which are irrigated [-]
4234 REAL(KIND(1D0)), INTENT(IN) :: IrrFracBSoil !fraction of bare soil trees which are irrigated [-]
4235 REAL(KIND(1D0)), INTENT(IN) :: IrrFracWater !fraction of water which are irrigated [-]
4236 REAL(KIND(1D0)), INTENT(IN) :: Kmax !annual maximum hourly solar radiation [W m-2]
4237 ! REAL(KIND(1D0)),INTENT(IN)::LAI_obs
4238 REAL(KIND(1D0)), INTENT(IN) :: lat !latitude [deg]
4239 ! REAL(KIND(1D0)),INTENT(IN)::ldown_obs
4240 REAL(KIND(1D0)), INTENT(IN) :: lng !longitude [deg]
4241 REAL(KIND(1D0)), INTENT(IN) :: MaxFCMetab ! maximum FC metabolism [umol m-2 s-1]
4242 REAL(KIND(1D0)), INTENT(IN) :: MaxQFMetab ! maximum QF Metabolism [W m-2]
4243 REAL(KIND(1D0)), INTENT(IN) :: MinFCMetab ! minimum QF metabolism [umol m-2 s-1]
4244 REAL(KIND(1D0)), INTENT(IN) :: MinQFMetab ! minimum FC metabolism [W m-2]
4245 REAL(KIND(1D0)), INTENT(IN) :: NARP_EMIS_SNOW ! snow emissivity in NARP model [-]
4246 REAL(KIND(1D0)), INTENT(IN) :: NARP_TRANS_SITE !atmospheric transmissivity for NARP [-]
4247 REAL(KIND(1D0)), INTENT(IN) :: PipeCapacity !capacity of pipes to transfer water [mm]
4248 REAL(KIND(1D0)), INTENT(IN) :: PopDensNighttime ! nighttime population density [ha-1] (i.e. residents)
4249 REAL(KIND(1D0)), INTENT(IN) :: PorMax_dec !full leaf-on summertime value used only for DecTr
4250 REAL(KIND(1D0)), INTENT(IN) :: PorMin_dec !leaf-off wintertime value used only for DecTr
4251 ! REAL(KIND(1D0)),INTENT(IN)::Precip
4252 REAL(KIND(1D0)), INTENT(IN) :: PrecipLimit !rain data [mm]
4253 REAL(KIND(1D0)), INTENT(IN) :: PrecipLimitAlb !temperature limit when precipitation falls as snow [degC]
4254 ! REAL(KIND(1D0)),INTENT(IN)::Press_hPa
4255 ! REAL(KIND(1D0)),INTENT(IN)::qh_obs
4256 ! REAL(KIND(1D0)),INTENT(IN)::qn1_obs
4257 ! REAL(KIND(1D0)),INTENT(IN)::qs_obs
4258 ! REAL(KIND(1D0)),INTENT(IN)::qf_obs
4259 REAL(KIND(1D0)), INTENT(IN) :: RadMeltFact !hourly radiation melt factor of snow [mm W-1 h-1]
4260 REAL(KIND(1D0)), INTENT(IN) :: RAINCOVER !limit when surface totally covered with water for LUMPS [mm]
4261 REAL(KIND(1D0)), INTENT(IN) :: RainMaxRes !maximum water bucket reservoir [mm] Used for LUMPS surface wetness control.
4262 REAL(KIND(1D0)), INTENT(IN) :: RunoffToWater !fraction of above-ground runoff flowing to water surface during flooding [-]
4263 REAL(KIND(1D0)), INTENT(IN) :: S1 !a parameter related to soil moisture dependence [-]
4264 REAL(KIND(1D0)), INTENT(IN) :: S2 !a parameter related to soil moisture dependence [mm]
4265 REAL(KIND(1D0)), INTENT(IN) :: SnowAlbMax !effective surface albedo (middle of the day value) for summertime [-]
4266 REAL(KIND(1D0)), INTENT(IN) :: SnowAlbMin !effective surface albedo (middle of the day value) for wintertime (not including snow) [-]
4267 REAL(KIND(1D0)), INTENT(IN) :: SnowDensMax !maximum snow density [kg m-3]
4268 REAL(KIND(1D0)), INTENT(IN) :: SnowDensMin !fresh snow density [kg m-3]
4269 REAL(KIND(1D0)), INTENT(IN) :: SnowLimBldg !Limit of the snow water equivalent for snow removal from building roofs [mm]
4270 REAL(KIND(1D0)), INTENT(IN) :: SnowLimPaved !llimit of the snow water equivalent for snow removal from roads[mm]
4271 ! REAL(KIND(1D0)),INTENT(IN)::snowFrac_obs
4272 REAL(KIND(1D0)), INTENT(IN) :: SurfaceArea !area of the grid [ha]
4273 REAL(KIND(1D0)), INTENT(IN) :: tau_a !time constant for snow albedo aging in cold snow [-]
4274 REAL(KIND(1D0)), INTENT(IN) :: tau_f !time constant for snow albedo aging in melting snow [-]
4275 REAL(KIND(1D0)), INTENT(IN) :: tau_r !time constant for snow density ageing [-]
4276 ! REAL(KIND(1D0)),INTENT(IN)::Temp_C
4277 REAL(KIND(1D0)), INTENT(IN) :: TempMeltFact !hourly temperature melt factor of snow [mm K-1 h-1]
4278 REAL(KIND(1D0)), INTENT(IN) :: TH !upper air temperature limit [degC]
4279 REAL(KIND(1D0)), INTENT(IN) :: timezone !time zone [h] for site relative to UTC (east is positive)
4280 REAL(KIND(1D0)), INTENT(IN) :: TL !lower air temperature limit [degC]
4281 REAL(KIND(1D0)), INTENT(IN) :: TrafficUnits ! traffic units choice [-]
4282 ! REAL(KIND(1D0)),INTENT(IN)::xsmd
4283 REAL(KIND(1D0)), INTENT(IN) :: Z ! measurement height [m]
4284 REAL(KIND(1D0)), INTENT(IN) :: z0m_in !roughness length for momentum [m]
4285 REAL(KIND(1D0)), INTENT(IN) :: zdm_in !zero-plane displacement [m]
4286
4287 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: AH_MIN !minimum QF values [W m-2]
4288 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: AH_SLOPE_Cooling ! cooling slope for the anthropogenic heat flux calculation [W m-2 K-1]
4289 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: AH_SLOPE_Heating ! heating slope for the anthropogenic heat flux calculation [W m-2 K-1]
4290 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: FcEF_v_kgkm ! CO2 Emission factor [kg km-1]
4291 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: QF0_BEU ! Fraction of base value coming from buildings [-]
4292 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: Qf_A ! Base value for QF [W m-2]
4293 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: Qf_B ! Parameter related to heating degree days [W m-2 K-1 (Cap ha-1 )-1]
4294 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: Qf_C ! Parameter related to cooling degree days [W m-2 K-1 (Cap ha-1 )-1]
4295 ! REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) ::Numcapita
4296 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: PopDensDaytime ! Daytime population density [people ha-1] (i.e. workers)
4297 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: BaseT_Cooling ! base temperature for cooling degree day [degC]
4298 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: BaseT_Heating ! base temperatrue for heating degree day [degC]
4299 REAL(KIND(1D0)), DIMENSION(2), INTENT(IN) :: TrafficRate ! Traffic rate [veh km m-2 s-1]
4300 REAL(KIND(1D0)), DIMENSION(3), INTENT(IN) :: Ie_a !Coefficient for automatic irrigation model
4301 REAL(KIND(1D0)), DIMENSION(3), INTENT(IN) :: Ie_m !Coefficients for manual irrigation models
4302 REAL(KIND(1D0)), DIMENSION(3), INTENT(IN) :: MaxConductance !the maximum conductance of each vegetation or surface type. [mm s-1]
4303 REAL(KIND(1D0)), DIMENSION(7), INTENT(IN) :: DayWat !Irrigation flag: 1 for on and 0 for off [-]
4304 REAL(KIND(1D0)), DIMENSION(7), INTENT(IN) :: DayWatPer !Fraction of properties using irrigation for each day of a week [-]
4305 REAL(KIND(1D0)), DIMENSION(nsurf + 1), INTENT(IN) :: OHM_threshSW !Temperature threshold determining whether summer/winter OHM coefficients are applied [degC]
4306 REAL(KIND(1D0)), DIMENSION(nsurf + 1), INTENT(IN) :: OHM_threshWD !Soil moisture threshold determining whether wet/dry OHM coefficients are applied [-]
4307 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: chAnOHM !Bulk transfer coefficient for this surface to use in AnOHM [-]
4308 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: cpAnOHM !Volumetric heat capacity for this surface to use in AnOHM [J m-3]
4309 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: emis !Effective surface emissivity[-]
4310 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: kkAnOHM !Thermal conductivity for this surface to use in AnOHM [W m K-1]
4311 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: SatHydraulicConduct !Hydraulic conductivity for saturated soil [mm s-1]
4312 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: sfr_surf !surface cover fraction[-]
4313 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: SnowPackLimit !Limit for the snow water equivalent when snow cover starts to be patchy [mm]
4314 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: SoilDepth !Depth of soil beneath the surface [mm]
4315 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: SoilStoreCap_surf !Capacity of soil store for each surface [mm]
4316 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: StateLimit_surf !Upper limit to the surface state [mm]
4317 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(IN) :: WetThresh_surf !surface wetness threshold [mm], When State > WetThresh, RS=0 limit in SUEWS_evap [mm]
4318 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: alpha_bioCO2 !The mean apparent ecosystem quantum. Represents the initial slope of the light-response curve [-]
4319 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: alpha_enh_bioCO2 !Part of the alpha coefficient related to the fraction of vegetation[-]
4320 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: BaseT !Base Temperature for initiating growing degree days (GDD) for leaf growth [degC]
4321 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: BaseTe !Base temperature for initiating sensesance degree days (SDD) for leaf off [degC]
4322 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: beta_bioCO2 !The light-saturated gross photosynthesis of the canopy [umol m-2 s-1 ]
4323 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: beta_enh_bioCO2 !Part of the beta coefficient related to the fraction of vegetation [umol m-2 s-1 ]
4324 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: GDDFull !the growing degree days (GDD) needed for full capacity of the leaf area index [degC]
4325 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: LAIMax !full leaf-on summertime value [m2 m-2]
4326 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: LAIMin !leaf-off wintertime value [m2 m-2]
4327 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: min_res_bioCO2 !Minimum soil respiration rate (for cold-temperature limit) [umol m-2 s-1]
4328 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: resp_a !Respiration coefficient a
4329 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: resp_b !Respiration coefficient b - related to air temperature dependency
4330 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: SDDFull !the sensesence degree days (SDD) needed to initiate leaf off [degC]
4331 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(IN) :: SnowProf_24hr !Hourly profile values used in snow clearing [-]
4332 REAL(KIND(1D0)), DIMENSION(NVEGSURF), INTENT(IN) :: theta_bioCO2 !The convexity of the curve at light saturation [-]
4333 REAL(KIND(1D0)), DIMENSION(4, NVEGSURF), INTENT(IN) :: LAIPower !parameters required by LAI calculation
4334 REAL(KIND(1D0)), DIMENSION(nsurf + 1, 4, 3), INTENT(IN) :: OHM_coef !Coefficients for OHM calculation
4335 REAL(KIND(1D0)), DIMENSION(NSURF + 1, NSURF - 1), INTENT(IN) :: WaterDist !Fraction of water redistribution [-]
4336 REAL(KIND(1D0)), DIMENSION(:), INTENT(IN) :: Ts5mindata_ir !surface temperature input data[degC]
4337
4338 ! diurnal profile values for 24hr
4339 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(IN) :: AHProf_24hr !Hourly profile values used in energy use calculation [-]
4340 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(IN) :: HumActivity_24hr !Hourly profile values used in human activity calculation[-]
4341 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(IN) :: PopProf_24hr !Hourly profile values used in dynamic population estimation[-]
4342 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(IN) :: TraffProf_24hr !Hourly profile values used in traffic activity calculation[-]
4343 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(IN) :: WUProfA_24hr !Hourly profile values used in automatic irrigation[-]
4344 REAL(KIND(1D0)), DIMENSION(0:23, 2), INTENT(IN) :: WUProfM_24hr !Hourly profile values used in manual irrigation[-]
4345 ! ########################################################################################
4346
4347 ! ########################################################################################
4348 ! inout variables
4349 ! OHM related:
4350 REAL(KIND(1D0)), INTENT(INOUT) :: qn_av ! weighted average of net all-wave radiation [W m-2]
4351 REAL(KIND(1D0)), INTENT(INOUT) :: dqndt ! rate of change of net radiation [W m-2 h-1]
4352 REAL(KIND(1D0)), INTENT(INOUT) :: qn_s_av ! weighted average of qn over snow [W m-2]
4353 REAL(KIND(1D0)), INTENT(INOUT) :: dqnsdt ! Rate of change of net radiation [W m-2 h-1]
4354
4355 ! snow related:
4356 REAL(KIND(1D0)), INTENT(INOUT) :: SnowfallCum !cumulated snow falling [mm]
4357 REAL(KIND(1D0)), INTENT(INOUT) :: SnowAlb !albedo of know [-]
4358 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: IceFrac !fraction of ice in snowpack [-]
4359 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: SnowWater ! snow water[mm]
4360 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: SnowDens !snow density [kg m-3]
4361 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: SnowFrac !snow fraction [-]
4362 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: SnowPack !snow water equivalent on each land cover [mm]
4363
4364 ! water balance related:
4365 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: soilstore_surf !soil moisture of each surface type [mm]
4366 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: state_surf !wetness status of each surface type [mm]
4367 REAL(KIND(1D0)), DIMENSION(6, NSURF), INTENT(INOUT) :: StoreDrainPrm !coefficients used in drainage calculation [-]
4368
4369 ! phenology related:
4370 REAL(KIND(1D0)), DIMENSION(NSURF), INTENT(INOUT) :: alb !albedo [-]
4371 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(INOUT) :: GDD_id !Growing Degree Days [degC](see SUEWS_DailyState.f95)
4372 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(INOUT) :: SDD_id !Senescence Degree Days [degC](see SUEWS_DailyState.f95)
4373 REAL(KIND(1D0)), DIMENSION(nvegsurf), INTENT(INOUT) :: LAI_id !LAI for each veg surface [m2 m-2]
4374 REAL(KIND(1D0)), INTENT(INOUT) :: DecidCap_id !Moisture storage capacity of deciduous trees [mm]
4375 REAL(KIND(1D0)), INTENT(INOUT) :: albDecTr_id !Albedo of deciduous trees [-]
4376 REAL(KIND(1D0)), INTENT(INOUT) :: albEveTr_id !Albedo of evergreen trees [-]
4377 REAL(KIND(1D0)), INTENT(INOUT) :: albGrass_id !Albedo of grass [-]
4378 REAL(KIND(1D0)), INTENT(INOUT) :: porosity_id !Porosity of deciduous trees [-]
4379 REAL(KIND(1D0)), INTENT(INOUT) :: Tmin_id !Daily minimum temperature [degC]
4380 REAL(KIND(1D0)), INTENT(INOUT) :: Tmax_id !Daily maximum temperature [degC]
4381 REAL(KIND(1D0)), INTENT(INOUT) :: lenday_id !daytime length [h]
4382
4383 ! anthropogenic heat related:
4384 REAL(KIND(1D0)), DIMENSION(12), INTENT(INOUT) :: HDD_id !Heating Degree Days [degC d](see SUEWS_DailyState.f95)
4385
4386 ! water use related:
4387 REAL(KIND(1D0)), DIMENSION(9), INTENT(INOUT) :: WUDay_id !Daily water use for EveTr, DecTr, Grass [mm] (see SUEWS_DailyState.f95)
4388
4389 ! ESTM related:
4390 REAL(KIND(1D0)), INTENT(INOUT) :: Tair_av !average air temperature [degC]
4391
4392 ! ! extended for ESTM_ext, TS 20 Jan 2022
4393 ! input arrays: standard suews surfaces
4394 ! REAL(KIND(1D0)), DIMENSION(nroof) :: tsfc_roof
4395 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(INOUT) :: tsfc_roof !roof surface temperature [degC]
4396 REAL(KIND(1D0)), DIMENSION(nlayer) :: sfr_roof !roof surface fraction [-]
4397 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tin_roof ! indoor temperature for roof [degC]
4398 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(inout) :: temp_roof !interface temperature between depth layers in roof[degC]
4399 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: k_roof ! thermal conductivity of roof [W m-1 K]
4400 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: cp_roof ! Heat capacity of roof [J m-3 K-1]
4401 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: dz_roof ! thickness of each layer in roof [m]
4402 ! input arrays: standard suews surfaces
4403 ! REAL(KIND(1D0)), DIMENSION(nwall) :: tsfc_wall
4404 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(INOUT) :: tsfc_wall !surface temperature of wall [degC]
4405 REAL(KIND(1D0)), DIMENSION(nlayer) :: sfr_wall !wall surface fraction [-]
4406 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tin_wall ! indoor temperature for wall [degC]
4407 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(inout) :: temp_wall !interface temperature between depth layers in wall[degC]
4408 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: k_wall ! thermal conductivity of wall [W m-1 K]
4409 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: cp_wall ! Heat capacity of wall [J m-3 K-1]
4410 REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: dz_wall ! thickness of each layer in wall [m]
4411 ! input arrays: standard suews surfaces
4412 ! REAL(KIND(1D0)), DIMENSION(nsurf) :: tsfc_surf
4413 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(INOUT) :: tsfc_surf !surface temperature [degC]
4414 REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: tin_surf !deep bottom temperature for each surface [degC]
4415 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(inout) :: temp_surf !interface temperature between depth layers for each surfaces[degC]
4416 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(in) :: k_surf ! thermal conductivity of v [W m-1 K]
4417 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(in) :: cp_surf ! Heat capacity of each surface [J m-3 K-1]
4418 REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(in) :: dz_surf ! thickness of each layer in each surface [m]
4419
4420 ! SPARTACUS input variables
4421 INTEGER, INTENT(IN) :: n_vegetation_region_urban, & !Number of regions used to describe vegetation
4422 n_stream_sw_urban, n_stream_lw_urban !shortwave diffuse streams per hemisphere; LW streams per hemisphere
4423 REAL(KIND(1D0)), INTENT(IN) :: sw_dn_direct_frac, air_ext_sw, air_ssa_sw, &
4424 veg_ssa_sw, air_ext_lw, air_ssa_lw, veg_ssa_lw, &
4425 veg_fsd_const, veg_contact_fraction_const, &
4426 ground_albedo_dir_mult_fact
4427 LOGICAL, INTENT(IN) :: use_sw_direct_albedo
4428 REAL(KIND(1D0)), DIMENSION(nlayer + 1), INTENT(IN) :: height ! height in spartacus [m]
4429 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: building_frac !building fraction [-]
4430 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: veg_frac !vegetation fraction [-]
4431 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: building_scale ! diameter of buildings [[m]
4432 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: veg_scale ! scale of tree crowns [m]
4433 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: alb_roof !albedo of roof [-]
4434 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: emis_roof ! emissivity of roof [-]
4435 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: alb_wall !albedo of wall [-]
4436 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: emis_wall ! emissivity of wall [-]
4437 REAL(KIND(1D0)), DIMENSION(nspec, nlayer), INTENT(IN) :: roof_albedo_dir_mult_fact !Ratio of the direct and diffuse albedo of the roof[-]
4438 REAL(KIND(1D0)), DIMENSION(nspec, nlayer), INTENT(IN) :: wall_specular_frac ! Fraction of wall reflection that is specular [-]
4439 ! ########################################################################################
4440
4441 ! ####################################################################################
4442 ! ESTM_EXT
4443 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: SoilStoreCap_roof !Capacity of soil store for roof [mm]
4444 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: StateLimit_roof !Limit for state_id of roof [mm]
4445 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: wetthresh_roof ! wetness threshold of roof[mm]
4446 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(INOUT) :: soilstore_roof !Soil moisture of roof [mm]
4447 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(INOUT) :: state_roof !wetness status of roof [mm]
4448
4449 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: SoilStoreCap_wall !Capacity of soil store for wall [mm]
4450 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: StateLimit_wall !Limit for state_id of wall [mm]
4451 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(IN) :: wetthresh_wall ! wetness threshold of wall[mm]
4452 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(INOUT) :: soilstore_wall !Soil moisture of wall [mm]
4453 REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(INOUT) :: state_wall !wetness status of wall [mm]
4454
4455 ! ########################################################################################
4456 ! output variables
4457 ! REAL(KIND(1D0)),DIMENSION(:,:,:),ALLOCATABLE,INTENT(OUT) ::datetimeBlock
4458 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutSUEWS), INTENT(OUT) :: dataOutBlockSUEWS
4459 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutSnow), INTENT(OUT) :: dataOutBlockSnow
4460 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutESTM), INTENT(OUT) :: dataOutBlockESTM
4461 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutESTMExt), INTENT(OUT) :: dataOutBlockESTMExt
4462 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutRSL), INTENT(OUT) :: dataOutBlockRSL
4463 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsdataOutBEERS), INTENT(OUT) :: dataOutBlockBEERS
4464 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutDebug), INTENT(OUT) :: dataOutBlockDebug
4465 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutSPARTACUS), INTENT(OUT) :: dataOutBlockSPARTACUS
4466 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutDailyState), INTENT(OUT) :: DailyStateBlock
4467 ! ########################################################################################
4468
4469 ! internal temporal iteration related variables
4470 ! INTEGER::dt_since_start ! time since simulation starts [s]
4471
4472 ! model output blocks of the same size as met forcing block
4473
4474 ! local variables
4475 ! length of met forcing block
4476 INTEGER :: ir
4477 ! met forcing variables
4478 INTEGER :: iy
4479 INTEGER :: id
4480 INTEGER :: it
4481 INTEGER :: imin
4482 INTEGER :: isec
4483 INTEGER, PARAMETER :: gridiv_x = 1 ! a dummy gridiv as this routine is only one grid
4484 REAL(KIND(1D0)) :: qn1_obs
4485 REAL(KIND(1D0)) :: qh_obs
4486 REAL(KIND(1D0)) :: qe_obs
4487 REAL(KIND(1D0)) :: qs_obs
4488 REAL(KIND(1D0)) :: qf_obs
4489 REAL(KIND(1D0)) :: avu1
4490 REAL(KIND(1D0)) :: avrh
4491 REAL(KIND(1D0)) :: Temp_C
4492 REAL(KIND(1D0)) :: Press_hPa
4493 REAL(KIND(1D0)) :: Precip
4494 REAL(KIND(1D0)) :: avkdn
4495 REAL(KIND(1D0)) :: snowFrac_obs
4496 REAL(KIND(1D0)) :: ldown_obs
4497 REAL(KIND(1D0)) :: fcld_obs
4498 REAL(KIND(1D0)) :: wu_m3
4499 REAL(KIND(1D0)) :: xsmd
4500 REAL(KIND(1D0)) :: LAI_obs
4501 REAL(KIND(1D0)) :: kdiff
4502 REAL(KIND(1D0)) :: kdir
4503 REAL(KIND(1D0)) :: wdir
4504
4505 REAL(KIND(1D0)), DIMENSION(5) :: datetimeLine
4506 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutSUEWS - 5) :: dataOutLineSUEWS
4507 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutSnow - 5) :: dataOutLineSnow
4508 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutESTM - 5) :: dataOutLineESTM
4509 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutESTMExt - 5) :: dataOutLineESTMExt
4510 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutRSL - 5) :: dataOutLineRSL
4511 ! REAL(KIND(1D0)), DIMENSION(ncolumnsdataOutSOLWEIG - 5) :: dataOutLineSOLWEIG
4512 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutBEERS - 5) :: dataOutLineBEERS
4513 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutDebug - 5) :: dataOutLinedebug
4514 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutSPARTACUS - 5) :: dataOutLineSPARTACUS
4515 REAL(KIND(1D0)), DIMENSION(ncolumnsDataOutDailyState - 5) :: DailyStateLine
4516
4517 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutSUEWS, 1) :: dataOutBlockSUEWS_X
4518 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutSnow, 1) :: dataOutBlockSnow_X
4519 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutESTM, 1) :: dataOutBlockESTM_X
4520 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutESTMExt, 1) :: dataOutBlockESTMExt_X
4521 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutRSL, 1) :: dataOutBlockRSL_X
4522 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsdataOutBEERS, 1) :: dataOutBlockBEERS_X
4523 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutDebug, 1) :: dataOutBlockDebug_X
4524 REAL(KIND(1D0)), DIMENSION(len_sim, ncolumnsDataOutSPARTACUS, 1) :: dataOutBlockSPARTACUS_X
4525 ! REAL(KIND(1d0)),DIMENSION(len_sim,ncolumnsDataOutDailyState,1) ::DailyStateBlock_X
4526
4527 REAL(KIND(1D0)), DIMENSION(10, 10) :: MetForcingData_grid ! fake array as a placeholder
4528
4529 ! CHARACTER(len=150):: FileStateInit
4530 ! CHARACTER(len=4):: year_txt
4531 ! CHARACTER(len=3):: id_text
4532 ! CHARACTER(len=2):: it_text, imin_text
4533
4534 ! get initial dt_since_start_x from dt_since_start, dt_since_start_x is used for Qn averaging. TS 28 Nov 2018
4535 ! dt_since_start = dt_since_start
4536
4537 DO ir = 1, len_sim, 1
4538 ! =============================================================================
4539 ! === Translate met data from MetForcingBlock to variable names used in model ==
4540 ! =============================================================================
4541 iy = int(metforcingblock(ir, 1)) !Integer variables
4542 id = int(metforcingblock(ir, 2))
4543 it = int(metforcingblock(ir, 3))
4544 imin = int(metforcingblock(ir, 4))
4545 isec = 0 ! NOT used by SUEWS but by WRF-SUEWS via the cal_main interface
4546 qn1_obs = metforcingblock(ir, 5) !Real values (kind(1d0))
4547 qh_obs = metforcingblock(ir, 6)
4548 qe_obs = metforcingblock(ir, 7)
4549 qs_obs = metforcingblock(ir, 8)
4550 qf_obs = metforcingblock(ir, 9)
4551 avu1 = metforcingblock(ir, 10)
4552 avrh = metforcingblock(ir, 11)
4553 temp_c = metforcingblock(ir, 12)
4554 press_hpa = metforcingblock(ir, 13)
4555 precip = metforcingblock(ir, 14)
4556 avkdn = metforcingblock(ir, 15)
4557 snowfrac_obs = metforcingblock(ir, 16)
4558 ldown_obs = metforcingblock(ir, 17)
4559 fcld_obs = metforcingblock(ir, 18)
4560 wu_m3 = metforcingblock(ir, 19)
4561 xsmd = metforcingblock(ir, 20)
4562 lai_obs = metforcingblock(ir, 21)
4563 kdiff = metforcingblock(ir, 22)
4564 kdir = metforcingblock(ir, 23)
4565 wdir = metforcingblock(ir, 24)
4566
4567 ! !================================================
4568 ! ! below is for debugging
4569 ! WRITE (year_txt, '(I4)') INT(iy)
4570 ! WRITE (id_text, '(I3)') INT(id)
4571 ! WRITE (it_text, '(I4)') INT(it)
4572 ! WRITE (imin_text, '(I4)') INT(imin)
4573
4574 ! FileStateInit = './'//TRIM(ADJUSTL(year_txt))//'_'&
4575 ! //TRIM(ADJUSTL(id_text))//'_'&
4576 ! //TRIM(ADJUSTL(it_text))//'_'&
4577 ! //TRIM(ADJUSTL(imin_text))//'_'&
4578 ! //'state_init.nml'
4579
4580 ! OPEN (12, file=FileStateInit, position='rewind')
4581
4582 ! write (12, *) '&state_init'
4583 ! write (12, *) 'aerodynamicresistancemethod=', aerodynamicresistancemethod
4584 ! write (12, *) 'ah_min=', ah_min
4585 ! write (12, *) 'ahprof_24hr=', ahprof_24hr
4586 ! write (12, *) 'ah_slope_cooling=', ah_slope_cooling
4587 ! write (12, *) 'ah_slope_heating=', ah_slope_heating
4588 ! write (12, *) 'alb=', alb
4589 ! write (12, *) 'albmax_dectr=', albmax_dectr
4590 ! write (12, *) 'albmax_evetr=', albmax_evetr
4591 ! write (12, *) 'albmax_grass=', albmax_grass
4592 ! write (12, *) 'albmin_dectr=', albmin_dectr
4593 ! write (12, *) 'albmin_evetr=', albmin_evetr
4594 ! write (12, *) 'albmin_grass=', albmin_grass
4595 ! write (12, *) 'alpha_bioco2=', alpha_bioco2
4596 ! write (12, *) 'alpha_enh_bioco2=', alpha_enh_bioco2
4597 ! write (12, *) 'alt=', alt
4598 ! write (12, *) 'avkdn=', avkdn
4599 ! write (12, *) 'avrh=', avrh
4600 ! write (12, *) 'avu1=', avu1
4601 ! write (12, *) 'baset=', baset
4602 ! write (12, *) 'basete=', basete
4603 ! write (12, *) 'BaseT_HC=', BaseT_HC
4604 ! write (12, *) 'beta_bioco2=', beta_bioco2
4605 ! write (12, *) 'beta_enh_bioco2=', beta_enh_bioco2
4606 ! write (12, *) 'bldgh=', bldgh
4607 ! write (12, *) 'capmax_dec=', capmax_dec
4608 ! write (12, *) 'capmin_dec=', capmin_dec
4609 ! write (12, *) 'chanohm=', chanohm
4610 ! write (12, *) 'co2pointsource=', co2pointsource
4611 ! write (12, *) 'cpanohm=', cpanohm
4612 ! write (12, *) 'crwmax=', crwmax
4613 ! write (12, *) 'crwmin=', crwmin
4614 ! write (12, *) 'daywat=', daywat
4615 ! write (12, *) 'daywatper=', daywatper
4616 ! write (12, *) 'dectreeh=', dectreeh
4617 ! write (12, *) 'diagnose=', diagnose
4618 ! write (12, *) 'diagqn=', diagqn
4619 ! write (12, *) 'diagqs=', diagqs
4620 ! write (12, *) 'drainrt=', drainrt
4621 ! write (12, *) 'dt_since_start=', dt_since_start
4622 ! write (12, *) 'dqndt=', dqndt
4623 ! write (12, *) 'qn_av=', qn_av
4624 ! write (12, *) 'dqnsdt=', dqnsdt
4625 ! write (12, *) 'qn1_s_av=', qn1_s_av
4626 ! write (12, *) 'ef_umolco2perj=', ef_umolco2perj
4627 ! write (12, *) 'emis=', emis
4628 ! write (12, *) 'emissionsmethod=', emissionsmethod
4629 ! write (12, *) 'enef_v_jkm=', enef_v_jkm
4630 ! write (12, *) 'enddls=', enddls
4631 ! write (12, *) 'evetreeh=', evetreeh
4632 ! write (12, *) 'faibldg=', faibldg
4633 ! write (12, *) 'faidectree=', faidectree
4634 ! write (12, *) 'faievetree=', faievetree
4635 ! write (12, *) 'faut=', faut
4636 ! write (12, *) 'fcef_v_kgkm=', fcef_v_kgkm
4637 ! write (12, *) 'fcld_obs=', fcld_obs
4638 ! write (12, *) 'flowchange=', flowchange
4639 ! write (12, *) 'frfossilfuel_heat=', frfossilfuel_heat
4640 ! write (12, *) 'frfossilfuel_nonheat=', frfossilfuel_nonheat
4641 ! write (12, *) 'g1=', g1
4642 ! write (12, *) 'g2=', g2
4643 ! write (12, *) 'g3=', g3
4644 ! write (12, *) 'g4=', g4
4645 ! write (12, *) 'g5=', g5
4646 ! write (12, *) 'g6=', g6
4647 ! write (12, *) 'gdd_id=', gdd_id
4648 ! write (12, *) 'gddfull=', gddfull
4649 ! write (12, *) 'gridiv=', gridiv
4650 ! write (12, *) 'gsmodel=', gsmodel
4651 ! write (12, *) 'hdd_id=', hdd_id
4652 ! write (12, *) 'humactivity_24hr=', humactivity_24hr
4653 ! write (12, *) 'icefrac=', icefrac
4654 ! write (12, *) 'id=', id
4655 ! write (12, *) 'ie_a=', ie_a
4656 ! write (12, *) 'ie_end=', ie_end
4657 ! write (12, *) 'ie_m=', ie_m
4658 ! write (12, *) 'ie_start=', ie_start
4659 ! write (12, *) 'imin=', imin
4660 ! write (12, *) 'internalwateruse_h=', internalwateruse_h
4661 ! write (12, *) 'IrrFracEveTr=', IrrFracEveTr
4662 ! write (12, *) 'IrrFracDecTr=', IrrFracDecTr
4663 ! write (12, *) 'irrfracgrass=', irrfracgrass
4664 ! write (12, *) 'isec=', isec
4665 ! write (12, *) 'it=', it
4666 ! write (12, *) 'evapmethod=', evapmethod
4667 ! write (12, *) 'iy=', iy
4668 ! write (12, *) 'kkanohm=', kkanohm
4669 ! write (12, *) 'kmax=', kmax
4670 ! write (12, *) 'lai_id=', lai_id
4671 ! write (12, *) 'laicalcyes=', laicalcyes
4672 ! write (12, *) 'laimax=', laimax
4673 ! write (12, *) 'laimin=', laimin
4674 ! write (12, *) 'lai_obs=', lai_obs
4675 ! write (12, *) 'laipower=', laipower
4676 ! write (12, *) 'laitype=', laitype
4677 ! write (12, *) 'lat=', lat
4678 ! write (12, *) 'lenday_id=', lenday_id
4679 ! write (12, *) 'ldown_obs=', ldown_obs
4680 ! write (12, *) 'lng=', lng
4681 ! write (12, *) 'maxconductance=', maxconductance
4682 ! write (12, *) 'maxfcmetab=', maxfcmetab
4683 ! write (12, *) 'maxqfmetab=', maxqfmetab
4684 ! write (12, *) 'snowwater=', snowwater
4685 ! ! write (12, *) 'metforcingdata_grid=', metforcingdata_grid
4686 ! write (12, *) 'minfcmetab=', minfcmetab
4687 ! write (12, *) 'minqfmetab=', minqfmetab
4688 ! write (12, *) 'min_res_bioco2=', min_res_bioco2
4689 ! write (12, *) 'narp_emis_snow=', narp_emis_snow
4690 ! write (12, *) 'narp_trans_site=', narp_trans_site
4691 ! write (12, *) 'netradiationmethod=', netradiationmethod
4692 ! write (12, *) 'ohm_coef=', ohm_coef
4693 ! write (12, *) 'ohmincqf=', ohmincqf
4694 ! write (12, *) 'ohm_threshsw=', ohm_threshsw
4695 ! write (12, *) 'ohm_threshwd=', ohm_threshwd
4696 ! write (12, *) 'pipecapacity=', pipecapacity
4697 ! write (12, *) 'popdensdaytime=', popdensdaytime
4698 ! write (12, *) 'popdensnighttime=', popdensnighttime
4699 ! write (12, *) 'popprof_24hr=', popprof_24hr
4700 ! write (12, *) 'pormax_dec=', pormax_dec
4701 ! write (12, *) 'pormin_dec=', pormin_dec
4702 ! write (12, *) 'precip=', precip
4703 ! write (12, *) 'preciplimit=', preciplimit
4704 ! write (12, *) 'preciplimitalb=', preciplimitalb
4705 ! write (12, *) 'press_hpa=', press_hpa
4706 ! write (12, *) 'qf0_beu=', qf0_beu
4707 ! write (12, *) 'qf_a=', qf_a
4708 ! write (12, *) 'qf_b=', qf_b
4709 ! write (12, *) 'qf_c=', qf_c
4710 ! write (12, *) 'qn1_obs=', qn1_obs
4711 ! write (12, *) 'qh_obs=', qh_obs
4712 ! write (12, *) 'qs_obs=', qs_obs
4713 ! write (12, *) 'qf_obs=', qf_obs
4714 ! write (12, *) 'radmeltfact=', radmeltfact
4715 ! write (12, *) 'raincover=', raincover
4716 ! write (12, *) 'rainmaxres=', rainmaxres
4717 ! write (12, *) 'resp_a=', resp_a
4718 ! write (12, *) 'resp_b=', resp_b
4719 ! write (12, *) 'roughlenheatmethod=', roughlenheatmethod
4720 ! write (12, *) 'roughlenmommethod=', roughlenmommethod
4721 ! write (12, *) 'runofftowater=', runofftowater
4722 ! write (12, *) 's1=', s1
4723 ! write (12, *) 's2=', s2
4724 ! write (12, *) 'sathydraulicconduct=', sathydraulicconduct
4725 ! write (12, *) 'sddfull=', sddfull
4726 ! write (12, *) 'sdd_id=', sdd_id
4727 ! write (12, *) 'sfr_surf=', sfr_surf
4728 ! write (12, *) 'smdmethod=', smdmethod
4729 ! write (12, *) 'snowalb=', snowalb
4730 ! write (12, *) 'snowalbmax=', snowalbmax
4731 ! write (12, *) 'snowalbmin=', snowalbmin
4732 ! write (12, *) 'snowpacklimit=', snowpacklimit
4733 ! write (12, *) 'snowdens=', snowdens
4734 ! write (12, *) 'snowdensmax=', snowdensmax
4735 ! write (12, *) 'snowdensmin=', snowdensmin
4736 ! write (12, *) 'snowfallcum=', snowfallcum
4737 ! write (12, *) 'snowfrac=', snowfrac
4738 ! write (12, *) 'snowlimbldg=', snowlimbldg
4739 ! write (12, *) 'snowlimpaved=', snowlimpaved
4740 ! write (12, *) 'snowfrac_obs=', snowfrac_obs
4741 ! write (12, *) 'snowpack=', snowpack
4742 ! write (12, *) 'snowprof_24hr=', snowprof_24hr
4743 ! write (12, *) 'SnowUse=', SnowUse
4744 ! write (12, *) 'soildepth=', soildepth
4745 ! write (12, *) 'soilstore_id=', soilstore_id
4746 ! write (12, *) 'soilstorecap=', soilstorecap
4747 ! write (12, *) 'stabilitymethod=', stabilitymethod
4748 ! write (12, *) 'startdls=', startdls
4749 ! write (12, *) 'state_id=', state_id
4750 ! write (12, *) 'statelimit=', statelimit
4751 ! write (12, *) 'storageheatmethod=', storageheatmethod
4752 ! write (12, *) 'storedrainprm=', storedrainprm
4753 ! write (12, *) 'surfacearea=', surfacearea
4754 ! write (12, *) 'tair_av=', tair_av
4755 ! write (12, *) 'tau_a=', tau_a
4756 ! write (12, *) 'tau_f=', tau_f
4757 ! write (12, *) 'tau_r=', tau_r
4758 ! write (12, *) 'tmax_id=', tmax_id
4759 ! write (12, *) 'tmin_id=', tmin_id
4760 ! write (12, *) 'BaseT_Cooling=', BaseT_Cooling
4761 ! write (12, *) 'BaseT_Heating=', BaseT_Heating
4762 ! write (12, *) 'temp_c=', temp_c
4763 ! write (12, *) 'tempmeltfact=', tempmeltfact
4764 ! write (12, *) 'th=', th
4765 ! write (12, *) 'theta_bioco2=', theta_bioco2
4766 ! write (12, *) 'timezone=', timezone
4767 ! write (12, *) 'tl=', tl
4768 ! write (12, *) 'trafficrate=', trafficrate
4769 ! write (12, *) 'trafficunits=', trafficunits
4770 ! write (12, *) 'traffprof_24hr=', traffprof_24hr
4771 ! ! write (12, *) 'ts5mindata_ir=', ts5mindata_ir
4772 ! write (12, *) 'tstep=', tstep
4773 ! write (12, *) 'tstep_prev=', tstep_prev
4774 ! write (12, *) 'veg_type=', veg_type
4775 ! write (12, *) 'waterdist=', waterdist
4776 ! write (12, *) 'waterusemethod=', waterusemethod
4777 ! write (12, *) 'wetthresh=', wetthresh
4778 ! write (12, *) 'wu_m3=', wu_m3
4779 ! write (12, *) 'wuday_id=', wuday_id
4780 ! write (12, *) 'decidcap_id=', decidcap_id
4781 ! write (12, *) 'albdectr_id=', albdectr_id
4782 ! write (12, *) 'albevetr_id=', albevetr_id
4783 ! write (12, *) 'albgrass_id=', albgrass_id
4784 ! write (12, *) 'porosity_id=', porosity_id
4785 ! write (12, *) 'wuprofa_24hr=', wuprofa_24hr
4786 ! write (12, *) 'wuprofm_24hr=', wuprofm_24hr
4787 ! write (12, *) 'xsmd=', xsmd
4788 ! write (12, *) 'z=', z
4789 ! write (12, *) 'z0m_in=', z0m_in
4790 ! write (12, *) 'zdm_in=', zdm_in
4791 ! write (12, *) '/'
4792
4793 ! WRITE (12, *) ''
4794
4795 ! CLOSE (12)
4796 ! !================================================
4797
4798 CALL suews_cal_main( &
4799 aerodynamicresistancemethod, ah_min, ahprof_24hr, ah_slope_cooling, & ! input&inout in alphabetical order
4800 ah_slope_heating, &
4801 alb, albmax_dectr, albmax_evetr, albmax_grass, &
4802 albmin_dectr, albmin_evetr, albmin_grass, &
4803 alpha_bioco2, alpha_enh_bioco2, alt, avkdn, avrh, avu1, baset, basete, &
4804 basetmethod, &
4805 baset_hc, beta_bioco2, beta_enh_bioco2, bldgh, capmax_dec, capmin_dec, &
4806 chanohm, co2pointsource, cpanohm, crwmax, crwmin, daywat, daywatper, &
4807 dectreeh, diagmethod, diagnose, diagqn, diagqs, drainrt, &
4808 dt_since_start, dqndt, qn_av, dqnsdt, qn_s_av, &
4809 ef_umolco2perj, emis, emissionsmethod, enef_v_jkm, enddls, evetreeh, faibldg, &
4810 faidectree, faievetree, faut, fcef_v_kgkm, fcld_obs, flowchange, &
4811 frfossilfuel_heat, frfossilfuel_nonheat, g1, g2, g3, g4, g5, g6, gdd_id, &
4812 gddfull, gridiv, gsmodel, h_maintain, hdd_id, humactivity_24hr, &
4813 icefrac, id, ie_a, ie_end, ie_m, ie_start, imin, &
4814 internalwateruse_h, &
4815 irrfracpaved, irrfracbldgs, &
4816 irrfracevetr, irrfracdectr, irrfracgrass, &
4817 irrfracbsoil, irrfracwater, &
4818 isec, it, evapmethod, &
4819 iy, kkanohm, kmax, lai_id, laicalcyes, laimax, laimin, lai_obs, &
4820 laipower, laitype, lat, lenday_id, ldown_obs, lng, maxconductance, maxfcmetab, maxqfmetab, &
4821 snowwater, metforcingdata_grid, minfcmetab, minqfmetab, min_res_bioco2, &
4822 narp_emis_snow, narp_trans_site, netradiationmethod, &
4823 nlayer, &
4824 n_vegetation_region_urban, &
4825 n_stream_sw_urban, n_stream_lw_urban, &
4826 sw_dn_direct_frac, air_ext_sw, air_ssa_sw, &
4827 veg_ssa_sw, air_ext_lw, air_ssa_lw, veg_ssa_lw, &
4828 veg_fsd_const, veg_contact_fraction_const, &
4829 ground_albedo_dir_mult_fact, use_sw_direct_albedo, & !input
4830 height, building_frac, veg_frac, building_scale, veg_scale, & !input: SPARTACUS
4831 alb_roof, emis_roof, alb_wall, emis_wall, &
4832 roof_albedo_dir_mult_fact, wall_specular_frac, &
4833 ohm_coef, ohmincqf, ohm_threshsw, &
4834 ohm_threshwd, pipecapacity, popdensdaytime, &
4835 popdensnighttime, popprof_24hr, pormax_dec, pormin_dec, &
4836 precip, preciplimit, preciplimitalb, press_hpa, &
4837 qf0_beu, qf_a, qf_b, qf_c, &
4838 qn1_obs, qs_obs, qf_obs, &
4839 radmeltfact, raincover, rainmaxres, resp_a, resp_b, &
4840 roughlenheatmethod, roughlenmommethod, runofftowater, s1, s2, &
4841 sathydraulicconduct, sddfull, sdd_id, smdmethod, snowalb, snowalbmax, &
4842 snowalbmin, snowpacklimit, snowdens, snowdensmax, snowdensmin, snowfallcum, snowfrac, &
4843 snowlimbldg, snowlimpaved, snowfrac_obs, snowpack, snowprof_24hr, snowuse, soildepth, &
4844 stabilitymethod, startdls, &
4845 soilstore_surf, soilstorecap_surf, state_surf, statelimit_surf, wetthresh_surf, &
4846 soilstore_roof, soilstorecap_roof, state_roof, statelimit_roof, wetthresh_roof, &
4847 soilstore_wall, soilstorecap_wall, state_wall, statelimit_wall, wetthresh_wall, &
4848 storageheatmethod, storedrainprm, surfacearea, tair_av, tau_a, tau_f, tau_r, &
4849 tmax_id, tmin_id, &
4850 baset_cooling, baset_heating, temp_c, tempmeltfact, th, &
4851 theta_bioco2, timezone, tl, trafficrate, trafficunits, &
4852 sfr_surf, &
4853 tsfc_roof, tsfc_wall, tsfc_surf, &
4854 temp_roof, temp_wall, temp_surf, &
4855 tin_roof, tin_wall, tin_surf, &
4856 k_roof, k_wall, k_surf, &
4857 cp_roof, cp_wall, cp_surf, &
4858 dz_roof, dz_wall, dz_surf, &
4859 traffprof_24hr, ts5mindata_ir, tstep, tstep_prev, veg_type, &
4860 waterdist, waterusemethod, wu_m3, &
4861 wuday_id, decidcap_id, albdectr_id, albevetr_id, albgrass_id, porosity_id, &
4862 wuprofa_24hr, wuprofm_24hr, xsmd, z, z0m_in, zdm_in, &
4863 datetimeline, dataoutlinesuews, dataoutlinesnow, dataoutlineestm, dataoutlinersl, & !output
4864 dataoutlinebeers, & !output
4865 dataoutlinedebug, dataoutlinespartacus, &
4866 dataoutlineestmext, &
4867 dailystateline) !output
4868
4869 ! update dt_since_start_x for next iteration, dt_since_start_x is used for Qn averaging. TS 28 Nov 2018
4870 dt_since_start = dt_since_start + tstep
4871
4872 !============ update DailyStateBlock ===============
4873 dailystateblock(ir, :) = [datetimeline, dailystateline]
4874
4875 !============ write out results ===============
4876 ! works at each timestep
4877 CALL suews_update_output( &
4878 snowuse, storageheatmethod, & !input
4879 len_sim, 1, &
4880 ir, gridiv_x, datetimeline, dataoutlinesuews, dataoutlinesnow, dataoutlineestm, & !input
4881 dataoutlinersl, dataoutlinebeers, dataoutlinedebug, dataoutlinespartacus, dataoutlineestmext, & !input
4882 dataoutblocksuews_x, dataoutblocksnow_x, dataoutblockestm_x, & !
4883 dataoutblockrsl_x, dataoutblockbeers_x, dataoutblockdebug_x, dataoutblockspartacus_x, dataoutblockestmext_x) !inout
4884
4885 END DO
4886
4887 dataoutblocksuews = dataoutblocksuews_x(:, :, 1)
4888 dataoutblocksnow = dataoutblocksnow_x(:, :, 1)
4889 dataoutblockestm = dataoutblockestm_x(:, :, 1)
4890 dataoutblockestmext = dataoutblockestmext_x(:, :, 1)
4891 dataoutblockrsl = dataoutblockrsl_x(:, :, 1)
4892 dataoutblockbeers = dataoutblockbeers_x(:, :, 1)
4893 dataoutblockdebug = dataoutblockdebug_x(:, :, 1)
4894 dataoutblockspartacus = dataoutblockspartacus_x(:, :, 1)
4895 ! DailyStateBlock=DailyStateBlock_X(:,:,1)
4896
4897 END SUBROUTINE suews_cal_multitsteps
4898
4899 ! a wrapper of NARP_cal_SunPosition used by supy
4901 year, idectime, UTC, locationlatitude, locationlongitude, locationaltitude, & !input
4902 sunazimuth, sunzenith) !output
4903 IMPLICIT NONE
4904
4905 REAL(KIND(1D0)), INTENT(in) :: year, idectime, UTC, &
4906 locationlatitude, locationlongitude, locationaltitude
4907 REAL(KIND(1D0)), INTENT(out) :: sunazimuth, sunzenith
4908
4909 CALL narp_cal_sunposition( &
4910 year, idectime, utc, locationlatitude, locationlongitude, locationaltitude, &
4911 sunazimuth, sunzenith)
4912
4913 END SUBROUTINE suews_cal_sunposition
4914
4915 ! function func(arg) result(retval)
4916 ! implicit none
4917 ! type :: arg
4918 ! type :: retval
4919
4920 ! end function func
4921
4922 FUNCTION cal_tair_av(tair_av_prev, dt_since_start, tstep, temp_c) RESULT(tair_av_next)
4923 ! calculate mean air temperature of past 24 hours
4924 ! TS, 17 Sep 2019
4925 IMPLICIT NONE
4926 REAL(kind(1d0)), INTENT(in) :: tair_av_prev
4927 REAL(kind(1d0)), INTENT(in) :: temp_c
4928 INTEGER, INTENT(in) :: dt_since_start
4929 INTEGER, INTENT(in) :: tstep
4930
4931 REAL(kind(1d0)) :: tair_av_next
4932
4933 REAL(kind(1d0)), PARAMETER :: len_day_s = 24*3600 ! day length in seconds
4934 REAL(kind(1d0)) :: len_cal_s ! length of average period in seconds
4935 REAL(kind(1d0)) :: temp_k ! temp in K
4936
4937 ! determine the average period
4938 IF (dt_since_start > len_day_s) THEN
4939 ! if simulation has been running over one day
4940 len_cal_s = len_day_s
4941 ELSE
4942 ! if simulation has been running less than one day
4943 len_cal_s = dt_since_start + tstep
4944 END IF
4945 temp_k = temp_c + 273.15
4946 tair_av_next = tair_av_prev*(len_cal_s - tstep*1.)/len_cal_s + temp_k*tstep/len_cal_s
4947
4948 END FUNCTION cal_tair_av
4949
4950 FUNCTION cal_tsfc(qh, avdens, avcp, RA, temp_c) RESULT(tsfc_C)
4951 ! calculate surface/skin temperature
4952 ! TS, 23 Oct 2019
4953 IMPLICIT NONE
4954 REAL(kind(1d0)), INTENT(in) :: qh ! sensible heat flux [W m-2]
4955 REAL(kind(1d0)), INTENT(in) :: avdens ! air density [kg m-3]
4956 REAL(kind(1d0)), INTENT(in) :: avcp !air heat capacity [J m-3 K-1]
4957 REAL(kind(1d0)), INTENT(in) :: ra !Aerodynamic resistance [s m^-1]
4958 REAL(kind(1d0)), INTENT(in) :: temp_c ! air temperature [C]
4959
4960 REAL(kind(1d0)) :: tsfc_c ! surface temperature [C]
4961
4962 tsfc_c = qh/(avdens*avcp)*ra + temp_c
4963 END FUNCTION cal_tsfc
4964
4965END MODULE suews_driver
integer, parameter bldgsurf
integer, parameter conifsurf
integer, parameter ncolumnsdataoutsuews
integer, parameter ncolumnsdataoutsolweig
integer, parameter ncolumnsdataoutestm
integer, parameter ncolumnsdataoutbeers
integer, parameter nspec
integer, parameter ncolumnsdataoutspartacus
integer, parameter ncolumnsdataoutrsl
integer, parameter ivgrass
integer, parameter ncolumnsdataoutestmext
integer, parameter ncolumnsdataoutsnow
integer, parameter watersurf
integer, parameter grasssurf
integer, parameter nvegsurf
integer, parameter ivdecid
integer, parameter bsoilsurf
integer, parameter ncolumnsdataoutdailystate
integer, parameter nsurf
integer, parameter pavsurf
integer, parameter ndepth
integer, parameter ivconif
integer, parameter decidsurf
integer, parameter ncolumnsdataoutdebug
subroutine anthropogenicemissions(CO2PointSource, EmissionsMethod, it, imin, DLS, DayofWeek_id, EF_umolCO2perJ, FcEF_v_kgkm, EnEF_v_Jkm, TrafficUnits, FrFossilFuel_Heat, FrFossilFuel_NonHeat, MinFCMetab, MaxFCMetab, MinQFMetab, MaxQFMetab, PopDensDaytime, PopDensNighttime, Temp_C, HDD_id, Qf_A, Qf_B, Qf_C, AH_MIN, AH_SLOPE_Heating, AH_SLOPE_Cooling, BaseT_Heating, BaseT_Cooling, TrafficRate, QF0_BEU, QF_SAHP, Fc_anthro, Fc_metab, Fc_traff, Fc_build, Fc_point, AHProf_24hr, HumActivity_24hr, TraffProf_24hr, PopProf_24hr, SurfaceArea)
AnOHM: Analytical Objective Hysteresis Model.
subroutine anohm(tstep, dt_since_start, qn1, qn_av_prev, dqndt_prev, qf, MetForcingData_grid, moist_surf, alb, emis, cpAnOHM, kkAnOHM, chAnOHM, sfr_surf, nsurf, EmissionsMethod, id, Gridiv, qn_av_next, dqndt_next, a1, a2, a3, qs, deltaQi)
High level wrapper for AnOHM calculation.
subroutine cal_atmmoist(Temp_C, Press_hPa, avRh, dectime, lv_J_kg, lvS_J_kg, es_hPa, Ea_hPa, VPd_hpa, VPD_Pa, dq, dens_dry, avcp, air_dens)
subroutine cal_stab(StabilityMethod, zzd, z0m, zdm, avU1, Temp_C, QH_init, avdens, avcp, L_MOD, TStar, UStar, zL)
real(kind(1d0)) function stab_psi_heat(StabilityMethod, ZL)
real(kind(1d0)) function stab_psi_mom(StabilityMethod, ZL)
subroutine suews_cal_tstep(tstep, nsh, nsh_real, tstep_real)
subroutine suews_cal_weekday(iy, id, lat, dayofWeek_id)
subroutine suews_cal_dls(id, startDLS, endDLS, DLS)
subroutine beers_cal_main(iy, id, dectime, lamdaP, lamdaF, avkdn, ldown, Temp_C, avrh, Press_hPa, Tsurf, lat, lng, alt, timezone, zenith_deg, azimuth, alb_ground, alb_bldg, emis_ground, emis_wall, dataOutLineBEERS)
subroutine suews_cal_dectime(id, it, imin, isec, dectime)
subroutine co2_biogen(alpha_bioCO2, alpha_enh_bioCO2, avkdn, beta_bioCO2, beta_enh_bioCO2, BSoilSurf, ConifSurf, DecidSurf, dectime, EmissionsMethod, gfunc, gfunc2, GrassSurf, gsmodel, id, it, ivConif, ivDecid, ivGrass, LAI_id, LAIMin, LAIMax, min_res_bioCO2, nsurf, NVegSurf, resp_a, resp_b, sfr_surf, SnowFrac, t2, Temp_C, theta_bioCO2, Fc_biogen, Fc_photo, Fc_respi)
type(varattr), dimension(1200) varlistall
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, BaseTMethod, WaterUseMethod, Ie_start, Ie_end, LAICalcYes, LAIType, nsh_real, avkdn, Temp_C, Precip, BaseT_HC, BaseT_Heating, BaseT_Cooling, 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, state_id, soilstore_id, SoilStoreCap, H_maintain, 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)
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 suews_update_dailystate(id, datetimeline, Gridiv, NumberOfGrids, DailyStateLine, dataOutDailyState)
subroutine estm(Gridiv, tstep, avkdn, avu1, temp_c, zenith_deg, avrh, press_hpa, ldown, bldgh, Ts5mindata_ir, Tair_av, dataOutLineESTM, QS)
subroutine estm_ext(tstep, nlayer, QG_surf, qg_roof, qg_wall, tsfc_roof, tin_roof, temp_in_roof, k_roof, cp_roof, dz_roof, sfr_roof, tsfc_wall, tin_wall, temp_in_wall, k_wall, cp_wall, dz_wall, sfr_wall, tsfc_surf, tin_surf, temp_in_surf, k_surf, cp_surf, dz_surf, sfr_surf, temp_out_roof, QS_roof, temp_out_wall, QS_wall, temp_out_surf, QS_surf, QS)
subroutine cal_evap_multi(EvapMethod, sfr_multi, state_multi, WetThresh_multi, capStore_multi, vpd_hPa, avdens, avcp, qn_e_multi, s_hPa, psyc_hPa, RS, RA, RB, tlv, RSS_multi, ev_multi, qe_multi)
subroutine lumps_cal_qhqe(veg_type, SnowUse, qn1, qf, qs, Temp_C, VegFraction, avcp, Press_hPa, lv_J_kg, tstep_real, DRAINRT, nsh_real, Precip, RainMaxRes, RAINCOVER, sfr_surf, LAI_id_prev, LAImax, LAImin, QH_LUMPS, QE_LUMPS, psyc_hPa, s_hPa, sIce_hpa, Veg_Fr_temp, VegPhenLumps)
real(kind(1d0)) function rh2qa(RH_dec, pres_hPa, Ta_degC)
real(kind(1d0)) function qsatf(T, PMB)
real(kind(1d0)) function qa2rh(qa_gkg, pres_hPa, Ta_degC)
real(kind(1d0)) avcp
real(kind(1d0)) avdens
real(kind(1d0)) lv_j_kg
subroutine radmethod(NetRadiationMethod, SnowUse, NetRadiationMethod_use, AlbedoChoice, ldown_option)
subroutine narp(storageheatmethod, nsurf, sfr_surf, tsfc_surf, SnowFrac, alb, emis, IceFrac, NARP_TRANS_SITE, NARP_EMIS_SNOW, DTIME, ZENITH_deg, tsurf_0, kdown, Temp_C, RH, Press_hPa, qn1_obs, ldown_obs, SnowAlb, AlbedoChoice, ldown_option, NetRadiationMethod_use, DiagQN, qn_surf, QSTARall, QSTAR_SF, QSTAR_S, kclear, KUPall, LDOWN, LUPall, fcld, TSURFall, qn1_ind_snow, kup_ind_snow, Tsurf_ind_snow, Tsurf_surf, albedo_snowfree, albedo_snow)
subroutine narp_cal_sunposition(year, idectime, UTC, locationlatitude, locationlongitude, locationaltitude, sunazimuth, sunzenith)
subroutine surfaceresistance(id, it, SMDMethod, SnowFrac, sfr_surf, avkdn, Temp_C, dq, xsmd, vsmd, MaxConductance, LAIMax, LAI_id, gsModel, Kmax, G1, G2, G3, G4, G5, G6, TH, TL, S1, S2, gfunc, gsc, ResistSurf)
subroutine suews_cal_roughnessparameters(RoughLenMomMethod, sfr_surf, bldgH, EveTreeH, DecTreeH, porosity_dectr, FAIBldg, FAIEveTree, FAIDecTree, z0m_in, zdm_in, Z, FAI, PAI, Zh, z0m, zdm, ZZD)
subroutine aerodynamicresistance(ZZD, z0m, AVU1, L_mod, UStar, VegFraction, AerodynamicResistanceMethod, StabilityMethod, RoughLenHeatMethod, RA_h, z0V)
subroutine boundarylayerresistance(zzd, z0m, avU1, UStar, rb)
real(kind(1d0)) function cal_z0v(RoughLenHeatMethod, z0m, VegFraction, UStar)
subroutine rslprofile(DiagMethod, Zh, z0m, zdm, z0v, L_MOD, sfr_surf, FAI, PAI, StabilityMethod, RA_h, avcp, lv_J_kg, avdens, avU1, Temp_C, avRH, Press_hPa, zMeas, qh, qe, T2_C, q2_gkg, U10_ms, RH2, dataoutLineRSL)
subroutine snowupdate(tstep, Temp_C, tau_a, tau_f, tau_r, SnowDensMax, SnowDensMin, SnowAlbMax, SnowAlbMin, SnowPack_prev, SnowAlb_prev, SnowDens_prev, SnowAlb_next, SnowDens_next)
subroutine snowcalc(tstep, imin, it, dectime, is, snowCalcSwitch, EvapMethod, CRWmin, CRWmax, nsh_real, lvS_J_kg, avdens, avRh, Press_hPa, Temp_C, RAsnow, psyc_hPa, avcp, sIce_hPa, PervFraction, vegfraction, addimpervious, vpd_hPa, qn_e, s_hPa, ResistSurf, RA, rb, tlv, snowdensmin, SnowProf_24hr, precip, PipeCapacity, RunoffToWater, addVeg, SnowLimPaved, SnowLimBldg, FlowChange, drain, WetThresh, stateOld, mw_ind, SoilStoreCap, rainonsnow, freezmelt, freezstate, freezstatevol, Qm_Melt, Qm_rain, Tsurf_ind, sfr_surf, dayofWeek_id, StoreDrainPrm, SnowPackLimit, AddWater, addwaterrunoff, soilstore_id, SnowPack, SurplusEvap, SnowFrac, SnowWater, iceFrac, SnowDens, runoffAGimpervious, runoffAGveg, surplusWaterBody, ev_tot, qe_tot, runoff_tot, surf_chang_tot, chSnow_tot, rss_surf, runoff_snowfree, chang, changSnow, SnowToSurf, state_id, ev_snow, SnowRemoval, swe, runoffPipes, mwstore, runoffwaterbody)
real(kind(1d0)) function, dimension(nsurf) update_snow_dens(tstep, SnowPack_prev, SnowDens_prev, tau_r, SnowDensMax, SnowDensMin)
real(kind(1d0)) function update_snow_albedo(tstep, SnowPack_prev, SnowAlb_prev, Temp_C, tau_a, tau_f, SnowAlbMax, SnowAlbMin)
subroutine meltheat(lvS_J_kg, lv_J_kg, tstep_real, RadMeltFact, TempMeltFact, SnowAlbMax, SnowDensMin, Temp_C, Precip, PrecipLimit, PrecipLimitAlb, nsh_real, sfr_surf, Tsurf_ind, state_id, qn1_ind_snow, SnowWater, deltaQi, SnowPack, SnowFrac, SnowAlb, SnowDens, SnowfallCum, mwh, fwh, Qm, QmFreez, QmRain, snowCalcSwitch, Qm_melt, Qm_freezState, Qm_rain, FreezMelt, FreezState, FreezStateVol, rainOnSnow, SnowDepth, mw_ind)
subroutine solweig_cal_main(id, it, dectime, lamdaP, lamdaF, avkdn, ldown, Temp_C, avrh, Press_hPa, Tg, lat, zenith_deg, azimuth, scale, alb_ground, alb_bldg, emis_ground, emis_wall, heightgravity, dataOutLineSOLWEIG)
subroutine spartacus(DiagQN, sfr_surf, zenith_deg, nlayer, tsfc_surf, tsfc_roof, tsfc_wall, kdown, ldown, Tair_C, alb_surf, emis_surf, LAI_id, n_vegetation_region_urban, n_stream_sw_urban, n_stream_lw_urban, sw_dn_direct_frac, air_ext_sw, air_ssa_sw, veg_ssa_sw, air_ext_lw, air_ssa_lw, veg_ssa_lw, veg_fsd_const, veg_contact_fraction_const, ground_albedo_dir_mult_fact, use_sw_direct_albedo, height, building_frac, veg_frac, sfr_roof, sfr_wall, building_scale, veg_scale, alb_roof, emis_roof, alb_wall, emis_wall, roof_albedo_dir_mult_fact, wall_specular_frac, qn, kup, lup, qn_roof, qn_wall, qn_surf, dataOutLineSPARTACUS)
real(kind(1d0)) function cal_tsfc(qh, avdens, avcp, RA, temp_c)
subroutine estmext_update_outputline(iy, id, it, imin, dectime, nlayer, tsfc_out_surf, qs_surf, tsfc_out_roof, Qn_roof, QS_roof, QE_roof, QH_roof, state_roof, soilstore_roof, tsfc_out_wall, Qn_wall, QS_wall, QE_wall, QH_wall, state_wall, soilstore_wall, datetimeLine, dataOutLineESTMExt)
subroutine suews_cal_snow(Diagnose, nlayer, tstep, imin, it, EvapMethod, dayofWeek_id, CRWmin, CRWmax, dectime, avdens, avcp, lv_J_kg, lvS_J_kg, avRh, Press_hPa, Temp_C, RAsnow, psyc_hPa, sIce_hPa, tau_r, RadMeltFact, TempMeltFact, SnowAlbMax, PrecipLimit, PrecipLimitAlb, qn_ind_snow, kup_ind_snow, deltaQi, Tsurf_ind_snow, SnowAlb_in, PervFraction, vegfraction, addimpervious, qn_snowfree, qf, qs, vpd_hPa, s_hPa, RS, RA, RB, SnowDensMax, SnowDensMin, precip, PipeCapacity, RunoffToWater, addVeg, SnowLimPaved, SnowLimBldg, FlowChange, drain, WetThresh_surf, SoilStoreCap, Tsurf_ind, sfr_surf, AddWater, addwaterrunoff, StoreDrainPrm, SnowPackLimit, SnowProf_24hr, SnowPack_in, SnowFrac_in, SnowWater_in, iceFrac_in, SnowDens_in, SnowfallCum_in, state_id_in, soilstore_id_in, qn_surf, qs_surf, SnowRemoval, SnowPack_out, SnowFrac_out, SnowWater_out, iceFrac_out, SnowDens_out, SnowfallCum_out, state_id_out, soilstore_id_out, state_per_tstep, NWstate_per_tstep, qe, qe_surf, qe_roof, qe_wall, SnowAlb_out, swe, chSnow_per_tstep, ev_per_tstep, runoff_per_tstep, surf_chang_per_tstep, runoffPipes, mwstore, runoffwaterbody, runoffAGveg, runoffAGimpervious, rss_surf, dataOutLineSnow)
subroutine output_name_n(i, name, group, aggreg, outlevel)
subroutine suews_cal_resistance(StabilityMethod, Diagnose, AerodynamicResistanceMethod, RoughLenHeatMethod, SnowUse, id, it, gsModel, SMDMethod, avdens, avcp, QH_init, zzd, z0m, zdm, avU1, Temp_C, VegFraction, avkdn, Kmax, G1, G2, G3, G4, G5, G6, S1, S2, TH, TL, dq, xsmd, vsmd, MaxConductance, LAIMax, LAI_id, SnowFrac, sfr_surf, UStar, TStar, L_mod, zL, gsc, RS, RA, RASnow, RB, z0v, z0vSnow)
subroutine suews_update_output(SnowUse, storageheatmethod, ReadLinesMetdata, NumberOfGrids, ir, gridiv, datetimeLine, dataOutLineSUEWS, dataOutLineSnow, dataOutLineESTM, dataoutLineRSL, dataOutLineBEERS, dataoutlineDebug, dataoutlineSPARTACUS, dataOutLineESTMExt, dataOutSUEWS, dataOutSnow, dataOutESTM, dataOutRSL, dataOutBEERS, dataOutDebug, dataOutSPARTACUS, dataOutESTMExt)
elemental real(kind(1d0)) function set_nan(x)
real(kind(1d0)) function square(x)
subroutine suews_cal_qs(StorageHeatMethod, qs_obs, OHMIncQF, Gridiv, id, tstep, dt_since_start, Diagnose, nlayer, QG_surf, QG_roof, QG_wall, tsfc_roof, tin_roof, temp_in_roof, k_roof, cp_roof, dz_roof, sfr_roof, tsfc_wall, tin_wall, temp_in_wall, k_wall, cp_wall, dz_wall, sfr_wall, tsfc_surf, tin_surf, temp_in_surf, k_surf, cp_surf, dz_surf, sfr_surf, OHM_coef, OHM_threshSW, OHM_threshWD, soilstore_id, SoilStoreCap, state_id, SnowUse, SnowFrac, DiagQS, HDD_id, MetForcingData_grid, Ts5mindata_ir, qf, qn, avkdn, avu1, temp_c, zenith_deg, avrh, press_hpa, ldown, bldgh, alb, emis, cpAnOHM, kkAnOHM, chAnOHM, EmissionsMethod, Tair_av, qn_av_prev, dqndt_prev, qn_s_av_prev, dqnsdt_prev, StoreDrainPrm, qn_S, dataOutLineESTM, qs, qn_av_next, dqndt_next, qn_s_av_next, dqnsdt_next, deltaQi, a1, a2, a3, temp_out_roof, QS_roof, temp_out_wall, QS_wall, temp_out_surf, QS_surf)
subroutine suews_init_qh(avdens, avcp, h_mod, qn1, dectime, H_init)
subroutine suews_cal_qn(storageheatmethod, NetRadiationMethod, SnowUse, tstep, nlayer, SnowPack_prev, tau_a, tau_f, SnowAlbMax, SnowAlbMin, Diagnose, ldown_obs, fcld_obs, dectime, ZENITH_deg, Tsurf_0, kdown, Tair_C, avRH, ea_hPa, qn1_obs, SnowAlb_prev, snowFrac_prev, DiagQN, NARP_TRANS_SITE, NARP_EMIS_SNOW, IceFrac, sfr_surf, sfr_roof, sfr_wall, tsfc_surf, tsfc_roof, tsfc_wall, emis, alb_prev, albDecTr_id, albEveTr_id, albGrass_id, LAI_id, n_vegetation_region_urban, n_stream_sw_urban, n_stream_lw_urban, sw_dn_direct_frac, air_ext_sw, air_ssa_sw, veg_ssa_sw, air_ext_lw, air_ssa_lw, veg_ssa_lw, veg_fsd_const, veg_contact_fraction_const, ground_albedo_dir_mult_fact, use_sw_direct_albedo, height, building_frac, veg_frac, building_scale, veg_scale, alb_roof, emis_roof, alb_wall, emis_wall, roof_albedo_dir_mult_fact, wall_specular_frac, alb_next, ldown, fcld, qn_surf, qn_roof, qn_wall, qn, qn_snowfree, qn_snow, kclear, kup, lup, tsurf, qn_ind_snow, kup_ind_snow, Tsurf_ind_snow, Tsurf_ind, albedo_snow, SnowAlb_next, dataOutLineSPARTACUS)
subroutine suews_cal_water(Diagnose, SnowUse, NonWaterFraction, addPipes, addImpervious, addVeg, addWaterBody, state_id, sfr_surf, StoreDrainPrm, WaterDist, nsh_real, drain_per_tstep, drain, frac_water2runoff, AdditionalWater, runoffPipes, runoff_per_interval, AddWater)
subroutine suews_cal_anthropogenicemission(AH_MIN, AHProf_24hr, AH_SLOPE_Cooling, AH_SLOPE_Heating, CO2PointSource, dayofWeek_id, DLS, EF_umolCO2perJ, EmissionsMethod, EnEF_v_Jkm, FcEF_v_kgkm, FrFossilFuel_Heat, FrFossilFuel_NonHeat, HDD_id, HumActivity_24hr, imin, it, MaxFCMetab, MaxQFMetab, MinFCMetab, MinQFMetab, PopDensDaytime, PopDensNighttime, PopProf_24hr, QF, QF0_BEU, Qf_A, Qf_B, Qf_C, QF_obs, QF_SAHP, SurfaceArea, BaseT_Cooling, BaseT_Heating, Temp_C, TrafficRate, TrafficUnits, TraffProf_24hr, Fc_anthro, Fc_build, Fc_metab, Fc_point, Fc_traff)
subroutine suews_cal_multitsteps(MetForcingBlock, len_sim, AerodynamicResistanceMethod, AH_MIN, AHProf_24hr, AH_SLOPE_Cooling, AH_SLOPE_Heating, alb, AlbMax_DecTr, AlbMax_EveTr, AlbMax_Grass, AlbMin_DecTr, AlbMin_EveTr, AlbMin_Grass, alpha_bioCO2, alpha_enh_bioCO2, alt, BaseT, BaseTe, BaseTMethod, BaseT_HC, beta_bioCO2, beta_enh_bioCO2, bldgH, CapMax_dec, CapMin_dec, chAnOHM, CO2PointSource, cpAnOHM, CRWmax, CRWmin, DayWat, DayWatPer, DecTreeH, DiagMethod, Diagnose, DiagQN, DiagQS, DRAINRT, dt_since_start, dqndt, qn_av, dqnsdt, qn_s_av, EF_umolCO2perJ, emis, EmissionsMethod, EnEF_v_Jkm, endDLS, EveTreeH, FAIBldg, FAIDecTree, FAIEveTree, Faut, FcEF_v_kgkm, FlowChange, FrFossilFuel_Heat, FrFossilFuel_NonHeat, G1, G2, G3, G4, G5, G6, GDD_id, GDDFull, Gridiv, gsModel, H_maintain, HDD_id, HumActivity_24hr, IceFrac, Ie_a, Ie_end, Ie_m, Ie_start, InternalWaterUse_h, IrrFracPaved, IrrFracBldgs, IrrFracEveTr, IrrFracDecTr, IrrFracGrass, IrrFracBSoil, IrrFracWater, EvapMethod, kkAnOHM, Kmax, LAI_id, LAICalcYes, LAIMax, LAIMin, LAIPower, LAIType, lat, lng, MaxConductance, MaxFCMetab, MaxQFMetab, SnowWater, MinFCMetab, MinQFMetab, min_res_bioCO2, NARP_EMIS_SNOW, NARP_TRANS_SITE, NetRadiationMethod, OHM_coef, OHMIncQF, OHM_threshSW, OHM_threshWD, PipeCapacity, PopDensDaytime, PopDensNighttime, PopProf_24hr, PorMax_dec, PorMin_dec, PrecipLimit, PrecipLimitAlb, QF0_BEU, Qf_A, Qf_B, Qf_C, nlayer, n_vegetation_region_urban, n_stream_sw_urban, n_stream_lw_urban, sw_dn_direct_frac, air_ext_sw, air_ssa_sw, veg_ssa_sw, air_ext_lw, air_ssa_lw, veg_ssa_lw, veg_fsd_const, veg_contact_fraction_const, ground_albedo_dir_mult_fact, use_sw_direct_albedo, height, building_frac, veg_frac, building_scale, veg_scale, alb_roof, emis_roof, alb_wall, emis_wall, roof_albedo_dir_mult_fact, wall_specular_frac, RadMeltFact, RAINCOVER, RainMaxRes, resp_a, resp_b, RoughLenHeatMethod, RoughLenMomMethod, RunoffToWater, S1, S2, SatHydraulicConduct, SDDFull, SDD_id, SMDMethod, SnowAlb, SnowAlbMax, SnowAlbMin, SnowPackLimit, SnowDens, SnowDensMax, SnowDensMin, SnowfallCum, SnowFrac, SnowLimBldg, SnowLimPaved, SnowPack, SnowProf_24hr, SnowUse, SoilDepth, StabilityMethod, startDLS, soilstore_surf, SoilStoreCap_surf, state_surf, StateLimit_surf, WetThresh_surf, soilstore_roof, SoilStoreCap_roof, state_roof, StateLimit_roof, WetThresh_roof, soilstore_wall, SoilStoreCap_wall, state_wall, StateLimit_wall, WetThresh_wall, StorageHeatMethod, StoreDrainPrm, SurfaceArea, Tair_av, tau_a, tau_f, tau_r, BaseT_Cooling, BaseT_Heating, TempMeltFact, TH, theta_bioCO2, timezone, TL, TrafficRate, TrafficUnits, sfr_surf, tsfc_roof, tsfc_wall, tsfc_surf, temp_roof, temp_wall, temp_surf, tin_roof, tin_wall, tin_surf, k_wall, k_roof, k_surf, cp_wall, cp_roof, cp_surf, dz_wall, dz_roof, dz_surf, Tmin_id, Tmax_id, lenday_id, TraffProf_24hr, Ts5mindata_ir, tstep, tstep_prev, veg_type, WaterDist, WaterUseMethod, WUDay_id, DecidCap_id, albDecTr_id, albEveTr_id, albGrass_id, porosity_id, WUProfA_24hr, WUProfM_24hr, Z, z0m_in, zdm_in, dataOutBlockSUEWS, dataOutBlockSnow, dataOutBlockESTM, dataOutBlockRSL, dataOutBlockBEERS, dataOutBlockDebug, dataOutBlockSPARTACUS, dataOutBlockESTMExt, DailyStateBlock)
subroutine output_size(nVar)
subroutine suews_cal_qh(QHMethod, nlayer, storageheatmethod, qn, qf, QmRain, qe, qs, QmFreez, qm, avdens, avcp, sfr_surf, sfr_roof, sfr_wall, tsfc_surf, tsfc_roof, tsfc_wall, Temp_C, RA, qh, qh_residual, qh_resist, qh_resist_surf, qh_resist_roof, qh_resist_wall)
subroutine suews_cal_main(AerodynamicResistanceMethod, AH_MIN, AHProf_24hr, AH_SLOPE_Cooling, AH_SLOPE_Heating, alb, AlbMax_DecTr, AlbMax_EveTr, AlbMax_Grass, AlbMin_DecTr, AlbMin_EveTr, AlbMin_Grass, alpha_bioCO2, alpha_enh_bioCO2, alt, kdown, avRh, avU1, BaseT, BaseTe, BaseTMethod, BaseT_HC, beta_bioCO2, beta_enh_bioCO2, bldgH, CapMax_dec, CapMin_dec, chAnOHM, CO2PointSource, cpAnOHM, CRWmax, CRWmin, DayWat, DayWatPer, DecTreeH, DiagMethod, Diagnose, DiagQN, DiagQS, DRAINRT, dt_since_start, dqndt, qn_av, dqnsdt, qn_s_av, EF_umolCO2perJ, emis, EmissionsMethod, EnEF_v_Jkm, endDLS, EveTreeH, FAIBldg, FAIDecTree, FAIEveTree, Faut, FcEF_v_kgkm, fcld_obs, FlowChange, FrFossilFuel_Heat, FrFossilFuel_NonHeat, G1, G2, G3, G4, G5, G6, GDD_id, GDDFull, Gridiv, gsModel, H_maintain, HDD_id, HumActivity_24hr, IceFrac, id, Ie_a, Ie_end, Ie_m, Ie_start, imin, InternalWaterUse_h, IrrFracPaved, IrrFracBldgs, IrrFracEveTr, IrrFracDecTr, IrrFracGrass, IrrFracBSoil, IrrFracWater, isec, it, EvapMethod, iy, kkAnOHM, Kmax, LAI_id, LAICalcYes, LAIMax, LAIMin, LAI_obs, LAIPower, LAIType, lat, lenDay_id, ldown_obs, lng, MaxConductance, MaxFCMetab, MaxQFMetab, SnowWater, MetForcingData_grid, MinFCMetab, MinQFMetab, min_res_bioCO2, NARP_EMIS_SNOW, NARP_TRANS_SITE, NetRadiationMethod, nlayer, n_vegetation_region_urban, n_stream_sw_urban, n_stream_lw_urban, sw_dn_direct_frac, air_ext_sw, air_ssa_sw, veg_ssa_sw, air_ext_lw, air_ssa_lw, veg_ssa_lw, veg_fsd_const, veg_contact_fraction_const, ground_albedo_dir_mult_fact, use_sw_direct_albedo, height, building_frac, veg_frac, building_scale, veg_scale, alb_roof, emis_roof, alb_wall, emis_wall, roof_albedo_dir_mult_fact, wall_specular_frac, OHM_coef, OHMIncQF, OHM_threshSW, OHM_threshWD, PipeCapacity, PopDensDaytime, PopDensNighttime, PopProf_24hr, PorMax_dec, PorMin_dec, Precip, PrecipLimit, PrecipLimitAlb, Press_hPa, QF0_BEU, Qf_A, Qf_B, Qf_C, qn1_obs, qs_obs, qf_obs, RadMeltFact, RAINCOVER, RainMaxRes, resp_a, resp_b, RoughLenHeatMethod, RoughLenMomMethod, RunoffToWater, S1, S2, SatHydraulicConduct, SDDFull, SDD_id, SMDMethod, SnowAlb, SnowAlbMax, SnowAlbMin, SnowPackLimit, SnowDens, SnowDensMax, SnowDensMin, SnowfallCum, SnowFrac, SnowLimBldg, SnowLimPaved, snowFrac_obs, SnowPack, SnowProf_24hr, SnowUse, SoilDepth, StabilityMethod, startDLS, soilstore_surf, SoilStoreCap_surf, state_surf, StateLimit_surf, WetThresh_surf, soilstore_roof, SoilStoreCap_roof, state_roof, StateLimit_roof, WetThresh_roof, soilstore_wall, SoilStoreCap_wall, state_wall, StateLimit_wall, WetThresh_wall, StorageHeatMethod, StoreDrainPrm, SurfaceArea, Tair_av, tau_a, tau_f, tau_r, Tmax_id, Tmin_id, BaseT_Cooling, BaseT_Heating, Temp_C, TempMeltFact, TH, theta_bioCO2, timezone, TL, TrafficRate, TrafficUnits, sfr_surf, tsfc_roof, tsfc_wall, tsfc_surf, temp_roof, temp_wall, temp_surf, tin_roof, tin_wall, tin_surf, k_roof, k_wall, k_surf, cp_roof, cp_wall, cp_surf, dz_roof, dz_wall, dz_surf, TraffProf_24hr, Ts5mindata_ir, tstep, tstep_prev, veg_type, WaterDist, WaterUseMethod, wu_m3, WUDay_id, DecidCap_id, albDecTr_id, albEveTr_id, albGrass_id, porosity_id, WUProfA_24hr, WUProfM_24hr, xsmd, Z, z0m_in, zdm_in, datetimeLine, dataOutLineSUEWS, dataOutLineSnow, dataOutLineESTM, dataoutLineRSL, dataOutLineBEERS, dataOutLineDebug, dataOutLineSPARTACUS, dataOutLineESTMExt, DailyStateLine)
subroutine suews_update_outputline(AdditionalWater, alb, avkdn, avU10_ms, azimuth, chSnow_per_interval, dectime, drain_per_tstep, E_mod, ev_per_tstep, ext_wu, Fc, Fc_build, fcld, Fc_metab, Fc_photo, Fc_respi, Fc_point, Fc_traff, FlowChange, h_mod, id, imin, int_wu, it, iy, kup, LAI_id, ldown, l_mod, lup, mwh, MwStore, nsh_real, NWstate_per_tstep, Precip, q2_gkg, qeOut, qf, qh, qh_resist, Qm, QmFreez, QmRain, qn, qn_snow, qn_snowfree, qs, RA, resistsurf, RH2, runoffAGimpervious, runoffAGveg, runoff_per_tstep, runoffPipes, runoffSoil_per_tstep, runoffWaterBody, sfr_surf, smd, smd_nsurf, SnowAlb, SnowRemoval, state_id, state_per_tstep, surf_chang_per_tstep, swe, t2_C, tskin_C, tot_chang_per_tstep, tsurf, UStar, wu_nsurf, z0m, zdm, zenith_deg, datetimeLine, dataOutLineSUEWS)
subroutine suews_cal_sunposition(year, idectime, UTC, locationlatitude, locationlongitude, locationaltitude, sunazimuth, sunzenith)
real function square_real(x)
subroutine suews_cal_qe(Diagnose, storageheatmethod, nlayer, tstep, EvapMethod, avdens, avcp, lv_J_kg, psyc_hPa, PervFraction, addimpervious, qf, vpd_hPa, s_hPa, RS, RA_h, RB, precip, PipeCapacity, RunoffToWater, NonWaterFraction, WU_surf, addVeg, addWaterBody, AddWater_surf, FlowChange, drain_surf, frac_water2runoff_surf, StoreDrainPrm, sfr_surf, StateLimit_surf, SoilStoreCap_surf, WetThresh_surf, state_surf_in, soilstore_surf_in, qn_surf, qs_surf, sfr_roof, StateLimit_roof, SoilStoreCap_roof, WetThresh_roof, state_roof_in, soilstore_roof_in, qn_roof, qs_roof, sfr_wall, StateLimit_wall, SoilStoreCap_wall, WetThresh_wall, state_wall_in, soilstore_wall_in, qn_wall, qs_wall, state_surf_out, soilstore_surf_out, ev_surf, state_roof_out, soilstore_roof_out, ev_roof, state_wall_out, soilstore_wall_out, ev_wall, state_grid, NWstate_grid, ev0_surf, qe0_surf, qe, qe_surf, qe_roof, qe_wall, ev_grid, runoff_grid, surf_chang_grid, runoffPipes_grid, runoffWaterBody_grid, runoffAGveg_grid, runoffAGimpervious_grid, rss_surf)
real(kind(1d0)) function, dimension(n_fill) fill_result(res_valid, n_fill)
real(kind(1d0)) function cal_tair_av(tair_av_prev, dt_since_start, tstep, temp_c)
subroutine suews_cal_biogenco2(alpha_bioCO2, alpha_enh_bioCO2, avkdn, avRh, beta_bioCO2, beta_enh_bioCO2, dectime, Diagnose, EmissionsMethod, Fc_anthro, G1, G2, G3, G4, G5, G6, gfunc, gsmodel, id, it, Kmax, LAI_id, LAIMin, LAIMax, MaxConductance, min_res_bioCO2, Press_hPa, resp_a, resp_b, S1, S2, sfr_surf, SMDMethod, SnowFrac, t2_C, Temp_C, theta_bioCO2, TH, TL, vsmd, xsmd, Fc, Fc_biogen, Fc_photo, Fc_respi)
subroutine suews_cal_surf(StorageHeatMethod, NetRadiationMethod, nlayer, sfr_surf, building_frac, building_scale, height, vegfraction, ImpervFraction, PervFraction, NonWaterFraction, sfr_roof, sfr_wall)
character(len=90) git_commit
character(len=90) compiler_ver
subroutine cal_water_storage_surf(pin, nsh_real, PipeCapacity, RunoffToWater, addImpervious, addVeg, addWaterBody, FlowChange, SoilStoreCap_surf, StateLimit_surf, PervFraction, sfr_surf, drain_surf, AddWater_surf, frac_water2runoff_surf, WU_surf, ev_surf_in, state_surf_in, soilstore_surf_in, ev_surf_out, state_surf_out, soilstore_surf_out, runoff_surf, runoffAGimpervious_grid, runoffAGveg_grid, runoffPipes_grid, runoffWaterBody_grid)
subroutine suews_update_soilmoist(NonWaterFraction, SoilStoreCap, sfr_surf, soilstore_id, SoilMoistCap, SoilState, vsmd, smd)
subroutine suews_cal_soilstate(SMDMethod, xsmd, NonWaterFraction, SoilMoistCap, SoilStoreCap, surf_chang_per_tstep, soilstore_id, soilstoreOld, sfr_surf, smd, smd_nsurf, tot_chang_per_tstep, SoilState)
subroutine drainage(is, state_is, StorCap, DrainEq, DrainCoef1, DrainCoef2, nsh_real, drain_is)
subroutine redistributewater(SnowUse, WaterDist, sfr_surf, Drain, AddWaterRunoff, AddWater)
subroutine cal_water_storage_building(pin, nsh_real, nlayer, sfr_roof, StateLimit_roof, SoilStoreCap_roof, WetThresh_roof, ev_roof_in, state_roof_in, soilstore_roof_in, sfr_wall, StateLimit_wall, SoilStoreCap_wall, WetThresh_wall, ev_wall_in, state_wall_in, soilstore_wall_in, ev_roof_out, state_roof_out, soilstore_roof_out, runoff_roof, ev_wall_out, state_wall_out, soilstore_wall_out, runoff_wall, state_building, soilstore_building, runoff_building, SoilStoreCap_building)
subroutine suews_cal_horizontalsoilwater(sfr_surf, SoilStoreCap, SoilDepth, SatHydraulicConduct, SurfaceArea, NonWaterFraction, tstep_real, soilstore_id, runoffSoil, runoffSoil_per_tstep)
subroutine suews_cal_wateruse(nsh_real, wu_m3, SurfaceArea, sfr_surf, IrrFracPaved, IrrFracBldgs, IrrFracEveTr, IrrFracDecTr, IrrFracGrass, IrrFracBSoil, IrrFracWater, DayofWeek_id, WUProfA_24hr, WUProfM_24hr, InternalWaterUse_h, HDD_id, WUDay_id, WaterUseMethod, NSH, it, imin, DLS, wu_surf, wu_int, wu_ext)
subroutine errorhint(errh, ProblemFile, VALUE, value2, valueI)
subroutine ohm(qn1, qn_av_prev, dqndt_prev, qn_av_next, dqndt_next, qn1_S, qn_s_av_prev, dqnsdt_prev, qn_s_av_next, dqnsdt_next, tstep, dt_since_start, sfr_surf, nsurf, Tair_mav_5d, OHM_coef, OHM_threshSW, OHM_threshWD, soilstore_id, SoilStoreCap, state_id, BldgSurf, WaterSurf, SnowUse, SnowFrac, DiagQS, a1, a2, a3, qs, deltaQi)