SUEWS API Site
Documentation of SUEWS source code
suews_phys_estm.f95
Go to the documentation of this file.
1MODULE estm_data !S.O. and FO
2
3 ! =======ESTMinput.nml==============================
4 INTEGER :: evolvetibld, &
7
8 REAL(kind(1d0)) :: lbc_soil, & !Lowest boundary condition in soil
9 theat_on, &
10 theat_off, &
11 theat_fix, &
12 ivf_iw, & !Internal view factors : im
13 ivf_ir, &
14 ivf_ii, &
15 ivf_if, &
16 ivf_ww, & !Internal view factors : wall
17 ivf_wr, &
18 ivf_wi, &
19 ivf_wf, &
20 ivf_rw, & !Internal view factors : roof
21 ivf_ri, &
22 ivf_rf, &
23 ivf_fw, & !Internal view factors : floor
24 ivf_fr, &
25 ivf_fi
26
27 !=======ESTMcoefficients.txt=================================
28 INTEGER :: ndepth_ibld, & !Number of layers in an internal element in buildings, calculated when the file is read.
29 ndepth_wall, & !Number of layers in external wall
30 ndepth_roof, & !Number of layers in roof
31 ndepth_ground !Number of layers in ground
32
33 REAL(kind(1d0)), DIMENSION(5) :: zibld, & !Thickness of layers in internal building
34 zwall, & !Thickness of layers in external wall
35 zroof, & !Thickness of layers in roof
36 zground, & !Thickness of layers in ground
37 kibld, & !Thermal conductivity of layers in internal building
38 kwall, & !Thermal conductivity of layers in external wall
39 kroof, & !Thermal conductivity of layers in roof
40 kground, & !Thermal conductivity of layers in ground
41 ribld, & !Volumetric heat capacity of layers in internal building
42 rwall, & !Volumetric heat capacity of layers in external wall
43 rroof, & !Volumetric heat capacity of layers in roof
44 rground !Volumetric heat capacity of layers in ground
45
46 ! Paved and Bldgs surfaces can include 3 and 5 classes respectively
47 !For the 3x Paved surfaces
48 REAL(kind(1d0)), DIMENSION(5, 3) :: zsurf_paved
49 REAL(kind(1d0)), DIMENSION(5, 3) :: ksurf_paved
50 REAL(kind(1d0)), DIMENSION(5, 3) :: rsurf_paved
51 !For the 5x Bldgs surfaces
52 REAL(kind(1d0)), DIMENSION(5, 5) :: zsurf_bldgs
53 REAL(kind(1d0)), DIMENSION(5, 5) :: ksurf_bldgs
54 REAL(kind(1d0)), DIMENSION(5, 5) :: rsurf_bldgs
55 REAL(kind(1d0)), DIMENSION(5, 5) :: zwall_bldgs
56 REAL(kind(1d0)), DIMENSION(5, 5) :: kwall_bldgs
57 REAL(kind(1d0)), DIMENSION(5, 5) :: rwall_bldgs
58 REAL(kind(1d0)), DIMENSION(5, 5) :: zibld_bldgs
59 REAL(kind(1d0)), DIMENSION(5, 5) :: kibld_bldgs
60 REAL(kind(1d0)), DIMENSION(5, 5) :: ribld_bldgs
61 REAL(kind(1d0)), DIMENSION(5) :: nroom_bldgs
62 REAL(kind(1d0)), DIMENSION(5) :: alb_ibld_bldgs
63 REAL(kind(1d0)), DIMENSION(5) :: em_ibld_bldgs
64 REAL(kind(1d0)), DIMENSION(5) :: ch_iwall_bldgs
65 REAL(kind(1d0)), DIMENSION(5) :: ch_iroof_bldgs
66 REAL(kind(1d0)), DIMENSION(5) :: ch_ibld_bldgs
67
68 REAL(kind(1d0)) :: nroom, & !Number of rooms in internal building (changed from integer to real HCW 16 Jun 2016)
69 alb_ibld, & !albedo value of internal elements
70 em_ibld, & !emissivity of internal elements
71 ch_iroof, & !bulk transfer coefficient of internal roof
72 ch_iwall, & !bulk transfer coefficient of internal wall
73 ch_ibld, & !bulk transfer coefficient of internal building element
74 fwall, & !fraction of wall
75 areawall ! Area of wall within grid [m2]
76
77 !=======ESTM Ts input=================================
78 REAL(kind(1d0)), ALLOCATABLE, DIMENSION(:) :: tibld, twall, troof, tground
79 REAL(kind(1d0)), ALLOCATABLE, DIMENSION(:, :) :: tw_4
80
81 REAL(kind(1d0)), ALLOCATABLE, DIMENSION(:, :) :: tibld_grids, twall_grids, troof_grids, tground_grids
82 REAL(kind(1d0)), ALLOCATABLE, DIMENSION(:, :, :) :: tw_4_grids
83
84 !=======variables and parameters created in ESTM=============================
85 REAL(kind(1d0)) :: alb_avg, &
86 alb_ground_estm, & !albedo value of ground
87 alb_roof_estm, & !albedo value of roof
88 alb_veg_estm, & !albedo value of veg
89 chair, &
90 chr, &
91 em_ground_estm, & !emissivity of ground
92 em_roof_estm, & !emissivity of roof
93 em_veg_estm, & !emissivity of veg
94 em_r, & !emissivity of roof inside building
95 em_w, & !emissivity of internal wall
96 em_i, & !QUESTION: emissivity of ?
97 em_f, & !emissivity of floor
98 fair, & !fraction of air (or ratio of outdoor air volume to indoor air volume)
99 fground, & !fraction of ground
100 fibld, & !QUESTION: fraction of internal elements (?)
101 finternal, & !sum of froof, fibld and fwall
102 froof, & !fraction of roof
103 fveg, & !fraction of veg
104 hw, & !Height Width ratio
105 lup_ground, &
106 lup_roof, &
107 lup_veg, &
108 lup_wall, &
110 pcoeff(5), &
111 qsground, & !Storage heat flux into ground
112 qsroof, & !Storage heat flux into roof
113 qswall, & !Storage heat flux into wall
114 qs_4(4), & !Storage heat flux into each external wall (N,E,S and W direction)
115 qsair, & !Storage heat flux into air
116 qsibld, & !Storage heat flux into internal building elements
117 rvf_ground, &
118 rvf_wall, &
119 rvf_roof, &
120 rvf_canyon, &
121 rvf_veg, &
122 shc_air, &
123 svf_ground, & !Sky view factor from ground
124 svf_wall, & !Sky view factor from wall
125 svf_roof, & !Sky view factor from roof
126 tanzenith, & !
127 tair1, &
128 tair2, &
129 tfloor, &
130 tievolve, &
131 tn_roof, &
132 tn_wall, &
133 t0_wall, &
134 t0_roof, &
135 t0_ground, &
136 t0_ibld, &
137 ws, & !Wind speed used in ESTM
138 xvf_wall, &
139 zref, & !local scale reference height
140 zvf_ground, & !wall view factor from ground
141 zvf_wall !wall view factor from ground
142
143 ! Arrays to store variables for each grid
144 REAL(kind(1d0)), DIMENSION(:), ALLOCATABLE :: tair2_grids
145 REAL(kind(1d0)), DIMENSION(:), ALLOCATABLE :: lup_ground_grids
146 REAL(kind(1d0)), DIMENSION(:), ALLOCATABLE :: lup_wall_grids
147 REAL(kind(1d0)), DIMENSION(:), ALLOCATABLE :: lup_roof_grids
148 REAL(kind(1d0)), DIMENSION(:), ALLOCATABLE :: tievolve_grids
149 REAL(kind(1d0)), DIMENSION(:), ALLOCATABLE :: t0_wall_grids
150 REAL(kind(1d0)), DIMENSION(:), ALLOCATABLE :: t0_roof_grids
151 REAL(kind(1d0)), DIMENSION(:), ALLOCATABLE :: t0_ground_grids
152 REAL(kind(1d0)), DIMENSION(:), ALLOCATABLE :: t0_ibld_grids
153 REAL(kind(1d0)), DIMENSION(:), ALLOCATABLE :: tn_roof_grids
154 REAL(kind(1d0)), DIMENSION(:), ALLOCATABLE :: tn_wall_grids
155
156 ! Surface fractions for ESTM classes
157 REAL(kind(1d0)), DIMENSION(3) :: estmsfr_paved
158 REAL(kind(1d0)), DIMENSION(5) :: estmsfr_bldgs
159
160 LOGICAL :: bctype(2), &
161 cflfail = .false., &
162 diagnoseti = .false., &
163 first, &
164 hvac = .false., &
165 spindone = .false.
166
167 REAL(kind(1d0)), PARAMETER :: alb_wall_fix = 0.23, em_wall_fix = 0.9 ! used only when radforce = T but radforce is always set to F.
168 INTEGER, PARAMETER :: maxiter = 100
169 REAL(kind(1d0)), PARAMETER :: conv = 0.0001
170
171 !=============variables maybe will be removed=======================================
172 INTEGER :: nalb, &
173 nemis
174 REAL(kind(1d0)) :: sumalb, &
175 sumemis
176
177END MODULE estm_data
178
179!==============================================================================
181 ! Created on Thu Jan 22 00:06:32 2004
182 IMPLICIT NONE
183
184CONTAINS
185 ELEMENTAL FUNCTION interp1d(x1, x2, y1, y2, xi) RESULT(yi)
186 REAL(kind(1d0)), INTENT(in) :: x1, x2, xi
187 REAL(kind(1d0)), INTENT(in) :: y1, y2
188 REAL(kind(1d0)) :: b0, b1
189 REAL(kind(1d0)) :: yi
190 !integer ::ny !!!!!FO!!!!!
191 b1 = (y2 - y1)/(x2 - x1)
192 b0 = y1 - b1*x1
193 yi = b0 + b1*xi
194 END FUNCTION interp1d
195END MODULE mod_interp
196
197!=============================================================================
199 ! Created on Thu Jan 22 07:50:01 2004
200 ! Copyright (c) 2001 MyCompany. All rights reserved.
201
202 IMPLICIT NONE
203
204CONTAINS
205
206 FUNCTION newtonpolynomial(x0, Pcoeff, conv, maxiter) RESULT(x)
207 !Solves Newton's Method for a polynomial of the form
208 !f(x)=Pcoeff(1)*x^n+Pcoeff(2)*x^n-1+...+Pcoeff(n+1)
209 ! f(x(i))
210 ! x(i+1) = x(i)- -------
211 ! f'(x(i))
212 !
213 !conv is the level required for convergence
214 !maxiter is the maximum allowed iterations
215 !----------------------------------------------------
216 REAL(kind(1d0)) :: x0, x, conv
217 REAL(kind(1d0)) :: pcoeff(:)
218 REAL(kind(1d0)) :: e, xprev
219 REAL(kind(1d0)) :: f, fp
220 INTEGER :: maxiter
221 INTEGER :: niter
222 LOGICAL :: converged = .false.
223 INTEGER :: n, i, j
224
225 e = huge(1.)
226 n = SIZE(pcoeff)
227 x = x0
228 DO i = 1, maxiter
229 IF (abs(e) < conv) THEN
230 converged = .true.
231 EXIT
232 END IF
233 f = 0; fp = 0
234 DO j = 1, n - 1
235 f = f + pcoeff(j)*x**(n - j)
236 fp = fp + pcoeff(j)*(n - j)*x**(n - j - 1) !!FO!! derivative
237 END DO
238
239 f = f + pcoeff(n)
240 xprev = x
241 IF (fp == 0.) fp = tiny(1.)
242 x = xprev - f/fp
243 e = x - xprev
244 END DO
245 niter = i - 1
246 IF (.NOT. converged) THEN
247 print *, "Solution did not converge. Niter=", niter, " Error=", e
248 x = x0
249 END IF
250 END FUNCTION newtonpolynomial
251END MODULE mod_solver
252!==============================================================================
253
254!==============================================================================
256 USE mathconstants
257 IMPLICIT NONE
258
259CONTAINS
260 !=======================================================
261 FUNCTION min_zenith(lat, doy) RESULT(zmin)
262 !returns max zenith
263 !returns zenith in radians for lat, lng in degrees
264 REAL(kind(1d0)) :: lat, dectime, zmin
265 REAL(kind(1d0)) :: latr, decl
266 INTEGER :: doy
267 dectime = float(doy)
268 latr = lat*dtr
269 decl = 0.409*cos(2*pi*(dectime - 173)/365.25)
270 zmin = pi/2.-asin(sin(latr)*sin(decl) - cos(latr)*cos(decl)*(-1))
271 END FUNCTION min_zenith
272 !=======================================================
273
274 !=======================================================
275 FUNCTION local_apparent_time(lng, dectime) RESULT(la_time)
276 !Oke, 1989, equation of time elsewhere
277 REAL(kind(1d0)) :: lng, dectime, la_time
278 REAL(kind(1d0)) :: gamma, eqtime, lmst
279
280 lmst = dectime - 4.*lng/60./1440.
281 gamma = 2.*pi/365.*(lmst - 1.)
282 eqtime = 229.18*(7.5e-5 + 1.868e-3*cos(gamma) - 0.032077*sin(gamma)&
283 & - 0.014615*cos(2.*gamma) - 0.040849*sin(2.*gamma))
284 la_time = lmst + eqtime/1440.
285 END FUNCTION local_apparent_time
286 !=======================================================
287
288 SUBROUTINE solar_angles(lat, lng, timezone, dectime, decl, zenith, azimuth)
289
290 REAL, INTENT(in) :: lat, lng, timezone, dectime
291 INTEGER :: doy, hour, mn
292 REAL(KIND(1D0)), INTENT(out) :: decl, zenith, azimuth
293 REAL(KIND(1D0)) :: ha, latr, eqtime, tst, &
294 time_offset, gamma !!!!!FO!!!!! lngr, phi, theta
295
296 latr = lat*pi/180.
297 doy = floor(dectime)
298 hour = floor((dectime - doy)*24.)
299 mn = floor((dectime - doy - hour/24.)*60.) !!!Check this
300
301 gamma = 2.*pi/365.25463*(doy - 1.+(hour - 12.)/24.)
302 eqtime = 229.18*(7.5e-5 + 1.868e-3*cos(gamma) - 0.032077*sin(gamma)&
303 & - 0.014615*cos(2.*gamma) - 0.040849*sin(2.*gamma))
304 decl = 6.918e-3 - 0.399912*cos(gamma) + 0.070257*sin(gamma)&
305 & - 0.006758*cos(2.*gamma) + 9.07e-4*sin(2.*gamma) - 2.697e-3*cos(3.*gamma)&
306 & + 1.48e-3*sin(3.*gamma)
307 time_offset = eqtime - 4.*lng + 60.*timezone
308 tst = hour*60.+mn + time_offset
309 ha = (tst/4.) - 180.
310 ha = ha*pi/180.
311
312 zenith = acos(sin(latr)*sin(decl) + cos(latr)*cos(decl)*cos(ha))
313 azimuth = pi + acos((sin(latr)*cos(zenith) - sin(decl))/(cos(latr)*sin(zenith)))
314
315 RETURN
316 END SUBROUTINE solar_angles
317
318 !=========================== SolarTimes ==================================
319 SUBROUTINE solar_times(lat, lng, timezone, dectime, sunrise, sunset, snoon)
320 ! for sunrise and sunset ha = ha(zenith=90)
321 ! timezone is offset to GMT e.g. -5 for EST
322
323 REAL(KIND(1D0)), INTENT(in) :: lat, lng, timezone, dectime
324 INTEGER :: doy
325 REAL(KIND(1D0)), INTENT(out) :: sunrise, sunset, snoon
326 REAL(KIND(1D0)) :: ha, latr, eqtime, gamma, zenith, decl
327 latr = lat*dtr
328 zenith = 90.833*dtr
329 doy = floor(dectime)
330 gamma = 2.*pi/365.*(float(doy) - 0.5) !fractional year
331 eqtime = 229.18*(7.5e-5 + 1.868e-3*cos(gamma) - 0.032077*sin(gamma)&
332 & - 0.014615*cos(2.*gamma) - 0.040849*sin(2.*gamma))
333 decl = 6.918e-3 - 0.399912*cos(gamma) + 0.070257*sin(gamma)&
334 & - 0.006758*cos(2.*gamma) + 9.07e-4*sin(2.*gamma) - 2.697e-3*cos(3.*gamma)&
335 & + 1.48e-3*sin(3.*gamma)
336 ha = acos(cos(zenith)/(cos(latr)*cos(decl)) - tan(latr)*tan(decl))
337 ha = ha*rtd
338 sunrise = (720.-4.*(lng - ha) - eqtime)/60.-timezone
339 sunset = (720.-4.*(lng + ha) - eqtime)/60.-timezone
340 snoon = (720.-4.*lng - eqtime)/60.-timezone
341 RETURN
342 END SUBROUTINE solar_times
343 !=======================================================
344 FUNCTION kdown_surface(doy, zenith) RESULT(Isurf)
345 ! Calculates ground level solar irradiance clear sky
346 ! assuming transmissivity = 1
347 ! let it report zero if zenith >= 90
348 REAL(kind(1d0)) :: zenith, isurf
349 INTEGER :: doy
350 REAL(kind(1d0)) :: rmean, rse, cosz, itoa
351
352 rmean = 149.6 !Stull 1998
353 rse = solar_esdist(doy)
354 IF (zenith < pi/2.) THEN
355 cosz = cos(zenith)
356 itoa = 1370*(rmean/rse)**2 !top of the atmosphere
357 isurf = itoa*cosz !ground level solar irradiance in W/m2
358 ELSE
359 isurf = 0.
360 END IF
361
362 END FUNCTION kdown_surface
363
364 !=======================================================
365 ! FUNCTION SmithLambda(lat) RESULT(G)
366 ! !read kriged data based on Smith 1966 (JAM)
367 ! INTEGER :: lat, ios
368 ! REAL, DIMENSION(365) :: G
369
370 ! OPEN (99, file="Smith1966.grd", access="direct", action="read", recl=365*4, iostat=ios)
371 ! IF (ios /= 0) THEN
372 ! PRINT *, "Iostat=", ios, " reading Smith1966.grd"
373 ! STOP
374 ! END IF
375 ! READ (99, rec=lat + 1, iostat=ios) G
376 ! IF (ios /= 0) PRINT *, "Iostat=", ios, " reading Smith1966.grd"
377 ! CLOSE (99)
378 ! END FUNCTION SmithLambda
379 !=======================================================
380 FUNCTION transmissivity_cd(P, Td, G, zenith) RESULT(trans) !!!!!FO!!!!! ,doy
381 ! bulk atmospheric transmissivity (Crawford and Duchon, 1999)
382 ! P = pressure (hPa)
383 ! Td = dewpoint (C)
384 ! G parameter is empirical value from Smith 1966 (JAM)
385 ! zenith in radians
386
387 ! integer ::doy !!!!!FO!!!!!
388 REAL(kind(1d0)) :: p, td, zenith, g, trans
389 REAL(kind(1d0)) :: m, trtpg, u, tw, ta, cosz
390 REAL(kind(1d0)) :: tdf
391
392 IF (zenith > 80.*dtr) THEN
393 cosz = cos(80.*dtr)
394 ELSE
395 cosz = cos(zenith)
396 END IF
397 tdf = td*1.8 + 32. !celsius to fahrenheit
398 ! Transmission coefficients
399 m = 35*cosz/sqrt(1224.*cosz*cosz + 1) !optical air mass at p=1013 mb
400 trtpg = 1.021 - 0.084*sqrt(m*(0.000949*p + 0.051)) !first two trans coeff
401 u = exp(0.113 - log(g + 1) + 0.0393*tdf) !precipitable water
402 tw = 1 - 0.077*(u*m)**0.3 !vapor transmission coe3ff.
403 ta = 0.935**m !4th trans coeff
404 trans = trtpg*tw*ta !bulk atmospherics transmissivity
405 END FUNCTION transmissivity_cd
406
407 ! !=======================================================
408 ! ! NB:this FUNCTION is problematic:
409 ! ! these variables are NEVER initialized/calculated: tr,tg,tw,ta
410 ! ! but used for calcuLAItng Sdir!
411 ! FUNCTION kdown_niemala(S0,vap_press,Tk) RESULT(kdown) !!!!!FO!!!!! ,albedo
412 ! !from Niemala et al. 2001. Atmospheric Research 58:141-154
413 ! ! using generalized formula only, no empirical data from site
414 ! !11 October 2001
415 ! ! S0=base solar insolation at the surface
416 ! ! albedo = surface albedo (required for multireflection diffuse)
417 ! ! vap_press=screen level vapor pressure (Pa)
418 ! ! Tk=screen level air temperature (K)
419 ! ! ta=aerosol transmissivity
420 ! ! tR=Rayleigh scattering transmissivity
421 ! ! tg=uniformly mixed gas transmissivity
422 ! ! tw=water vapor transmissivity
423 ! ! toz=ozone transmissivity
424 ! !!!!!!!INCOMPLETE
425 ! REAL ::S0,vap_press,Tk,kdown !!!!!FO!!!!! ,albedo
426 ! REAL ::Sdir,Diffuse,Diffuse_R,Diffuse_a,Diffuse_m
427 ! REAL ::tr,tg,tw,ta,toz, theta
428 ! CALL transmissivity(vap_press,Tk,theta,tr,tg,tw,ta,toz)
429 ! Sdir=0.9751*S0*tr*tg*tw*ta*toz
430 ! Diffuse_R=0.
431 ! Diffuse_a=0.
432 ! Diffuse_m=0.
433 ! Diffuse=Diffuse_R+Diffuse_a+Diffuse_m
434 ! kdown=Sdir+Diffuse
435 ! END FUNCTION kdown_niemala
436 ! !=======================================================
437 ! SUBROUTINE transmissivity(vap_press,Tk,theta,tr,tg,tw,ta,toz)
438 ! !calculates atmospheric transmissivities for
439 ! ! ta=aerosol transmissivity
440 ! ! tR=Rayleigh scattering transmissivity
441 ! ! tg=uniformly mixed gas transmissivity
442 ! ! tw=water vapor transmissivity
443 ! ! toz=ozone transmissivity
444 ! ! from Iqbal (1983) and Niemala(2001)
445 ! ! vap_press (Pa)
446 ! ! Tk air temp (K)
447 ! ! w=precipitable water content (cm)
448 ! !==========INCOMPLETE
449 ! REAL ::Tk, vap_press,theta
450 ! REAL ::tr,tg,tw,ta,toz,w
451 ! w=0.493*vap_press/Tk
452 ! ta=0.59+0.012*theta-1.336e-4*theta*theta
453 !
454 ! END SUBROUTINE transmissivity
455
456 !=======================================================
457 FUNCTION solar_esdist(doy) RESULT(Rse)
458 !from Stull, 1998
459 INTEGER :: doy
460 REAL(kind(1d0)) :: rse
461 REAL(kind(1d0)) :: ma, nu, e, a
462
463 e = 0.0167
464 a = 146.457
465
466 ma = 2.*pi*(doy - 3)/365.25463 !Mean anomaly
467 nu = ma + 0.0333988*sin(ma) + .0003486*sin(2.*ma) + 5e-6*sin(3.*ma) !true anomaly
468 rse = a*(1 - e*e)/(1 + e*cos(nu))
469
470 END FUNCTION solar_esdist
471
472END MODULE modsolarcalc
473
474!=====================================================================================
475!=====================================================================================
476MODULE heatflux
477 IMPLICIT NONE
478CONTAINS
479
480 SUBROUTINE heatcond1d(T, Qs, dx, dt, k, rhocp, bc, bctype)
481 REAL(KIND(1D0)), INTENT(inout) :: T(:)
482 REAL(KIND(1D0)), INTENT(in) :: dx(:), dt, k(:), rhocp(:), bc(2)
483 REAL(KIND(1D0)), INTENT(out) :: Qs
484 LOGICAL, INTENT(in) :: bctype(2)
485 INTEGER :: i, n !,j !!!!!FO!!!!!
486 REAL(KIND(1D0)), ALLOCATABLE :: w(:), a(:), T1(:)
487 n = SIZE(t)
488 ALLOCATE (w(0:n), a(n), t1(n))
489 ! w = interface temperature
490 w(1:n) = t
491 w(0) = bc(1); w(n) = bc(2)
492 !convert from flux to equivalent temperature, not exact
493 ! F = k dT/dX => dx*F/k + T(i+1) = T(i)
494 IF (bctype(1)) w(0) = bc(1)*0.5*dx(1)/k(1) + w(1)
495 IF (bctype(2)) w(n) = bc(2)*0.5*dx(n)/k(n) + w(n)
496 ! print *, 'w(0)=', w(0), 'w(n)=', w(n)
497 ! print *, 'k=', k, 'dx=', dx
498 a = k/dx
499 DO i = 1, n - 1
500 w(i) = (t(i + 1)*a(i + 1) + t(i)*a(i))/(a(i) + a(i + 1))
501 END DO
502 !!FO!!
503 ! PRINT *, 'w: ', w
504 ! PRINT *, 'rhocp: ', rhocp
505 ! PRINT *, 'dx: ', dx
506 ! PRINT *, 'a: ', a
507 DO i = 1, n
508 ! PRINT *, 'i: ', i
509 ! PRINT *, 'i: ', (dt/rhocp(i))
510 ! PRINT *, 'i: ', (w(i - 1) - 2*T(i) + w(i))
511 ! PRINT *, 'i: ', 2*a(i)/dx(i)
512 t1(i) = &
513 (dt/rhocp(i)) &
514 *(w(i - 1) - 2*t(i) + w(i)) &
515 *a(i)/dx(i) &
516 + t(i)
517 END DO
518 !!FO!!
519 ! PRINT *, 'T1: ', T1
520 !for storage the internal distribution of heat should not be important
521 !!FO!! k*d(dT/dx)/dx = rhoCp*(dT/dt) => rhoCp*(dT/dt)*dx = dQs => dQs = k*d(dT/dx)
522 qs = (w(0) - t(1))*2*a(1) + (w(n) - t(n))*2*a(n)
523 ! Qs=sum((T1-T)*rhocp*dx)/dt!
524 t = t1
525 END SUBROUTINE heatcond1d
526
527 ! modified from heatcond1d for ESTM_ehc
528 ! TS 17 Feb 2022
529 RECURSIVE SUBROUTINE heatcond1d_ext(T, Qs, Tsfc, dx, dt, k, rhocp, bc, bctype, debug)
530 REAL(kind(1d0)), INTENT(inout) :: t(:)
531 REAL(kind(1d0)), INTENT(in) :: dx(:), dt, k(:), rhocp(:), bc(2)
532 REAL(kind(1d0)), INTENT(out) :: qs, tsfc
533 LOGICAL, INTENT(in) :: bctype(2) ! if true, use surrogate flux as boundary condition
534 LOGICAL, INTENT(in) :: debug
535 INTEGER :: i, n !,j !!!!!FO!!!!!
536 REAL(kind(1d0)), ALLOCATABLE :: w(:), a(:), t1(:), cfl(:)
537 REAL(kind(1d0)) :: cfl_max
538 REAL(kind(1d0)), ALLOCATABLE :: t_in(:), t_out(:)
539 REAL(kind(1d0)) :: dt_x ! for recursion
540 INTEGER :: n_div ! for recursion
541 n = SIZE(t)
542 ALLOCATE (w(0:n), a(n), t1(n), cfl(n), t_in(n), t_out(n))
543
544 ! save initial temperatures
545 t_in = t
546 ! w = interface temperature
547 w(1:n) = t
548 w(0) = bc(1); w(n) = bc(2)
549 !convert from flux to equivalent temperature, not exact
550 ! F = k dT/dX => dx*F/k + T(i+1) = T(i)
551 IF (bctype(1)) w(0) = bc(1)*0.5*dx(1)/k(1) + w(1)
552 IF (bctype(2)) w(n) = bc(2)*0.5*dx(n)/k(n) + w(n)
553 ! print *, 'bc(1)=', bc(1), 'bc(2)=',bc(2)
554 ! print *, 'w(0)=', w(0), 'w(n)=', w(n)
555 ! print *, 'k=', k, 'dx=', dx
556 a = k/dx
557 DO i = 1, n - 1
558 w(i) = (t(i + 1)*a(i + 1) + t(i)*a(i))/(a(i) + a(i + 1))
559 END DO
560 !!FO!!
561 ! PRINT *, 'w: ', w
562 ! PRINT *, 'rhocp: ', rhocp
563 ! PRINT *, 'dt: ', dt
564 ! PRINT *, 'dx: ', dx
565 ! PRINT *, 'a: ', a
566 DO i = 1, n
567 ! PRINT *, 'i: ', i
568 ! PRINT *, 'i: ', (dt/rhocp(i))
569 ! PRINT *, 'i: ', (w(i - 1) - 2*T(i) + w(i))
570 ! PRINT *, 'i: ', 2*a(i)/dx(i)
571 t1(i) = &
572 (dt/rhocp(i)) &
573 *(w(i - 1) - 2*t(i) + w(i)) &
574 *a(i)/dx(i) &
575 + t(i)
576 END DO
577 !!FO!!
578 ! PRINT *, 'T1: ', T1
579 !for storage the internal distribution of heat should not be important
580 !!FO!! k*d(dT/dx)/dx = rhoCp*(dT/dt) => rhoCp*(dT/dt)*dx = dQs => dQs = k*d(dT/dx)
581 ! Qs = (w(0) - T(1))*2*a(1) + (w(n) - T(n))*2*a(n)
582 ! Qs=sum((T1-T)*rhocp*dx)/dt!
583 t = t1
584 tsfc = w(0)
585 ! save output temperatures
586 t_out = t1
587 ! new way for calcualating heat storage
588 qs = sum( &
589 (([bc(1), t_out(1:n - 1)] + t_out)/2. & ! updated temperature
590 -([bc(1), t_in(1:n - 1)] + t_in)/2) & ! initial temperature
591 *rhocp*dx/dt)
592
593 ! fix convergece issue with recursion
594 cfl = abs((w(0:n - 1) - w(1:n))*k/rhocp/(dx**2)*dt)
595 cfl_max = maxval(cfl)
596 ! if (debug) then
597 ! print *, 'T: ', T
598 ! print *, 'rhocp: ', rhocp
599 ! print *, 'w: ', w
600 ! print *, 'a: ', a
601 ! print *, 'cfl: ', cfl
602 ! print *, 'cfl_max: ', cfl_max, MAXLOC(cfl)
603 ! endif
604 IF (cfl_max > .005 .AND. dt > 1) THEN
605 ! re-initialise temperatures at inner nodes
606 t = t_in
607 n_div = 2
608 dt_x = dt/n_div
609 IF (debug) THEN
610 print *, 'entering recursion ', cfl_max, dt_x
611 END IF
612 DO i = 1, n_div
613 CALL heatcond1d_ext(t, qs, tsfc, dx, dt_x, k, rhocp, bc, bctype, debug)
614 END DO
615 END IF
616 ! print *, 'cfl_max: ', cfl_max, MAXLOC(cfl)
617 END SUBROUTINE heatcond1d_ext
618
619 ! SUBROUTINE heatcond1d_vstep(T, Qs, Tsfc, dx, dt, k, rhocp, bc, bctype, debug)
620 ! REAL(KIND(1D0)), INTENT(inout) :: T(:)
621 ! REAL(KIND(1D0)), INTENT(in) :: dx(:), dt, k(:), rhocp(:), bc(2)
622 ! REAL(KIND(1D0)), INTENT(out) :: Qs, Tsfc
623 ! LOGICAL, INTENT(in) :: bctype(2) ! if true, use surrogate flux as boundary condition
624 ! LOGICAL, INTENT(in) :: debug
625 ! INTEGER :: i, n
626 ! REAL(KIND(1D0)), ALLOCATABLE :: w(:), a(:), T1(:), cfl(:)
627
628 ! REAL(KIND(1D0)) :: cfl_max
629 ! REAL(KIND(1D0)) :: dt_remain
630 ! REAL(KIND(1D0)) :: dt_step
631 ! REAL(KIND(1D0)) :: dt_step_cfl
632
633 ! REAL(KIND(1D0)), ALLOCATABLE :: T_in(:), T_out(:)
634 ! REAL(KIND(1D0)) :: dt_x ! for recursion
635 ! INTEGER :: n_div ! for recursion
636 ! n = SIZE(T)
637 ! ALLOCATE (w(0:n), a(n), T1(n), cfl(n), T_in(n), T_out(n))
638
639 ! ! save initial temperatures
640 ! T_in = T
641 ! ! w = interface temperature
642 ! w(1:n) = T
643 ! w(0) = bc(1); w(n) = bc(2)
644 ! !convert from flux to equivalent temperature, not exact
645 ! ! F = k dT/dX => dx*F/k + T(i+1) = T(i)
646 ! IF (bctype(1)) w(0) = bc(1)*0.5*dx(1)/k(1) + w(1)
647 ! IF (bctype(2)) w(n) = bc(2)*0.5*dx(n)/k(n) + w(n)
648 ! ! print *, 'bc(1)=', bc(1), 'bc(2)=',bc(2)
649 ! ! print *, 'w(0)=', w(0), 'w(n)=', w(n)
650 ! ! print *, 'k=', k, 'dx=', dx
651 ! a = k/dx
652 ! DO i = 1, n - 1
653 ! w(i) = (T(i + 1)*a(i + 1) + T(i)*a(i))/(a(i) + a(i + 1))
654 ! END DO
655
656 ! ! fix convergece issue with recursion
657 ! dt_remain = dt
658 ! dt_step_cfl = 0.05*MINVAL(dx**2/(k/rhocp))
659 ! DO WHILE (dt_remain > 1E-10)
660 ! dt_step = MIN(dt_step_cfl, dt_remain)
661 ! !PRINT *, 'dt_remain: ', dt_remain
662 ! !PRINT *, 'dt_step_cfl: ', dt_step_cfl
663 ! !PRINT *, '***** dt_step: ', dt_step
664 ! !!FO!!
665 ! ! PRINT *, 'w: ', w
666 ! ! PRINT *, 'rhocp: ', rhocp
667 ! ! PRINT *, 'dt: ', dt
668 ! ! PRINT *, 'dx: ', dx
669 ! ! PRINT *, 'a: ', a
670 ! DO i = 1, n
671 ! ! PRINT *, 'i: ', i
672 ! ! PRINT *, 'i: ', (dt/rhocp(i))
673 ! ! PRINT *, 'i: ', (w(i - 1) - 2*T(i) + w(i))
674 ! ! PRINT *, 'i: ', 2*a(i)/dx(i)
675 ! T1(i) = &
676 ! (dt_step/rhocp(i)) &
677 ! *(w(i - 1) - 2*T(i) + w(i)) &
678 ! *a(i)/dx(i) &
679 ! + T(i)
680 ! END DO
681 ! T = T1
682 ! DO i = 1, n - 1
683 ! w(i) = (T(i + 1)*a(i + 1) + T(i)*a(i))/(a(i) + a(i + 1))
684 ! END DO
685 ! dt_remain = dt_remain - dt_step
686 ! END DO
687 ! !!FO!!
688 ! ! PRINT *, 'T1: ', T1
689 ! !for storage the internal distribution of heat should not be important
690 ! !!FO!! k*d(dT/dx)/dx = rhoCp*(dT/dt) => rhoCp*(dT/dt)*dx = dQs => dQs = k*d(dT/dx)
691 ! ! Qs = (w(0) - T(1))*2*a(1) + (w(n) - T(n))*2*a(n)
692 ! ! Qs=sum((T1-T)*rhocp*dx)/dt!
693
694 ! Tsfc = w(0)
695 ! ! save output temperatures
696 ! T_out = T1
697 ! ! new way for calcualating heat storage
698 ! Qs = SUM( &
699 ! (([bc(1), T_out(1:n - 1)] + T_out)/2. & ! updated temperature
700 ! -([bc(1), T_in(1:n - 1)] + T_in)/2) & ! initial temperature
701 ! *rhocp*dx/dt)
702 ! END SUBROUTINE heatcond1d_vstep
703END MODULE heatflux
704
705!==================================================================================
706
708 !===============================================================================
709 ! revision history:
710 ! TS 09 Oct 2017: re-organised ESTM subroutines into a module
711 !===============================================================================
712 IMPLICIT NONE
713
714CONTAINS
715
716 !======================================================================================
717 ! Subroutine to read in ESTM data in the same way as met data (SUEWS_InitializeMetData)
718 ! HCW 30 Jun 2016
719 SUBROUTINE suews_getestmdata(lunit)
722 USE sues_data, ONLY: tstep_real, tstep
723 USE defaultnotused, ONLY: notused, ios_out
725
726 IMPLICIT NONE
727
728 INTEGER, INTENT(in) :: lunit
729 INTEGER :: i, iyy !,RunNumber,NSHcounter
730 INTEGER :: iostat_var
731 REAL(KIND(1D0)), DIMENSION(ncolsESTMdata) :: ESTMArray
732 REAL(KIND(1D0)) :: imin_prev, ih_prev, iday_prev, tstep_estm !For checks on temporal resolution of estm data
733
734 ! initialise
735 imin_prev = 0
736 ih_prev = 0
737 iday_prev = 0
738
739 !---------------------------------------------------------------
740
741 !Open the file for reading and read the actual data
742 !write(*,*) FileESTMTs
743 OPEN (lunit, file=trim(fileestmts), status='old', err=315)
744 CALL skipheader(lunit, skipheadermet)
745
746 ! Skip to the right place in the ESTM file, depending on how many chunks have been read already
747 IF (skippedlines > 0) THEN
748 DO iyy = 1, skippedlines
749 READ (lunit, *)
750 END DO
751 END IF
752
753 ! Read in next chunk of ESTM data and fill ESTMForcingData array with data for every timestep
754 DO i = 1, readlinesmetdata
755 READ (lunit, *, iostat=iostat_var) estmarray
756 estmforcingdata(i, 1:ncolsestmdata, gridcounter) = estmarray
757 ! Check timestamp of met data file matches TSTEP specified in RunControl
758 IF (i == 1) THEN
759 imin_prev = estmarray(4)
760 ih_prev = estmarray(3)
761 iday_prev = estmarray(2)
762 ELSEIF (i == 2) THEN
763 tstep_estm = ((estmarray(4) + 60*estmarray(3)) - (imin_prev + 60*ih_prev))*60 !tstep in seconds
764 IF (tstep_estm /= tstep_real .AND. estmarray(2) == iday_prev) THEN
765 CALL errorhint(39, 'TSTEP in RunControl does not match TSTEP of ESTM data (DOY).', &
766 REAL(tstep, KIND(1D0)), tstep_estm, INT(ESTMArray(2)))
767 END IF
768 END IF
769 END DO
770
771 CLOSE (lunit)
772
773 RETURN
774
775315 CALL errorhint(11, trim(fileestmts), notused, notused, ios_out)
776
777 END SUBROUTINE suews_getestmdata
778 !======================================================================================
779
780 !======================================================================================
781 SUBROUTINE estm_initials
782
783 ! Last modified HCW 30 Jun 2016 - reading in now done by SUEWS_GetESTMData subroutine.
784 ! ESTM_initials now only runs once per run at the very start.
785 ! Last modified HCW 15 Jun 2016 - code now reads in 5-min file (interpolation done beforehand, outside of SUEWS itself)
786
788 USE physconstants, ONLY: c2k
789 USE estm_data
790 USE allocatearray
791 USE data_in, ONLY: fileinputpath
792 USE initial, ONLY: numberofgrids
793
794 IMPLICIT NONE
795
796 !=====Read ESTMinput.nml================================
797 namelist /estminput/ tsurfchoice, &
798 evolvetibld, &
799 ibldchmod, &
800 lbc_soil, &
801 theat_on, &
802 theat_off, &
804
805 OPEN (511, file=trim(fileinputpath)//'ESTMinput.nml', status='old')
806 READ (511, nml=estminput)
807 CLOSE (511)
808
809 !Convert specified temperatures to Kelvin
813
814 ALLOCATE (tair2_grids(numberofgrids))
816 ALLOCATE (lup_wall_grids(numberofgrids))
817 ALLOCATE (lup_roof_grids(numberofgrids))
818 ALLOCATE (tievolve_grids(numberofgrids))
819 ALLOCATE (t0_ibld_grids(numberofgrids))
821 ALLOCATE (t0_wall_grids(numberofgrids))
822 ALLOCATE (t0_roof_grids(numberofgrids))
823 ALLOCATE (tn_wall_grids(numberofgrids))
824 ALLOCATE (tn_roof_grids(numberofgrids))
825
826 END SUBROUTINE estm_initials
827 !======================================================================================
828 SUBROUTINE load_gridlayout(gridIV, MultipleLayoutFiles, diagnose)
829 USE allocatearray, ONLY: &
830 ndepth, &
865 nsurf, &
870 nspec
871 USE data_in, ONLY: fileinputpath, filecode
872 USE strings, ONLY: writenum
873 IMPLICIT NONE
874 INTEGER, INTENT(IN) :: gridIV
875 INTEGER, INTENT(IN) :: diagnose
876 LOGICAL, INTENT(IN) :: MultipleLayoutFiles
877 CHARACTER(len=100) :: FileLayout, str_gridIV
878 INTEGER :: istat, iunit, ERROR_UNIT, i
879 INTEGER :: igroup, ilayer, idepth
880 CHARACTER(len=1000) :: line
881 REAL(KIND(1D0)) :: k, dz
882
883 namelist &
884 ! basic dimension info
885 /dim/ &
886 nlayer, &
887 /geom/ &
888 height, &
890 veg_frac, &
892 veg_scale, &
893 ! read in roof part
894 /roof/ &
895 sfr_roof, &
897 tin_roof, &
898 alb_roof, &
899 emis_roof, &
900 state_roof, &
905 dz_roof, &
906 k_roof, &
907 cp_roof &
908 ! read in wall part
909 /wall/ &
910 sfr_wall, &
912 tin_wall, &
913 alb_wall, &
914 emis_wall, &
915 state_wall, &
920 dz_wall, &
921 k_wall, &
922 cp_wall, &
923 /surf/ &
924 tin_surf, &
925 dz_surf, &
926 k_surf, &
927 cp_surf
928
929 IF (multiplelayoutfiles) THEN
930 CALL writenum(gridiv, str_gridiv, 'i4')
931 filelayout = 'GridLayout'//trim(filecode)//trim(str_gridiv)//'.nml'
932 ELSE
933 filelayout = 'GridLayout'//trim(filecode)//'.nml'
934 END IF
935
936 IF (diagnose == 1) print *, 'Reading layout file: ', trim(fileinputpath)//filelayout
937 iunit = 212
938 OPEN (iunit, file=trim(fileinputpath)//trim(filelayout), status='old')
939 IF (diagnose == 1) print *, 'Read dim info of GridLayout'
940 READ (iunit, nml=dim, iostat=istat)
941 IF (diagnose == 1) print *, 'Number of layers to read: ', nlayer
942
943 IF (istat /= 0) THEN
944 backspace(iunit)
945 READ (iunit, fmt='(A)') line
946 error_unit = 119
947 WRITE (error_unit, '(A)') &
948 'Invalid line in namelist: '//trim(line)
949 END IF
950 CLOSE (iunit)
951
952 ALLOCATE (height(nlayer + 1))
953 ALLOCATE (building_frac(nlayer))
954 ALLOCATE (veg_frac(nlayer))
955 ALLOCATE (building_scale(nlayer))
956 ALLOCATE (veg_scale(nlayer))
957
958 ALLOCATE (sfr_roof(nlayer))
959 ALLOCATE (dz_roof(nlayer, ndepth))
960 ALLOCATE (k_roof(nlayer, ndepth))
961 ALLOCATE (cp_roof(nlayer, ndepth))
962 ALLOCATE (tin_roof(nlayer))
963 ALLOCATE (alb_roof(nlayer))
964 ALLOCATE (emis_roof(nlayer))
965 ALLOCATE (state_roof(nlayer))
966 ALLOCATE (statelimit_roof(nlayer))
967 ALLOCATE (wetthresh_roof(nlayer))
968 ALLOCATE (soilstore_roof(nlayer))
969 ALLOCATE (soilstorecap_roof(nlayer))
971
972 ALLOCATE (sfr_wall(nlayer))
973 ALLOCATE (dz_wall(nlayer, ndepth))
974 ALLOCATE (k_wall(nlayer, ndepth))
975 ALLOCATE (cp_wall(nlayer, ndepth))
976 ALLOCATE (tin_wall(nlayer))
977 ALLOCATE (alb_wall(nlayer))
978 ALLOCATE (emis_wall(nlayer))
979 ALLOCATE (state_wall(nlayer))
980 ALLOCATE (statelimit_wall(nlayer))
981 ALLOCATE (wetthresh_wall(nlayer))
982 ALLOCATE (soilstore_wall(nlayer))
983 ALLOCATE (soilstorecap_wall(nlayer))
984 ALLOCATE (wall_specular_frac(nspec, nlayer))
985
986 ALLOCATE (dz_surf(nsurf, ndepth))
987 ALLOCATE (k_surf(nsurf, ndepth))
988 ALLOCATE (cp_surf(nsurf, ndepth))
989 ALLOCATE (tin_surf(nsurf))
990
991 OPEN (iunit, file=trim(fileinputpath)//trim(filelayout), status='old')
992 IF (diagnose == 1) print *, 'Read geometry part of GridLayout'
993 READ (iunit, nml=geom, iostat=istat)
994 IF (diagnose == 1) print *, 'height', height
995 IF (diagnose == 1) print *, 'building_frac', building_frac
996 IF (diagnose == 1) print *, 'veg_frac', veg_frac
997 IF (diagnose == 1) print *, 'building_scale', building_scale
998 IF (diagnose == 1) print *, 'veg_scale', veg_scale
999
1000 IF (diagnose == 1) print *, 'Read roof part of GridLayout'
1001 READ (iunit, nml=roof, iostat=istat)
1002 IF (diagnose == 1) print *, 'sfr_roof', sfr_roof
1003 IF (diagnose == 1) print *, 'dz_roof', dz_roof
1004 IF (diagnose == 1) print *, 'k_roof', k_roof
1005 IF (diagnose == 1) print *, 'cp_roof', cp_roof
1006 IF (diagnose == 1) print *, 'tin_roof', tin_roof
1007 IF (diagnose == 1) print *, 'alb_roof', alb_roof
1008 IF (diagnose == 1) print *, 'emis_roof', emis_roof
1009 IF (diagnose == 1) print *, 'state_roof', state_roof
1010 IF (diagnose == 1) print *, 'statelimit_roof', statelimit_roof
1011 IF (diagnose == 1) print *, 'wetthresh_roof', wetthresh_roof
1012 IF (diagnose == 1) print *, 'soilstore_roof', soilstore_roof
1013 IF (diagnose == 1) print *, 'soilstorecap_roof', soilstorecap_roof
1014
1015 IF (diagnose == 1) print *, 'Read wall part of GridLayout'
1016 READ (iunit, nml=wall, iostat=istat)
1017 IF (diagnose == 1) print *, 'sfr_wall', sfr_wall
1018 IF (diagnose == 1) print *, 'dz_wall', dz_wall
1019 IF (diagnose == 1) print *, 'k_wall', k_wall
1020 IF (diagnose == 1) print *, 'cp_wall', cp_wall
1021 IF (diagnose == 1) print *, 'tin_wall', tin_wall
1022 IF (diagnose == 1) print *, 'alb_wall', alb_wall
1023 IF (diagnose == 1) print *, 'emis_wall', emis_wall
1024 IF (diagnose == 1) print *, 'state_wall', state_wall
1025 IF (diagnose == 1) print *, 'statelimit_wall', statelimit_wall
1026 IF (diagnose == 1) print *, 'wetthresh_wall', wetthresh_wall
1027 IF (diagnose == 1) print *, 'soilstore_wall', soilstore_wall
1028 IF (diagnose == 1) print *, 'soilstorecap_wall', soilstorecap_wall
1029
1030 ! PRINT *, 'Read surf part of GridLayout'
1031 READ (iunit, nml=surf, iostat=istat)
1032 IF (istat /= 0) THEN
1033 backspace(iunit)
1034 READ (iunit, fmt='(A)') line
1035 error_unit = 119
1036 WRITE (error_unit, '(A)') &
1037 'Invalid line in namelist: '//trim(line)
1038 END IF
1039 CLOSE (iunit)
1040
1041 IF (diagnose == 1) print *, 'Read GridLayout'
1042 IF (diagnose == 1) print *, 'sfr_roof in load_GridLayout', sfr_roof
1043 IF (diagnose == 1) print *, 'sfr_wall in load_GridLayout', sfr_wall
1044 IF (diagnose == 1) print *, 'tin_surf in load_GridLayout', tin_surf
1045 IF (diagnose == 1) print *, 'dz_surf(1,:) in load_GridLayout', dz_surf(1, :)
1046 IF (diagnose == 1) print *, 'k_surf(1,:) in load_GridLayout', k_surf(1, :)
1047 IF (diagnose == 1) print *, 'dz_roof in load_GridLayout', dz_roof(1:nlayer, :ndepth)
1048 ! PRINT *, 'dz_roof in load_GridLayout', dz_roof(1, :ndepth)
1049
1050 ! assign values to the grid container
1051 nlayer_grids(gridiv) = nlayer
1052 height_grids(gridiv, 1:nlayer + 1) = height(1:nlayer + 1)
1054 veg_frac_grids(gridiv, 1:nlayer) = veg_frac(1:nlayer)
1056 veg_scale_grids(gridiv, 1:nlayer) = veg_scale(1:nlayer)
1057
1058 ! roof
1059 sfr_roof_grids(gridiv, 1:nlayer) = sfr_roof
1060 tin_roof_grids(gridiv, 1:nlayer) = tin_roof
1061 DO i = 1, nlayer
1062 temp_roof_grids(gridiv, i, :) = tin_roof(i)
1063 END DO
1064 dz_roof_grids(gridiv, 1:nlayer, 1:ndepth) = dz_roof(1:nlayer, 1:ndepth)
1065 k_roof_grids(gridiv, 1:nlayer, 1:ndepth) = k_roof(1:nlayer, 1:ndepth)
1066 cp_roof_grids(gridiv, 1:nlayer, 1:ndepth) = cp_roof(1:nlayer, 1:ndepth)
1067 alb_roof_grids(gridiv, 1:nlayer) = alb_roof(1:nlayer)
1068 emis_roof_grids(gridiv, 1:nlayer) = emis_roof(1:nlayer)
1075 ! PRINT *, 'dz_roof_grids in loading', dz_roof_grids(Gridiv, 1:nroof, 1:ndepth)
1076 ! PRINT *, 'dz_roof_grids(1,1) in loading', dz_roof_grids(Gridiv, 1, 1:ndepth)
1077 ! tsfc_roof_grids(gridIV) = tsfc_roof
1078 ! tin_roof_grids(gridIV) = temp_in_roof
1079
1080 ! wall
1081 sfr_wall_grids(gridiv, 1:nlayer) = sfr_wall
1082 tin_wall_grids(gridiv, 1:nlayer) = tin_wall
1083 DO i = 1, nlayer
1084 temp_wall_grids(gridiv, i, :) = tin_wall(i)
1085 END DO
1086 dz_wall_grids(gridiv, 1:nlayer, 1:ndepth) = dz_wall(1:nlayer, 1:ndepth)
1087 k_wall_grids(gridiv, 1:nlayer, 1:ndepth) = k_wall(1:nlayer, 1:ndepth)
1088 cp_wall_grids(gridiv, 1:nlayer, 1:ndepth) = cp_wall(1:nlayer, 1:ndepth)
1089 alb_wall_grids(gridiv, 1:nlayer) = alb_wall(1:nlayer)
1090 emis_wall_grids(gridiv, 1:nlayer) = emis_wall(1:nlayer)
1097 ! PRINT *, 'dz_wall_grids in loading', dz_wall_grids(Gridiv, 1:nwall, 1:ndepth)
1098 ! PRINT *, 'dz_wall_grids(1,1) in loading', dz_wall_grids(Gridiv, 1, 1:ndepth)
1099 ! tsfc_wall_grids(gridIV) = tsfc_wall
1100 ! tin_wall_grids(gridIV) = temp_in_wall
1101
1102 ! generic surfaces
1103 tin_surf_grids(gridiv, 1:nsurf) = tin_surf
1104 ! DO i = 1, nsurf
1105 ! tin_surf_grids(gridIV, i, :) = tin_surf(i)
1106 ! END DO
1107 dz_surf_grids(gridiv, 1:nsurf, 1:ndepth) = dz_surf(1:nsurf, 1:ndepth)
1108 k_surf_grids(gridiv, 1:nsurf, 1:ndepth) = k_surf(1:nsurf, 1:ndepth)
1109 cp_surf_grids(gridiv, 1:nsurf, 1:ndepth) = cp_surf(1:nsurf, 1:ndepth)
1110
1111 ! ! check if CFL condition is met
1112 ! DO igroup = 1, 3
1113 ! DO ilayer = 1, merge(nlayer,7,igroup<3)
1114 ! idepth = 1
1115 ! ! DO idepth = 1, ndepth
1116 ! IF (igroup == 1) THEN
1117 ! k = k_roof_grids(gridIV, ilayer, idepth)
1118 ! dz = dz_roof_grids(gridIV, ilayer, idepth)
1119 ! str_igroup='roof'
1120 ! ELSE IF (igroup == 2) THEN
1121 ! k = k_wall_grids(gridIV, ilayer, idepth)
1122 ! dz = dz_wall_grids(gridIV, ilayer, idepth)
1123 ! str_igroup='wall'
1124 ! ELSE IF (igroup == 3) THEN
1125 ! k = k_surf_grids(gridIV, ilayer, idepth)
1126 ! dz = dz_surf_grids(gridIV, ilayer, idepth)
1127 ! str_igroup='surf'
1128 ! END IF
1129
1130 ! IF (dz/k > 0.02) THEN
1131 ! PRINT *, 'CFL condition, dz/k < 0.02, is not met for top layer of:'
1132 ! PRINT *, 'grid', gridIV
1133
1134 ! PRINT *, 'group: ', str_igroup
1135 ! PRINT *, 'layer', ilayer
1136 ! PRINT *, 'dz/k=', dz/k
1137 ! PRINT *, 'dz=', dz
1138 ! PRINT *, 'k=', k
1139 ! PRINT *, ''
1140 ! WRITE (str_gridIV, '(I5.5)') gridIV
1141 ! ! WRITE (str_igroup, '(I5.5)') igroup
1142 ! WRITE (str_idepth, '(I5.5)') idepth
1143 ! WRITE (str_ilayer, '(I5.5)') ilayer
1144
1145 ! CALL ErrorHint(77, 'CFL condition is not met for '// &
1146 ! 'grid: '//TRIM(str_gridIV)// &
1147 ! ', group: '//TRIM(str_igroup)// &
1148 ! ', layer: '//TRIM(str_ilayer)// &
1149 ! ', depth: '//TRIM(str_idepth) &
1150 ! , dz/k, idepth*1.D0, ilayer)
1151 ! END IF
1152 ! ! END DO
1153 ! END DO
1154
1155 ! END DO
1156
1157 DEALLOCATE (height)
1158 DEALLOCATE (building_frac)
1159 DEALLOCATE (veg_frac)
1160 DEALLOCATE (building_scale)
1161 DEALLOCATE (veg_scale)
1162
1163 DEALLOCATE (sfr_roof)
1164 DEALLOCATE (alb_roof)
1165 DEALLOCATE (emis_roof)
1166 DEALLOCATE (state_roof)
1167 DEALLOCATE (statelimit_roof)
1168 DEALLOCATE (wetthresh_roof)
1169 DEALLOCATE (soilstore_roof)
1170 DEALLOCATE (soilstorecap_roof)
1171 DEALLOCATE (dz_roof)
1172 DEALLOCATE (k_roof)
1173 DEALLOCATE (cp_roof)
1174 DEALLOCATE (tin_roof)
1175 DEALLOCATE (roof_albedo_dir_mult_fact)
1176
1177 DEALLOCATE (sfr_wall)
1178 DEALLOCATE (alb_wall)
1179 DEALLOCATE (emis_wall)
1180 DEALLOCATE (state_wall)
1181 DEALLOCATE (statelimit_wall)
1182 DEALLOCATE (wetthresh_wall)
1183 DEALLOCATE (soilstore_wall)
1184 DEALLOCATE (soilstorecap_wall)
1185 DEALLOCATE (dz_wall)
1186 DEALLOCATE (k_wall)
1187 DEALLOCATE (cp_wall)
1188 DEALLOCATE (tin_wall)
1189 DEALLOCATE (wall_specular_frac)
1190
1191 DEALLOCATE (tin_surf)
1192 DEALLOCATE (dz_surf)
1193 DEALLOCATE (k_surf)
1194 DEALLOCATE (cp_surf)
1195
1196 END SUBROUTINE load_gridlayout
1197
1198 !======================================================================================
1200
1201 ! Last modified HCW 30 Jun 2016 - reading in now done by SUEWS_GetESTMData subroutine.
1202 ! ESTM_initials now only runs once per run at the very start.
1203 ! Last modified HCW 15 Jun 2016 - code now reads in 5-min file (interpolation done beforehand, outside of SUEWS itself)
1204
1205 ! USE defaultNotUsed
1206 USE physconstants, ONLY: c2k
1207 ! USE ESTM_data
1208 USE allocatearray
1210 USE initial, ONLY: numberofgrids
1211
1212 IMPLICIT NONE
1213 LOGICAL :: flag_mutiple_layout_files
1214 INTEGER :: i_grid
1215
1216 IF (multiplelayoutfiles == 0) THEN
1217 flag_mutiple_layout_files = .false.
1218 ELSE IF (multiplelayoutfiles == 1) THEN
1219 flag_mutiple_layout_files = .true.
1220 END IF
1221
1222 ALLOCATE (nlayer_grids(numberofgrids))
1223
1229
1230 ! allocate roof variables
1246
1247 ! allocate wall variables
1263
1264 ! allocate surf variables
1265 ! ALLOCATE (tsfc_surf_grids(NumberOfGrids, nsurf))
1271
1272 DO i_grid = 1, numberofgrids
1273 print *, 'Reading layout data for grid ', i_grid
1274 CALL load_gridlayout(i_grid, flag_mutiple_layout_files, diagnose)
1275 END DO
1276
1277 END SUBROUTINE estm_ehc_initialise
1278
1280 USE allocatearray
1281 IMPLICIT NONE
1282
1283 IF (ALLOCATED(nlayer_grids)) DEALLOCATE (nlayer_grids)
1284
1285 IF (ALLOCATED(height_grids)) DEALLOCATE (height_grids)
1286 IF (ALLOCATED(building_frac_grids)) DEALLOCATE (building_frac_grids)
1287 IF (ALLOCATED(veg_frac_grids)) DEALLOCATE (veg_frac_grids)
1288 IF (ALLOCATED(building_scale_grids)) DEALLOCATE (building_scale_grids)
1289 IF (ALLOCATED(veg_scale_grids)) DEALLOCATE (veg_scale_grids)
1290
1291 IF (ALLOCATED(sfr_roof_grids)) DEALLOCATE (sfr_roof_grids)
1292 IF (ALLOCATED(alb_roof_grids)) DEALLOCATE (alb_roof_grids)
1293 IF (ALLOCATED(emis_roof_grids)) DEALLOCATE (emis_roof_grids)
1294 IF (ALLOCATED(k_roof_grids)) DEALLOCATE (k_roof_grids)
1295 IF (ALLOCATED(cp_roof_grids)) DEALLOCATE (cp_roof_grids)
1296 IF (ALLOCATED(dz_roof_grids)) DEALLOCATE (dz_roof_grids)
1297 IF (ALLOCATED(tin_roof_grids)) DEALLOCATE (tin_roof_grids)
1298 IF (ALLOCATED(temp_roof_grids)) DEALLOCATE (temp_roof_grids)
1299 IF (ALLOCATED(state_roof_grids)) DEALLOCATE (state_roof_grids)
1300 IF (ALLOCATED(statelimit_roof_grids)) DEALLOCATE (statelimit_roof_grids)
1301 IF (ALLOCATED(wetthresh_roof_grids)) DEALLOCATE (wetthresh_roof_grids)
1302 IF (ALLOCATED(soilstore_roof_grids)) DEALLOCATE (soilstore_roof_grids)
1303 IF (ALLOCATED(soilstorecap_roof_grids)) DEALLOCATE (soilstorecap_roof_grids)
1305
1306 IF (ALLOCATED(sfr_wall_grids)) DEALLOCATE (sfr_wall_grids)
1307 IF (ALLOCATED(alb_wall_grids)) DEALLOCATE (alb_wall_grids)
1308 IF (ALLOCATED(emis_wall_grids)) DEALLOCATE (emis_wall_grids)
1309 IF (ALLOCATED(k_wall_grids)) DEALLOCATE (k_wall_grids)
1310 IF (ALLOCATED(cp_wall_grids)) DEALLOCATE (cp_wall_grids)
1311 IF (ALLOCATED(dz_wall_grids)) DEALLOCATE (dz_wall_grids)
1312 IF (ALLOCATED(tin_wall_grids)) DEALLOCATE (tin_wall_grids)
1313 IF (ALLOCATED(temp_wall_grids)) DEALLOCATE (temp_wall_grids)
1314 IF (ALLOCATED(state_wall_grids)) DEALLOCATE (state_wall_grids)
1315 IF (ALLOCATED(statelimit_wall_grids)) DEALLOCATE (statelimit_wall_grids)
1316 IF (ALLOCATED(wetthresh_wall_grids)) DEALLOCATE (wetthresh_wall_grids)
1317 IF (ALLOCATED(soilstore_wall_grids)) DEALLOCATE (soilstore_wall_grids)
1318 IF (ALLOCATED(soilstorecap_wall_grids)) DEALLOCATE (soilstorecap_wall_grids)
1319 IF (ALLOCATED(wall_specular_frac_grids)) DEALLOCATE (wall_specular_frac_grids)
1320
1321 IF (ALLOCATED(k_surf_grids)) DEALLOCATE (k_surf_grids)
1322 IF (ALLOCATED(cp_surf_grids)) DEALLOCATE (cp_surf_grids)
1323 IF (ALLOCATED(dz_surf_grids)) DEALLOCATE (dz_surf_grids)
1324 ! IF (ALLOCATED(tin_surf_grids)) DEALLOCATE (tin_surf_grids)
1325 IF (ALLOCATED(temp_surf_grids)) DEALLOCATE (temp_surf_grids)
1326
1327 END SUBROUTINE estm_ehc_finalise
1328 !======================================================================================
1329
1330 SUBROUTINE estm_translate(Gridiv)
1331 ! HCW 30 Jun 2016
1332
1333 USE defaultnotused, ONLY: nan
1334 USE physconstants, ONLY: c2k, sbconst
1335 USE estm_data
1336 USE allocatearray
1337 USE gis_data, ONLY: bldgh
1338 USE initial, ONLY: numberofgrids
1339
1340 IMPLICIT NONE
1341 INTEGER :: i
1342 !REAL(KIND(1d0)) :: CFLval
1343 !REAL(KIND(1d0)) :: t5min
1344 REAL(KIND(1D0)) :: W, WB
1345 !CHARACTER (len=20)::FileCodeX
1346 !CHARACTER (len=150):: FileFinalTemp
1347 !LOGICAL:: inittemps=.FALSE.
1348 INTEGER :: ESTMStart = 0
1349 INTEGER :: Gridiv
1350
1351 !Set initial values at the start of each run for each grid
1352 ! the initiliastion part is problematic:
1353 ! cannot be initialised under a multi-grid scenario
1354 IF (gridiv == 1) estmstart = estmstart + 1
1355 ! print *, 'gridiv in ESTM',gridiv,'ESTMStart',ESTMStart
1356 IF (estmstart == 1) THEN
1357
1358 ! write(*,*) ' ESTMStart: ',ESTMStart, 'initialising ESTM for grid no. ', Gridiv
1359
1360 tfloor = 20.0 ! This is used only when radforce =T !TODO: should be put in the namelist
1361 tfloor = tfloor + c2k
1362
1363 ! Initial values
1364 tievolve = 20.0 + c2k
1365 shc_air = 1230.0
1366 minshc_airbld = 1300
1367
1368 ! ---- Internal view factors ----
1369 !constant now but should be calculated in the future
1370 ivf_iw = 0.100000
1371 ivf_ir = 0.000000
1372 ivf_ii = 0.900000
1373 ivf_if = 0.000000
1374 ivf_ww = 0.050000
1375 ivf_wr = 0.000000
1376 ivf_wi = 0.950000
1377 ivf_wf = 0.000000
1378 ivf_rw = 0.050000
1379 ivf_ri = 0.950000
1380 ivf_rf = 0.000000
1381 ivf_fw = 0.050000
1382 ivf_fr = 0.000000
1383 ivf_fi = 0.950000
1384
1385 tair24hr = c2k
1386
1387 !Ts5mindata(1,ncolsESTMdata) = -999
1388 ! !Fill Ts5mindata for current grid and met block - this is done in SUEWS_translate
1390
1391 ! ---- Initialization of variables and parameters for first row of run for each grid ----
1392 ! N layers are calculated in SUEWS_translate
1393 IF (.NOT. ALLOCATED(tibld)) THEN
1394 ! print *, "Nibld", Nibld
1395 ! print *, "Nwall", Nwall
1396 ! print *, "Nroof", Nroof
1397 ! print *, "Nground", Nground
1404 END IF
1405
1406 ! Transfer variables from Ts5mindata to variable names
1407 ! N.B. column numbers here for the following file format - need to change if input columns change!
1408 ! dectime iy id it imin Tiair Tsurf Troof Troad Twall Twall_n Twall_e Twall_s Twall_w
1409 ! 1 2 3 4 5 6 7 8 9 10 11 12 13 !new
1410 !
1411 ! Calculate temperature of each layer in Kelvin
1412 ! QUESTION: what if (Nground/Nwall/Nroof-1)==0? TS 21 Oct 2017
1413 DO i = 1, ndepth_ground
1414 tground(i) = (lbc_soil - ts5mindata(1, cts_troad))*(i - 1)/(ndepth_ground - 1) + ts5mindata(1, cts_troad) + c2k
1415 END DO
1416 DO i = 1, ndepth_wall
1417 twall(i) = &
1418 (ts5mindata(1, cts_tiair) - ts5mindata(1, cts_twall))*(i - 1)/(ndepth_wall - 1) + ts5mindata(1, cts_twall) &
1419 + c2k
1420 END DO
1421 DO i = 1, ndepth_roof
1422 troof(i) = &
1423 (ts5mindata(1, cts_tiair) - ts5mindata(1, cts_troof))*(i - 1)/(ndepth_roof - 1) + ts5mindata(1, cts_troof) &
1424 + c2k
1425 END DO
1427
1428 END IF !End of loop run only at start (for each grid)
1429
1430 ! ---- Parameters related to land surface characteristics ----
1431 ! QUESTION: Would Zref=z be more appropriate?
1432 zref = 2.0*bldgh !!FO!! BldgH: mean bulding hight, zref: local scale reference height (local: ~ 10^2 x 10^2 -- 10^3 x 10^3 m^2)
1433
1434 svf_ground = 1.0
1435 svf_roof = 1.0
1436
1437 ! ==== roof (i.e. Bldgs)
1438 !froof=sfr_surf(BldgSurf) ! Moved to SUEWS_translate HCW 16 Jun 2016
1441
1442 ! ==== vegetation (i.e. EveTr, DecTr, Grass)
1443 !fveg=sfr_surf(ConifSurf)+sfr_surf(DecidSurf)+sfr_surf(GrassSurf) ! Moved to SUEWS_translate HCW 16 Jun 2016
1444 IF (fveg /= 0) THEN
1447 ELSE ! check fveg==0 scenario to avoid division-by-zero error, TS 21 Oct 2017
1450 END IF
1451
1452 ! ==== ground (i.e. Paved, EveTr, DecTr, Grass, BSoil, Water - all except Bldgs)
1453 !fground=sfr_surf(ConifSurf)+sfr_surf(DecidSurf)+sfr_surf(GrassSurf)+sfr_surf(PavSurf)+sfr_surf(BsoilSurf)+sfr_surf(WaterSurf) ! Moved to SUEWS_translate HCW 16 Jun 2016
1454 IF (fground /= 0) THEN
1461 ELSE ! check fground==0 scenario to avoid division-by-zero error, TS 21 Jul 2016
1464 END IF
1465
1466 IF (froof < 1.0) THEN
1467 hw = fwall/(2.0*(1.0 - froof))
1468 ELSE
1469 ! HW=0 !HCW if only roof, no ground
1470 hw = 0.00001 ! to avoid zero-HW scenario TS 21 Oct 2017
1471
1472 END IF
1473 hw = max(0.00001, hw) ! to avoid zero-HW scenario TS 27 Oct 2017
1474
1475 IF (fground == 1.0) THEN !!FO!! if only ground, i.e. no houses
1476 w = 1
1477 wb = 0
1478 svf_ground = 1.
1479 zvf_wall = 0.
1480 svf_wall = 0.
1481 svf_roof = 1.
1482 zvf_ground = 0.
1483 xvf_wall = 0.
1484 rvf_canyon = 1.
1485 rvf_ground = 1.-fveg
1486 rvf_roof = 0
1487 rvf_wall = 0
1488 rvf_veg = fveg
1489 ELSE IF (fground == 0.0) THEN !check fground==0 (or HW==0) scenario to avoid division-by-zero error, TS 21 Jul 2016
1490 ! the following values are calculated given HW=0
1491 w = 0
1492 wb = 1
1493 zvf_wall = 0 !COS(ATAN(2/HW)) when HW=0 !!FO!! wall view factor for wall
1494 hw = 0
1495 svf_ground = max(cos(atan(2*hw)), 0.00001) !!FO!! sky view factor for ground ! to avoid zero-division scenario TS 21 Oct 2017
1496 svf_wall = (1 - zvf_wall)/2 !!FO!! sky view factor for wall
1497 zvf_ground = 1 - svf_ground !!FO!! wall view factor for ground
1498 xvf_wall = svf_wall !!FO!! ground view factor
1499 ! RVF_CANYON=COS(ATAN(2*ZREF/W))
1500 ! RVF_ROOF=1-RVF_CANYON
1501 ! RVF_WALL=(COS(ATAN(2*(ZREF-BldgH)/W))-RVF_CANYON)*RVF_CANYON
1502 ! RVF_ground=RVF_CANYON-RVF_WALL
1505 rvf_roof = froof
1507 ELSE
1508 w = bldgh/hw !What about if HW = 0, need to add IF(Fground ==0) option ! fixed by setting a small number, TS 21 Oct 2017
1509 wb = w*sqrt(froof/fground)
1510 svf_ground = cos(atan(2*hw)) !!FO!! sky view factor for ground
1511 zvf_wall = cos(atan(2/hw)) !!FO!! wall view factor for wall
1512 svf_wall = (1 - zvf_wall)/2 !!FO!! sky view factor for wall
1513 zvf_ground = 1 - svf_ground !!FO!! wall view factor for ground
1514 xvf_wall = svf_wall !!FO!! ground view factor
1515 ! RVF_CANYON=COS(ATAN(2*ZREF/W))
1516 ! RVF_ROOF=1-RVF_CANYON
1517 ! RVF_WALL=(COS(ATAN(2*(ZREF-BldgH)/W))-RVF_CANYON)*RVF_CANYON
1518 ! RVF_ground=RVF_CANYON-RVF_WALL
1521 rvf_roof = froof
1523 END IF
1524
1526
1527 sumalb = 0.; nalb = 0
1528 sumemis = 0.; nemis = 0
1529
1530 !set emissivity for ceiling, wall and floor inside of buildings
1532
1533 !internal elements
1534 IF (nroom == 0) THEN
1535 fibld = (floor(bldgh/3.1 - 0.5) - 1)*froof
1536 ELSE
1537 fibld = (2.-2./nroom)*fwall + (floor(bldgh/3.1 - 0.5) - 1)*froof
1538 END IF
1539
1540 IF (fibld == 0) fibld = 0.00001 !this just ensures a solution to radiation
1542 IF (finternal == 0) finternal = 0.00001 ! to avoid zero-devision error TS 21 Oct 2017
1543 fair = zref - bldgh*froof
1544 IF (fair == 0) fair = 0.00001 ! to avoid zero-devision error TS 21 Oct 2017
1545 !ivf_ii=1.-ivf_iw-ivf_ir-ivf_if !S.O. I do not know these are should be calculated or read from input files
1546 !ivf_ww=1.-ivf_wi-ivf_wr-ivf_wf
1547 !ivf_rw=1.-ivf_ri-ivf_rf;
1548 !ivf_fr=ivf_rf;
1549
1550 IF ((ivf_ii + ivf_iw + ivf_ir + ivf_if > 1.0001) .OR. &
1551 (ivf_wi + ivf_ww + ivf_wr + ivf_wf > 1.0001) .OR. &
1552 (ivf_ri + ivf_rw + ivf_rf > 1.0001) .OR. &
1553 (ivf_fi + ivf_fw + ivf_fr > 1.0001) .OR. &
1554 (ivf_ii + ivf_iw + ivf_ir + ivf_if < 0.9999) .OR. &
1555 (ivf_wi + ivf_ww + ivf_wr + ivf_wf < 0.9999) .OR. &
1556 (ivf_ri + ivf_rw + ivf_rf < 0.9999) .OR. &
1557 (ivf_fi + ivf_fw + ivf_fr < 0.9999)) THEN
1558 print *, "At least one internal view factor <> 1. Check ivf in ESTMinput.nml"
1559 END IF
1560
1561 !=======Initial setting==============================================
1562 !! Rewritten by HCW 15 Jun 2016 to use existing SUEWS error handling
1563 !IF(inittemps) THEN
1564 ! write(*,*) 'inittemps:',inittemps
1565 ! FileFinalTemp=TRIM(FileOutputPath)//TRIM(FileCodeX)//'_ESTM_finaltemp.txt'
1566 ! OPEN(99,file=TRIM(FileFinalTemp),status='old',err=316) ! Program stopped if error opening file
1567 ! READ(99,*) Twall,Troof,Tground,Tibld ! Twall, Troof, Tground & Tibld get new values
1568 ! CLOSE(99)
1569 !ENDIF
1570 !
1571 !!IF (inittemps) THEN !!FO!! inittemps=.true. set in nml file
1572 !! OPEN(99,file='outputfiles/finaltemp.txt',status='old',iostat=ios) !!FO!! has to exist
1573 !!
1574 !! IF (ios/=0) CALL error('outputfiles/finaltemp.txt',ios,1) !!FO!! calls mod_error.f95, writes that the opening failed and stops prg
1575 !! IF (ios/=0) THEN
1576 !! Twall = (/273., 285., 291./)
1577 !! Troof = (/273., 285., 291./)
1578 !! Tground = (/273., 275., 280., 290./)
1579 !! Tibld = (/293., 293., 293./)
1580 !! ELSE
1581 !! READ(99,*) Twall,Troof,Tground,Tibld !!FO!! if finaltemp.txt exists Twall[3], Troof[3], Tground[4] & Tibld[3] get new values
1582 !! CLOSE(99)
1583 !! ENDIF
1584 !!ENDIF
1585
1586 !where (isnan(Twall))
1587 ! Twall = 273
1588 !endwhere
1589 !where (isnan(Troof))
1590 ! Troof = 273
1591 !endwhere
1592 !where (isnan(Tground))
1593 ! Tground = 281
1594 !endwhere
1595 !where (isnan(Tibld))
1596 ! Tibld = 293
1597 !endwhere
1598
1599 IF (estmstart == 1) THEN
1600 DO i = 1, 4
1601 tw_4(:, i) = twall !!FO!! Tw_4 holds three differnet temp:s for each wall layer but the same set for all points of the compass
1602 END DO
1603
1604 !initialize surface temperatures
1605 t0_ground = tground(1)
1606 t0_wall = twall(1)
1607 t0_roof = troof(1)
1608 t0_ibld = tibld(1)
1611
1612 !initialize outgoing longwave !QUESTION: HCW - Are these calculations compatible with those in LUMPS_NARP?
1616
1617 ! PRINT*,"W,WB= ",W,WB
1618 ! PRINT*,'SVF_ground ','SVF_WALL ','zvf_WALL ','HW '
1619 ! PRINT*,SVF_ground,SVF_WALL,zvf_WALL,HW
1620 ! PRINT*,'RVF_ground ','RVF_WALL ','RVF_ROOF ','RVF_VEG'
1621 ! PRINT*,RVF_ground,RVF_WALL,RVF_ROOF,RVF_VEG
1622 ! print*,'Alb_avg (VF)=',alb_avg
1623 ! print*,'z0m, Zd', z0m, ZD
1624
1625 END IF
1626
1627 first = .true.
1628
1629 !======Courant-Friedrichs-Lewy condition=================================
1630 !This is comment out by S.O. for now
1631 ! NB: should be recovered for calculation stability, FO and TS, 11 Oct 2017
1632 ! CFLval = minval(0.5*zibld*zibld*ribld/kibld) !!FO!! z*z*r/k => unit [s]
1633 ! if (Tstep>CFLval) then !CFL condition !!FO!! CFL condition: Courant�Friedrichs�Lewy condition is a necessary condition for convergence while solving
1634 ! write(*,*) "IBLD: CFL condition: Tstep=",Tstep,">",CFLval !!FO!! certain partial differential equations numerically by the method of finite differences (like eq 5 in Offerle et al.,2005)
1635 ! CFLfail=.TRUE.
1636 ! endif
1637 ! CFLval = minval(0.5*zroof*zroof*rroof/kroof)
1638 ! if (Tstep>CFLval) then !CFL condition
1639 ! write(*,*) "ROOF: CFL condition: Tstep=",Tstep,">",CFLval
1640 ! CFLfail=.TRUE.
1641 ! endif
1642 ! CFLval = minval(0.5*zwall*zwall*rwall/kwall)
1643 ! if (Tstep>CFLval) then !CFL condition
1644 ! write(*,*) "WALL: CFL condition: Tstep=",Tstep,">",CFLval
1645 ! CFLfail=.TRUE.
1646 ! endif
1647 ! CFLval = minval(0.5*zground*zground*rground/kground)
1648 ! if (Tstep>CFLval) then !CFL condition
1649 ! write(*,*) "ground: CFL condition: Tstep=",Tstep,">",CFLval
1650 ! CFLfail=.TRUE.
1651 ! endif
1652 ! if (CFLfail) then
1653 ! write(*,*) "Increase dX or decrease maxtimestep. Hit any key to continue"
1654 ! read (*,*)
1655 ! endif
1656
1657 ! Tiaircyc = (1+(LondonQSJune_Barbican.Tair-Tiair)./(5*Tiair)).*(Tiair + 0.4*sin(LondonQSJune_Barbican.HOUR*2*pi/24-10/24*2*pi)) !!FO!! outdoor temp affected
1658
1659 RETURN
1660
1661 ! 315 CALL errorHint(11,TRIM(fileESTMTs),notUsed,notUsed,NotUsedI)
1662 ! 316 CALL errorHint(11,TRIM(fileFinalTemp),notUsed,notUsed,NotUsedI)
1663
1664 END SUBROUTINE estm_translate
1665
1666 !===============================================================================
1667 SUBROUTINE estm( &
1668 Gridiv, & !input
1669 tstep, &
1670 avkdn, avu1, temp_c, zenith_deg, avrh, press_hpa, ldown, &
1671 bldgh, Ts5mindata_ir, &
1672 Tair_av, &
1673 dataOutLineESTM, QS) !output
1674 ! NB: HCW Questions:
1675 ! - should TFloor be set in namelist instead of hard-coded here?
1676 ! - zref used for radiation calculation and fair is set to 2*BldgH here. For compatibility with the rest of the
1677 ! SUEWS model, should this be the (wind speed) measurement height z specified in RunControl.nml?
1678 ! - In SUEWS_translate, fwall=AreaWall/SurfaceArea. Is this correct?
1679 ! - If froof=1 (i.e. whole grid is building), is HW=0 correct?
1680 ! - Then is an IF(Fground ==0) option needed?
1681 ! - alb_wall=0.23 and em_wall=0.9 are set in LUMPS_module_constants. Shouldn't these be provided as input?
1682 ! - Do the LUP calculations here need to be compatible with those in LUMPS_NARP?
1683 ! - File opening rewritten using existing error handling in SUEWS - can delete mod_error module from SUEWS_ESTM_functions
1684 ! - In SUEWS_ESTM_v2016, the first row is set to -999. This may be acceptable at the
1685 ! start of the run but should be handled properly between blocks of met data? - need to check what's actually happening here.
1686 ! - Many duplicate functions in SUEWS_ESTM_functions need changing to the existing SUEWS versions.
1687 ! - Are the following correctly initialised? T0_ibld, T0_ground, T0_wall, T0_roof, TN_wall, TN_roof, Tground, Twall, Troof, Tibld
1688 ! - What are Nalb, sumalb, Nemis and Sumemis for? Are they used correctly?
1689 !
1690
1691 !SUEWS_ESTM_v2016
1692 ! revision:
1693 ! HCW 14 Jun 2016
1694 ! HCW 27 Jun 2016 Corrected iESTMcount bug - now increases for all grids together
1695 ! HCW 30 Jun 2016 Major changes to handle grids and met blocks
1696 ! TS 09 Oct 2017 Added explicit interface
1697
1698 !Contains calculation for each time step
1699 !Calculate local scale heat storage from single building and surroundings observations
1700 !OFferle, May 2003
1701 !
1702 !MODIFICATION HISTORY
1703 ! 15 DECEMBER 2003
1704 ! (1) CHANGED AIR EXCHANGE RATE TO ALSO BE DEPENDENT ON OUTSIDE AIR TEMPERATURE
1705 ! (2) ADDED SPECIFIC HEAT CALCULATION FOR AIR
1706 ! (3) RH ADDED AS VAR(14) IN INPUT FILE
1707 ! 12 JANUARY 2004
1708 ! (1) ADDED ESTIMATED AVG NADIR LOOKING EXTERNAL SURFACE TEMPERATURE TO OUTPUT
1709 ! WEIGHTED BY SURFACE FRACTION AND SVF. SVF_ROOF=1, SVF_WALLS = 1-SVF_ground
1710 ! (2) ADDED NET RADIATION (RN) CALCULATIONS FOR ALL SURFACES AND AVG RN TO OUTPUT BASED ON
1711 ! RADIOMETER VIEW FROM ZREF
1712 ! 14 JANUARY 2004
1713 ! (1) MOVED GRID SPECIFIC PARAMETERS OUT OF NAMELIST, INTO PARAMETER FILE E.G. ALB,EM,F
1714 ! T0 MAKE CHANGES IN LOCATIONS EASIER.
1715 !
1716 ! 23 JANUARY 2004 - Version 2
1717 ! (1) PUT ALL TEMPERATURES INTO K
1718 ! (2) added interpolation routine to run on shorter timesteps.
1719 ! tested so that it doesn't change solution for forced temperatures.
1720 ! however in version 2 the energy balance at the surface isn't correctly solved
1721 !
1722 ! 25 JANUARY 2004 - Version 3
1723 ! (1) added solution to energy balance at surface
1724 ! (2) removed some extraneous code
1725 ! (3) added vegetation fractions for future development
1726 ! (4) some changes to input namelist.
1727 ! (5) need to add wind speed dependence for exchange coefficients
1728 ! (6) changed the way Rn_net is calculated. also radiometer view factor relationships
1729 ! (7) added a calculation for heat loss/gain to outside air (that going into building mass is storage)
1730 ! this is labelled QFBLD which it is in a sense.
1731 ! 6 FEBRUARY 2004
1732 ! (1) ADDED INTERNAL VIEW FACTOR FILE FOR INTERNAL GEOMETRY, INCLUDING FIXED FLOOR TEMPERATURE
1733 ! (2) added MeanU, MinWS to config, and U to ILOC.
1734 !
1735 ! 11 FEBRUARY 2004
1736 ! (1) added site lat, long, elevation to inputs
1737 ! (2) need zenith angle for wall direct radiation interception
1738 !
1739 ! 15 JUNE 2004
1740 ! (1) CORRECTED OUTPUT OF T0 FOR FORCED SURFACE TEMPERATURES
1741 ! (2) MADE SOME CHANGES TO RADIATION, COMPUTATION OF AVERAGE ALBEDO, ADDED AVERAGE EMISSIVITY
1742 ! (3) ADDED OUTPUT FILE FOR RADIATION COMPONENTS
1743 ! (4) CHANGED INPUT CONFIG SO CONVECTIVE EXCHANGE COEFFS ARE NOT USER SELECTABLE
1744 ! (5) MAY STILL BE PROBLEMS WITH WALL RADIATIVE EXCHANGE AND AVERAGE ALBEDO
1745 ! (6) CHANGED THE WAY HEAT STORAGE IS COMPUTED IN HEATCONDUCTION MODULE BUT THIS SHOULD NOT CHANGE RESULTS
1746 !
1747 ! 16 NOVEMBER 2004
1748 ! (1) CHANGED AIR EXCHANGE RATE TO BE BASES ON DAILY TEMPERATURE CHANGES.
1749 ! (2) WRITES OUT FINAL LAYER TEMPERATURES AND INCLUDES OPTION TO READ AT BEGINNING.
1750 !
1751 !DESCRIPTION: uses explicit time differencing to compute heat conduction through roof, walls,
1752 ! internal mass, and grounds (elements). Air heat storage is computed from average air temperature
1753 ! Boundary conditions are determined by measured surface temperature(s) or computed
1754 ! from energy balance at the surface.
1755 ! Internal air temperature can either be fixed or allowed to evolve in response
1756 ! to air mass exchanges and convective heating from internal surfaces.
1757 !
1758 !INPUT:
1759 !FORCING DATA: DTIME,KDOWN,LDOWN,TSURF,TAIR_OUT,TAIR_IN,TROOF,TWALL_AVG,TWALL_N,TWALL_E,TWALL_S,TWALL_W,Tground,RH,U
1760 !NAMELIST : HEATSTORAGE_vFO.NML
1761 ! &config
1762 ! ifile=FORCING DATA
1763 ! ofile=OUTPUT FILE
1764 ! pfile=HEAT STORAGE PARAMETER FILE
1765 ! Nibld = INTERNAL MASS LAYERS
1766 ! Nwall = EXTERNAL WALL LAYERS
1767 ! Nroof = ROOF LAYERS
1768 ! Nground = ground/SOIL LAYERS
1769 ! LBC_soil = LOWER BOUNDARY CONDITION FOR ground/SOIL
1770 ! iloc= INPUT COLUMNS IN DATA FILE
1771 ! evolveTibld= USE DIAGNOSTIC VALUE FOR INTERNAL BUILDING TEMPERATURE
1772 ! 0: don't use, use measured
1773 ! 1: TURN ON USE when temp goess ABOVE TINT_ON, off when temp is below TINT_OFF
1774 ! 2: always use diagnostic
1775 ! THEAT_ON= TEMPERATURE AT WHICH HEAT CONTROL IS TURNED ON
1776 ! THEAT_OFF= TEMPERATURE AT WHICH HEAT CONTROL IS TURNED OFF
1777 ! THEAT_FIX = Fixed internal temperature for climate control
1778 ! oneTsurf= USE SINGLE SURFACE TEMPERATURE TO DRIVE ALL LAYERS
1779 ! radforce= USE RADIATIVE ENERGY BALANCE TO DRIVE EXTERNAL TEMPERATURES
1780 ! maxtimestep=302, maximum time step in s for filling data gaps.
1781 ! Alt = STATION HEIGHT (m) FOR PRESSURE CALCULATION
1782 ! SPINUP = NUMBER OF LINES TO USE FOR SPINUP (REPEATS THESE LINES BUT ONLY OUTPUTS THE 2ND TIME)
1783 ! INITTEMP = if TRUE INITIALIZES TEMPERATURES TO THOSE IN FINALTEMP.TXT FILE
1784 ! CH_ibld = INTERNAL BUILDING CONVECTIVE EXCHANGE COEFFICIENT
1785 ! **** THESE SHOULD DEPEND ON WIND SPEED BUT CURRENTLY DO NOT ****
1786 ! CHAIR = CONVECTIVE EXCHANGE COEFFICIENT FOR ROOF
1787 ! chair_ground = ... FOR ground
1788 ! chair_wall = ... FOR WALL
1789 ! /
1790 ! ***************** PARAMETER FILE VARIABLES
1791 ! fveg = FRACTION OF ground SURFACE COVERED WITH VEG
1792 ! zveg = VEGETATION HEIGHT
1793 ! alb_veg = VEGETATION ALBEDO
1794 ! em_veg = VEGETATION EMISSIVITY
1795 ! ZREF = REFERENCE HEIGHT FOR FLUX CALCULATION
1796 ! BldgH = mean building height
1797 ! HW = CANYON ASPECT RATION
1798 ! f_X = FRACTION OF X WHERE X IS INTERNAL, WALL, ROOF, ground
1799 ! Alb_x = ALBEDO OF X
1800 ! em_ibld = EMISSIVITY OF X
1801 ! TX = INITIAL LAYER TEMPERATURES
1802 ! zX = LAYER THICKNESS
1803 ! kX = LAYER THERMAL CONDUCTIVITY
1804 ! ribld = LAYER VOLUMETRIC HEAT CAPACITY
1805 !
1806 !****************** INTERNAL VIEW FACTOR FILE
1807 !OUTPUT: fixed format text with single header, heatstorage for all elements, and temperatures
1808 ! for each element-layer.
1809 !===============================================================================
1810
1811 USE meteo, ONLY: pi, heatcapacity_air
1812 USE mod_solver, ONLY: newtonpolynomial
1813 ! USE modSolarCalc !!FO!! :modsolarcalc.f95
1814 ! USE MathConstants !!FO!! :MathConstants_module.f95
1815 USE physconstants, ONLY: c2k, sbconst
1816 USE heatflux, ONLY: heatcond1d
1817 USE estm_data
1818
1819 IMPLICIT NONE
1820 INTEGER, PARAMETER :: ncolsESTMdata = 13
1821 ! INTEGER, PARAMETER:: ncolumnsDataOutESTM=32
1822 INTEGER, PARAMETER :: cTs_Tiair = 5
1823 INTEGER, PARAMETER :: cTs_Tsurf = 6
1824 INTEGER, PARAMETER :: cTs_Troof = 7
1825 INTEGER, PARAMETER :: cTs_Troad = 8
1826 INTEGER, PARAMETER :: cTs_Twall = 9
1827 INTEGER, PARAMETER :: cTs_Twall_n = 10
1828 INTEGER, PARAMETER :: cTs_Twall_e = 11
1829 INTEGER, PARAMETER :: cTs_Twall_s = 12
1830 INTEGER, PARAMETER :: cTs_Twall_w = 13
1831 REAL(KIND(1D0)), PARAMETER :: NAN = -999
1832
1833 INTEGER, INTENT(in) :: Gridiv
1834 INTEGER, INTENT(in) :: tstep
1835 ! INTEGER,INTENT(in)::iy !Year
1836 ! INTEGER,INTENT(in)::id !Day of year
1837 ! INTEGER,INTENT(in)::it !Hour
1838 ! INTEGER,INTENT(in)::imin !Minutes
1839
1840 REAL(KIND(1D0)), INTENT(in) :: avkdn
1841 REAL(KIND(1D0)), INTENT(in) :: avu1
1842 REAL(KIND(1D0)), INTENT(in) :: temp_c
1843 REAL(KIND(1D0)), INTENT(in) :: zenith_deg
1844 REAL(KIND(1D0)), INTENT(in) :: avrh
1845 REAL(KIND(1D0)), INTENT(in) :: press_hpa
1846 REAL(KIND(1D0)), INTENT(in) :: ldown
1847 REAL(KIND(1D0)), INTENT(in) :: bldgh
1848 ! REAL(KIND(1d0)),INTENT(in):: dectime !Decimal time
1849 REAL(KIND(1D0)), DIMENSION(ncolsESTMdata), INTENT(in) :: Ts5mindata_ir !surface temperature input data
1850 REAL(KIND(1D0)), INTENT(in) :: Tair_av ! mean air temperature of past 24hr
1851
1852 REAL(KIND(1D0)), DIMENSION(27), INTENT(out) :: dataOutLineESTM
1853 !Output to SUEWS
1854 REAL(KIND(1D0)), INTENT(out) :: QS
1855 !Input from SUEWS, corrected as Gridiv by TS 09 Jun 2016
1856
1857 !Use only in this subroutine
1858 INTEGER :: i, ii
1859 INTEGER :: Tair2Set = 0
1860 REAL(KIND(1D0)) :: AIREXHR, AIREXDT
1861 REAL(KIND(1D0)), DIMENSION(2) :: bc
1862 REAL(KIND(1D0)) :: chair_ground, chair_wall
1863 REAL(KIND(1D0)) :: EM_EQUIV
1864 REAL(KIND(1D0)) :: kdz
1865 REAL(KIND(1D0)) :: kup_estm, LUP_net, kdn_estm
1866 REAL(KIND(1D0)) :: QHestm
1867 REAL(KIND(1D0)) :: QFBld !Anthropogenic heat from HVAC
1868 REAL(KIND(1D0)) :: shc_airbld
1869 REAL(KIND(1D0)) :: sw_hor, sw_vert
1870 REAL(KIND(1D0)) :: T0
1871 REAL(KIND(1D0)) :: Tinternal, Tsurf_all, Troof_in, Troad, Twall_all, Tw_n, Tw_e, Tw_s, Tw_w
1872 REAL(KIND(1D0)) :: Twallout(5), Troofout(5), Tibldout(5), Tgroundout(5)
1873 REAL(KIND(1D0)) :: Tadd, Tveg
1874 REAL(KIND(1D0)) :: Tairmix
1875 REAL(KIND(1D0)) :: RN
1876 REAL(KIND(1D0)) :: Rs_roof, Rl_roof, RN_ROOF
1877 REAL(KIND(1D0)) :: Rs_wall, Rl_wall, RN_WALL
1878 REAL(KIND(1D0)) :: Rs_ground, Rl_ground, RN_ground
1879 REAL(KIND(1D0)) :: Rs_ibld, Rl_ibld
1880 REAL(KIND(1D0)) :: Rs_iroof, Rl_iroof
1881 REAL(KIND(1D0)) :: Rs_iwall, Rl_iwall
1882 REAL(KIND(1D0)) :: zenith_rad
1883 REAL(KIND(1D0)) :: dum(50)
1884 REAL(KIND(1D0)) :: bldgHX ! local bldgHX=max(bldgH,0.001)
1885 REAL(KIND(1D0)), PARAMETER :: WSmin = 0.1 ! Check why there is this condition. S.O.
1886 LOGICAL :: radforce, groundradforce
1887
1888 radforce = .false.
1889 groundradforce = .false. !Close the radiation scheme in original ESTM S.O.O.
1890
1891 bldghx = max(bldgh, 0.001) ! this is to prevent zero building height
1892
1893 ! Set -999s for first row
1894 ! dum=(/-999.,-999.,-999.,-999.,-999.,-999.,-999.,-999.,-999.,-999.,&
1895 ! -999.,-999.,-999.,-999.,-999.,-999.,-999.,-999.,-999.,-999.,&
1896 ! -999.,-999.,-999.,-999.,-999.,-999.,-999.,-999.,-999.,-999.,&
1897 ! -999.,-999.,-999.,-999.,-999.,-999.,-999.,-999.,-999.,-999.,&
1898 ! -999.,-999.,-999.,-999.,-999.,-999.,-999.,-999.,-999.,-999./)
1899 dum = [(-999, i=1, 50)]
1900
1901 !External bulk exchange coefficients - set these somewhere more sensible***
1902 chr = 0.005
1903 chair = chr
1904 chair_ground = chair
1905 chair_wall = chair
1906
1907 !Get met data for use in ESTM subroutine
1908 kdn_estm = avkdn
1909 ws = avu1
1910 IF (ws < wsmin) ws = wsmin
1911 tair1 = temp_c + c2k
1912 ! Set initial value of Tair2 to air temp
1913 IF (gridiv == 1) tair2set = tair2set + 1
1914 IF (tair2set == 1) THEN
1915 tair2 = temp_c + c2k
1916 ELSE
1917 tair2 = tair2_grids(gridiv)
1918 ! Also get other variables for this grid
1919 tievolve = tievolve_grids(gridiv)
1921 lup_wall = lup_wall_grids(gridiv)
1922 lup_roof = lup_roof_grids(gridiv)
1923 t0_ibld = t0_ibld_grids(gridiv)
1924 t0_ground = t0_ground_grids(gridiv)
1925 t0_wall = t0_wall_grids(gridiv)
1926 t0_roof = t0_roof_grids(gridiv)
1927 tn_wall = tn_wall_grids(gridiv)
1928 tn_roof = tn_roof_grids(gridiv)
1929 tground(:) = tground_grids(:, gridiv)
1930 twall(:) = twall_grids(:, gridiv)
1931 troof(:) = troof_grids(:, gridiv)
1932 tibld(:) = tibld_grids(:, gridiv)
1933 tw_4 = tw_4_grids(:, :, gridiv)
1934
1935 END IF
1936
1937 ! Get Ts from Ts5min data array
1938 ! Tinternal = Ts5mindata(ir,cTs_Tiair)
1939 ! Tsurf_all = Ts5mindata(ir,cTs_Tsurf)
1940 ! Troof_in = Ts5mindata(ir,cTs_Troof)
1941 ! Troad = Ts5mindata(ir,cTs_Troad)
1942 ! Twall_all = Ts5mindata(ir,cTs_Twall)
1943 !
1944 ! Tw_n = Ts5mindata(ir,cTs_Twall_n)
1945 ! Tw_e = Ts5mindata(ir,cTs_Twall_e)
1946 ! Tw_s = Ts5mindata(ir,cTs_Twall_s)
1947 ! Tw_w = Ts5mindata(ir,cTs_Twall_w)
1948 tinternal = ts5mindata_ir(cts_tiair)
1949 tsurf_all = ts5mindata_ir(cts_tsurf)
1950 troof_in = ts5mindata_ir(cts_troof)
1951 troad = ts5mindata_ir(cts_troad)
1952 twall_all = ts5mindata_ir(cts_twall)
1953
1954 tw_n = ts5mindata_ir(cts_twall_n)
1955 tw_e = ts5mindata_ir(cts_twall_e)
1956 tw_s = ts5mindata_ir(cts_twall_s)
1957 tw_w = ts5mindata_ir(cts_twall_w)
1958
1959 ! if (any(isnan(Ts5mindata))) then !!FO!! can't use data when time gap is too big (or neg.) or data is NaN
1960 ! if (spindone) then !!FO!! writes a line of NaNs
1961 ! write(20,'(1F8.4,I6,100f10.1)') dectime,it,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,&
1962 ! -0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,&
1963 ! -0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,&
1964 ! -0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.,-0./0.
1965 ! endif
1966 ! return ! changed from cycle !!FO!! returns to beginning of do-loop, i.e. doesn't make any heat calculations
1967 ! endif
1968 !!FO!! this loop is used to run through the calculations (SPINUP number of times) to achieve better numerical stability
1969 !!FO!! when if condition is met the program starts over from the beginning of the input file and the calculations are performed
1970 !!FO!! ...once again, but this time saved to the output file
1971 !!FO!! it's because of this if statement arrangement that the output result starts at input time #2 (if not SPINUP=0 as originally in heatstorage_vFO.nml)
1972 ! IF (NLINESREAD>datalines.AND..NOT.SPINDONE) THEN !!FO!! at this stage spindone = .false.
1973 ! NLINESREAD=0
1974 ! SPINDONE=.TRUE.
1975 !PRINT*, "SPUNUP"
1976 ! return ! changed from cycle
1977 ! ENDIF
1978
1979 !! Write first row of each met block as -999
1980 !IF (first) THEN !Set to true in ESTM_initials
1981 !! !Tair2=Temp_C+C2K !This is now set in SUEWS_translate for ir=0 only
1982 !! ! first=.FALSE.
1983 ! IF(Gridiv == NumberOfGrids) first=.FALSE. !Set to false only after all grids have run
1984 ! dataOutESTM(ir,1:32,Gridiv)=(/REAL(iy,KIND(1D0)),REAL(id,KIND(1D0)),&
1985 ! REAL(it,KIND(1D0)),REAL(imin,KIND(1D0)),dectime,(dum(ii),ii=1,27)/)
1986 ! RETURN
1987 !ENDIF
1988
1989 ! What are these constants? - Need defining somewhere
1990 zenith_rad = zenith_deg/180*pi
1991 IF (zenith_rad > 0 .AND. zenith_rad < pi/2.-hw) THEN !ZENITH MUST BE HIGHER THAN BUILDINGS FOR DIRECT INTERCEPTION
1992 tanzenith = min(tan(zenith_rad), 5.67) !LIMITS TO ANGLES LESS THAN 80 EVEN FOR LOW HW
1993 tanzenith = tanzenith*kdn_estm/(1370*cos(zenith_rad)) !REDUCTION FACTOR FOR MAXIMUM
1994 ELSE
1995 tanzenith = 0.
1996 END IF
1997
1998 shc_air = heatcapacity_air(tair1, avrh, press_hpa) ! Use SUEWS version
1999
2000 !Evolution of building temperature from heat added by convection
2001 SELECT CASE (evolvetibld) !EvolveTiBld specifies which internal building temperature approach to use
2002 CASE (0)
2003 diagnoseti = .false.
2004 hvac = .false. !use data in file !!FO!! use measured indoor temperature (Tref in Lodz2002HS.txt)
2005 CASE (1) !!FO!! use of HVAC to counteract T changes
2006 diagnoseti = .true.
2007 IF (tievolve > theat_off) THEN !THEAT_OFF now converted to Kelvin in ESTM_initials - HCW 15 Jun 2016
2008 !IF (Tievolve>THEAT_OFF+C2K) THEN
2009 hvac = .false.
2010 ELSEIF (tievolve < theat_on) THEN !THEAT_OFF now converted to Kelvin in ESTM_initials - HCW 15 Jun 2016
2011 !ELSEIF (Tievolve<THEAT_ON+C2K) THEN
2012 hvac = .true.
2013 END IF
2014 CASE (2)
2015 diagnoseti = .true. !!FO!! convection between ibld and inside of external walls(?)
2016 END SELECT
2017
2018 !ASSUME AIR MIXES IN PROPORTION TO # OF EXCHANGES
2019 IF (tair_av > 20.+c2k .AND. tievolve > 25.+c2k .AND. tair1 < tievolve .AND. .NOT. hvac) THEN
2020 airexhr = 2.0 !Windows or exterior doors on 3 sides (ASHRAE 1981 22.8)
2021 ELSEIF (tair_av < 17.+c2k .OR. hvac) THEN
2022 airexhr = 0.5 !No window or exterior doors, storm sash or weathertripped (ASHRAE 1981 22.8)
2023 ELSE
2024 airexhr = 1.0
2025 END IF
2026
2027 airexdt = airexhr*(tstep/3600.0)
2028 shc_airbld = max(heatcapacity_air(tievolve, avrh, press_hpa), 0.00001) ! to avoid zero-division scenario TS 21 Oct 2017
2029 IF (shc_airbld < minshc_airbld) minshc_airbld = shc_airbld
2030
2031 !internal convective exchange coefficients !!FO!! ibldCHmod = 0 originally
2032 !iBldCHmod specifies method for convective exchange coeffs
2033 IF (ibldchmod == 1) THEN !ASHRAE 2001
2034 ch_ibld = 1.31*(abs(t0_ibld - tievolve))**0.25/shc_airbld
2035 ch_iwall = 1.31*(abs(tn_wall - tievolve))**0.25/shc_airbld
2036 ch_iroof = 1.52*(abs(tn_roof - tievolve))**0.25/shc_airbld
2037 IF (abs(tn_roof - tievolve) > 0) ch_iroof = ch_iroof*0.39 !effect of convection is weaker downward
2038 ELSEIF (ibldchmod == 2) THEN !Awbi, H.B. 1998, Energy and Buildings 28: 219-227
2039 ch_ibld = 1.823*(abs(t0_ibld - tievolve))**0.293/shc_airbld
2040 ch_iwall = 1.823*(abs(tn_wall - tievolve))**0.293/shc_airbld
2041 ch_iroof = 2.175*(abs(tn_roof - tievolve))**0.308/shc_airbld
2042 IF (abs(tn_roof - tievolve) > 0) ch_iroof = 0.704*(abs(tn_roof - tievolve))**0.133/shc_airbld !effect of convection is weaker downward
2043 END IF
2044
2045 !Evolving T = (Previous Temp + dT from Sensible heat flux) mixed with outside air
2046 !ASSUMES THE CH_BLD INCLUDES THE EFFECT OF VENTILATION RATE IN m/s (e.g. if a normal CH is .005 and
2047 !the value here is .003 the assumed ventilation is 0.6 m/s !!FO!! CH_ibld=0.0015 from heatstorage_Barbican.nml => ventilation=0.3 m/s
2048 tairmix = (tievolve + tair1*airexdt)/(1.0 + airexdt)
2049 qfbld = froof*(tievolve - tairmix)*shc_airbld*bldghx/tstep !heat added or lost, requires cooling or heating if HVAC on
2050
2051 !!FO!! CH_xxxx has unit [m/s] !!**HCW what is going on with tstep here??
2052 tievolve = tairmix + tstep/bldghx/finternal & !!FO!! finternal(=froof+fibld+fwall) => normalisation of fractions
2055 + ch_iwall*fwall*(tn_wall - tievolve)) !!FO!! [K] = [K] + [s/m]*([m/s]*([K]))
2056
2057 IF (.NOT. diagnoseti) tievolve = tinternal + c2k
2058 IF (hvac) THEN !Run up/down to set point +/- 1 degree with adjustment of 90% per hour
2059 tadd = (sign(-1.0d0, theat_fix - tievolve) + theat_fix - tievolve)*min(4.*tstep/3600.0, 0.9) !!**HCW check??
2060 tievolve = tievolve + tadd
2061 END IF
2062
2063 !========>RADIATION<================
2064 IF (kdn_estm < 0) kdn_estm = 0. !set non-zero shortwave to zero !Should this be moved up to line 183/4?
2065
2066 !external components, no diffuse
2067 !for reflections complete absorption is assumed
2068 !for shortwave these are net values
2069 !for longwave these are incoming only
2070 !MUST DIVIDE SHORTWAVE INTO DIRECT AND DIFFUSE
2071 sw_hor = kdn_estm !incoming solar on horizontal surface
2072 sw_vert = kdn_estm*tanzenith !incoming solar on vertical surface = kdown(obs)*sin(zenith)/cos(zenith)
2073
2074 rs_roof = svf_roof*(1.0 - alb_roof_estm)*sw_hor
2075 rl_roof = svf_roof*em_roof_estm*ldown
2076
2077 rs_ground = svf_ground*(1.-alb_ground_estm)*sw_hor + &
2080
2082
2083 rs_wall = svf_wall*(1.-alb_wall_fix)*sw_vert + &
2087
2088 !wall to wall exchange handled simultaneously with seb calc
2089 rl_wall = svf_wall*ldown*em_wall_fix + zvf_wall*svf_wall*ldown*(1 - em_wall_fix)*em_wall_fix + &
2091
2092 !DIFFICULT TO DETERMINE WHAT THIS IS EXACTLY, DONT INCLUDE WALLS
2093 kup_estm = kdn_estm - rvf_roof*rs_roof - (rvf_ground + rvf_wall)*rs_ground/svf_ground - rvf_veg*alb_veg_estm*kdn_estm
2094 IF (kdn_estm > 10 .AND. kup_estm > 0) THEN
2095 alb_avg = kup_estm/kdn_estm
2097 nalb = nalb + 1
2098 END IF
2099
2100 !internal components
2101 rs_ibld = 0 ! This could change if there are windows (need solar angles or wall svf * fraction glazing * transmissivity)
2102 !internal incoming longwave terms do not include the view factors for its own surface e.g. for ibld and walls
2103 !added floor view factors
2104 rl_ibld = sbconst*(ivf_iw*em_w*tn_wall**4 + &
2105 ivf_ir*em_r*tn_roof**4 + &
2106 ivf_if*em_f*tfloor**4)
2107 rs_iwall = 0
2108 rl_iwall = sbconst*(ivf_wi*em_i*t0_ibld**4 + &
2109 ivf_wr*em_r*tn_roof**4 + &
2110 ivf_wf*em_f*tfloor**4)
2111 rs_iroof = 0
2112 rl_iroof = sbconst*(ivf_ri*em_i*t0_ibld**4 + &
2113 ivf_rw*em_w*tn_wall**4 + &
2114 ivf_rf*em_f*tfloor**4)
2115
2116 !========>INTERNAL<================
2117 bctype = .false.
2118 kdz = 2*kibld(1)/zibld(1)
2119 pcoeff = (/em_ibld*sbconst*(1 - ivf_ii*em_ibld), 0.0d0, 0.0d0, kdz + shc_airbld*ch_ibld, &
2120 -kdz*tibld(1) - shc_airbld*ch_ibld*tievolve - rs_ibld - rl_ibld/)
2122
2123 !!FO!! this leads to Tibld(1) = Tibld(3) , i.e. ...
2124 bc(1) = t0_ibld
2125
2126 !!FO!! temperature equal on both sides of inside wall
2127 bc(2) = bc(1)
2128
2129 ! print*,'ESTM Qsibld cal before',Qsibld,Tibld,zibld(1:Nibld)
2131 REAL(Tstep, KIND(1D0)), kibld(1:Ndepth_ibld), &
2132 ribld(1:Ndepth_ibld), bc, bctype)
2133
2134 ! print*,'ESTM Qsibld cal after',Qsibld,Tibld
2135
2136 !========>WALLS<================
2137 bctype = .false.
2139 pcoeff = (/em_ibld*sbconst*(1 - ivf_ww*em_ibld), 0.0d0, 0.0d0, kdz + shc_airbld*ch_iwall, &
2140 -kdz*twall(ndepth_wall) - shc_airbld*ch_iwall*tievolve - rs_iwall - rl_iwall/)
2142 bc(2) = tn_wall !!FO!! boundary condition #2 = inner surface Twall, originally from lodz_parms_ltm.txt or finaltemp.txt
2143
2144 IF (tsurfchoice < 2 .OR. radforce) THEN
2145 IF (radforce) THEN !!FO!! 1st prio: radforce
2146 kdz = 2*kwall(1)/zwall(1)
2147 pcoeff = (/em_wall_fix*sbconst*(1 - zvf_wall*em_wall_fix), 0.0d0, 0.0d0, kdz + shc_air*chair_wall*ws, &
2148 -kdz*twall(1) - shc_air*chair_wall*ws*tair1 - rs_wall - rl_wall/)
2150 bc(1) = t0_wall !!FO!! boundary condition #1 = outer surface Twall, originally from lodz_parms_ltm.txt or finaltemp.txt
2151 ELSEIF (tsurfchoice == 0) THEN
2152 bc(1) = tsurf_all + c2k; t0_wall = bc(1)
2153 ELSEIF (tsurfchoice == 1) THEN
2154 bc(1) = twall_all + c2k; t0_wall = bc(1)
2155 END IF !!FO!! Tsoil in Lodz2002HS.txt NB => Lodz2002HS.txt doesn't work with onewall = TRUE
2156
2157 CALL heatcond1d(twall, qswall, zwall(1:ndepth_wall), real(tstep, kind(1d0)), &
2158 kwall(1:ndepth_wall), rwall(1:ndepth_wall), bc, bctype) !!FO!! new set of Twalls are calculated from heat conduction through wall
2159
2160 ELSEIF (tsurfchoice == 2) THEN !SPECIAL FOR 4 WALLS
2161 t0_wall = 0.
2162 DO i = 1, 4 !do 4 walls
2163 bc(1) = tw_n + tw_e + tw_s + tw_w + c2k; t0_wall = t0_wall + bc(1)
2164 CALL heatcond1d(tw_4(:, i), qs_4(i), zwall(1:ndepth_wall), real(tstep, kind(1d0)), &
2165 kwall(1:ndepth_wall), rwall(1:ndepth_wall), bc, bctype)
2166 END DO
2167 !Take average of 4 wall values
2168 t0_wall = t0_wall/4.
2169 qswall = sum(qs_4)/4.
2170 twall = sum(tw_4, 2)/4.
2171 END IF
2172
2173 !========>ROOF<================
2174 bctype = .false.
2176 pcoeff = (/em_ibld*sbconst, 0.0d0, 0.0d0, kdz + shc_airbld*ch_iroof, &
2177 -kdz*troof(ndepth_roof) - shc_airbld*ch_iroof*tievolve - rs_iroof - rl_iroof/)
2179 bc(2) = tn_roof
2180
2181 IF (radforce) THEN
2182 kdz = 2*kroof(1)/zroof(1)
2183 pcoeff = (/em_roof_estm*sbconst, 0.0d0, 0.0d0, kdz + shc_air*chair*ws, &
2184 -kdz*troof(1) - shc_air*chair*ws*tair1 - rs_roof - rl_roof/)
2186 bc(1) = t0_roof
2187 ELSEIF (tsurfchoice == 0) THEN
2188 bc(1) = tsurf_all + c2k; t0_roof = bc(1)
2189 ELSE
2190 bc(1) = troof_in + c2k; t0_roof = bc(1)
2191 END IF
2192
2193 CALL heatcond1d(troof, qsroof, zroof(1:ndepth_roof), real(tstep, kind(1d0)), &
2194 kroof(1:ndepth_roof), rroof(1:ndepth_roof), bc, bctype)
2195
2196 !========>ground<================
2197 bctype = .false.
2198 kdz = 2*kground(1)/zground(1)
2199
2200 IF (radforce .OR. groundradforce) THEN
2201 pcoeff = (/em_ground_estm*sbconst, 0.0d0, 0.0d0, kdz + shc_air*chair_ground*ws, &
2202 -kdz*tground(1) - shc_air*chair_ground*ws*tair1 - rs_ground - rl_ground/)
2204 bc(1) = t0_ground
2205 ELSEIF (tsurfchoice == 0) THEN
2206 bc(1) = tsurf_all + c2k; t0_ground = bc(1)
2207 ELSE
2208 bc(1) = troad + c2k; t0_ground = bc(1)
2209 END IF
2210
2211 bc(2) = lbc_soil + c2k
2212 ! bc(2)=0.; bctype(2)=.t.
2213
2214 IF (fground /= 0.) THEN ! check fground==0 scenario to avoid division-by-zero error, TS 21 Jul 2016
2216 REAL(Tstep, KIND(1D0)), kground(1:Ndepth_ground), rground(1:Ndepth_ground), bc, bctype)
2217 ELSE
2218 qsground = nan
2219 END IF
2220
2221 qsair = fair*shc_air*(tair1 - tair2)/tstep
2226 qs = qsibld + qswall + qsroof + qsground !!FO!! QSair not included; called QS in output file (column #10)
2227
2228 ! print*,'ESTM QS',qs,Qsibld,Qswall,Qsroof ,Qsground
2229 ! print*,'ESTM Qsibld',Qsibld,fibld
2230 !write(*,*) Qsair, QSibld, Qswall, Qsroof, Qsground, QS
2231
2232 !========>Radiation<================
2233 !note that the LUP for individual components does not include reflected
2237 tveg = tair1
2238 lup_veg = sbconst*em_veg_estm*tveg**4
2241 em_equiv = lup_net/(sbconst*t0**4) !!FO!! apparent emissivity of the atmosphere [cloudless sky: >� Ldown from gases in the lowest 100 m] calculated from surface at T0
2242 rn_ground = rs_ground + rl_ground - lup_ground
2243 rn_roof = rs_roof + rl_roof - lup_roof
2244 rn_wall = rs_wall + rl_wall - lup_wall*(1 - zvf_wall*em_wall_fix)
2245 rn = kdn_estm - kup_estm + ldown*em_equiv - lup_net !!FO!! average net radiation (at z > zref ????) = shortwave down - shortwave up + [longwave down * apparent emissivity] - longwave up
2246 qhestm = (t0 - tair1)*chair*shc_air*ws
2247 sumemis = sumemis + em_equiv
2248 nemis = nemis + 1
2249
2250 ! IF (SPINDONE) THEN !!FO!! only the last set of values in the time interpolation loop is written to file
2251
2252 IF (ndepth_wall < 5) THEN
2253 twallout = (/twall, (dum(ii), ii=1, (5 - ndepth_wall))/)
2254 ELSE
2255 twallout = twall
2256 END IF
2257
2258 IF (ndepth_roof < 5) THEN
2259 troofout = (/troof, (dum(ii), ii=1, (5 - ndepth_roof))/)
2260 ELSE
2261 troofout = troof
2262 END IF
2263
2264 IF (ndepth_ground < 5) THEN
2265 tgroundout = (/tground, (dum(ii), ii=1, (5 - ndepth_ground))/)
2266 ELSE
2267 tgroundout = tground
2268 END IF
2269
2270 IF (ndepth_ibld < 5) THEN
2271 tibldout = (/tibld, (dum(ii), ii=1, (5 - ndepth_ibld))/)
2272 ELSE
2273 tibldout = tibld
2274 END IF
2275
2276 ! dataOutESTM(ir,1:ncolumnsDataOutESTM,Gridiv)=[&
2277 ! REAL(iy,KIND(1D0)),REAL(id,KIND(1D0)),REAL(it,KIND(1D0)),REAL(imin,KIND(1D0)), dectime,&!5
2278 ! QS,Qsair,Qswall,Qsroof,Qsground,Qsibld,&!11
2279 ! Twallout,Troofout,Tgroundout,Tibldout,Tievolve]!32 !NB. These all have 5 elements except Tievolve (1).
2280 dataoutlineestm = [ &
2281 qs, qsair, qswall, qsroof, qsground, qsibld, & !6
2282 twallout, troofout, tgroundout, tibldout, tievolve] !27 !NB. These all have 5 elements except Tievolve (1).
2283 ! set invalid values to nan
2284 dataoutlineestm = set_nan(dataoutlineestm)
2285 ! call r8vec_print(ncolumnsDataOutESTM-5,dataOutESTM(ir,6:ncolumnsDataOutESTM,Gridiv),'dataOutESTM')
2286
2287 tair2 = tair1
2288
2289 ! Save variables for this grid
2290 tair2_grids(gridiv) = tair1
2292 lup_wall_grids(gridiv) = lup_wall
2293 lup_roof_grids(gridiv) = lup_roof
2294 tievolve_grids(gridiv) = tievolve
2295 t0_ibld_grids(gridiv) = t0_ibld
2296 t0_ground_grids(gridiv) = t0_ground
2297 t0_wall_grids(gridiv) = t0_wall
2298 t0_roof_grids(gridiv) = t0_roof
2299 tn_wall_grids(gridiv) = tn_wall
2300 tn_roof_grids(gridiv) = tn_roof
2301 tground_grids(:, gridiv) = tground(:)
2302 twall_grids(:, gridiv) = twall(:)
2303 troof_grids(:, gridiv) = troof(:)
2304 tibld_grids(:, gridiv) = tibld(:)
2305 tw_4_grids(:, :, gridiv) = tw_4(:, :)
2306
2307 END SUBROUTINE estm
2308
2309 ! ===============================================================================================
2310 ! extended ESTM, TS 20 Jan 2022
2311 ! ESTM_ehc accoutns for
2312 ! 1. heterogeneous building facets (roofs, walls) at different vertical levels
2313 ! 2. all standard ground-level surfaces (dectr, evetr, grass, bsoil and water)
2314 ! SUBROUTINE ESTM_ehc( &
2315 ! tstep, & !input
2316 ! nlayer, &
2317 ! QG_surf, qg_roof, qg_wall, &
2318 ! tsfc_roof, tin_roof, temp_in_roof, k_roof, cp_roof, dz_roof, sfr_roof, & !input
2319 ! tsfc_wall, tin_wall, temp_in_wall, k_wall, cp_wall, dz_wall, sfr_wall, & !input
2320 ! tsfc_surf, tin_surf, temp_in_surf, k_surf, cp_surf, dz_surf, sfr_surf, & !input
2321 ! temp_out_roof, QS_roof, & !output
2322 ! temp_out_wall, QS_wall, & !output
2323 ! temp_out_surf, QS_surf, & !output
2324 ! QS) !output
2325 ! USE allocateArray, ONLY: &
2326 ! nsurf, ndepth, &
2327 ! PavSurf, BldgSurf, ConifSurf, DecidSurf, GrassSurf, BSoilSurf, WaterSurf
2328 ! USE heatflux, ONLY: heatcond1d_ext, heatcond1d_vstep
2329
2330 ! IMPLICIT NONE
2331 ! INTEGER, INTENT(in) :: tstep
2332 ! INTEGER, INTENT(in) :: nlayer ! number of vertical levels in urban canopy
2333
2334 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: QG_surf ! ground heat flux
2335 ! ! extended for ESTM_ehc
2336
2337 ! ! keys:
2338 ! ! tsfc: surface temperature
2339 ! ! tin: indoor/deep bottom temperature
2340 ! ! temp_in: temperature at inner interfaces
2341 ! ! k: thermal conductivity
2342 ! ! cp: heat capacity
2343 ! ! dz: thickness of each layer
2344 ! ! roof/wall/surf: roof/wall/ground surface types
2345
2346 ! ! input arrays: roof facets
2347 ! REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: qg_roof
2348 ! REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tsfc_roof
2349 ! REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tin_roof
2350 ! REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: sfr_roof
2351 ! REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: temp_in_roof
2352 ! REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: k_roof
2353 ! REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: cp_roof
2354 ! REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: dz_roof
2355 ! ! input arrays: wall facets
2356 ! REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: qg_wall
2357 ! REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tsfc_wall
2358 ! REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: tin_wall
2359 ! REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(in) :: sfr_wall
2360 ! REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: temp_in_wall
2361 ! REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: k_wall
2362 ! REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: cp_wall
2363 ! REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(in) :: dz_wall
2364 ! ! input arrays: standard suews surfaces
2365 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: tsfc_surf
2366 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: tin_surf
2367 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(in) :: sfr_surf
2368 ! REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(in) :: temp_in_surf
2369 ! REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(in) :: k_surf
2370 ! REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(in) :: cp_surf
2371 ! REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(in) :: dz_surf
2372
2373 ! ! output arrays
2374 ! ! roof facets
2375 ! REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: QS_roof
2376 ! REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(out) :: temp_out_roof !interface temperature between depth layers
2377 ! ! wall facets
2378 ! REAL(KIND(1D0)), DIMENSION(nlayer), INTENT(out) :: QS_wall
2379 ! REAL(KIND(1D0)), DIMENSION(nlayer, ndepth), INTENT(out) :: temp_out_wall !interface temperature between depth layers
2380 ! ! standard suews surfaces
2381 ! REAL(KIND(1D0)), DIMENSION(nsurf), INTENT(out) :: QS_surf
2382 ! REAL(KIND(1D0)), DIMENSION(nsurf, ndepth), INTENT(out) :: temp_out_surf !interface temperature between depth layers
2383
2384 ! ! grid aggregated results
2385 ! REAL(KIND(1D0)), INTENT(out) :: QS
2386
2387 ! ! internal use
2388 ! ! temporary arrays in calculations
2389 ! ! note: nsurf is used as the maximum number of surfaces
2390 ! REAL(KIND(1D0)), DIMENSION(:), ALLOCATABLE :: tsfc_cal
2391 ! REAL(KIND(1D0)), DIMENSION(:), ALLOCATABLE :: tin_cal
2392 ! REAL(KIND(1D0)), DIMENSION(:, :), ALLOCATABLE :: temp_cal
2393 ! REAL(KIND(1D0)), DIMENSION(:, :), ALLOCATABLE :: k_cal
2394 ! REAL(KIND(1D0)), DIMENSION(:, :), ALLOCATABLE :: cp_cal
2395 ! REAL(KIND(1D0)), DIMENSION(:, :), ALLOCATABLE :: dz_cal
2396 ! REAL(KIND(1D0)), DIMENSION(:), ALLOCATABLE :: qs_cal
2397
2398 ! ! REAL(KIND(1D0)), DIMENSION(ndepth) :: temp_all_cal
2399 ! ! surface temperatures at innermost depth layer
2400 ! ! REAL(KIND(1D0)) :: temp_IBC
2401 ! INTEGER :: i_facet, i_group, nfacet, i_depth
2402
2403 ! ! settings for boundary conditions
2404 ! REAL(KIND(1D0)), DIMENSION(2) :: bc
2405
2406 ! ! use temperature as boundary conditions
2407 ! LOGICAL, DIMENSION(2) :: bctype
2408 ! LOGICAL :: debug
2409
2410 ! ! use finite depth heat conduction solver
2411 ! LOGICAL :: use_heatcond1d, use_heatcond1d_water
2412
2413 ! ! normalised surface fractions
2414 ! REAL(KIND(1D0)), DIMENSION(nlayer) :: sfr_roof_n
2415 ! REAL(KIND(1D0)), DIMENSION(nlayer) :: sfr_wall_n
2416
2417 ! ! initialise solver flags
2418 ! use_heatcond1d = .TRUE.
2419 ! use_heatcond1d_water = .FALSE.
2420 ! debug = .FALSE.
2421
2422 ! ! normalised surface fractions
2423 ! ! NB: the sum of sfr_roof (sfr_wall) is NOT unity; so need to be normalised by the sum
2424 ! sfr_roof_n = sfr_roof/SUM(sfr_roof)
2425 ! sfr_wall_n = sfr_wall/SUM(sfr_wall)
2426 ! ! sub-facets of buildings: e.g. walls, roofs, etc.
2427 ! DO i_group = 1, 3
2428
2429 ! ! allocate arrays
2430 ! IF (i_group == 1) THEN
2431 ! ! PRINT *, 'group: ', 'roof'
2432 ! nfacet = nlayer
2433 ! ELSE IF (i_group == 2) THEN
2434 ! ! PRINT *, 'group: ', 'wall'
2435 ! nfacet = nlayer
2436 ! ELSE IF (i_group == 3) THEN
2437 ! ! PRINT *, 'group: ', 'surf'
2438 ! nfacet = nsurf
2439 ! END IF
2440 ! ! PRINT *, 'nfacet here: ', nfacet
2441 ! ALLOCATE (tsfc_cal(nfacet))
2442 ! ALLOCATE (tin_cal(nfacet))
2443 ! ALLOCATE (qs_cal(nfacet))
2444 ! ALLOCATE (temp_cal(nfacet, ndepth))
2445 ! ALLOCATE (k_cal(nfacet, ndepth))
2446 ! ALLOCATE (cp_cal(nfacet, ndepth))
2447 ! ALLOCATE (dz_cal(nfacet, ndepth))
2448 ! ! PRINT *, 'allocation done! '
2449
2450 ! ! translate input arrays of facet groups to internal use arrays
2451 ! IF (i_group == 1) THEN
2452 ! ! PRINT *, 'translation for roof! '
2453 ! ! TODO: to update with actual values from input files
2454 ! tsfc_cal(1:nfacet) = tsfc_roof(1:nfacet)
2455 ! ! PRINT *, 'tsfc_cal for roof! ', tsfc_cal
2456 ! tin_cal(1:nfacet) = tin_roof(1:nfacet)
2457 ! ! PRINT *, 'tin_cal for roof! ', tin_cal
2458 ! temp_cal(1:nfacet, 1:ndepth) = temp_in_roof(1:nfacet, 1:ndepth)
2459 ! ! PRINT *, 'temp_cal for roof! ',temp_cal
2460 ! k_cal(1:nfacet, 1:ndepth) = k_roof(1:nfacet, 1:ndepth)
2461 ! ! PRINT *, 'k_roof for roof! ',k_roof(1,:)
2462 ! cp_cal(1:nfacet, 1:ndepth) = cp_roof(1:nfacet, 1:ndepth)
2463 ! dz_cal(1:nfacet, 1:ndepth) = dz_roof(1:nfacet, 1:ndepth)
2464 ! ! qs_cal(1:nfacet) = qs_roof(1:nfacet)
2465 ! ELSE IF (i_group == 2) THEN
2466 ! ! PRINT *, 'translation for wall! '
2467 ! ! TODO: to update with actual values from input files
2468 ! tsfc_cal(1:nfacet) = tsfc_wall(1:nfacet)
2469 ! tin_cal(1:nfacet) = tin_wall(1:nfacet)
2470 ! temp_cal(1:nfacet, 1:ndepth) = temp_in_wall(1:nfacet, 1:ndepth)
2471 ! ! TODO: temporarily set this for testing
2472 ! k_cal(1:nfacet, 1:ndepth) = k_wall(1:nfacet, 1:ndepth)
2473 ! cp_cal(1:nfacet, 1:ndepth) = cp_wall(1:nfacet, 1:ndepth)
2474 ! dz_cal(1:nfacet, 1:ndepth) = dz_wall(1:nfacet, 1:ndepth)
2475 ! ! qs_cal(1:nfacet) = qs_wall(1:nfacet)
2476
2477 ! ELSE IF (i_group == 3) THEN
2478 ! ! PRINT *, 'translation for surf! '
2479 ! ! nfacet = nsurf
2480 ! tsfc_cal(1:nfacet) = tsfc_surf(1:nfacet)
2481 ! tin_cal(1:nfacet) = tin_surf(1:nfacet)
2482 ! temp_cal(1:nfacet, 1:ndepth) = temp_in_surf(1:nfacet, 1:ndepth)
2483 ! ! TODO: to update with actual values from input files
2484 ! k_cal(1:nfacet, 1:ndepth) = k_surf(1:nfacet, 1:ndepth)
2485 ! cp_cal(1:nfacet, 1:ndepth) = cp_surf(1:nfacet, 1:ndepth)
2486 ! dz_cal(1:nfacet, 1:ndepth) = dz_surf(1:nfacet, 1:ndepth)
2487 ! ! k_cal(1:nfacet, 1:ndepth) = 1.2
2488 ! ! cp_cal(1:nfacet, 1:ndepth) = 2E6
2489 ! ! dz_cal(1:nfacet, 1:ndepth) = 0.1
2490 ! ! qs_cal(1:nfacet) = QS_surf(1:nfacet)
2491 ! END IF
2492 ! ! PRINT *, 'translation done! '
2493 ! ! TODO: temporary setting
2494 ! ! k_cal(1:nfacet, 1:ndepth) = 1.2
2495 ! ! cp_cal(1:nfacet, 1:ndepth) = 2E6
2496 ! ! dz_cal(1:nfacet, 1:ndepth) = 0.2
2497
2498 ! ! PRINT *, 'nfacet: ', nfacet
2499 ! DO i_facet = 1, nfacet
2500 ! ! PRINT *, 'i_facet: ', i_facet
2501 ! ! ASSOCIATE (v => dz_cal(i_facet, 1:ndepth))
2502 ! ! PRINT *, 'dz_cal in ESTM_ehc', v, SIZE(v)
2503 ! ! END ASSOCIATE
2504
2505 ! ! determine the calculation method
2506 ! IF (i_group == 3) THEN
2507 ! use_heatcond1d = .TRUE.
2508 ! IF (i_facet == BldgSurf) THEN
2509 ! ! building surface needs a different treatment
2510 ! use_heatcond1d = .FALSE.
2511 ! ELSE IF (i_facet == WaterSurf) THEN
2512 ! ! water surface needs a different treatment
2513 ! use_heatcond1d = .FALSE.
2514 ! use_heatcond1d_water = .TRUE.
2515 ! END IF
2516 ! ELSE
2517 ! use_heatcond1d = .TRUE.
2518 ! END IF
2519
2520 ! ! actual heat conduction calculations
2521 ! IF (dz_cal(i_facet, 1) /= -999.0 .AND. use_heatcond1d) THEN
2522
2523 ! ! surface heat flux
2524 ! IF (i_group == 1) THEN
2525 ! bc(1) = qg_roof(i_facet)
2526 ! ELSE IF (i_group == 2) THEN
2527 ! bc(1) = qg_wall(i_facet)
2528 ! ELSE IF (i_group == 3) THEN
2529 ! bc(1) = QG_surf(i_facet)
2530 ! END IF
2531 ! ! bctype(1) = .TRUE.
2532 ! bc(1) = tsfc_cal(i_facet)
2533 ! bctype(1) = .FALSE.
2534
2535 ! !TODO: should be a prescribed temperature of the innermost boundary
2536 ! bc(2) = tin_cal(i_facet)
2537 ! bctype(2) = .FALSE.
2538
2539 ! ! IF (i_group == 3 .AND. i_facet == 3) THEN
2540 ! ! PRINT *, 'temp_cal before: ', temp_cal(i_facet, :)
2541 ! ! PRINT *, 'k_cal: ', k_cal(i_facet, 1:ndepth)
2542 ! ! PRINT *, 'cp_cal: ', cp_cal(i_facet, 1:ndepth)
2543 ! ! PRINT *, 'dz_cal: ', dz_cal(i_facet, 1:ndepth)
2544 ! ! PRINT *, 'bc: ', bc
2545
2546 ! ! END IF
2547
2548 ! ! 1D heat conduction for finite depth layers
2549
2550 ! ! IF ((i_group == 3) .AND. (i_facet == 1)) THEN
2551 ! ! debug = .FALSE.
2552 ! ! ELSE
2553 ! ! debug = .FALSE.
2554 ! ! END IF
2555 ! ! CALL heatcond1d_ext( &
2556 ! CALL heatcond1d_vstep( &
2557 ! temp_cal(i_facet, :), &
2558 ! QS_cal(i_facet), &
2559 ! tsfc_cal(i_facet), &
2560 ! dz_cal(i_facet, 1:ndepth), &
2561 ! tstep*1.D0, &
2562 ! k_cal(i_facet, 1:ndepth), &
2563 ! cp_cal(i_facet, 1:ndepth), &
2564 ! bc, &
2565 ! bctype, debug)
2566
2567 ! ! update temperature at all inner interfaces
2568 ! ! tin_cal(i_facet, :) = temp_all_cal
2569 ! ! IF (i_group == 3 .AND. i_facet == 3) THEN
2570 ! ! PRINT *, 'temp_cal after: ', temp_cal(i_facet, :)
2571 ! ! PRINT *, 'QS_cal after: ', QS_cal(i_facet)
2572 ! ! PRINT *, 'k_cal: ', k_cal(i_facet, 1:ndepth)
2573 ! ! PRINT *, 'cp_cal: ', cp_cal(i_facet, 1:ndepth)
2574 ! ! PRINT *, 'dz_cal: ', dz_cal(i_facet, 1:ndepth)
2575 ! ! PRINT *, 'bc: ', bc
2576 ! ! PRINT *, ''
2577
2578 ! ! END IF
2579 ! END IF
2580
2581 ! IF (dz_cal(i_facet, 1) /= -999.0 .AND. use_heatcond1d_water) THEN
2582 ! ! temperatures at all interfaces, including the outmost surface
2583 ! ! temp_all_cal = temp_cal(i_facet, :)
2584
2585 ! ! outermost surface temperature
2586 ! ! bc(1) = tsfc_cal(i_facet)
2587 ! bc(1) = tsfc_cal(i_facet)
2588 ! bctype(1) = .FALSE.
2589
2590 ! !TODO: should be a prescribed temperature of the innermost boundary
2591 ! bc(2) = tin_cal(i_facet)
2592 ! bctype(2) = .FALSE.
2593
2594 ! ! 1D heat conduction for finite depth layers
2595 ! ! TODO: this should be a water specific heat conduction solver: to implement
2596 ! ! CALL heatcond1d_ext( &
2597 ! CALL heatcond1d_vstep( &
2598 ! temp_cal(i_facet, :), &
2599 ! QS_cal(i_facet), &
2600 ! tsfc_cal(i_facet), &
2601 ! dz_cal(i_facet, 1:ndepth), &
2602 ! tstep*1.D0, &
2603 ! k_cal(i_facet, 1:ndepth), &
2604 ! cp_cal(i_facet, 1:ndepth), &
2605 ! bc, &
2606 ! bctype, debug)
2607
2608 ! ! ! update temperature at all inner interfaces
2609 ! ! temp_cal(i_facet, :) = temp_all_cal
2610 ! END IF
2611
2612 ! END DO ! end of i_facet loop
2613
2614 ! ! translate results to back to the output arrays of facet groups
2615 ! IF (i_group == 1) THEN
2616 ! QS_roof = QS_cal(1:nfacet)
2617 ! ! tsfc_roof = tsfc_cal(1:nfacet)
2618 ! temp_out_roof = temp_cal(:nfacet, :)
2619 ! ELSE IF (i_group == 2) THEN
2620 ! QS_wall = QS_cal(1:nfacet)
2621 ! ! tsfc_wall = tsfc_cal(1:nfacet)
2622 ! temp_out_wall = temp_cal(:nfacet, :)
2623 ! ELSE IF (i_group == 3) THEN
2624 ! QS_surf = QS_cal(1:nfacet)
2625 ! ! tsfc_surf = tsfc_cal(1:nfacet)
2626 ! temp_out_surf = temp_cal(:nfacet, :)
2627 ! END IF
2628
2629 ! ! deallocate memory
2630 ! DEALLOCATE (tsfc_cal)
2631 ! DEALLOCATE (tin_cal)
2632 ! DEALLOCATE (qs_cal)
2633 ! DEALLOCATE (temp_cal)
2634 ! DEALLOCATE (k_cal)
2635 ! DEALLOCATE (cp_cal)
2636 ! DEALLOCATE (dz_cal)
2637
2638 ! END DO ! end do i_group
2639
2640 ! ! aggregated results
2641 ! ! building surface
2642 ! ! PRINT *, 'QS_roof in ESTM_ehc', DOT_PRODUCT(QS_roof, sfr_roof), 'for', sfr_roof
2643 ! ! PRINT *, 'QS_wall in ESTM_ehc', DOT_PRODUCT(QS_wall, sfr_wall), 'for', sfr_wall
2644 ! IF (sfr_surf(BldgSurf) < 1.0E-8) THEN
2645 ! QS_surf(BldgSurf) = 0.0
2646 ! ELSE
2647 ! QS_surf(BldgSurf) = (DOT_PRODUCT(QS_roof, sfr_roof) + DOT_PRODUCT(QS_wall, sfr_wall))/sfr_surf(BldgSurf)
2648 ! END IF
2649
2650 ! DO i_depth = 1, ndepth
2651 ! temp_out_surf(BldgSurf, i_depth) = &
2652 ! (DOT_PRODUCT(temp_out_roof(:, i_depth), sfr_roof) &
2653 ! + DOT_PRODUCT(temp_out_wall(:, i_depth), sfr_wall)) &
2654 ! /(SUM(sfr_roof) + SUM(sfr_wall))
2655 ! END DO
2656
2657 ! ! all standard suews surfaces
2658 ! qs = DOT_PRODUCT(QS_surf, sfr_surf)
2659
2660 ! END SUBROUTINE ESTM_ehc
2661 ! ===============================================================================================
2662 !===============set variable of invalid value to NAN====================================
2663 ELEMENTAL FUNCTION set_nan(x) RESULT(xx)
2664 IMPLICIT NONE
2665 REAL(kind(1d0)), PARAMETER :: pnan = 9999
2666 REAL(kind(1d0)), PARAMETER :: nan = -999
2667 REAL(kind(1d0)), INTENT(in) :: x
2668 REAL(kind(1d0)) :: xx
2669
2670 IF (abs(x) > pnan) THEN
2671 xx = nan
2672 ELSE
2673 xx = x
2674 END IF
2675
2676 END FUNCTION set_nan
2677 !========================================================================
2678
2679END MODULE estm_module
real(kind(1d0)), dimension(:), allocatable statelimit_wall
integer, parameter bldgsurf
real(kind(1d0)), dimension(:, :), allocatable tsfc_wall_grids
real(kind(1d0)), dimension(:, :), allocatable soilstorecap_wall_grids
real(kind(1d0)), dimension(:, :), allocatable dz_wall
real(kind(1d0)), dimension(:, :), allocatable ts5mindata
real(kind(1d0)), dimension(:, :), allocatable soilstore_wall_grids
real(kind(1d0)), dimension(:, :), allocatable tin_surf_grids
integer, parameter ncolsestmdata
integer, parameter conifsurf
real(kind(1d0)), dimension(:, :, :), allocatable cp_wall_grids
real(kind(1d0)), dimension(:, :), allocatable emis_wall_grids
real(kind(1d0)), dimension(:), allocatable soilstorecap_wall
integer, parameter cts_twall
real(kind(1d0)), dimension(:), allocatable alb_roof
real(kind(1d0)), dimension(:, :, :), allocatable temp_surf_grids
real(kind(1d0)), dimension(:), allocatable state_wall
real(kind(1d0)), dimension(:, :), allocatable tin_roof_grids
real(kind(1d0)), dimension(:, :), allocatable building_frac_grids
real(kind(1d0)), dimension(:, :, :), allocatable temp_wall_grids
real(kind(1d0)), dimension(:, :), allocatable tin_wall_grids
real(kind(1d0)), dimension(:), allocatable wetthresh_wall
real(kind(1d0)), dimension(:), allocatable state_roof
real(kind(1d0)), dimension(:, :), allocatable tsfc_roof_grids
real(kind(1d0)), dimension(:, :), allocatable dz_surf
integer, parameter cts_troad
real(kind(1d0)), dimension(nsurf) sfr_surf
integer, dimension(:), allocatable nlayer_grids
real(kind(1d0)), dimension(:, :), allocatable alb_wall_grids
real(kind(1d0)), dimension(:, :, :), allocatable cp_surf_grids
real(kind(1d0)), dimension(:), allocatable sfr_roof
real(kind(1d0)), dimension(nsurf) emis
real(kind(1d0)), dimension(:, :, :), allocatable wall_specular_frac_grids
real(kind(1d0)), dimension(:, :), allocatable alb_roof_grids
real(kind(1d0)), dimension(:, :, :), allocatable k_wall_grids
real(kind(1d0)), dimension(:, :), allocatable emis_roof_grids
real(kind(1d0)), dimension(:), allocatable building_scale
real(kind(1d0)), dimension(:, :, :), allocatable temp_roof_grids
real(kind(1d0)), dimension(:), allocatable soilstore_roof
real(kind(1d0)), dimension(:, :, :), allocatable cp_roof_grids
real(kind(1d0)), dimension(:, :), allocatable sfr_wall_grids
real(kind(1d0)), dimension(:, :), allocatable state_wall_grids
real(kind(1d0)), dimension(:, :), allocatable building_scale_grids
real(kind(1d0)), dimension(:, :, :), allocatable dz_surf_grids
real(kind(1d0)), dimension(:), allocatable height
real(kind(1d0)), dimension(:, :), allocatable cp_wall
real(kind(1d0)), dimension(:), allocatable tair24hr
real(kind(1d0)), dimension(:, :), allocatable soilstore_roof_grids
integer, parameter nspec
real(kind(1d0)), dimension(:), allocatable emis_roof
real(kind(1d0)), dimension(:, :), allocatable cp_surf
real(kind(1d0)), dimension(:, :, :), allocatable k_roof_grids
real(kind(1d0)), dimension(:, :), allocatable k_roof
real(kind(1d0)), dimension(:), allocatable wetthresh_roof
real(kind(1d0)), dimension(:), allocatable soilstorecap_roof
real(kind(1d0)), dimension(:), allocatable veg_frac
real(kind(1d0)), dimension(:, :), allocatable k_surf
real(kind(1d0)), dimension(:, :), allocatable statelimit_wall_grids
real(kind(1d0)), dimension(:, :), allocatable wetthresh_roof_grids
real(kind(1d0)), dimension(:, :), allocatable roof_albedo_dir_mult_fact
real(kind(1d0)), dimension(:, :), allocatable soilstorecap_roof_grids
real(kind(1d0)), dimension(:), allocatable tin_surf
integer, parameter watersurf
real(kind(1d0)), dimension(:), allocatable tin_wall
integer, parameter grasssurf
real(kind(1d0)), dimension(:, :, :), allocatable dz_roof_grids
real(kind(1d0)), dimension(:), allocatable statelimit_roof
real(kind(1d0)), dimension(:), allocatable alb_wall
real(kind(1d0)), dimension(:, :, :), allocatable roof_albedo_dir_mult_fact_grids
real(kind(1d0)), dimension(:, :), allocatable wall_specular_frac
real(kind(1d0)), dimension(:, :), allocatable height_grids
real(kind(1d0)), dimension(:, :), allocatable veg_scale_grids
real(kind(1d0)), dimension(:, :), allocatable dz_roof
real(kind(1d0)), dimension(:, :, :), allocatable k_surf_grids
integer, parameter bsoilsurf
real(kind(1d0)), dimension(:), allocatable emis_wall
integer, parameter nsurf
integer, parameter pavsurf
real(kind(1d0)), dimension(:, :), allocatable cp_roof
real(kind(1d0)), dimension(nsurf) alb
real(kind(1d0)), dimension(:), allocatable building_frac
integer, parameter ndepth
real(kind(1d0)), dimension(:, :), allocatable veg_frac_grids
real(kind(1d0)), dimension(:, :), allocatable state_roof_grids
real(kind(1d0)), dimension(:, :), allocatable statelimit_roof_grids
real(kind(1d0)), dimension(:, :), allocatable sfr_roof_grids
integer, parameter cts_tiair
real(kind(1d0)), dimension(:, :, :), allocatable dz_wall_grids
real(kind(1d0)), dimension(:, :), allocatable k_wall
real(kind(1d0)), dimension(:, :, :), allocatable estmforcingdata
real(kind(1d0)), dimension(:), allocatable sfr_wall
integer, parameter nlayer_max
real(kind(1d0)), dimension(:), allocatable veg_scale
real(kind(1d0)), dimension(:, :), allocatable wetthresh_wall_grids
real(kind(1d0)), dimension(:), allocatable tin_roof
real(kind(1d0)), dimension(:), allocatable soilstore_wall
integer, parameter decidsurf
integer, parameter cts_troof
character(len=20) filecode
character(len=150) fileestmts
integer multiplelayoutfiles
character(len=150) fileinputpath
integer skipheadermet
real(kind(1d0)) nan
real(kind(1d0)) notused
integer tsurfchoice
real(kind(1d0)), dimension(:), allocatable lup_roof_grids
real(kind(1d0)), dimension(5, 3) rsurf_paved
real(kind(1d0)) em_r
real(kind(1d0)), dimension(5) em_ibld_bldgs
real(kind(1d0)) lbc_soil
real(kind(1d0)) theat_fix
real(kind(1d0)), dimension(:), allocatable t0_wall_grids
real(kind(1d0)), dimension(5) zground
real(kind(1d0)) em_roof_estm
real(kind(1d0)) ivf_ii
real(kind(1d0)), dimension(5, 5) ribld_bldgs
real(kind(1d0)) ivf_wf
integer ndepth_roof
real(kind(1d0)), dimension(:), allocatable t0_ground_grids
real(kind(1d0)) ivf_ri
real(kind(1d0)), dimension(5, 5) kibld_bldgs
real(kind(1d0)), dimension(5, 5) rwall_bldgs
real(kind(1d0)) froof
real(kind(1d0)) theat_off
real(kind(1d0)) lup_ground
real(kind(1d0)) alb_ibld
real(kind(1d0)) t0_ground
real(kind(1d0)), dimension(:), allocatable tground
real(kind(1d0)) ivf_rf
real(kind(1d0)) rvf_roof
real(kind(1d0)) fair
real(kind(1d0)) zvf_ground
real(kind(1d0)), dimension(5) alb_ibld_bldgs
real(kind(1d0)) t0_ibld
real(kind(1d0)) ch_iwall
real(kind(1d0)), dimension(5, 3) zsurf_paved
integer ndepth_ibld
real(kind(1d0)) minshc_airbld
real(kind(1d0)) ivf_fr
real(kind(1d0)), dimension(5) kwall
real(kind(1d0)) nroom
real(kind(1d0)) alb_ground_estm
real(kind(1d0)) tair1
real(kind(1d0)), dimension(:), allocatable twall
real(kind(1d0)) chr
real(kind(1d0)), dimension(5) kroof
real(kind(1d0)), dimension(5) kground
real(kind(1d0)) t0_roof
real(kind(1d0)) tn_roof
real(kind(1d0)) lup_roof
real(kind(1d0)) alb_veg_estm
integer ndepth_wall
real(kind(1d0)) tn_wall
real(kind(1d0)), dimension(:), allocatable tn_wall_grids
real(kind(1d0)) em_w
real(kind(1d0)), dimension(5) zibld
real(kind(1d0)), dimension(5, 5) zibld_bldgs
real(kind(1d0)), dimension(:), allocatable troof
real(kind(1d0)) tievolve
real(kind(1d0)) zvf_wall
real(kind(1d0)), dimension(4) qs_4
real(kind(1d0)) tanzenith
real(kind(1d0)), dimension(5) ch_iwall_bldgs
real(kind(1d0)), dimension(:), allocatable t0_ibld_grids
real(kind(1d0)), dimension(:), allocatable tair2_grids
real(kind(1d0)), dimension(5, 5) kwall_bldgs
real(kind(1d0)), dimension(5) rwall
real(kind(1d0)), dimension(:), allocatable t0_roof_grids
real(kind(1d0)) shc_air
real(kind(1d0)) zref
real(kind(1d0)), dimension(5) ch_iroof_bldgs
real(kind(1d0)) fibld
real(kind(1d0)), dimension(:, :), allocatable tw_4
real(kind(1d0)), dimension(5) pcoeff
real(kind(1d0)) ivf_fw
real(kind(1d0)) fwall
real(kind(1d0)), dimension(5, 5) zwall_bldgs
real(kind(1d0)) areawall
real(kind(1d0)), dimension(5) estmsfr_bldgs
real(kind(1d0)) alb_roof_estm
real(kind(1d0)) em_i
real(kind(1d0)) qsibld
real(kind(1d0)), dimension(5, 5) rsurf_bldgs
real(kind(1d0)) rvf_ground
real(kind(1d0)) lup_veg
real(kind(1d0)), dimension(:, :, :), allocatable tw_4_grids
real(kind(1d0)) lup_wall
real(kind(1d0)), dimension(:), allocatable lup_ground_grids
real(kind(1d0)) ch_ibld
real(kind(1d0)) fground
real(kind(1d0)) ivf_wi
real(kind(1d0)), dimension(:, :), allocatable twall_grids
real(kind(1d0)) qsroof
real(kind(1d0)) ivf_fi
real(kind(1d0)) ivf_if
real(kind(1d0)) chair
real(kind(1d0)) tfloor
real(kind(1d0)) em_ibld
real(kind(1d0)) ch_iroof
real(kind(1d0)), dimension(5) rroof
real(kind(1d0)), dimension(:), allocatable lup_wall_grids
real(kind(1d0)) ivf_ww
real(kind(1d0)), dimension(5, 3) ksurf_paved
real(kind(1d0)) qswall
real(kind(1d0)) qsground
real(kind(1d0)) finternal
real(kind(1d0)) ivf_ir
real(kind(1d0)) sumemis
real(kind(1d0)) rvf_veg
real(kind(1d0)) em_f
real(kind(1d0)) tair2
real(kind(1d0)) svf_wall
real(kind(1d0)), dimension(5, 5) ksurf_bldgs
real(kind(1d0)), dimension(:), allocatable tibld
integer ibldchmod
real(kind(1d0)) ivf_iw
real(kind(1d0)), dimension(:), allocatable tn_roof_grids
integer evolvetibld
real(kind(1d0)) ivf_rw
real(kind(1d0)), parameter alb_wall_fix
real(kind(1d0)), dimension(5) kibld
real(kind(1d0)) em_veg_estm
integer ndepth_ground
real(kind(1d0)) em_ground_estm
real(kind(1d0)), parameter em_wall_fix
real(kind(1d0)), dimension(5) zwall
real(kind(1d0)), dimension(:, :), allocatable tibld_grids
real(kind(1d0)), parameter conv
real(kind(1d0)) hw
real(kind(1d0)), dimension(5, 5) zsurf_bldgs
real(kind(1d0)) ivf_wr
real(kind(1d0)), dimension(3) estmsfr_paved
real(kind(1d0)) alb_avg
real(kind(1d0)) svf_roof
real(kind(1d0)) fveg
real(kind(1d0)) qsair
real(kind(1d0)), dimension(:, :), allocatable troof_grids
real(kind(1d0)), dimension(5) rground
real(kind(1d0)), dimension(:), allocatable tievolve_grids
real(kind(1d0)) xvf_wall
real(kind(1d0)), dimension(5) nroom_bldgs
real(kind(1d0)) t0_wall
real(kind(1d0)) rvf_canyon
real(kind(1d0)), dimension(5) ribld
real(kind(1d0)), dimension(5) ch_ibld_bldgs
integer, parameter maxiter
real(kind(1d0)) sumalb
real(kind(1d0)), dimension(5) zroof
logical, dimension(2) bctype
real(kind(1d0)) ws
real(kind(1d0)) theat_on
real(kind(1d0)) svf_ground
real(kind(1d0)) rvf_wall
real(kind(1d0)), dimension(:, :), allocatable tground_grids
subroutine estm_initials
subroutine estm_ehc_finalise
subroutine suews_getestmdata(lunit)
elemental real(kind(1d0)) function set_nan(x)
subroutine estm_ehc_initialise
subroutine estm_translate(gridiv)
subroutine estm(gridiv, tstep, avkdn, avu1, temp_c, zenith_deg, avrh, press_hpa, ldown, bldgh, ts5mindata_ir, tair_av, dataoutlineestm, qs)
subroutine load_gridlayout(gridiv, multiplelayoutfiles, diagnose)
real(kind(1d0)) bldgh
subroutine heatcond1d(t, qs, dx, dt, k, rhocp, bc, bctype)
recursive subroutine heatcond1d_ext(t, qs, tsfc, dx, dt, k, rhocp, bc, bctype, debug)
integer readlinesmetdata
integer gridcounter
integer numberofgrids
integer skippedlines
real(kind(1d0)), parameter dtr
real(kind(1d0)), parameter pi
real(kind(1d0)), parameter rtd
real(kind(1d0)) function heatcapacity_air(tk, rh, p)
elemental real(kind(1d0)) function interp1d(x1, x2, y1, y2, xi)
real(kind(1d0)) function newtonpolynomial(x0, pcoeff, conv, maxiter)
real(kind(1d0)) function min_zenith(lat, doy)
subroutine solar_times(lat, lng, timezone, dectime, sunrise, sunset, snoon)
real(kind(1d0)) function local_apparent_time(lng, dectime)
subroutine solar_angles(lat, lng, timezone, dectime, decl, zenith, azimuth)
real(kind(1d0)) function transmissivity_cd(p, td, g, zenith)
real(kind(1d0)) function solar_esdist(doy)
real(kind(1d0)) function kdown_surface(doy, zenith)
real(kind(1d0)), parameter c2k
real(kind(1d0)), parameter sbconst
real(kind(1d0)) tstep_real
subroutine errorhint(errh, problemfile, value, value2, valuei)
subroutine skipheader(lfn, skip)