5 REAL(KIND(1D0)),
INTENT(inout) :: T(:)
6 REAL(KIND(1D0)),
INTENT(in) :: dx(:), dt, k(:), rhocp(:), bc(2)
7 REAL(KIND(1D0)),
INTENT(out) :: Qs, Tsfc
8 LOGICAL,
INTENT(in) :: bctype(2)
9 LOGICAL,
INTENT(in) :: debug
11 REAL(KIND(1D0)),
ALLOCATABLE :: w(:), a(:), T1(:), cfl(:)
13 REAL(KIND(1D0)) :: cfl_max
14 REAL(KIND(1D0)) :: dt_remain
15 REAL(KIND(1D0)) :: dt_step
16 REAL(KIND(1D0)) :: dt_step_cfl
18 REAL(KIND(1D0)),
ALLOCATABLE :: T_in(:), T_out(:)
19 REAL(KIND(1D0)) :: dt_x
22 ALLOCATE (w(0:n), a(n), t1(n), cfl(n), t_in(n), t_out(n))
28 w(0) = bc(1); w(n) = bc(2)
31 IF (bctype(1)) w(0) = bc(1)*0.5*dx(1)/k(1) + w(1)
32 IF (bctype(2)) w(n) = bc(2)*0.5*dx(n)/k(n) + w(n)
38 w(i) = (t(i + 1)*a(i + 1) + t(i)*a(i))/(a(i) + a(i + 1))
43 dt_step_cfl = 0.05*minval(dx**2/(k/rhocp))
44 DO WHILE (dt_remain > 1e-10)
45 dt_step = min(dt_step_cfl, dt_remain)
62 *(w(i - 1) - 2*t(i) + w(i)) &
68 w(i) = (t(i + 1)*a(i + 1) + t(i)*a(i))/(a(i) + a(i + 1))
70 dt_remain = dt_remain - dt_step
84 (([bc(1), t_out(1:n - 1)] + t_out)/2. &
85 -([bc(1), t_in(1:n - 1)] + t_in)/2) &
107 QG_surf, qg_roof, qg_wall, &
108 tsfc_roof, tin_roof, temp_in_roof, k_roof, cp_roof, dz_roof, sfr_roof, & !input
109 tsfc_wall, tin_wall, temp_in_wall, k_wall, cp_wall, dz_wall, sfr_wall, & !input
110 tsfc_surf, tin_surf, temp_in_surf, k_surf, cp_surf, dz_surf, sfr_surf, & !input
111 temp_out_roof, QS_roof, & !output
112 temp_out_wall, QS_wall, & !output
113 temp_out_surf, QS_surf, & !output
121 INTEGER,
INTENT(in) :: tstep
122 INTEGER,
INTENT(in) :: nlayer
124 REAL(KIND(1D0)),
DIMENSION(nsurf),
INTENT(in) :: QG_surf
137 REAL(KIND(1D0)),
DIMENSION(nlayer),
INTENT(in) :: qg_roof
138 REAL(KIND(1D0)),
DIMENSION(nlayer),
INTENT(in) :: tsfc_roof
139 REAL(KIND(1D0)),
DIMENSION(nlayer),
INTENT(in) :: tin_roof
140 REAL(KIND(1D0)),
DIMENSION(nlayer),
INTENT(in) :: sfr_roof
141 REAL(KIND(1D0)),
DIMENSION(nlayer, ndepth),
INTENT(in) :: temp_in_roof
142 REAL(KIND(1D0)),
DIMENSION(nlayer, ndepth),
INTENT(in) :: k_roof
143 REAL(KIND(1D0)),
DIMENSION(nlayer, ndepth),
INTENT(in) :: cp_roof
144 REAL(KIND(1D0)),
DIMENSION(nlayer, ndepth),
INTENT(in) :: dz_roof
146 REAL(KIND(1D0)),
DIMENSION(nlayer),
INTENT(in) :: qg_wall
147 REAL(KIND(1D0)),
DIMENSION(nlayer),
INTENT(in) :: tsfc_wall
148 REAL(KIND(1D0)),
DIMENSION(nlayer),
INTENT(in) :: tin_wall
149 REAL(KIND(1D0)),
DIMENSION(nlayer),
INTENT(in) :: sfr_wall
150 REAL(KIND(1D0)),
DIMENSION(nlayer, ndepth),
INTENT(in) :: temp_in_wall
151 REAL(KIND(1D0)),
DIMENSION(nlayer, ndepth),
INTENT(in) :: k_wall
152 REAL(KIND(1D0)),
DIMENSION(nlayer, ndepth),
INTENT(in) :: cp_wall
153 REAL(KIND(1D0)),
DIMENSION(nlayer, ndepth),
INTENT(in) :: dz_wall
155 REAL(KIND(1D0)),
DIMENSION(nsurf),
INTENT(in) :: tsfc_surf
156 REAL(KIND(1D0)),
DIMENSION(nsurf),
INTENT(in) :: tin_surf
157 REAL(KIND(1D0)),
DIMENSION(nsurf),
INTENT(in) :: sfr_surf
158 REAL(KIND(1D0)),
DIMENSION(nsurf, ndepth),
INTENT(in) :: temp_in_surf
159 REAL(KIND(1D0)),
DIMENSION(nsurf, ndepth),
INTENT(in) :: k_surf
160 REAL(KIND(1D0)),
DIMENSION(nsurf, ndepth),
INTENT(in) :: cp_surf
161 REAL(KIND(1D0)),
DIMENSION(nsurf, ndepth),
INTENT(in) :: dz_surf
165 REAL(KIND(1D0)),
DIMENSION(nlayer),
INTENT(out) :: QS_roof
166 REAL(KIND(1D0)),
DIMENSION(nlayer, ndepth),
INTENT(out) :: temp_out_roof
168 REAL(KIND(1D0)),
DIMENSION(nlayer),
INTENT(out) :: QS_wall
169 REAL(KIND(1D0)),
DIMENSION(nlayer, ndepth),
INTENT(out) :: temp_out_wall
171 REAL(KIND(1D0)),
DIMENSION(nsurf),
INTENT(out) :: QS_surf
172 REAL(KIND(1D0)),
DIMENSION(nsurf, ndepth),
INTENT(out) :: temp_out_surf
175 REAL(KIND(1D0)),
INTENT(out) :: QS
180 REAL(KIND(1D0)),
DIMENSION(:),
ALLOCATABLE :: tsfc_cal
181 REAL(KIND(1D0)),
DIMENSION(:),
ALLOCATABLE :: tin_cal
182 REAL(KIND(1D0)),
DIMENSION(:, :),
ALLOCATABLE :: temp_cal
183 REAL(KIND(1D0)),
DIMENSION(:, :),
ALLOCATABLE :: k_cal
184 REAL(KIND(1D0)),
DIMENSION(:, :),
ALLOCATABLE :: cp_cal
185 REAL(KIND(1D0)),
DIMENSION(:, :),
ALLOCATABLE :: dz_cal
186 REAL(KIND(1D0)),
DIMENSION(:),
ALLOCATABLE :: qs_cal
191 INTEGER :: i_facet, i_group, nfacet, i_depth
194 REAL(KIND(1D0)),
DIMENSION(2) :: bc
197 LOGICAL,
DIMENSION(2) :: bctype
201 LOGICAL :: use_heatcond1d, use_heatcond1d_water
204 REAL(KIND(1D0)),
DIMENSION(nlayer) :: sfr_roof_n
205 REAL(KIND(1D0)),
DIMENSION(nlayer) :: sfr_wall_n
208 use_heatcond1d = .true.
209 use_heatcond1d_water = .false.
214 sfr_roof_n = sfr_roof/sum(sfr_roof)
215 sfr_wall_n = sfr_wall/sum(sfr_wall)
220 IF (i_group == 1)
THEN
223 ELSE IF (i_group == 2)
THEN
226 ELSE IF (i_group == 3)
THEN
231 ALLOCATE (tsfc_cal(nfacet))
232 ALLOCATE (tin_cal(nfacet))
233 ALLOCATE (qs_cal(nfacet))
234 ALLOCATE (temp_cal(nfacet,
ndepth))
235 ALLOCATE (k_cal(nfacet,
ndepth))
236 ALLOCATE (cp_cal(nfacet,
ndepth))
237 ALLOCATE (dz_cal(nfacet,
ndepth))
241 IF (i_group == 1)
THEN
244 tsfc_cal(1:nfacet) = tsfc_roof(1:nfacet)
246 tin_cal(1:nfacet) = tin_roof(1:nfacet)
248 temp_cal(1:nfacet, 1:
ndepth) = temp_in_roof(1:nfacet, 1:
ndepth)
252 cp_cal(1:nfacet, 1:
ndepth) = cp_roof(1:nfacet, 1:
ndepth)
253 dz_cal(1:nfacet, 1:
ndepth) = dz_roof(1:nfacet, 1:
ndepth)
255 ELSE IF (i_group == 2)
THEN
258 tsfc_cal(1:nfacet) = tsfc_wall(1:nfacet)
259 tin_cal(1:nfacet) = tin_wall(1:nfacet)
260 temp_cal(1:nfacet, 1:
ndepth) = temp_in_wall(1:nfacet, 1:
ndepth)
263 cp_cal(1:nfacet, 1:
ndepth) = cp_wall(1:nfacet, 1:
ndepth)
264 dz_cal(1:nfacet, 1:
ndepth) = dz_wall(1:nfacet, 1:
ndepth)
267 ELSE IF (i_group == 3)
THEN
270 tsfc_cal(1:nfacet) = tsfc_surf(1:nfacet)
271 tin_cal(1:nfacet) = tin_surf(1:nfacet)
272 temp_cal(1:nfacet, 1:
ndepth) = temp_in_surf(1:nfacet, 1:
ndepth)
275 cp_cal(1:nfacet, 1:
ndepth) = cp_surf(1:nfacet, 1:
ndepth)
276 dz_cal(1:nfacet, 1:
ndepth) = dz_surf(1:nfacet, 1:
ndepth)
289 DO i_facet = 1, nfacet
296 IF (i_group == 3)
THEN
297 use_heatcond1d = .true.
300 use_heatcond1d = .false.
303 use_heatcond1d = .false.
304 use_heatcond1d_water = .true.
307 use_heatcond1d = .true.
311 IF (dz_cal(i_facet, 1) /= -999.0 .AND. use_heatcond1d)
THEN
314 IF (i_group == 1)
THEN
315 bc(1) = qg_roof(i_facet)
316 ELSE IF (i_group == 2)
THEN
317 bc(1) = qg_wall(i_facet)
318 ELSE IF (i_group == 3)
THEN
319 bc(1) = qg_surf(i_facet)
322 bc(1) = tsfc_cal(i_facet)
326 bc(2) = tin_cal(i_facet)
347 temp_cal(i_facet, :), &
350 dz_cal(i_facet, 1:
ndepth), &
352 k_cal(i_facet, 1:
ndepth), &
353 cp_cal(i_facet, 1:
ndepth), &
371 IF (dz_cal(i_facet, 1) /= -999.0 .AND. use_heatcond1d_water)
THEN
377 bc(1) = tsfc_cal(i_facet)
381 bc(2) = tin_cal(i_facet)
388 temp_cal(i_facet, :), &
391 dz_cal(i_facet, 1:
ndepth), &
393 k_cal(i_facet, 1:
ndepth), &
394 cp_cal(i_facet, 1:
ndepth), &
405 IF (i_group == 1)
THEN
406 qs_roof = qs_cal(1:nfacet)
408 temp_out_roof = temp_cal(:nfacet, :)
409 ELSE IF (i_group == 2)
THEN
410 qs_wall = qs_cal(1:nfacet)
412 temp_out_wall = temp_cal(:nfacet, :)
413 ELSE IF (i_group == 3)
THEN
414 qs_surf = qs_cal(1:nfacet)
416 temp_out_surf = temp_cal(:nfacet, :)
420 DEALLOCATE (tsfc_cal)
423 DEALLOCATE (temp_cal)
434 IF (sfr_surf(
bldgsurf) < 1.0e-8)
THEN
437 qs_surf(
bldgsurf) = (dot_product(qs_roof, sfr_roof) + dot_product(qs_wall, sfr_wall))/sfr_surf(
bldgsurf)
441 temp_out_surf(
bldgsurf, i_depth) = &
442 (dot_product(temp_out_roof(:, i_depth), sfr_roof) &
443 + dot_product(temp_out_wall(:, i_depth), sfr_wall)) &
444 /(sum(sfr_roof) + sum(sfr_wall))
448 qs = dot_product(qs_surf, sfr_surf)
subroutine ehc(tstep, nlayer, qg_surf, qg_roof, qg_wall, tsfc_roof, tin_roof, temp_in_roof, k_roof, cp_roof, dz_roof, sfr_roof, tsfc_wall, tin_wall, temp_in_wall, k_wall, cp_wall, dz_wall, sfr_wall, tsfc_surf, tin_surf, temp_in_surf, k_surf, cp_surf, dz_surf, sfr_surf, temp_out_roof, qs_roof, temp_out_wall, qs_wall, temp_out_surf, qs_surf, qs)