1 MODULE module_sf_bep_bem
3 use mpas_atmphys_utilities, only: physics_error_fatal
4 #define FATAL_ERROR(M) call physics_error_fatal( M )
7 #define FATAL_ERROR(M) call wrf_error_fatal( M )
8 !USE module_model_constants
12 USE module_bep_bem_helper, ONLY: nurbm
15 ! Access urban_param.tbl values through calling urban_param_init in module_physics_init
16 ! for CASE (BEPSCHEME) select sf_urban_physics
18 ! -----------------------------------------------------------------------
19 ! Dimension for the array used in the BEP module
20 ! -----------------------------------------------------------------------
22 integer nurbmax ! Maximum number of urban classes
23 parameter (nurbmax=11)
25 integer ndm ! Maximum number of street directions
28 integer nz_um ! Maximum number of vertical levels in the urban grid
31 integer ng_u ! Number of grid levels in the ground
34 integer ngr_u ! Number of grid levels in green roof
37 integer nwr_u ! Number of grid levels in the walls or roofs
40 integer nf_u !Number of grid levels in the floors (BEM)
43 integer ngb_u !Number of grid levels in the ground below building (BEM)
46 real dz_u ! Urban grid resolution
49 integer nbui_max !maximum number of types of buildings in an urban class
50 parameter (nbui_max=15) !must be less or equal than nz_um
54 parameter(h_water=0.0009722) !mm of irrigation per hour
56 !---------------------------------------------------------------------------------
57 !Parameters of the windows. The glasses of windows are considered without films -
58 !Read the paper of J.Karlsson and A.Roos(2000):"modelling the angular behaviour -
59 !of the total solar energy transmittance of windows".Solar Energy Vol.69,No.4, -
60 !pp. 321-329, for more details. -
61 !---------------------------------------------------------------------------------
62 integer p_num !number of panes in the windows (1,2 or 3)
64 integer q_num !category number for the windows (q_num= 4, standard glasses)
65 parameter(q_num=4) !Possible values 1,2,...,10
67 ! The change of ng_u, nwr_u should be done in agreement with the block data
68 ! in the routine "surf_temp"
69 ! -----------------------------------------------------------------------
70 ! Constant used in the BEP module
71 ! -----------------------------------------------------------------------
73 real vk ! von Karman constant
74 real g_u ! Gravity acceleration
76 real r ! Perfect gas constant
77 real cp_u ! Specific heat at constant pressure
80 real p0 ! Reference pressure at the sea level
81 real latent ! Latent heat of vaporization [J/kg] (used in BEM)
82 real dgmax ! Maximum ground water holding capacity (mm)
83 real drmax ! Maximum ground roof holding capacity (mm)
85 parameter(vk=0.40,g_u=9.81,pi=3.141592653,r=287.,cp_u=1004.)
86 parameter(rcp_u=r/cp_u,sigma=5.67e-08,p0=1.e+5,latent=2.45e+06,dgmax=1.,drmax=1.)
88 ! -----------------------------------------------------------------------
95 subroutine BEP_BEM(FRC_URB2D,UTYPE_URB2D,itimestep,dz8w,dt,u_phy,v_phy, &
96 th_phy,rho,p_phy,swdown,glw, &
97 gmt,julday,xlong,xlat, &
98 declin_urb,cosz_urb2d,omg_urb2d, &
99 num_urban_ndm, urban_map_zrd, urban_map_zwd, urban_map_gd, &
100 urban_map_zd, urban_map_zdf, urban_map_bd, urban_map_wd, &
101 urban_map_gbd, urban_map_fbd, &
102 urban_map_zgrd, num_urban_hi, &
103 trb_urb4d,tw1_urb4d,tw2_urb4d,tgb_urb4d, &
104 tlev_urb3d,qlev_urb3d,tw1lev_urb3d,tw2lev_urb3d, &
105 tglev_urb3d,tflev_urb3d,sf_ac_urb3d,lf_ac_urb3d, &
107 sfvent_urb3d,lfvent_urb3d, &
108 sfwin1_urb3d,sfwin2_urb3d, &
109 sfw1_urb3d,sfw2_urb3d,sfr_urb3d,sfg_urb3d, &
110 ep_pv_urb3d,t_pv_urb3d, &
111 trv_urb4d,qr_urb4d,qgr_urb3d,tgr_urb3d, &
112 drain_urb4d,draingr_urb3d, &
113 sfrv_urb3d,lfrv_urb3d, &
114 dgr_urb3d,dg_urb3d, &
115 lfr_urb3d,lfg_urb3d,rainbl,swddir,swddif, &
116 lp_urb2d,hi_urb2d,lb_urb2d,hgt_urb2d, &
117 a_u,a_v,a_t,a_e,b_u,b_v, &
118 b_t,b_e,b_q,dlg,dl_u,sf,vl, &
119 rl_up,rs_abs,emiss,grdflx_urb,qv_phy, &
120 ids,ide, jds,jde, kds,kde, &
121 ims,ime, jms,jme, kms,kme, &
122 its,ite, jts,jte, kts,kte)
126 !------------------------------------------------------------------------
128 !------------------------------------------------------------------------
129 INTEGER :: ids,ide, jds,jde, kds,kde, &
130 ims,ime, jms,jme, kms,kme, &
131 its,ite, jts,jte, kts,kte, &
135 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: DZ8W
136 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: P_PHY
137 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: RHO
138 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: TH_PHY
139 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: T_PHY
140 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: U_PHY
141 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: V_PHY
142 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: U
143 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: V
144 REAL, DIMENSION( ims:ime , jms:jme ) :: GLW
145 REAL, DIMENSION( ims:ime , jms:jme ) :: swdown
146 REAL, DIMENSION( ims:ime , jms:jme ) :: swddir
147 REAL, DIMENSION( ims:ime , jms:jme ) :: swddif
148 REAL, DIMENSION( ims:ime, jms:jme ) :: UST
149 INTEGER, DIMENSION( ims:ime , jms:jme ), INTENT(IN ):: UTYPE_URB2D
150 REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN ):: FRC_URB2D
151 REAL, INTENT(IN ) :: GMT
152 INTEGER, INTENT(IN ) :: JULDAY
153 REAL, DIMENSION( ims:ime, jms:jme ), &
154 INTENT(IN ) :: XLAT, XLONG
155 REAL, INTENT(IN) :: DECLIN_URB
156 REAL, DIMENSION( ims:ime, jms:jme ), INTENT(IN) :: COSZ_URB2D
157 REAL, DIMENSION( ims:ime, jms:jme ), INTENT(IN) :: OMG_URB2D
158 INTEGER, INTENT(IN ) :: urban_map_zrd
159 INTEGER, INTENT(IN ) :: urban_map_zwd
160 INTEGER, INTENT(IN ) :: urban_map_gd
161 INTEGER, INTENT(IN ) :: urban_map_zd
162 INTEGER, INTENT(IN ) :: urban_map_zdf
163 INTEGER, INTENT(IN ) :: urban_map_bd
164 INTEGER, INTENT(IN ) :: urban_map_wd
165 INTEGER, INTENT(IN ) :: urban_map_gbd
166 INTEGER, INTENT(IN ) :: urban_map_fbd
167 INTEGER, INTENT(IN ) :: num_urban_ndm
168 INTEGER, INTENT(IN) :: num_urban_hi
169 INTEGER , INTENT(IN) :: urban_map_zgrd
170 REAL, DIMENSION( ims:ime, 1:urban_map_zrd, jms:jme ), INTENT(INOUT) :: trb_urb4d
171 REAL, DIMENSION( ims:ime, 1:urban_map_zwd, jms:jme ), INTENT(INOUT) :: tw1_urb4d
172 REAL, DIMENSION( ims:ime, 1:urban_map_zwd, jms:jme ), INTENT(INOUT) :: tw2_urb4d
173 REAL, DIMENSION( ims:ime, 1:urban_map_gd , jms:jme ), INTENT(INOUT) :: tgb_urb4d
174 REAL, DIMENSION( ims:ime, 1:urban_map_zgrd, jms:jme ), INTENT(INOUT) :: trv_urb4d
175 REAL, DIMENSION( ims:ime, 1:urban_map_zgrd, jms:jme ), INTENT(INOUT) :: qr_urb4d
176 REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) :: qgr_urb3d
177 REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) :: tgr_urb3d
178 REAL, DIMENSION( ims:ime, 1:urban_map_zdf, jms:jme ), INTENT(INOUT) :: drain_urb4d
179 REAL, DIMENSION( ims:ime, jms:jme ), INTENT(IN) :: rainbl
180 REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) :: draingr_urb3d
181 !New variables used for BEM
182 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: qv_phy
183 REAL, DIMENSION( ims:ime, 1:urban_map_bd, jms:jme ), INTENT(INOUT) :: tlev_urb3d
184 REAL, DIMENSION( ims:ime, 1:urban_map_bd , jms:jme ), INTENT(INOUT) :: qlev_urb3d
185 REAL, DIMENSION( ims:ime, 1:urban_map_wd , jms:jme ), INTENT(INOUT) :: tw1lev_urb3d
186 REAL, DIMENSION( ims:ime, 1:urban_map_wd , jms:jme ), INTENT(INOUT) :: tw2lev_urb3d
187 REAL, DIMENSION( ims:ime, 1:urban_map_gbd, jms:jme ), INTENT(INOUT) :: tglev_urb3d
188 REAL, DIMENSION( ims:ime, 1:urban_map_fbd, jms:jme ), INTENT(INOUT) :: tflev_urb3d
189 REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) :: lf_ac_urb3d
190 REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) :: sf_ac_urb3d
191 REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) :: cm_ac_urb3d
192 REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) :: ep_pv_urb3d
193 REAL, DIMENSION( ims:ime, 1:urban_map_zdf, jms:jme ), INTENT(INOUT) :: t_pv_urb3d
194 REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) :: sfvent_urb3d
195 REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) :: lfvent_urb3d
196 REAL, DIMENSION( ims:ime, 1:urban_map_wd , jms:jme ), INTENT(INOUT) :: sfwin1_urb3d
197 REAL, DIMENSION( ims:ime, 1:urban_map_wd , jms:jme ), INTENT(INOUT) :: sfwin2_urb3d
200 REAL, DIMENSION( ims:ime, 1:urban_map_zd , jms:jme ), INTENT(INOUT) :: sfw1_urb3d
201 REAL, DIMENSION( ims:ime, 1:urban_map_zd , jms:jme ), INTENT(INOUT) :: sfw2_urb3d
202 REAL, DIMENSION( ims:ime, 1:urban_map_zdf, jms:jme ), INTENT(INOUT) :: sfr_urb3d
203 REAL, DIMENSION( ims:ime, 1:num_urban_ndm, jms:jme ), INTENT(INOUT) :: sfg_urb3d
204 REAL, DIMENSION( ims:ime, 1:urban_map_zdf, jms:jme ), INTENT(INOUT) :: sfrv_urb3d
205 REAL, DIMENSION( ims:ime, 1:urban_map_zdf, jms:jme ), INTENT(INOUT) :: lfrv_urb3d
206 REAL, OPTIONAL, DIMENSION( ims:ime, 1:urban_map_zdf, jms:jme ),INTENT(INOUT) :: dgr_urb3d !GRZ
207 REAL, OPTIONAL, DIMENSION( ims:ime, 1:num_urban_ndm, jms:jme ),INTENT(INOUT) :: dg_urb3d !GRZ
208 REAL, OPTIONAL, DIMENSION( ims:ime, 1:urban_map_zdf, jms:jme ),INTENT(INOUT) :: lfr_urb3d !GRZ
209 REAL, OPTIONAL, DIMENSION( ims:ime, 1:num_urban_ndm, jms:jme ),INTENT(INOUT) :: lfg_urb3d !G
211 REAL, DIMENSION( ims:ime, 1:num_urban_hi, jms:jme ), INTENT(IN) :: hi_urb2d
212 REAL, DIMENSION( ims:ime,jms:jme), INTENT(IN) :: lp_urb2d
213 REAL, DIMENSION( ims:ime,jms:jme), INTENT(IN) :: lb_urb2d
214 REAL, DIMENSION( ims:ime,jms:jme), INTENT(IN) :: hgt_urb2d
216 real z(ims:ime,kms:kme,jms:jme) ! Vertical coordinates
217 REAL, INTENT(IN ):: DT ! Time step
219 !------------------------------------------------------------------------
221 !------------------------------------------------------------------------
223 ! Implicit and explicit components of the source and sink terms at each levels,
224 ! the fluxes can be computed as follow: FX = A*X + B example: t_fluxes = a_t * pt + b_t
225 real a_u(ims:ime,kms:kme,jms:jme) ! Implicit component for the momemtum in X-direction (center)
226 real a_v(ims:ime,kms:kme,jms:jme) ! Implicit component for the momemtum in Y-direction (center)
227 real a_t(ims:ime,kms:kme,jms:jme) ! Implicit component for the temperature
228 real a_e(ims:ime,kms:kme,jms:jme) ! Implicit component for the TKE
229 real b_u(ims:ime,kms:kme,jms:jme) ! Explicit component for the momemtum in X-direction (center)
230 real b_v(ims:ime,kms:kme,jms:jme) ! Explicit component for the momemtum in Y-direction (center)
231 real b_t(ims:ime,kms:kme,jms:jme) ! Explicit component for the temperature
232 real b_e(ims:ime,kms:kme,jms:jme) ! Explicit component for the TKE
233 real b_q(ims:ime,kms:kme,jms:jme) ! Explicit component for the Humidity
234 real dlg(ims:ime,kms:kme,jms:jme) ! Height above ground (L_ground in formula (24) of the BLM paper).
235 real dl_u(ims:ime,kms:kme,jms:jme) ! Length scale (lb in formula (22) ofthe BLM paper).
236 ! urban surface and volumes
237 real sf(ims:ime,kms:kme,jms:jme) ! surface of the urban grid cells
238 real vl(ims:ime,kms:kme,jms:jme) ! volume of the urban grid cells
240 real rl_up(its:ite,jts:jte) ! upward long wave radiation
241 real rs_abs(its:ite,jts:jte) ! absorbed short wave radiation
242 real emiss(its:ite,jts:jte) ! emissivity averaged for urban surfaces
243 real grdflx_urb(its:ite,jts:jte) ! ground heat flux for urban areas
244 !------------------------------------------------------------------------
246 !------------------------------------------------------------------------
247 real hi_urb(its:ite,1:nz_um,jts:jte) ! Height histograms of buildings
248 real hi_urb1D(nz_um) ! Height histograms of buildings
249 real ss_urb(nz_um,nurbmax) ! Probability that a building has an height equal to z
250 real pb_urb(nz_um) ! Probability that a building has an height greater or equal to z
251 real hb_u(nz_um) ! Bulding's heights
252 integer nz_urb(nurbmax) ! Number of layer in the urban grid
253 integer nzurban(nurbmax)
255 ! Building parameters
256 real alag_u(nurbmax) ! Ground thermal diffusivity [m^2 s^-1]
257 real alaw_u(nurbmax) ! Wall thermal diffusivity [m^2 s^-1]
258 real alar_u(nurbmax) ! Roof thermal diffusivity [m^2 s^-1]
259 real csg_u(nurbmax) ! Specific heat of the ground material [J m^3 K^-1]
260 real csw_u(nurbmax) ! Specific heat of the wall material [J m^3 K^-1]
261 real csr_u(nurbmax) ! Specific heat of the roof material [J m^3 K^-1]
262 real twini_u(nurbmax) ! Initial temperature inside the building's wall [K]
263 real trini_u(nurbmax) ! Initial temperature inside the building's roof [K]
264 real tgini_u(nurbmax) ! Initial road temperature
270 real csg(ng_u) ! Specific heat of the ground material [J m^3 K^-1]
271 real csw(nwr_u) ! Specific heat of the wall material for the current urban class [J m^3 K^-1]
272 real csr(nwr_u) ! Specific heat of the roof material for the current urban class [J m^3 K^-1]
273 real csgb(ngb_u) ! Specific heat of the ground material below the buildings at each ground levels[J m^3 K^-1]
274 real csf(nf_u) ! Specific heat of the floors materials in the buildings at each levels[J m^3 K^-1]
275 real alar(nwr_u+1) ! Roof thermal diffusivity for the current urban class [W/m K]
276 real alaw(nwr_u+1) ! Walls thermal diffusivity for the current urban class [W/m K]
277 real alag(ng_u) ! Ground thermal diffusivity for the current urban class [m^2 s^-1]
278 real alagb(ngb_u+1) ! Ground thermal diffusivity below the building at each wall layer [W/m K]
279 real alaf(nf_u+1) ! Floor thermal diffusivity at each wall layers [W/m K]
280 real dzr(nwr_u) ! Layer sizes in the roofs [m]
281 real dzf(nf_u) ! Layer sizes in the floors[m]
282 real dzw(nwr_u) ! Layer sizes in the walls [m]
283 real dzgb(ngb_u) ! Layer sizes in the ground below the buildings [m]
286 !New street and radiation parameters
289 real bs(ndm) ! Building width for the current urban class
290 real ws(ndm) ! Street widths of the current urban class
291 real strd(ndm) ! Street lengths for the current urban class
292 real drst(ndm) ! street directions for the current urban class
293 real ss(nz_um) ! Probability to have a building with height h
294 real pb(nz_um) ! Probability to have a building with an height equal
296 !New roughness and buildings parameters
298 real z0(ndm,nz_um) ! Roughness lengths "profiles"
299 real bs_urb(ndm,nurbmax) ! Building width
300 real ws_urb(ndm,nurbmax) ! Street width
303 ! for twini_u, and trini_u the initial value at the deepest level is kept constant during the simulation
305 ! Radiation paramters
306 real albg_u(nurbmax) ! Albedo of the ground
307 real albw_u(nurbmax) ! Albedo of the wall
308 real albr_u(nurbmax) ! Albedo of the roof
309 real albwin_u(nurbmax) ! Albedo of the windows
310 real emwind_u(nurbmax) ! Emissivity of windows
311 real emg_u(nurbmax) ! Emissivity of ground
312 real emw_u(nurbmax) ! Emissivity of wall
313 real emr_u(nurbmax) ! Emissivity of roof
314 real gr_frac_roof_u(nurbmax)
315 real pv_frac_roof_u(nurbmax)
319 ! fww_u,fwg_u,fgw_u,fsw_u,fsg_u are the view factors used to compute the long wave
320 ! and the short wave radiation.
321 real fww_u(nz_um,nz_um,ndm,nurbmax) ! from wall to wall
322 real fwg_u(nz_um,ndm,nurbmax) ! from wall to ground
323 real fgw_u(nz_um,ndm,nurbmax) ! from ground to wall
324 real fsw_u(nz_um,ndm,nurbmax) ! from sky to wall
325 real fws_u(nz_um,ndm,nurbmax) ! from sky to wall
326 real fsg_u(ndm,nurbmax) ! from sky to ground
328 ! Roughness parameters
329 real z0g_u(nurbmax) ! The ground's roughness length
330 real z0r_u(nurbmax) ! The roof's roughness length
333 integer nd_u(nurbmax) ! Number of street direction for each urban class
334 real strd_u(ndm,nurbmax) ! Street length (fix to greater value to the horizontal length of the cells)
335 real drst_u(ndm,nurbmax) ! Street direction
336 real ws_u(ndm,nurbmax) ! Street width
337 real bs_u(ndm,nurbmax) ! Building width
338 real h_b(nz_um,nurbmax) ! Bulding's heights
339 real d_b(nz_um,nurbmax) ! Probability that a building has an height h_b
340 real ss_u(nz_um,nurbmax)! Probability that a building has an height equal to z
341 real pb_u(nz_um,nurbmax)! Probability that a building has an height greater or equal to z
345 integer nz_u(nurbmax) ! Number of layer in the urban grid
347 real z_u(nz_um) ! Height of the urban grid levels
350 real bldac_frc_u(nurbmax)
351 real cooled_frc_u(nurbmax)
354 integer sw_cond_u(nurbmax)
355 real time_on_u(nurbmax)
356 real time_off_u(nurbmax)
357 real targtemp_u(nurbmax)
358 real gaptemp_u(nurbmax)
359 real targhum_u(nurbmax)
360 real gaphum_u(nurbmax)
361 real perflo_u(nurbmax)
362 real hsesf_u(nurbmax)
365 ! 1D array used for the input and output of the routine "urban"
367 real z1D(kms:kme) ! vertical coordinates
368 real ua1D(kms:kme) ! wind speed in the x directions
369 real va1D(kms:kme) ! wind speed in the y directions
370 real pt1D(kms:kme) ! potential temperature
371 real da1D(kms:kme) ! air density
372 real pr1D(kms:kme) ! air pressure
373 real pt01D(kms:kme) ! reference potential temperature
374 real zr1D ! zenith angle
375 real deltar1D ! declination of the sun
376 real ah1D ! hour angle (it should come from the radiation routine)
377 real rs1D ! solar radiation
378 real rld1D ! downward flux of the longwave radiation
380 real swddif1D ! short wave diffuse solar radiation _gl
384 real tw1D(2*ndm,nz_um,nwr_u,nbui_max) ! temperature in each layer of the wall
385 real tg1D(ndm,ng_u) ! temperature in each layer of the ground
386 real tr1D(ndm,nz_um,nwr_u) ! temperature in each layer of the roof
387 real trv1D(ndm,nz_um,ngr_u) ! temperature in each layer of the GREEN roof
388 real qr1D(ndm,nz_um,ngr_u) ! humidity in each layer of the GREEN roof
391 !New variable for BEM
393 real tlev1D(nz_um,nbui_max) ! temperature in each floor and in each different type of building
394 real qlev1D(nz_um,nbui_max) ! specific humidity in each floor and in each different type of building
395 real twlev1D(2*ndm,nz_um,nbui_max) ! temperature in each window in each floor in each different type of building
396 real tglev1D(ndm,ngb_u,nbui_max) ! temperature in each layer of the ground below of a type of building
397 real tflev1D(ndm,nf_u,nz_um-1,nbui_max)! temperature in each layer of the floors in each building
398 real lflev1D(nz_um,nz_um) ! latent heat flux due to the air conditioning systems
399 real sflev1D(nz_um,nz_um) ! sensible heat flux due to the air conditioning systems
400 real lfvlev1D(nz_um,nz_um) ! latent heat flux due to ventilation
401 real sfvlev1D(nz_um,nz_um) ! sensible heat flux due to ventilation
402 real sfwin1D(2*ndm,nz_um,nbui_max) ! sensible heat flux from windows
403 real consumlev1D(nz_um,nz_um) ! consumption due to the air conditioning systems
404 real eppvlev1D(nz_um) ! electricity production of PV panels
406 real tpvlev1D(ndm,nz_um)
407 real qv1D(kms:kme) ! specific humidity
408 real meso_urb ! constant to link meso and urban scales [m-2]
410 real roof_frac ! Surface fraction occupied by roof
420 real sfw1D(2*ndm,nz_um,nbui_max) ! sensible heat flux from walls
421 real sfg1D(ndm) ! sensible heat flux from ground (road)
422 real sfr1D(ndm,nz_um) ! sensible heat flux from roofs
423 real sfrpv1D(ndm,nz_um)
426 real sfr_indoor1D(nbui_max)
427 real sfrv1D(ndm,nz_um) ! sensible heat flux from roofs
428 real lfrv1D(ndm,nz_um) ! latent heat flux from roofs
429 real dg1D(ndm) ! water depth from ground
430 real dgr1D(ndm,nz_um) ! water depth from roofs
431 real lfg1D(ndm) ! latent heat flux from ground (road)
432 real lfr1D(ndm,nz_um) ! latent heat flux from roofs
433 real drain1D(ndm,nz_um) ! sensible heat flux from roofs
434 real sf1D(kms:kme) ! surface of the urban grid cells
435 real vl1D(kms:kme) ! volume of the urban grid cells
436 real a_u1D(kms:kme) ! Implicit component of the momentum sources or sinks in the X-direction
437 real a_v1D(kms:kme) ! Implicit component of the momentum sources or sinks in the Y-direction
438 real a_t1D(kms:kme) ! Implicit component of the heat sources or sinks
439 real a_e1D(kms:kme) ! Implicit component of the TKE sources or sinks
440 real b_u1D(kms:kme) ! Explicit component of the momentum sources or sinks in the X-direction
441 real b_v1D(kms:kme) ! Explicit component of the momentum sources or sinks in the Y-direction
442 real b_t1D(kms:kme) ! Explicit component of the heat sources or sinks
444 real b_e1D(kms:kme) ! Explicit component of the TKE sources or sinks
445 real b_q1D(kms:kme) ! Explicit component of the Humidity sources or sinks
446 real dlg1D(kms:kme) ! Height above ground (L_ground in formula (24) of the BLM paper).
447 real dl_u1D(kms:kme) ! Length scale (lb in formula (22) ofthe BLM paper)
448 real gfr1D(ndm,nz_um)
450 ! arrays used to collapse indexes
451 integer ind_zwd(nbui_max,nz_um,nwr_u,ndm)
452 integer ind_gd(ng_u,ndm)
453 integer ind_zd(nbui_max,nz_um,ndm)
454 integer ind_zdf(nz_um,ndm)
455 integer ind_zrd(nz_um,nwr_u,ndm)
456 integer ind_grd(nz_um,ngr_u,ndm)
458 integer ind_bd(nbui_max,nz_um)
459 integer ind_wd(nbui_max,nz_um,ndm)
460 integer ind_gbd(nbui_max,ngb_u,ndm)
461 integer ind_fbd(nbui_max,nf_u,nz_um-1,ndm)
463 integer ix,iy,iz,iurb,id,iz_u,iw,ig,ir,ix1,iy1,k
467 character(len=80) :: text
471 save alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u, &
472 albg_u,albw_u,albr_u,emg_u,emw_u,emr_u, &
473 z0g_u,z0r_u, nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b,ss_u,pb_u, &
474 nz_u,z_u,albwin_u,emwind_u,cop_u,pwin_u,beta_u,sw_cond_u, &
475 bldac_frc_u,cooled_frc_u, &
476 time_on_u,time_off_u,targtemp_u,gaptemp_u,targhum_u,gaphum_u, &
477 perflo_u,gr_frac_roof_u, &
478 pv_frac_roof_u,hsesf_u,hsequip,irho,gr_flag_u,gr_type_u
480 !------------------------------------------------------------------------
481 ! Calculation of the momentum, heat and turbulent kinetic fluxes
482 ! produced by buildings
485 ! Martilli, A., Clappier, A., Rotach, M.W.:2002, 'AN URBAN SURFACE EXCHANGE
486 ! PARAMETERISATION FOR MESOSCALE MODELS', Boundary-Layer Meteorolgy 104:
489 ! F. Salamanca and A. Martilli, 2009: 'A new Building Energy Model coupled
490 ! with an Urban Canopy Parameterization for urban climate simulations - part II.
491 ! Validation with one dimension off-line simulations'. Theor Appl Climatol
492 ! DOI 10.1007/s00704-009-0143-8
493 !------------------------------------------------------------------------
495 !prepare the arrays to collapse indexes
499 if(urban_map_zwd.lt.nbui_max*nz_um*ndm*max(nwr_u,ng_u))then
500 write(*,*)'urban_map_zwd too small, please increase to at least ', nbui_max*nz_um*ndm*max(nwr_u,ng_u)
504 !New conditions for BEM
506 if(urban_map_bd.lt.nbui_max*nz_um)then !limit for indoor temperature and indoor humidity
507 write(*,*)'urban_map_bd too small, please increase to at least ', nbui_max*nz_um
511 if(urban_map_wd.lt.nbui_max*nz_um*ndm)then !limit for window temperature
512 write(*,*)'urban_map_wd too small, please increase to at least ', nbui_max*nz_um*ndm
516 if(urban_map_gbd.lt.nbui_max*ndm*ngb_u)then !limit for ground temperature below a building
517 write(*,*)'urban_map_gbd too small, please increase to at least ', nbui_max*ndm*ngb_u
521 if(urban_map_fbd.lt.(nz_um-1)*nbui_max*ndm*nf_u)then !limit for floor temperature
522 write(*,*)'urban_map_fbd too small, please increase to at least ', nbui_max*ndm*nf_u*(nz_um-1)
527 write(*,*) 'number of directions is not correct',ndm
531 !End of new conditions
534 !Initialize collapse indexes
547 !End initialization indexes
556 ind_zwd(ibui,iz_u,iw,id)=iii
575 ind_zd(ibui,iz_u,id)=iii
585 ind_zrd(iz_u,iw,id)=iii
595 ind_grd(iz_u,iw,id)=iii
612 do ibui=1,nbui_max !Type of building
613 do iz_u=1,nz_um !vertical levels
615 ind_bd(ibui,iz_u)=iii
622 do ibui=1,nbui_max !type of building
623 do iz_u=1,nz_um !vertical levels
624 do id=1,ndm !direction
626 ind_wd(ibui,iz_u,id)=iii
632 do ibui=1,nbui_max!type of building
633 do iw=1,ngb_u !layers in the wall (ground below a building)
634 do id=1,ndm !direction
636 ind_gbd(ibui,iw,id)=iii
642 do ibui=1,nbui_max !type of building
643 do iw=1,nf_u !layers in the wall (floor)
644 do iz_u=1,nz_um-1 !vertical levels
645 do id=1,ndm !direction
647 ind_fbd(ibui,iw,iz_u,id)=iii
656 if (num_urban_hi.ge.nz_um)then
657 write(*,*)'nz_um too small, please increase to at least ', num_urban_hi+1
664 hi_urb(ix,iz_u,iy)=0.
673 z(ix,iz,iy)=z(ix,iz-1,iy)+dz8w(ix,iz-1,iy)
676 do iz_u=1,num_urban_hi
677 hi_urb(ix,iz_u,iy)= hi_urb2d(ix,iz_u,iy)
678 if (hi_urb(ix,iz_u,iy)/=0.) then
682 if (iii.gt.nbui_max) then
683 write(*,*) 'nbui_max too small, please increase to at least ',iii
690 if (first) then ! True only on first call
692 call init_para(alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u,&
693 twini_u,trini_u,tgini_u,albg_u,albw_u,albr_u,albwin_u,emg_u,emw_u,&
694 emr_u,emwind_u,z0g_u,z0r_u,nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b, &
695 cop_u,pwin_u,beta_u,sw_cond_u,time_on_u,time_off_u,targtemp_u, &
696 bldac_frc_u,cooled_frc_u, &
697 gaptemp_u,targhum_u,gaphum_u,perflo_u, &
698 gr_frac_roof_u,pv_frac_roof_u, &
699 hsesf_u,hsequip,irho,gr_flag_u,gr_type_u)
701 !Initialisation of the urban parameters and calculation of the view factor
702 call icBEP(nd_u,h_b,d_b,ss_u,pb_u,nz_u,z_u)
710 if (FRC_URB2D(ix,iy).gt.0.) then ! Calling BEP only for existing urban classes.
712 iurb=UTYPE_URB2D(ix,iy)
716 hi_urb1D(iz_u)=hi_urb(ix,iz_u,iy)
720 call icBEPHI_XY(iurb,hb_u,hi_urb1D,ss_urb,pb_urb, &
723 call param(iurb,nz_u(iurb),nz_urb(iurb),nzurban(iurb), &
724 nd_u(iurb),csg_u,csg,alag_u,alag,csr_u,csr, &
725 alar_u,alar,csw_u,csw,alaw_u,alaw, &
726 ws_u,ws_urb,ws,bs_u,bs_urb,bs,z0g_u,z0r_u,z0, &
727 strd_u,strd,drst_u,drst,ss_u,ss_urb,ss,pb_u, &
728 pb_urb,pb,dzw,dzr,dzf,csf,alaf,dzgb,csgb,alagb, &
729 lp_urb2d(ix,iy),lb_urb2d(ix,iy), &
730 hgt_urb2d(ix,iy),FRC_URB2D(ix,iy))
733 !We compute the view factors in the icBEP_XY routine
736 call icBEP_XY(iurb,fww_u,fwg_u,fgw_u,fsw_u,fws_u,fsg_u, &
737 nd_u(iurb),strd,ws,nzurban(iurb),z_u)
744 if(ss_urb(iz,iurb).gt.0) then
747 d_urb(ibui)=ss_urb(iz,iurb)
752 if (nbui.gt.nbui_max) then
753 write (*,*) 'nbui_max must be increased to',nbui
760 ua1D(iz)=u_phy(ix,iz,iy)
761 va1D(iz)=v_phy(ix,iz,iy)
762 pt1D(iz)=th_phy(ix,iz,iy)
763 da1D(iz)=rho(ix,iz,iy)
764 pr1D(iz)=p_phy(ix,iz,iy)
767 qv1D(iz)=qv_phy(ix,iz,iy)
778 z1D(kte+1)=z(ix,kte+1,iy)
786 tw1D(2*id-1,iz_u,iw,ibui)=tw1_urb4d(ix,ind_zwd(ibui,iz_u,iw,id),iy)
787 tw1D(2*id,iz_u,iw,ibui)=tw2_urb4d(ix,ind_zwd(ibui,iz_u,iw,id),iy)
795 tg1D(id,ig)=tgb_urb4d(ix,ind_gd(ig,id),iy)
800 tr1D(id,iz_u,ir)=trb_urb4d(ix,ind_zrd(iz_u,ir,id),iy)
803 if(gr_flag_u.eq.1)then
804 trv1D(id,iz_u,ir)=trv_urb4d(ix,ind_grd(iz_u,ir,id),iy)
805 qr1D(id,iz_u,ir)=qr_urb4d(ix,ind_grd(iz_u,ir,id),iy)
816 !Initialize variables for BEM
818 tlev1D=0. !Indoor temperature
819 qlev1D=0. !Indoor humidity
821 twlev1D=0. !Window temperature
822 tglev1D=0. !Ground temperature
823 tflev1D=0. !Floor temperature
825 sflev1D=0. !Sensible heat flux from the a.c.
826 lflev1D=0. !latent heat flux from the a.c.
827 consumlev1D=0.!consumption of the a.c.
828 eppvlev1D=0. !electricity production of PV panels
830 sfvlev1D=0. !Sensible heat flux from natural ventilation
831 lfvlev1D=0. !Latent heat flux from natural ventilation
832 sfwin1D=0. !Sensible heat flux from windows
833 sfw1D=0. !Sensible heat flux from walls
835 do iz_u=1,nz_um !vertical levels
836 do ibui=1,nbui_max !Type of building
837 tlev1D(iz_u,ibui)= tlev_urb3d(ix,ind_bd(ibui,iz_u),iy)
838 qlev1D(iz_u,ibui)= qlev_urb3d(ix,ind_bd(ibui,iz_u),iy)
844 do id=1,ndm !direction
845 do iz_u=1,nz_um !vertical levels
846 do ibui=1,nbui_max !type of building
847 twlev1D(2*id-1,iz_u,ibui)=tw1lev_urb3d(ix,ind_wd(ibui,iz_u,id),iy)
848 twlev1D(2*id,iz_u,ibui)=tw2lev_urb3d(ix,ind_wd(ibui,iz_u,id),iy)
849 sfwin1D(2*id-1,iz_u,ibui)=sfwin1_urb3d(ix,ind_wd(ibui,iz_u,id),iy)
850 sfwin1D(2*id,iz_u,ibui)=sfwin2_urb3d(ix,ind_wd(ibui,iz_u,id),iy)
855 do id=1,ndm !direction
856 do iw=1,ngb_u !layer in the wall
857 do ibui=1,nbui_max !type of building
858 tglev1D(id,iw,ibui)=tglev_urb3d(ix,ind_gbd(ibui,iw,id),iy)
863 do id=1,ndm !direction
864 do iw=1,nf_u !layer in the walls
865 do iz_u=1,nz_um-1 !verticals levels
866 do ibui=1,nbui_max !type of building
867 tflev1D(id,iw,iz_u,ibui)=tflev_urb3d(ix,ind_fbd(ibui,iw,iz_u,id),iy)
875 !End initialization for BEM
880 do ibui=1,nbui_max !type of building
881 !! sfw1D(2*id-1,iz)=sfw1(ix,iy,ind_zd(iz,id))
882 !! sfw1D(2*id,iz)=sfw2(ix,iy,ind_zd(iz,id))
883 sfw1D(2*id-1,iz,ibui)=sfw1_urb3d(ix,ind_zd(ibui,iz,id),iy)
884 sfw1D(2*id,iz,ibui)=sfw2_urb3d(ix,ind_zd(ibui,iz,id),iy)
890 sfg1D(id)=sfg_urb3d(ix,id,iy)
891 lfg1D(id)=lfg_urb3d(ix,id,iy)
892 dg1D(id)=dg_urb3d(ix,id,iy)
898 tpvlev1D(id,iz)=t_pv_urb3d(ix,ind_zdf(iz,id),iy)
899 sfr1D(id,iz)=sfr_urb3d(ix,ind_zdf(iz,id),iy)
900 lfr1D(id,iz)=lfr_urb3d(ix,ind_zdf(iz,id),iy)
901 dgr1D(id,iz)=dgr_urb3d(ix,ind_zdf(iz,id),iy)
902 if(gr_flag_u.eq.1)then
903 sfrv1D(id,iz)=sfrv_urb3d(ix,ind_zdf(iz,id),iy)
904 lfrv1D(id,iz)=lfrv_urb3d(ix,ind_zdf(iz,id),iy)
905 drain1D(id,iz)=drain_urb4d(ix,ind_zdf(iz,id),iy)
918 swddir1D=swddir(ix,iy) !_gl
919 swddif1D=swddif(ix,iy) !_gl
920 zr1D=acos(COSZ_URB2D(ix,iy))
922 ah1D=OMG_URB2D(ix,iy)
925 call BEP1D(itimestep,ix,iy,iurb,kms,kme,kts,kte,z1D,dt,ua1D,va1D,pt1D,da1D,pr1D,pt01D, &
926 zr1D,deltar1D,ah1D,rs1D,rld1D,alagb, &
927 alag,alaw,alar,alaf,csgb,csg,csw,csr,csf, &
928 dzr,dzf,dzw,dzgb,xlat(ix,iy),swddir1D,swddif1D, &
929 albg_u(iurb),albw_u(iurb),albr_u(iurb), &
930 albwin_u(iurb),emg_u(iurb),emw_u(iurb), &
931 emr_u(iurb),emwind_u(iurb),fww_u,fwg_u, &
932 fgw_u,fsw_u,fws_u,fsg_u,z0, &
933 nd_u(iurb),strd,drst,ws,bs_urb,bs,ss,pb, &
934 nzurban(iurb),z_u,cop_u,pwin_u,beta_u, &
935 sw_cond_u,time_on_u,time_off_u,targtemp_u, &
936 gaptemp_u,targhum_u,gaphum_u,perflo_u, &
937 gr_frac_roof_u(iurb),pv_frac_roof_u(iurb), &
938 hsesf_u,hsequip,irho,gr_flag_u,gr_type_u, &
939 tw1D,tg1D,tr1D,trv1D,sfw1D,sfg1D,sfr1D, &
941 dgr1D,dg1D,lfr1D,lfg1D, &
942 drain1D,rainbl(ix,iy),qr1D, &
943 a_u1D,a_v1D,a_t1D,a_e1D, &
944 b_u1D,b_v1D,b_t1D,b_ac1D,b_e1D,b_q1D, &
945 dlg1D,dl_u1D,sf1D,vl1D,rl_up(ix,iy), &
946 rs_abs(ix,iy),emiss(ix,iy),grdflx_urb(ix,iy), &
947 qv1D,tlev1D,qlev1D,sflev1D,lflev1D,consumlev1D, &
948 eppvlev1D,tpvlev1D,sfvlev1D,lfvlev1D,twlev1D,tglev1D,tflev1D,sfwin1D,tair1D,sfr_indoor1D,sfrpv1D,gfr1D)
950 do ibui=1,nbui_max !type of building
951 do iz=1,nz_um !vertical levels
952 do id=1,ndm ! direction
953 sfw1_urb3d(ix,ind_zd(ibui,iz,id),iy)=sfw1D(2*id-1,iz,ibui)
954 sfw2_urb3d(ix,ind_zd(ibui,iz,id),iy)=sfw1D(2*id,iz,ibui)
960 sfg_urb3d(ix,id,iy)=sfg1D(id)
961 lfg_urb3d(ix,id,iy)=lfg1D(id)
962 dg_urb3d(ix,id,iy)=dg1D(id)
967 t_pv_urb3d(ix,ind_zdf(iz,id),iy)=tpvlev1D(id,iz)
968 sfr_urb3d(ix,ind_zdf(iz,id),iy)=sfr1D(id,iz)
969 dgr_urb3d(ix,ind_zdf(iz,id),iy)=dgr1D(id,iz)
970 lfr_urb3d(ix,ind_zdf(iz,id),iy)=lfr1D(id,iz)
971 if(gr_flag_u.eq.1)then
972 sfrv_urb3d(ix,ind_zdf(iz,id),iy)=sfrv1D(id,iz)
973 lfrv_urb3d(ix,ind_zdf(iz,id),iy)=lfrv1D(id,iz)
974 drain_urb4d(ix,ind_zdf(iz,id),iy)=drain1D(id,iz)
983 tw1_urb4d(ix,ind_zwd(ibui,iz_u,iw,id),iy)=tw1D(2*id-1,iz_u,iw,ibui)
984 tw2_urb4d(ix,ind_zwd(ibui,iz_u,iw,id),iy)=tw1D(2*id,iz_u,iw,ibui)
994 tgb_urb4d(ix,ind_gd(ig,id),iy)=tg1D(id,ig)
998 trb_urb4d(ix,ind_zrd(iz_u,ir,id),iy)=tr1D(id,iz_u,ir)
1000 if(gr_flag_u.eq.1)then
1002 trv_urb4d(ix,ind_grd(iz_u,ir,id),iy)=trv1D(id,iz_u,ir)
1003 qr_urb4d(ix,ind_grd(iz_u,ir,id),iy)=qr1D(id,iz_u,ir)
1014 do ibui=1,nbui_max !type of building
1015 do iz_u=1,nz_um !vertical levels
1016 tlev_urb3d(ix,ind_bd(ibui,iz_u),iy)=tlev1D(iz_u,ibui)
1017 qlev_urb3d(ix,ind_bd(ibui,iz_u),iy)=qlev1D(iz_u,ibui)
1021 do ibui=1,nbui_max !type of building
1022 do iz_u=1,nz_um !vertical levels
1023 do id=1,ndm !direction
1024 tw1lev_urb3d(ix,ind_wd(ibui,iz_u,id),iy)=twlev1D(2*id-1,iz_u,ibui)
1025 tw2lev_urb3d(ix,ind_wd(ibui,iz_u,id),iy)=twlev1D(2*id,iz_u,ibui)
1026 sfwin1_urb3d(ix,ind_wd(ibui,iz_u,id),iy)=sfwin1D(2*id-1,iz_u,ibui)
1027 sfwin2_urb3d(ix,ind_wd(ibui,iz_u,id),iy)=sfwin1D(2*id,iz_u,ibui)
1032 do ibui=1,nbui_max !type of building
1033 do iw=1,ngb_u !layers in the walls
1034 do id=1,ndm !direction
1035 tglev_urb3d(ix,ind_gbd(ibui,iw,id),iy)=tglev1D(id,iw,ibui)
1040 do ibui=1,nbui_max !type of building
1041 do iw=1,nf_u !layer in the walls
1042 do iz_u=1,nz_um-1 !verticals levels
1044 tflev_urb3d(ix,ind_fbd(ibui,iw,iz_u,id),iy)=tflev1D(id,iw,iz_u,ibui)
1052 sf_ac_urb3d(ix,iy)=0.
1053 lf_ac_urb3d(ix,iy)=0.
1054 cm_ac_urb3d(ix,iy)=0.
1055 ep_pv_urb3d(ix,iy)=0.
1056 sfvent_urb3d(ix,iy)=0.
1057 lfvent_urb3d(ix,iy)=0.
1058 draingr_urb3d(ix,iy)=0.
1061 meso_urb=(1./4.)*FRC_URB2D(ix,iy)/((bs_urb(1,iurb)+ws_urb(1,iurb))*bs_urb(2,iurb))+ &
1062 (1./4.)*FRC_URB2D(ix,iy)/((bs_urb(2,iurb)+ws_urb(2,iurb))*bs_urb(1,iurb))
1063 meso_urb_ac=meso_urb*bldac_frc_u(iurb)*cooled_frc_u(iurb)
1064 roof_frac=FRC_URB2D(ix,iy)*bs_urb(1,iurb)/(bs_urb(1,iurb)+ws_urb(1,iurb))
1070 if(ss_urb(iz,iurb).gt.0) then
1073 d_urb(ibui)=ss_urb(iz,iurb)
1081 do ibui=1,nbui !type of building
1082 ep_pv_urb3d(ix,iy)=ep_pv_urb3d(ix,iy)+meso_urb_ac*d_urb(ibui)*eppvlev1D(ibui)
1083 do iz_u=1,nlev(ibui) !vertical levels
1084 sf_ac_urb3d(ix,iy)=sf_ac_urb3d(ix,iy)+meso_urb_ac*d_urb(ibui)*sflev1D(iz_u,ibui)
1085 lf_ac_urb3d(ix,iy)=lf_ac_urb3d(ix,iy)+meso_urb_ac*d_urb(ibui)*lflev1D(iz_u,ibui)
1086 cm_ac_urb3d(ix,iy)=cm_ac_urb3d(ix,iy)+meso_urb_ac*d_urb(ibui)*consumlev1D(iz_u,ibui)
1087 !if(consumlev1D(iz_u,ibui).gt.0.)then
1088 !print*,'IX',ix,'IY',iy,'IZ_U',iz_u,'IBUI',ibui,'CONSUM',consumlev1D(iz_u,ibui),'D_URB',d_urb(ibui),'MESO_URB',meso_urb_ac
1091 sfvent_urb3d(ix,iy)=sfvent_urb3d(ix,iy)+meso_urb_ac*d_urb(ibui)*sfvlev1D(iz_u,ibui)
1092 lfvent_urb3d(ix,iy)=lfvent_urb3d(ix,iy)+meso_urb_ac*d_urb(ibui)*lfvlev1D(iz_u,ibui)
1098 if(gr_flag_u.eq.1)then
1101 draingr_urb3d(ix,iy)=draingr_urb3d(ix,iy)+d_urb(iz-1)*roof_frac*drain1D(id,iz)*1000
1103 qgr_urb3d(ix,iy)=qgr_urb3d(ix,iy)+qr1D(id,iz,ig)/ndm/(nz_um-2)/ngr_u
1104 tgr_urb3d(ix,iy)=tgr_urb3d(ix,iy)+trv1D(id,iz,ig)/ndm/(nz_um-2)/ngr_u
1114 sf(ix,kts:kte,iy)=0.
1115 vl(ix,kts:kte,iy)=0.
1116 a_u(ix,kts:kte,iy)=0.
1117 a_v(ix,kts:kte,iy)=0.
1118 a_t(ix,kts:kte,iy)=0.
1119 a_e(ix,kts:kte,iy)=0.
1120 b_u(ix,kts:kte,iy)=0.
1121 b_v(ix,kts:kte,iy)=0.
1122 b_t(ix,kts:kte,iy)=0.
1123 b_e(ix,kts:kte,iy)=0.
1124 b_q(ix,kts:kte,iy)=0.
1125 dlg(ix,kts:kte,iy)=0.
1126 dl_u(ix,kts:kte,iy)=0.
1129 sf(ix,iz,iy)=sf1D(iz)
1130 vl(ix,iz,iy)=vl1D(iz)
1131 a_u(ix,iz,iy)=a_u1D(iz)
1132 a_v(ix,iz,iy)=a_v1D(iz)
1133 a_t(ix,iz,iy)=a_t1D(iz)
1134 a_e(ix,iz,iy)=a_e1D(iz)
1135 b_u(ix,iz,iy)=b_u1D(iz)
1136 b_v(ix,iz,iy)=b_v1D(iz)
1137 b_t(ix,iz,iy)=b_t1D(iz)
1138 sf_ac=sf_ac+b_ac1D(iz)*da1D(iz)*cp_u*dz8w(ix,iz,iy)*vl1D(iz)*FRC_URB2D(ix,iy)
1139 b_e(ix,iz,iy)=b_e1D(iz)
1140 b_q(ix,iz,iy)=b_q1D(iz)
1141 dlg(ix,iz,iy)=dlg1D(iz)
1142 dl_u(ix,iz,iy)=dl_u1D(iz)
1144 sf(ix,kte+1,iy)=sf1D(kte+1)
1153 time_bep=time_bep+dt
1155 ! print*, 'ss_urb', ss_urb
1156 ! print*, 'pb_urb', pb_urb
1157 ! print*, 'nz_urb', nz_urb
1158 ! print*, 'd_urb', d_urb
1162 end subroutine BEP_BEM
1165 ! ===6=8===============================================================72
1167 subroutine BEP1D(itimestep,ix,iy,iurb,kms,kme,kts,kte,z,dt,ua,va,pt,da,pr,pt0, &
1168 zr,deltar,ah,rs,rld,alagb, &
1169 alag,alaw,alar,alaf,csgb,csg,csw,csr,csf, &
1170 dzr,dzf,dzw,dzgb,xlat,swddir,swddif, &
1171 albg,albw,albr,albwin,emg,emw,emr, &
1172 emwind,fww,fwg,fgw,fsw,fws,fsg,z0, &
1173 ndu,strd,drst,ws,bs_u,bs,ss,pb, &
1174 nzu,z_u,cop_u,pwin_u,beta_u,sw_cond_u, &
1175 time_on_u,time_off_u,targtemp_u, &
1176 gaptemp_u,targhum_u,gaphum_u,perflo_u, &
1177 gr_frac_roof,pv_frac_roof, &
1178 hsesf_u,hsequip,irho,gr_flag,gr_type, &
1179 tw,tg,tr,trv,sfw,sfg,sfr, &
1180 sfrv,lfrv,dgr,dg,lfr,lfg,drain,rainbl,qr, &
1182 b_u,b_v,b_t,b_ac,b_e,b_q, &
1183 dlg,dl_u,sf,vl,rl_up,rs_abs,emiss,grdflx_urb, &
1184 qv,tlev,qlev,sflev,lflev,consumlev, &
1185 eppvlev,tpvlev,sfvlev,lfvlev,twlev,tglev,tflev,sfwin,tmp_u,sfr_indoor,sfrpv,gfr)
1186 ! print*,'SFR_AFT',sfr(id,iz)
1192 ! ----------------------------------------------------------------------
1194 ! ----------------------------------------------------------------------
1196 ! Data relative to the "mesoscale grid"
1198 !! integer nz ! Number of vertical levels
1199 integer kms,kme,kts,kte,ix,iy,itimestep
1200 real z(kms:kme) ! Altitude above the ground of the cell interfaces.
1201 real ua(kms:kme) ! Wind speed in the x direction
1202 real va(kms:kme) ! Wind speed in the y direction
1203 real pt(kms:kme) ! Potential temperature
1204 real da(kms:kme) ! Air density
1205 real pr(kms:kme) ! Air pressure
1206 real pt0(kms:kme) ! Reference potential temperature (could be equal to "pt")
1207 real qv(kms:kme) ! Specific humidity
1209 real zr ! Zenith angle
1210 real deltar ! Declination of the sun
1211 real ah ! Hour angle
1212 real rs ! Solar radiation
1213 real rld ! Downward flux of the longwave radiation
1214 real xlat ! Latitude
1215 real swddir ! short wave direct solar radiation !_gl
1216 real swddif ! short wave diffuse solar radiation !_gl
1218 ! Data relative to the "urban grid"
1220 integer iurb ! Current urban class
1222 ! Radiation parameters
1223 real albg ! Albedo of the ground
1224 real albw ! Albedo of the wall
1225 real albr ! Albedo of the roof
1226 real albwin ! Albedo of the windows
1227 real emwind ! Emissivity of windows
1228 real emg ! Emissivity of ground
1229 real emw ! Emissivity of wall
1230 real emr ! Emissivity of roof
1233 ! fww,fwg,fgw,fsw,fsg are the view factors used to compute the long and
1234 ! short wave radation.
1235 ! The calculation of these factor is explained in the Appendix A of the BLM paper
1236 real fww(nz_um,nz_um,ndm,nurbm) ! from wall to wall
1237 real fwg(nz_um,ndm,nurbm) ! from wall to ground
1238 real fgw(nz_um,ndm,nurbm) ! from ground to wall
1239 real fsw(nz_um,ndm,nurbm) ! from sky to wall
1240 real fws(nz_um,ndm,nurbm) ! from wall to sky
1241 real fsg(ndm,nurbm) ! from sky to ground
1244 integer ndu ! Number of street direction for each urban class
1245 real bs_u(ndm,nurbm) ! Building width
1248 integer nzu ! Number of layer in the urban grid
1249 real z_u(nz_um) ! Height of the urban grid levels
1254 integer sw_cond_u(nurbm)
1255 real time_on_u(nurbm)
1256 real time_off_u(nurbm)
1257 real targtemp_u(nurbm)
1258 real gaptemp_u(nurbm)
1259 real targhum_u(nurbm)
1260 real gaphum_u(nurbm)
1261 real perflo_u(nurbm)
1271 real sfr_indoor(nbui_max)
1272 ! ----------------------------------------------------------------------
1274 ! ----------------------------------------------------------------------
1276 ! Data relative to the "urban grid" which should be stored from the current time step to the next one
1278 real tw(2*ndm,nz_um,nwr_u,nbui_max) ! Temperature in each layer of the wall [K]
1279 real tr(ndm,nz_um,nwr_u) ! Temperature in each layer of the roof [K]
1280 real tg(ndm,ng_u) ! Temperature in each layer of the ground [K]
1281 real trv(ndm,nz_um,ngr_u) ! Temperature in each layer of the green roof [K]
1282 real sfw(2*ndm,nz_um,nbui_max) ! Sensible heat flux from walls
1283 real sfg(ndm) ! Sensible heat flux from ground (road)
1284 real sfr(ndm,nz_um) ! Sensible heat flux from roofs
1285 real sfrv(ndm,nz_um) ! Sensible heat flux from green roofs
1286 real lfrv(ndm,nz_um) ! Latent heat flux from green roofs
1287 real dg(ndm) ! water depth ground (road)
1288 real dgr(ndm,nz_um) ! water depth roofs
1289 real lfr(ndm,nz_um) ! Latent heat flux from roofs
1290 real lfg(ndm) ! Latent heat flux from ground (road)
1291 real drain(ndm,nz_um) ! Green roof drainage
1292 real rainbl ! Rainfall
1293 real gfg(ndm) ! Heat flux transferred from the surface of the ground (road) towards the interior
1294 real gfr(ndm,nz_um) ! Heat flux transferred from the surface of the roof towards the interior
1295 real gfw(2*ndm,nz_um,nbui_max) ! Heat flux transfered from the surface of the walls towards the interior
1296 real qr(ndm,nz_um,ngr_u) ! Green Roof soil moisture
1298 ! ----------------------------------------------------------------------
1300 ! ----------------------------------------------------------------------
1303 ! Data relative to the "mesoscale grid"
1305 real sf(kms:kme) ! Surface of the "mesoscale grid" cells taking into account the buildings
1306 real vl(kms:kme) ! Volume of the "mesoscale grid" cells taking into account the buildings
1308 ! Implicit and explicit components of the source and sink terms at each levels,
1309 ! the fluxes can be computed as follow: FX = A*X + B example: Heat fluxes = a_t * pt + b_t
1310 real a_u(kms:kme) ! Implicit component of the momentum sources or sinks in the X-direction
1311 real a_v(kms:kme) ! Implicit component of the momentum sources or sinks in the Y-direction
1312 real a_t(kms:kme) ! Implicit component of the heat sources or sinks
1313 real a_e(kms:kme) ! Implicit component of the TKE sources or sinks
1314 real b_u(kms:kme) ! Explicit component of the momentum sources or sinks in the X-direction
1315 real b_v(kms:kme) ! Explicit component of the momentum sources or sinks in the Y-direction
1316 real b_t(kms:kme) ! Explicit component of the heat sources or sinks
1318 real b_e(kms:kme) ! Explicit component of the TKE sources or sinks
1319 real b_q(kms:kme) ! Explicit component of the humidity sources or sinks
1320 real dlg(kms:kme) ! Height above ground (L_ground in formula (24) of the BLM paper).
1321 real dl_u(kms:kme) ! Length scale (lb in formula (22) ofthe BLM paper).
1322 ! ----------------------------------------------------------------------
1324 ! ----------------------------------------------------------------------
1326 real dz(kms:kme) ! vertical space steps of the "mesoscale grid"
1327 ! Data interpolated from the "mesoscale grid" to the "urban grid"
1329 real ua_u(nz_um) ! Wind speed in the x direction
1330 real va_u(nz_um) ! Wind speed in the y direction
1331 real pt_u(nz_um) ! Potential temperature
1332 real da_u(nz_um) ! Air density
1333 real pt0_u(nz_um) ! Reference potential temperature
1334 real pr_u(nz_um) ! Air pressure
1335 real qv_u(nz_um) !Specific humidity
1337 ! Data defining the building and street charateristics
1339 real alag(ng_u) ! Ground thermal diffusivity for the current urban class [m^2 s^-1]
1341 real csg(ng_u) ! Specific heat of the ground material of the current urban class [J m^3 K^-1]
1342 real csr(nwr_u) ! Specific heat of the roof material for the current urban class [J m^3 K^-1]
1343 real csw(nwr_u) ! Specific heat of the wall material for the current urban class [J m^3 K^-1]
1345 real z0(ndm,nz_um) ! Roughness lengths "profiles"
1346 real ws(ndm) ! Street widths of the current urban class
1347 real bs(ndm) ! Building widths of the current urban class
1348 real strd(ndm) ! Street lengths for the current urban class
1349 real drst(ndm) ! Street directions for the current urban class
1350 real ss(nz_um) ! Probability to have a building with height h
1351 real pb(nz_um) ! Probability to have a building with an height equal
1355 ! Solar radiation at each level of the "urban grid"
1357 real rsg(ndm) ! Short wave radiation from the ground
1358 real rsw(2*ndm,nz_um) ! Short wave radiation from the walls
1359 real rsd(2*ndm,nz_um) ! Direct Short wave radiation received by the walls
1360 real rlg(ndm) ! Long wave radiation from the ground
1361 real rlw(2*ndm,nz_um) ! Long wave radiation from the walls
1363 ! Potential temperature of the surfaces at each level of the "urban grid"
1365 real ptg(ndm) ! Ground potential temperatures
1366 real ptr(ndm,nz_um) ! Roof potential temperatures
1367 real ptrv(ndm,nz_um) ! Roof potential temperatures
1368 real ptw(2*ndm,nz_um,nbui_max) ! Walls potential temperatures
1371 ! Explicit and implicit component of the momentum, temperature and TKE sources or sinks on
1372 ! vertical surfaces (walls) ans horizontal surfaces (roofs and street)
1373 ! The fluxes can be computed as follow: Fluxes of X = A*X + B
1374 ! Example: Momentum fluxes on vertical surfaces = uva_u * ua_u + uvb_u
1376 real uhb_u(ndm,nz_um) ! U (wind component) Horizontal surfaces, B (explicit) term
1377 real uva_u(2*ndm,nz_um) ! U (wind component) Vertical surfaces, A (implicit) term
1378 real uvb_u(2*ndm,nz_um) ! U (wind component) Vertical surfaces, B (explicit) term
1379 real vhb_u(ndm,nz_um) ! V (wind component) Horizontal surfaces, B (explicit) term
1380 real vva_u(2*ndm,nz_um) ! V (wind component) Vertical surfaces, A (implicit) term
1381 real vvb_u(2*ndm,nz_um) ! V (wind component) Vertical surfaces, B (explicit) term
1382 real thb_u(ndm,nz_um) ! Temperature Horizontal surfaces, B (explicit) term
1383 real tva_u(2*ndm,nz_um) ! Temperature Vertical surfaces, A (implicit) term
1384 real tvb_u(2*ndm,nz_um) ! Temperature Vertical surfaces, B (explicit) term
1387 real tvb_ac(2*ndm,nz_um)
1388 real ehb_u(ndm,nz_um) ! Energy (TKE) Horizontal surfaces, B (explicit) term
1389 real evb_u(2*ndm,nz_um) ! Energy (TKE) Vertical surfaces, B (explicit) term
1390 real qhb_u(ndm,nz_um) ! Humidity Horizontal surfaces, B (explicit) term
1391 real qvb_u(2*ndm,nz_um) ! Humidity Vertical surfaces, B (explicit) term
1393 real rs_abs ! solar radiation absorbed by urban surfaces
1394 real rl_up ! longwave radiation emitted by urban surface to the atmosphere
1395 real emiss ! mean emissivity of the urban surface
1396 real grdflx_urb ! ground heat flux
1397 real dt_int ! internal time step
1398 integer nt_int ! number of internal time step
1399 integer iz,id, it_int,it
1402 !---------------------------------------
1403 !New variables uses in BEM
1404 !----------------------------------------
1406 real tmp_u(nz_um) !Air Temperature [K]
1408 real dzw(nwr_u) !Layer sizes in the walls
1409 real dzr(nwr_u) !Layer sizes in the roofs
1410 real dzf(nf_u) !Layer sizes in the floors
1411 real dzgb(ngb_u) !Layer sizes in the ground below the buildings
1413 real csgb(ngb_u) !Specific heat of the ground material below the buildings
1415 real csf(nf_u) !Specific heat of the floors materials in the buildings
1416 !of the current urban class at each levels[J m^3 K^-1]
1417 real alar(nwr_u+1) ! Roof thermal diffusivity for the current urban class [W/m K]
1418 real alaw(nwr_u+1) ! Walls thermal diffusivity for the current urban class [W/m K]
1419 real alaf(nf_u+1) ! Floor thermal diffusivity at each wall layers [W/m K]
1420 real alagb(ngb_u+1) ! Ground thermal diffusivity below the building at each wall layer [W/m K]
1422 real sfrb(ndm,nbui_max) ! Sensible heat flux from roofs [W/m2]
1423 real sfrbpv(ndm,nbui_max) ! Sensible heat flux from PV panels [W/m2]
1424 real sfrpv(ndm,nz_um) ! Sensible heat flux from PV panels [W/m2]
1425 real sfrvb(ndm,nbui_max) ! Sensible heat flux from roofs [W/m2]
1426 real lfrvb(ndm,nbui_max) ! Sensible heat flux from roofs [W/m2]
1427 real lfrb(ndm,nbui_max) ! Sensible heat flux from roofs [W/m2]
1429 real gfrb(ndm,nbui_max) ! Heat flux flowing inside the roofs [W/m2]
1430 real sfwb1D(2*ndm,nz_um) !Sensible heat flux from the walls [W/m2]
1431 real sfwin(2*ndm,nz_um,nbui_max)!Sensible heat flux from windows [W/m2]
1432 real sfwinb1D(2*ndm,nz_um) !Sensible heat flux from windows [W/m2]
1433 real gfwb1D(2*ndm,nz_um) !Heat flux flowing inside the walls [W/m2]
1435 real qlev(nz_um,nbui_max) !specific humidity [kg/kg]
1436 real qlevb1D(nz_um) !specific humidity [kg/kg]
1437 real tlev(nz_um,nbui_max) !Indoor temperature [K]
1438 real tlevb1D(nz_um) !Indoor temperature [K]
1439 real twb1D(2*ndm,nwr_u,nz_um) !Wall temperature in BEM [K]
1440 real twlev(2*ndm,nz_um,nbui_max) !Window temperature in BEM [K]
1441 real twlevb1D(2*ndm,nz_um) !Window temperature in BEM [K]
1442 real tglev(ndm,ngb_u,nbui_max) !Ground temperature below a building in BEM [K]
1443 real tglevb1D(ngb_u) !Ground temperature below a building in BEM [K]
1444 real tflev(ndm,nf_u,nz_um-1,nbui_max)!Floor temperature in BEM[K]
1445 real tflevb1D(nf_u,nz_um-1) !Floor temperature in BEM[K]
1446 real trb(ndm,nwr_u,nbui_max) !Roof temperature in BEM [K]
1447 real trvb(ndm,ngr_u,nbui_max) !Roof temperature in BEM [K]
1450 real sflev(nz_um,nz_um) ! sensible heat flux due to the air conditioning systems [W]
1451 real lflev(nz_um,nz_um) ! latent heat flux due to the air conditioning systems [W]
1452 real consumlev(nz_um,nz_um) ! consumption due to the air conditioning systems [W]
1453 real sflev1D(nz_um) ! sensible heat flux due to the air conditioning systems [W]
1454 real lflev1D(nz_um) ! latent heat flux due to the air conditioning systems [W]
1455 real consumlev1D(nz_um) ! consumption due to the air conditioning systems [W]
1456 real eppvlev(nz_um) ! Electricity production of PV panels [W]
1457 real tpvlev(ndm,nz_um)
1458 real tpvlevb(ndm,nbui_max) ! Sensible heat flux from roofs [W/m2]
1459 real sfvlev(nz_um,nz_um) ! sensible heat flux due to ventilation [W]
1460 real lfvlev(nz_um,nz_um) ! latent heat flux due to ventilation [W]
1461 real sfvlev1D(nz_um) ! sensible heat flux due to ventilation [W]
1462 real lfvlev1D(nz_um) ! Latent heat flux due to ventilation [W]
1464 real ptwin(2*ndm,nz_um,nbui_max) ! window potential temperature
1465 real tw_av(2*ndm,nz_um) ! Averaged temperature of the wall surfaces
1466 real twlev_av(2*ndm,nz_um) ! Averaged temperature of the windows
1467 real sfw_av(2*ndm,nz_um) ! Averaged sensible heat from walls
1468 real sfwind_av(2*ndm,nz_um) ! Averaged sensible heat from windows
1470 integer nbui !Total number of different type of buildings in an urban class
1471 integer nlev(nz_um) !Number of levels in each different type of buildings in an urban class
1473 real :: nhourday ! Number of hours from midnight, local time
1474 real :: st4,gamma,fp,lmr,smr,prova
1475 real hfgr(ndm,nz_um)!heat flux green roof
1476 real hfgrb(ndm,nbui_max)
1479 real tr_av(ndm,nz_um)
1480 real tr_avb(ndm,nbui_max)
1481 real sfr_avb(ndm,nbui_max)
1482 ! ----------------------------------------------------------------------
1483 ! END VARIABLES DEFINITIONS
1484 ! ----------------------------------------------------------------------
1486 ! Fix some usefull parameters for the computation of the sources or sinks
1488 !initialize the variables inside the param routine
1490 nhourday=ah/PI*180./15.+12.
1491 if (nhourday >= 24) nhourday = nhourday - 24
1492 if (nhourday < 0) nhourday = nhourday + 24
1495 if(sum(irho).gt.0)then
1496 irri_per_ts=h_water/sum(irho)
1501 if(irho(int(nhourday)+1).ne.0)then
1502 irri_now=irri_per_ts
1508 dz(iz)=z(iz+1)-z(iz)
1510 ! Interpolation on the "urban grid"
1511 call interpol(kms,kme,kts,kte,nzu,z,z_u,ua,ua_u)
1512 call interpol(kms,kme,kts,kte,nzu,z,z_u,va,va_u)
1513 call interpol(kms,kme,kts,kte,nzu,z,z_u,pt,pt_u)
1514 call interpol(kms,kme,kts,kte,nzu,z,z_u,pt0,pt0_u)
1515 call interpol(kms,kme,kts,kte,nzu,z,z_u,pr,pr_u)
1516 call interpol(kms,kme,kts,kte,nzu,z,z_u,da,da_u)
1517 call interpol(kms,kme,kts,kte,nzu,z,z_u,qv,qv_u)
1518 ! Compute the modification of the radiation due to the buildings
1521 call averaging_temp(tw,twlev,ss,pb,tw_av,twlev_av, &
1522 sfw_av,sfwind_av,sfw,sfwin)
1525 tg_av(id)=tg(id,ng_u)
1528 tr_av(id,iz)=((1-gr_frac_roof)*tr(id,iz,nwr_u)**4.+ &
1529 gr_frac_roof*trv(id,iz,ngr_u)**4.)**(1./4.)
1538 call modif_rad(iurb,ndu,nzu,z_u,ws, &
1540 tw_av,tg_av,twlev_av,albg,albw, &
1541 emw,emg,pwin_u(iurb),albwin, &
1542 emwind,fww,fwg,fgw,fsw,fsg, &
1543 zr,deltar,ah,xlat,swddir,swddif, & !_gl
1544 rs,rld,rsw,rsd,rsg,rlw,rlg)
1549 ! calculation of the urban albedo and the upward long wave radiation
1552 call upward_rad(ndu,nzu,ws,bs,sigma,pb,ss, &
1553 tg_av,emg,albg,rlg,rsg,sfg,lfg, &
1554 tw_av,emw,albw,rlw,rsw,sfw_av, &
1555 tr_av,emr,albr,emwind, &
1556 albwin,twlev_av,pwin_u(iurb),sfwind_av,rld,rs,sfr,sfrv,lfr,lfrv, &
1557 rs_abs,rl_up,emiss,grdflx_urb,gr_frac_roof,tpvlev,pv_frac_roof)
1560 if(dg(id).le.dgmax) then
1561 dg(id)=dg(id)+(rainbl+(lfg(id)*dt)/latent)
1563 if (dg(id).lt.0) then
1566 if (dg(id).gt.dgmax) then
1570 if(dgr(id,iz).le.drmax) then
1571 dgr(id,iz)=dgr(id,iz)+(rainbl+(lfr(id,iz)*dt)/latent)
1573 if (dgr(id,iz).lt.0) then
1576 if (dgr(id,iz).gt.drmax) then
1585 call surf_temp(ndu,pr_u,dt, &
1587 tg,alag,csg,emg,albg,ptg,sfg,lfg,gfg)
1588 if(gr_flag.eq.1)then
1589 if(gr_frac_roof.gt.0.)then
1591 call roof_temp_veg(ndu,pr_u,dt, &
1593 trv,ptrv,sfrv,lfrv,gfr,qr,rainbl,drain,hfgr,tr,alar(5),dzr(5),csr(5),nzu,irri_now,gr_type,pv_frac_roof,tpvlev)
1600 do iz=1,nz_um !Compute the outdoor temperature
1601 tmp_u(iz)=pt_u(iz)*(pr_u(iz)/p0)**(rcp_u)
1608 sfrb=0. !Sensible heat flux from roof
1609 sfrbpv=0. !Sensible heat flux from PV panels
1610 sfrpv=0. !Sensible heat flux from PV panels
1614 gfrb=0. !Heat flux flowing inside the roof
1615 sfwb1D=0. !Sensible heat flux from walls
1616 sfwinb1D=0. !Sensible heat flux from windows
1617 gfwb1D=0. !Heat flux flowing inside the walls[W/m2]
1620 twb1D=0. !Wall temperature
1621 twlevb1D=0. !Window temperature
1622 tglevb1D=0. !Ground temperature below a building
1623 tflevb1D=0. !Floor temperature
1625 trb=0. !Roof temperature
1626 trb1D=0. !Roof temperature
1628 qlevb1D=0. !Indoor humidity
1629 tlevb1D=0. !indoor temperature
1631 sflev1D=0. !Sensible heat flux from the a.c.
1632 lflev1D=0. !Latent heat flux from the a.c.
1633 consumlev1D=0.!Consumption from the a.c.
1636 sfvlev1D=0. !Sensible heat flux from the natural ventilation
1637 lfvlev1D=0. !Latent heat flux from natural ventilation
1638 ptw=0. !Wall potential temperature
1639 ptwin=0. !Window potential temperature
1640 ptr=0. !Roof potential temperature
1643 if(ss(iz).gt.0) then
1648 tr_avb(id,ibui)=tr_av(id,iz)
1649 tpvlevb(id,ibui)=tpvlev(id,iz)
1650 hfgrb(id,ibui)=hfgr(id,iz)
1651 sfrb(id,ibui)=sfr(id,iz)
1652 sfrvb(id,ibui)=sfrv(id,iz)
1653 lfrvb(id,ibui)=lfrv(id,iz)
1654 lfrb(id,ibui)=lfr(id,iz)
1655 sfr_avb(id,ibui)=(1-gr_frac_roof)*sfr(id,iz)+gr_frac_roof*(sfrv(id,iz))
1657 trb(id,ily,ibui)=tr(id,iz,ily)
1660 trvb(id,ily,ibui)=trv(id,iz,ily)
1667 !--------------------------------------------------------------------------------
1668 !Loop over BEM -----------------------------------------------------------------
1669 !--------------------------------------------------------------------------------
1670 !--------------------------------------------------------------------------------
1674 qlevb1D(iz)=qlev(iz,ibui)
1675 tlevb1D(iz)=tlev(iz,ibui)
1681 trb1D(ily)=trb(id,ily,ibui)
1684 tglevb1D(ily)=tglev(id,ily,ibui)
1689 tflevb1D(ily,iz)=tflev(id,ily,iz,ibui)
1694 sfwinb1D(2*id-1,iz)=sfwin(2*id-1,iz,ibui)
1695 sfwinb1D(2*id,iz)=sfwin(2*id,iz,ibui)
1700 twb1D(2*id-1,ily,iz)=tw(2*id-1,iz,ily,ibui)
1701 twb1D(2*id,ily,iz)=tw(2*id,iz,ily,ibui)
1703 sfwb1D(2*id-1,iz)=sfw(2*id-1,iz,ibui)
1704 sfwb1D(2*id,iz)=sfw(2*id,iz,ibui)
1705 twlevb1D(2*id-1,iz)=twlev(2*id-1,iz,ibui)
1706 twlevb1D(2*id,iz)=twlev(2*id,iz,ibui)
1710 !print*,'HFGR_BEFORE_CALLING_BEM',hfgr(nlev(ibui))
1712 call BEM(nz_um,nlev(ibui),nhourday,dt,bs_u(1,iurb), &
1713 bs_u(2,iurb),dz_u,nwr_u,nf_u,nwr_u,ngb_u,sfwb1D,gfwb1D, &
1714 sfwinb1D,sfr_avb(1,ibui),lfrb(1,ibui),gfrb(1,ibui), &
1716 latent,sigma,albw,albwin,albr, &
1717 emr,emw,emwind,rsw,rlw,r,cp_u, &
1718 da_u,tmp_u,qv_u,pr_u,rs,swddif,rld,dzw,csw,alaw,pwin_u(iurb), &
1719 cop_u(iurb),beta_u(iurb),sw_cond_u(iurb),time_on_u(iurb), &
1720 time_off_u(iurb),targtemp_u(iurb),gaptemp_u(iurb), &
1721 targhum_u(iurb),gaphum_u(iurb),perflo_u(iurb), &
1722 gr_frac_roof,pv_frac_roof,gr_flag, &
1724 hsesf_u(iurb),hsequip, &
1725 dzf,csf,alaf,dzgb,csgb,alagb,dzr,csr, &
1726 alar,tlevb1D,qlevb1D,twb1D,twlevb1D,tflevb1D,tglevb1D, &
1727 trb1D,sflev1D,lflev1D,consumlev1D,eppvlev(ibui), &
1729 sfvlev1D,lfvlev1D,hfgrb(1,ibui),tr_avb(1,ibui), &
1730 tpv(ibui),sfpv(ibui),sfr_indoor(ibui))
1734 !Temporal modifications
1736 tpvlevb(2,ibui)=tpvlevb(1,ibui)
1737 sfrb(2,ibui)=sfrb(1,ibui)
1738 sfrvb(2,ibui)=sfrvb(1,ibui)
1739 lfrvb(2,ibui)=lfrvb(1,ibui)
1740 lfrb(2,ibui)=lfrb(1,ibui)
1741 sfrbpv(2,ibui)=sfrbpv(1,ibui)
1742 gfrb(2,ibui)=gfrb(1,ibui)
1743 hfgrb(2,ibui)=hfgrb(1,ibui)
1744 !End temporal modifications
1747 qlev(iz,ibui)=qlevb1D(iz)
1748 tlev(iz,ibui)=tlevb1D(iz)
1749 sflev(iz,ibui)=sflev1D(iz)
1750 lflev(iz,ibui)=lflev1D(iz)
1751 consumlev(iz,ibui)=consumlev1D(iz)
1752 sfvlev(iz,ibui)=sfvlev1D(iz)
1753 lfvlev(iz,ibui)=lfvlev1D(iz)
1758 trb(id,ily,ibui)=trb1D(ily)
1761 tglev(id,ily,ibui)=tglevb1D(ily)
1766 tflev(id,ily,iz,ibui)=tflevb1D(ily,iz)
1773 tw(2*id-1,iz,ily,ibui)=twb1D(2*id-1,ily,iz)
1774 tw(2*id,iz,ily,ibui)=twb1D(2*id,ily,iz)
1776 gfw(2*id-1,iz,ibui)=gfwb1D(2*id-1,iz)
1777 gfw(2*id,iz,ibui)=gfwb1D(2*id,iz)
1778 twlev(2*id-1,iz,ibui)=twlevb1D(2*id-1,iz)
1779 twlev(2*id,iz,ibui)=twlevb1D(2*id,iz)
1785 !-----------------------------------------------------------------------------
1786 !End loop over BEM -----------------------------------------------------------
1787 !-----------------------------------------------------------------------------
1788 !-----------------------------------------------------------------------------
1794 if(ss(iz).gt.0) then
1797 gfr(id,iz)=gfrb(id,ibui)
1798 tpvlev(id,iz)=tpvlevb(id,ibui)
1799 sfr(id,iz)=sfrb(id,ibui)
1800 hfgr(id,iz)=hfgrb(id,ibui)
1801 sfrpv(id,iz)=-sfrbpv(id,ibui)
1802 lfr(id,iz)=lfrb(id,ibui)
1804 tr(id,iz,ily)=trb(id,ily,ibui)
1806 ptr(id,iz)=tr(id,iz,nwr_u)*(pr_u(iz)/p0)**(-rcp_u)
1811 !Compute the potential temperature for the vertical surfaces of the buildings
1816 ptw(2*id-1,iz,ibui)=tw(2*id-1,iz,nwr_u,ibui)*(pr_u(iz)/p0)**(-rcp_u)
1817 ptw(2*id,iz,ibui)=tw(2*id,iz,nwr_u,ibui)*(pr_u(iz)/p0)**(-rcp_u)
1818 ptwin(2*id-1,iz,ibui)=twlev(2*id-1,iz,ibui)*(pr_u(iz)/p0)**(-rcp_u)
1819 ptwin(2*id,iz,ibui)=twlev(2*id,iz,ibui)*(pr_u(iz)/p0)**(-rcp_u)
1828 alp=alp+bs(id)/(ws(id)+bs(id))*pb(iz)
1832 cdrag(iz)=3.32*alp**0.47
1840 ! Compute the implicit and explicit components of the sources or sinks on the "urban grid"
1842 call buildings(iurb,ndu,nzu,z0,cdrag,ua_u,va_u, &
1843 pt_u,pt0_u,ptg,ptr,ptrv,da_u,qv_u,pr_u,tmp_u,ptw,ptwin,pwin_u(iurb),drst, &
1844 uva_u,vva_u,uvb_u,vvb_u,tva_u,tvb_u,evb_u,qvb_u,qhb_u, &
1845 uhb_u,vhb_u,thb_u,ehb_u,ss,dt,sfw,sfg,sfr,sfrpv,sfrv,lfrv, &
1847 sfwin,pb,bs_u,dz_u,sflev,lflev,sfvlev,lfvlev,tvb_ac,ix,iy,rsg,rs,qr,gr_frac_roof, &
1848 pv_frac_roof,gr_flag,gr_type)
1853 ! Calculation of the sensible heat fluxes for the ground, the wall and roof
1854 ! Sensible Heat Flux = density * Cp_U * ( A* potential temperature + B )
1855 ! where A and B are the implicit and explicit components of the heat sources or sinks.
1857 ! Interpolation on the "mesoscale grid"
1859 call urban_meso(ndu,kms,kme,kts,kte,nzu,z,dz,z_u,pb,ss,bs,ws,sf, &
1860 vl,uva_u,vva_u,uvb_u,vvb_u,tva_u,tvb_u,evb_u, &
1861 uhb_u,vhb_u,thb_u,ehb_u,qhb_u,qvb_u, &
1862 a_u,a_v,a_t,a_e,b_u,b_v,b_t,b_e,b_q,tvb_ac,b_ac)
1865 ! Calculation of the length scale taking into account the buildings effects
1867 call interp_length(ndu,kms,kme,kts,kte,nzu,z_u,z,ss,ws,bs,dlg,dl_u)
1870 end subroutine BEP1D
1872 ! ===6=8===============================================================72
1873 ! ===6=8===============================================================72
1875 subroutine param(iurb,nzu,nzurb,nzurban,ndu, &
1876 csg_u,csg,alag_u,alag,csr_u,csr, &
1877 alar_u,alar,csw_u,csw,alaw_u,alaw, &
1878 ws_u,ws_urb,ws,bs_u,bs_urb,bs,z0g_u,z0r_u,z0, &
1879 strd_u,strd,drst_u,drst,ss_u,ss_urb,ss,pb_u, &
1880 pb_urb,pb,dzw,dzr,dzf,csf,alaf,dzgb,csgb,alagb,&
1881 lp_urb,lb_urb,hgt_urb,frc_urb)
1883 ! ----------------------------------------------------------------------
1884 ! This routine prepare some usefull parameters
1885 ! ----------------------------------------------------------------------
1890 ! ----------------------------------------------------------------------
1892 ! ----------------------------------------------------------------------
1893 integer iurb ! Current urban class
1894 integer nzu ! Number of vertical urban levels in the current class
1895 integer ndu ! Number of street direction for the current urban class
1896 integer nzurb ! Number of vertical urban levels in the current class
1897 real alag_u(nurbm) ! Ground thermal diffusivity [m^2 s^-1]
1898 real alar_u(nurbm) ! Roof thermal diffusivity [m^2 s^-1]
1899 real alaw_u(nurbm) ! Wall thermal diffusivity [m^2 s^-1]
1900 real bs_u(ndm,nurbm) ! Building width
1901 real csg_u(nurbm) ! Specific heat of the ground material [J m^3 K^-1]
1902 real csr_u(nurbm) ! Specific heat of the roof material [J m^3 K^-1]
1903 real csw_u(nurbm) ! Specific heat of the wall material [J m^3 K^-1]
1904 real drst_u(ndm,nurbm) ! Street direction
1905 real strd_u(ndm,nurbm) ! Street length
1906 real ws_u(ndm,nurbm) ! Street width
1907 real z0g_u(nurbm) ! The ground's roughness length
1908 real z0r_u(nurbm) ! The roof's roughness length
1909 real ss_u(nz_um,nurbm) ! The probability that a building has an height equal to "z"
1910 real pb_u(nz_um,nurbm) ! The probability that a building has an height greater or equal to "z"
1911 real lp_urb ! Building plan area density
1912 real lb_urb ! Building surface area to plan area ratio
1913 real hgt_urb ! Average building height weighted by building plan area [m]
1914 real frc_urb ! Urban fraction
1916 ! ----------------------------------------------------------------------
1918 ! ----------------------------------------------------------------------
1919 real alag(ng_u) ! Ground thermal diffusivity at each ground levels
1920 real csg(ng_u) ! Specific heat of the ground material at each ground levels
1921 real bs(ndm) ! Building width for the current urban class
1922 real drst(ndm) ! street directions for the current urban class
1923 real strd(ndm) ! Street lengths for the current urban class
1924 real ws(ndm) ! Street widths of the current urban class
1925 real z0(ndm,nz_um) ! Roughness lengths "profiles"
1926 real ss(nz_um) ! Probability to have a building with height h
1927 real pb(nz_um) ! Probability to have a building with an height greater or equal to "z"
1930 !-----------------------------------------------------------------------------
1932 !-----------------------------------------------------------------------------
1934 real dzw(nwr_u) !Layer sizes in the walls [m]
1935 real dzr(nwr_u) !Layer sizes in the roofs [m]
1936 real dzf(nf_u) !Layer sizes in the floors [m]
1937 real dzgb(ngb_u) !layer sizes in the ground below the buildings [m]
1939 real csr(nwr_u) ! Specific heat of the roof material at each roof levels
1940 real csw(nwr_u) ! Specific heat of the wall material at each wall levels
1942 real csf(nf_u) !Specific heat of the floors materials in the buildings
1943 !of the current urban class [J m^3 K^-1]
1944 real csgb(ngb_u) !Specific heat of the ground material below the buildings
1945 !of the current urban class [J m^3 K^-1]
1946 real alar(nwr_u+1) ! Roof thermal diffusivity at each roof levels [W/ m K]
1947 real alaw(nwr_u+1) ! Wall thermal diffusivity at each wall levels [W/ m K]
1948 real alaf(nf_u+1) ! Floor thermal diffusivity at each wall levels [W/m K]
1949 real alagb(ngb_u+1) ! Ground thermal diffusivity below the building at each wall levels [W/m K]
1950 real bs_urb(ndm,nurbm) ! Building width
1951 real ws_urb(ndm,nurbm) ! Street width
1952 real ss_urb(nz_um,nurbm) ! The probability that a building has an height equal to "z"
1953 real pb_urb(nz_um) ! Probability that a building has an height greater or equal to z
1954 ! ----------------------------------------------------------------------
1956 ! ----------------------------------------------------------------------
1957 integer id,ig,ir,iw,iz,iflo,ihu
1958 ! ----------------------------------------------------------------------
1959 ! END VARIABLES DEFINITIONS
1960 ! ----------------------------------------------------------------------
1962 !Initialize variables
1985 !Define the layer sizes in the walls
1987 dzgb=(/0.2,0.12,0.08,0.05,0.03,0.02,0.02,0.01,0.005,0.0025/)
1988 dzr=(/0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.01,0.005,0.0025/)
1989 dzw=(/0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.01,0.005,0.0025/)
1990 dzf=(/0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02/)
1995 if (ss_urb(iz,iurb)/=0.) then
2005 ss(iz)=ss_urb(iz,iurb)
2011 ss(iz)=ss_u(iz,iurb)
2012 pb(iz)=pb_u(iz,iurb)
2013 ss_urb(iz,iurb)=ss_u(iz,iurb)
2014 pb_urb(iz)=pb_u(iz,iurb)
2020 csgb(ig) = csg_u(iurb)
2021 alagb(ig)= csg_u(iurb)*alag_u(iurb)
2023 alagb(ngb_u+1)= csg_u(iurb)*alag_u(iurb)
2026 csf(iflo) = csw_u(iurb)
2027 alaf(iflo)= csw_u(iurb)*alaw_u(iurb)
2029 alaf(nf_u+1)= csw_u(iurb)*alaw_u(iurb)
2032 csr(ir) = csr_u(iurb)
2033 alar(ir)= csr_u(iurb)*alar_u(iurb)
2035 alar(nwr_u+1)= csr_u(iurb)*alar_u(iurb)
2038 csw(iw) = csw_u(iurb)
2039 alaw(iw)= csw_u(iurb)*alaw_u(iurb)
2041 alaw(nwr_u+1)=csw_u(iurb)*alaw_u(iurb)
2043 !------------------------------------------------------------------------
2047 alag(ig)=alag_u(iurb)
2051 z0(id,1)=z0g_u(iurb)
2053 z0(id,iz)=z0r_u(iurb)
2058 strd(id)=strd_u(id,iurb)
2059 drst(id)=drst_u(id,iurb)
2063 if ((hgt_urb<=0.).OR.(lp_urb<=0.).OR.(lb_urb<=0.)) then
2064 ws(id)=ws_u(id,iurb)
2065 bs(id)=bs_u(id,iurb)
2066 bs_urb(id,iurb)=bs_u(id,iurb)
2067 ws_urb(id,iurb)=ws_u(id,iurb)
2068 else if ((lp_urb/frc_urb<1.).and.(lp_urb<lb_urb)) then
2069 bs(id)=2.*hgt_urb*lp_urb/(lb_urb-lp_urb)
2070 ws(id)=2.*hgt_urb*lp_urb*((frc_urb/lp_urb)-1.)/(lb_urb-lp_urb)
2071 bs_urb(id,iurb)=bs(id)
2072 ws_urb(id,iurb)=ws(id)
2074 ws(id)=ws_u(id,iurb)
2075 bs(id)=bs_u(id,iurb)
2076 bs_urb(id,iurb)=bs_u(id,iurb)
2077 ws_urb(id,iurb)=ws_u(id,iurb)
2081 if ((bs(id)<=1.).OR.(bs(id)>=150.)) then
2082 bs(id)=bs_u(id,iurb)
2083 ws(id)=ws_u(id,iurb)
2084 bs_urb(id,iurb)=bs_u(id,iurb)
2085 ws_urb(id,iurb)=ws_u(id,iurb)
2087 if ((ws(id)<=1.).OR.(ws(id)>=150.)) then
2088 ws(id)=ws_u(id,iurb)
2089 bs(id)=bs_u(id,iurb)
2090 bs_urb(id,iurb)=bs_u(id,iurb)
2091 ws_urb(id,iurb)=ws_u(id,iurb)
2095 end subroutine param
2097 ! ===6=8===============================================================72
2098 ! ===6=8===============================================================72
2100 subroutine interpol(kms,kme,kts,kte,nz_u,z,z_u,c,c_u)
2102 ! ----------------------------------------------------------------------
2103 ! This routine interpolate para
2104 ! meters from the "mesoscale grid" to
2106 ! See p300 Appendix B.1 of the BLM paper.
2107 ! ----------------------------------------------------------------------
2111 ! ----------------------------------------------------------------------
2113 ! ----------------------------------------------------------------------
2114 ! Data relative to the "mesoscale grid"
2115 integer kts,kte,kms,kme
2116 real z(kms:kme) ! Altitude of the cell interface
2117 real c(kms:kme) ! Parameter which has to be interpolated
2118 ! Data relative to the "urban grid"
2119 integer nz_u ! Number of levels
2120 !! real z_u(nz_u+1) ! Altitude of the cell interface
2121 real z_u(nz_um) ! Altitude of the cell interface
2123 ! ----------------------------------------------------------------------
2125 ! ----------------------------------------------------------------------
2126 !! real c_u(nz_u) ! Interpolated paramters in the "urban grid"
2127 real c_u(nz_um) ! Interpolated paramters in the "urban grid"
2130 ! ----------------------------------------------------------------------
2134 ! ----------------------------------------------------------------------
2135 ! END VARIABLES DEFINITIONS
2136 ! ----------------------------------------------------------------------
2141 dz=max(min(z(iz+1),z_u(iz_u+1))-max(z(iz),z_u(iz_u)),0.)
2144 c_u(iz_u)=ctot/(z_u(iz_u+1)-z_u(iz_u))
2148 end subroutine interpol
2150 ! ===6=8===============================================================72
2151 ! ===6=8===============================================================72
2153 subroutine averaging_temp(tw,twlev,ss,pb,tw_av,twlev_av, &
2154 sfw_av,sfwind_av,sfw,sfwin)
2160 real tw(2*ndm,nz_um,nwr_u,nbui_max) ! Temperature in each layer of the wall [K]
2161 real twlev(2*ndm,nz_um,nbui_max) ! Window temperature in BEM [K]
2162 real pb(nz_um) ! Probability to have a building with an height equal or greater h
2163 real ss(nz_um) ! Probability to have a building with height h
2164 real sfw(2*ndm,nz_um,nbui_max) ! Surface fluxes from the walls
2165 real sfwin(2*ndm,nz_um,nbui_max) ! Surface fluxes from the windows
2169 real tw_av(2*ndm,nz_um) ! Averaged temperature of the wall surfaces
2170 real twlev_av(2*ndm,nz_um) ! Averaged temperature of the windows
2171 real sfw_av(2*ndm,nz_um) ! Averaged sensible heat from walls
2172 real sfwind_av(2*ndm,nz_um) ! Averaged sensible heat from windows
2181 !Initialize Variables
2193 if(ss(iz).gt.0) then
2203 if (pb(iz+1).gt.0) then
2205 if (iz.le.nlev(ibui)) then
2206 tw_av(2*id-1,iz)=tw_av(2*id-1,iz)+(d_urb(ibui)/pb(iz+1))*&
2207 tw(2*id-1,iz,nwr_u,ibui)**4
2208 tw_av(2*id,iz)=tw_av(2*id,iz)+(d_urb(ibui)/pb(iz+1))*&
2209 tw(2*id,iz,nwr_u,ibui)**4
2210 twlev_av(2*id-1,iz)=twlev_av(2*id-1,iz)+(d_urb(ibui)/pb(iz+1))*&
2211 twlev(2*id-1,iz,ibui)**4
2212 twlev_av(2*id,iz)=twlev_av(2*id,iz)+(d_urb(ibui)/pb(iz+1))*&
2213 twlev(2*id,iz,ibui)**4
2214 sfw_av(2*id-1,iz)=sfw_av(2*id-1,iz)+(d_urb(ibui)/pb(iz+1))*sfw(2*id-1,iz,ibui)
2215 sfw_av(2*id,iz)=sfw_av(2*id,iz)+(d_urb(ibui)/pb(iz+1))*sfw(2*id,iz,ibui)
2216 sfwind_av(2*id-1,iz)=sfwind_av(2*id-1,iz)+(d_urb(ibui)/pb(iz+1))*sfwin(2*id-1,iz,ibui)
2217 sfwind_av(2*id,iz)=sfwind_av(2*id,iz)+(d_urb(ibui)/pb(iz+1))*sfwin(2*id,iz,ibui)
2220 tw_av(2*id-1,iz)=tw_av(2*id-1,iz)**(1./4.)
2221 tw_av(2*id,iz)=tw_av(2*id,iz)**(1./4.)
2222 twlev_av(2*id-1,iz)=twlev_av(2*id-1,iz)**(1./4.)
2223 twlev_av(2*id,iz)=twlev_av(2*id,iz)**(1./4.)
2228 end subroutine averaging_temp
2229 ! ===6=8===============================================================72
2230 ! ===6=8===============================================================72
2232 subroutine modif_rad(iurb,nd,nz_u,z,ws,drst,strd,ss,pb, &
2233 tw,tg_av,twlev,albg,albw,emw,emg,pwin,albwin, &
2234 emwin,fww,fwg,fgw,fsw,fsg, &
2235 zr,deltar,ah,xlat,swddir,swddif, &
2236 rs,rl,rsw,rsd,rsg,rlw,rlg)
2238 ! ----------------------------------------------------------------------
2239 ! This routine computes the modification of the short wave and
2240 ! long wave radiation due to the buildings.
2241 ! ----------------------------------------------------------------------
2246 ! ----------------------------------------------------------------------
2248 ! ----------------------------------------------------------------------
2249 integer iurb ! current urban class
2250 integer nd ! Number of street direction for the current urban class
2251 integer nz_u ! Number of layer in the urban grid
2252 real z(nz_um) ! Height of the urban grid levels
2253 real ws(ndm) ! Street widths of the current urban class
2254 real drst(ndm) ! street directions for the current urban class
2255 real strd(ndm) ! Street lengths for the current urban class
2256 real ss(nz_um) ! probability to have a building with height h
2257 real pb(nz_um) ! probability to have a building with an height equal
2258 real tw(2*ndm,nz_um) ! Temperature in each layer of the wall [K]
2259 real tg_av(ndm) ! Temperature in each layer of the ground [K]
2260 real albg ! Albedo of the ground for the current urban class
2261 real albw ! Albedo of the wall for the current urban class
2262 real emg ! Emissivity of ground for the current urban class
2263 real emw ! Emissivity of wall for the current urban class
2264 real fgw(nz_um,ndm,nurbm) ! View factors from ground to wall
2265 real fsg(ndm,nurbm) ! View factors from sky to ground
2266 real fsw(nz_um,ndm,nurbm) ! View factors from sky to wall
2267 real fws(nz_um,ndm,nurbm) ! View factors from wall to sky
2268 real fwg(nz_um,ndm,nurbm) ! View factors from wall to ground
2269 real fww(nz_um,nz_um,ndm,nurbm) ! View factors from wall to wall
2270 real ah ! Hour angle (it should come from the radiation routine)
2271 real zr ! zenith angle
2272 real deltar ! Declination of the sun
2273 real rs ! solar radiation
2274 real rl ! downward flux of the longwave radiation
2275 real xlat ! latitudine
2276 real swddir ! short wave direct solar radiation _gl
2277 real swddif ! short wave diffuse solar radiation _gl
2282 real twlev(2*ndm,nz_um) ! Window temperature in BEM [K]
2283 real pwin ! Coverage area fraction of windows in the walls of the buildings
2284 real albwin ! Albedo of the windows for the current urban class
2285 real emwin ! Emissivity of the windows for the current urban class
2286 real alb_av ! Averaged albedo (window and wall)
2287 ! ----------------------------------------------------------------------
2289 ! ----------------------------------------------------------------------
2290 real rlg(ndm) ! Long wave radiation at the ground
2291 real rlw(2*ndm,nz_um) ! Long wave radiation at the walls
2292 real rsg(ndm) ! Short wave radiation at the ground
2293 real rsw(2*ndm,nz_um) ! Short wave radiation at the walls
2294 real rsd(2*ndm,nz_um) ! Direct Short wave radiation at the walls
2296 ! ----------------------------------------------------------------------
2298 ! ----------------------------------------------------------------------
2302 ! Calculation of the shadow effects
2304 call shadow_mas(nd,nz_u,zr,deltar,ah,drst,ws,ss,pb,z, &
2305 swddir,rsw,rsg,xlat)
2308 ! Calculation of the reflection effects
2310 call long_rad(iurb,nz_u,id,emw,emg,emwin,pwin,twlev, &
2311 fwg,fww,fgw,fsw,fsg,tg_av,tw,rlg,rlw,rl,pb)
2313 alb_av=pwin*albwin+(1.-pwin)*albw
2315 call short_rad_dd(iurb,nz_u,id,alb_av, &
2316 albg,swddif,fwg,fww,fgw,fsw,fsg,rsg,rsw,pb)
2321 end subroutine modif_rad
2325 ! ===6=8===============================================================72
2326 ! ===6=8===============================================================72
2328 subroutine surf_temp(nd,pr,dt,rl,rsg,rlg, &
2329 tg,alag,csg,emg,albg,ptg,sfg,lfg,gfg)
2331 ! ----------------------------------------------------------------------
2332 ! Computation of the surface temperatures for walls, ground and roofs
2333 ! ----------------------------------------------------------------------
2337 ! ----------------------------------------------------------------------
2339 ! ----------------------------------------------------------------------
2341 integer nd ! Number of street direction for the current urban class
2342 real alag(ng_u) ! Ground thermal diffusivity for the current urban class [m^2 s^-1]
2344 real albg ! Albedo of the ground for the current urban class
2346 real csg(ng_u) ! Specific heat of the ground material of the current urban class [J m^3 K^-1]
2349 real emg ! Emissivity of ground for the current urban class
2351 real pr(nz_um) ! Air pressure
2353 real rl ! Downward flux of the longwave radiation
2354 real rlg(ndm) ! Long wave radiation at the ground
2356 real rsg(ndm) ! Short wave radiation at the ground
2358 real sfg(ndm) ! Sensible heat flux from ground (road)
2360 real lfg(ndm) ! Latent heat flux from ground (road)
2362 real gfg(ndm) ! Heat flux transferred from the surface of the ground (road) toward the interior
2364 real tg(ndm,ng_u) ! Temperature in each layer of the ground [K]
2366 ! ----------------------------------------------------------------------
2368 ! ----------------------------------------------------------------------
2369 real ptg(ndm) ! Ground potential temperatures
2371 ! ----------------------------------------------------------------------
2373 ! ----------------------------------------------------------------------
2374 integer id,ig,ir,iw,iz
2376 real rtg(ndm) ! Total radiation at ground(road) surface (solar+incoming long+outgoing long)
2380 real dzg_u(ng_u) ! Layer sizes in the ground
2382 data dzg_u /0.2,0.12,0.08,0.05,0.03,0.02,0.02,0.01,0.005,0.0025/
2385 ! ----------------------------------------------------------------------
2386 ! END VARIABLES DEFINITIONS
2387 ! ----------------------------------------------------------------------
2393 ! Calculation for the ground surfaces
2395 tg_tmp(ig)=tg(id,ig)
2398 ! print*,'alag','cs',alag(1),csg(1)
2400 call soil_temp(ng_u,dzg_u,tg_tmp,ptg(id),alag,csg, &
2401 rsg(id),rlg(id),pr(1), &
2403 rtg(id),sfg(id),lfg(id),gfg(id))
2406 tg(id,ig)=tg_tmp(ig)
2412 end subroutine surf_temp
2415 ! ===6=8===============================================================72
2416 ! ===6=8===============================================================72
2419 subroutine roof_temp_veg(nd,pr,dt,rl,rsr, &
2420 trv,ptrv,sfrv,lfrv,gfr,qr,rainbl,drain,hfgroof,tr,alar,dzr,csr,nzu,irri_now,gr_type,pv_frac_roof,tpvlev)
2422 ! ----------------------------------------------------------------------
2423 ! Computation of the surface temperatures for walls, ground and roofs
2424 ! ----------------------------------------------------------------------
2428 ! ----------------------------------------------------------------------
2430 ! ----------------------------------------------------------------------
2432 integer nd ! Number of street direction for the current urban class
2434 integer nzu ! Number of urban layers
2435 real irho(24) ! Which hour of irrigation\
2438 real alar ! Roof thermal diffusivity for the current urban class [m^2 s^-1]
2442 real dzr ! Layer sizes in the roofs [m]
2446 real pr(nz_um) ! Air pressure
2448 real rl ! Downward flux of the longwave radiation
2450 real rsr ! Short wave radiation at the ground
2452 real tpvlev(ndm,nz_um)
2454 real sfrv(ndm,nz_um) ! Sensible heat flux from ground (road)
2456 real lfrv(ndm,nz_um) ! Latent heat flux from ground (road)
2458 real gfr(ndm,nz_um) ! Heat flux transferred from the surface of the ground (road) toward the interior
2460 real trv(ndm,nz_um,ngr_u) ! Temperature in each layer of the green roof [K]
2462 real qr(ndm,nz_um,ngr_u) ! Humidity in each layer of the green roof
2464 real tr(ndm,nz_um,nwr_u) !Roof temperature in BEM [K]
2466 ! ----------------------------------------------------------------------
2468 ! ----------------------------------------------------------------------
2469 real ptrv(ndm,nz_um) ! Ground potential temperatures
2471 real hfgroof(ndm,nz_um)
2472 ! ----------------------------------------------------------------------
2474 ! ----------------------------------------------------------------------
2475 integer id,ig,ir,iw,iz
2477 real alagr(ngr_u) ! Green Roof thermal diffusivity for the current urban class [m^2 s^-1]
2479 real rtr(ndm,nz_um) ! Total radiation at ground(road) surface (solar+incoming long+outgoing long)
2484 real qr_tmp_old(ngr_u)
2485 real dzgr_u(ngr_u) ! Layer sizes in the green roof
2487 data dzgr_u /0.1,0.003,0.06,0.003,0.05,0.04,0.02,0.0125,0.005,0.0025/
2488 real cs(ngr_u) ! Specific heat of the ground material
2490 parameter(cw=4.295e6)
2494 real qr_m ! mean soil moisture between layers
2503 parameter(qref=0.37)
2504 data qrmax /0.0,0.0,0.0,0.0,0.439,0.37,0.37,0.37,0.37,0.37/
2505 data smax /0,0,0,0,-0.01,-0.1,-0.1,-0.1,-0.1,-0.1/
2506 data kmax /0,0,0,0,3.32e-3,2.162e-3,2.162e-3,2.162e-3,2.162e-3,2.162e-3/
2507 data b /0,0,0,0,2.7,3.9,3.9,3.9,3.9,3.9/
2508 data cd /0,0,0,0,331500,1.342e6,1.342e6,1.342e6,1.342e6,1.342e6/
2509 data csa /7.5e4,2.1e6,4.48e4,2.1e6/
2510 data ka /0.035,0.7,0.024,0.7/
2515 real drain(ndm,nz_um)
2516 ! ----------------------------------------------------------------------
2517 ! END VARIABLES DEFINITIONS
2519 if(gr_type.eq.1)then
2522 elseif(gr_type.eq.2)then
2535 ! Calculation for the ground surfaces
2538 tr_tmp(ig)=trv(id,iz,ig)
2539 qr(id,iz,ig) = max(qr(id,iz,ig),1e-6) !cenlin, 11/4/2020
2540 qr_tmp(ig)=qr(id,iz,ig)
2541 qr_tmp_old(ig)=qr(id,iz,ig)
2546 alagr(ig)=ka(ig)/csa(ig)
2552 qr_m=(qr(id,iz,ig)*dzgr_u(ig-1)+qr(id,iz,ig-1)*dzgr_u(ig))/(dzgr_u(ig)+dzgr_u(ig-1))
2556 cs(ig)=(1-qr_m)*cd(ig)+qr_m*cw
2557 s(ig)=smax(ig)*(qrmax(ig)/qr_m)**b(ig)
2558 k(ig)=kmax(ig)*(qr_m/qrmax(ig))**(2*b(ig)+3)
2559 d(ig)=-b(ig)*kmax(ig)*smax(ig)*((qr_m/qrmax(ig))**(b(ig)+3))/qr_m
2560 if (log10(abs(s(ig))).le.5.1) then
2561 alagr(ig)=exp(-(log10(abs(s(ig)))+2.7))*4.186e2/cs(ig)
2563 if (log10(abs(s(ig))).gt.5.1) then
2564 alagr(ig)=0.00041*4.186e2/cs(ig)
2570 hfgroof(id,iz)=(alar/csr+alagr(1))*(tr_tmp(1)-tr(id,iz,5))/(dzr+dzgr_u(1))
2572 call soil_temp_veg(hfgroof(id,iz),ngr_u,dzgr_u,tr_tmp,ptrv(id,iz),alagr,cs, &
2574 dt,em_gr(1),alb_gr(1), &
2575 rtr(id,iz),sfrv(id,iz),lfrv(id,iz),gfr(id,iz),pv_frac_roof,tpvlev(id,iz))
2577 trv(id,iz,ig)=tr_tmp(ig)
2579 drain(id,iz)=kmax(5)*(qr(id,iz,5)/qrmax(5))**(2*b(5)+3)
2580 call soil_moist(ngr_u,dzgr_u,qr_tmp,dt,lfrv(id,iz),d,k,rainbl,drain(id,iz),irri_now)
2584 ! qr(id,iz,ig)=min(qr_tmp(ig),qrmax(ig))
2585 qr(id,iz,ig)=max(min(qr_tmp(ig),qrmax(ig)),1e-6) !cenlin,11/4/2020
2592 end subroutine roof_temp_veg
2594 ! ===6=8===============================================================72
2595 ! ===6=8===============================================================72
2597 subroutine buildings(iurb,nd,nz,z0,cdrag,ua_u,va_u,pt_u,pt0_u, &
2598 ptg,ptr,ptrv,da_u,qv_u,pr_u,tmp_u,ptw,ptwin,pwin, &
2599 drst,uva_u,vva_u,uvb_u,vvb_u, &
2600 tva_u,tvb_u,evb_u,qvb_u,qhb_u, &
2601 uhb_u,vhb_u,thb_u,ehb_u,ss,dt,sfw,sfg,sfr,sfrpv,sfrv,lfrv, &
2603 sfwin,pb,bs_u,dz_u,sflev,lflev,sfvlev,lfvlev,tvb_ac,ix,iy,rsg,rs,qr,gr_frac_roof, &
2604 pv_frac_roof,gr_flag,gr_type)
2606 ! ----------------------------------------------------------------------
2607 ! This routine computes the sources or sinks of the different quantities
2608 ! on the urban grid. The actual calculation is done in the subroutines
2609 ! called flux_wall, and flux_flat.
2610 ! ----------------------------------------------------------------------
2615 ! ----------------------------------------------------------------------
2617 ! ----------------------------------------------------------------------
2618 integer nd ! Number of street direction for the current urban class
2620 integer nz ! number of vertical space steps
2621 real ua_u(nz_um) ! Wind speed in the x direction on the urban grid
2622 real va_u(nz_um) ! Wind speed in the y direction on the urban grid
2623 real da_u(nz_um) ! air density on the urban grid
2624 real qv_u(nz_um) ! specific humidity on the urban grid
2625 real pr_u(nz_um) ! pressure on the urban grid
2626 real tmp_u(nz_um) ! temperaure on the urban grid
2627 real drst(ndm) ! Street directions for the current urban class
2629 real pt_u(nz_um) ! Potential temperature on the urban grid
2630 real pt0_u(nz_um) ! reference potential temperature on the urban grid
2631 real ptg(ndm) ! Ground potential temperatures
2632 real ptr(ndm,nz_um) ! Roof potential temperatures
2633 real ptrv(ndm,nz_um) ! Green Roof potential temperatures
2634 real ptw(2*ndm,nz_um,nbui_max) ! Walls potential temperatures
2635 real ss(nz_um) ! probability to have a building with height h
2638 real z0(ndm,nz_um) ! Roughness lengths "profiles"
2640 integer iurb !Urban class
2641 real rsg(ndm) ! Solar Radiation
2642 real rs ! Solar Radiation
2643 real qr(ndm,nz_um,ngr_u) ! Ground Soil Moisture
2644 real trv(ndm,nz_um,ngr_u) ! Ground Soil Moisture
2648 !New variables (BEM)
2650 real bs_u(ndm,nurbm) ! Building width [m]
2651 real dz_u ! Urban grid resolution
2652 real sflev(nz_um,nz_um) ! sensible heat flux due to the air conditioning systems [W]
2653 real lflev(nz_um,nz_um) ! latent heat flux due to the air conditioning systems [W]
2654 real sfvlev(nz_um,nz_um) ! sensible heat flux due to ventilation [W]
2655 real lfvlev(nz_um,nz_um) ! latent heat flux due to ventilation [W]
2656 real qvb_u(2*ndm,nz_um)
2657 real qhb_u(ndm,nz_um)
2658 real ptwin(2*ndm,nz_um,nbui_max) ! window potential temperature
2660 real tvb_ac(2*ndm,nz_um)
2663 integer gr_flag,gr_type
2665 ! ----------------------------------------------------------------------
2667 ! ----------------------------------------------------------------------
2668 ! Explicit and implicit component of the momentum, temperature and TKE sources or sinks on
2669 ! vertical surfaces (walls) and horizontal surfaces (roofs and street)
2670 ! The fluxes can be computed as follow: Fluxes of X = A*X + B
2671 ! Example: Momentum fluxes on vertical surfaces = uva_u * ua_u + uvb_u
2673 real uhb_u(ndm,nz_um) ! U (wind component) Horizontal surfaces, B (explicit) term
2674 real uva_u(2*ndm,nz_um) ! U (wind component) Vertical surfaces, A (implicit) term
2675 real uvb_u(2*ndm,nz_um) ! U (wind component) Vertical surfaces, B (explicit) term
2676 real vhb_u(ndm,nz_um) ! V (wind component) Horizontal surfaces, B (explicit) term
2677 real vva_u(2*ndm,nz_um) ! V (wind component) Vertical surfaces, A (implicit) term
2678 real vvb_u(2*ndm,nz_um) ! V (wind component) Vertical surfaces, B (explicit) term
2679 real thb_u(ndm,nz_um) ! Temperature Horizontal surfaces, B (explicit) term
2680 real tva_u(2*ndm,nz_um) ! Temperature Vertical surfaces, A (implicit) term
2681 real tvb_u(2*ndm,nz_um) ! Temperature Vertical surfaces, B (explicit) term
2682 real ehb_u(ndm,nz_um) ! Energy (TKE) Horizontal surfaces, B (explicit) term
2683 real evb_u(2*ndm,nz_um) ! Energy (TKE) Vertical surfaces, B (explicit) term
2684 real uhb(2*ndm,nz_um)
2685 real vhb(2*ndm,nz_um)
2686 real ehb(2*ndm,nz_um)
2687 real sfw(2*ndm,nz_um,nbui_max) ! sensible heat flux from walls
2688 real sfwin(2*ndm,nz_um,nbui_max) ! sensible heat flux form windows
2689 real sfr(ndm,nz_um) ! sensible heat flux from roof
2690 real sfrv(ndm,nz_um) ! sensible heat flux from roof
2691 real lfrv(ndm,nz_um) ! Latent heat flux from roof
2692 real dgr(ndm,nz_um) ! sensible heat flux from roof
2694 real lfr(ndm,nz_um) ! Latent heat flux from roof
2695 real lfg(ndm) ! Latent heat flux from street
2696 real sfrpv(ndm,nz_um) ! sensible heat flux from PV panels
2697 real sfg(ndm) ! sensible heat flux from street
2700 ! ----------------------------------------------------------------------
2702 ! ----------------------------------------------------------------------
2710 integer id,iz,ibui,nbui,il
2711 real wfg !Ground water pool fraction
2712 real wfr !Roof water pool fraction
2713 real uhbv(2*ndm,nz_um)
2714 real vhbv(2*ndm,nz_um)
2715 real ehbv(2*ndm,nz_um)
2716 real z0v !Vegetation roughness
2725 !------------------------------------------------------------------
2726 ! END VARIABLES DEFINITIONS
2727 ! ----------------------------------------------------------------------
2765 ! Calculation at the ground surfaces
2768 call flux_flat(dz,z0(id,1),ua_u(1),va_u(1),pt_u(1),pt0_u(1), &
2769 ptg(id),qv_u(1),uhb(id,1), &
2770 vhb(id,1),sfg(id),lfg(id),ehb(id,1),da_u(1),pr_u(1))
2773 lfg(id)=-da_u(1)*latent*(-(wfg*lfg(id))/(da_u(1)*latent))
2778 thb_u(id,1)=-(sfg(id))/(da_u(1)*cp_u)
2779 vhb_u(id,1)=vhb(id,1)
2780 uhb_u(id,1)=uhb(id,1)
2781 ehb_u(id,1)=ehb(id,1)
2782 qhb_u(id,1)=-lfg(id)/(da_u(1)*latent)
2786 call flux_flat(dz,z0(id,iz),ua_u(iz),&
2787 va_u(iz),pt_u(iz),pt0_u(iz), &
2788 ptr(id,iz),qv_u(iz),uhb(id,iz), &
2789 vhb(id,iz),sfr(id,iz),lfr(id,iz),ehb(id,iz),da_u(iz),pr_u(iz))
2790 if(dgr(id,iz).gt.0)then
2791 wfr=dgr(id,iz)/drmax
2792 lfr(id,iz)=-da_u(iz)*latent*(-(wfr*lfr(id,iz))/(da_u(iz)*latent))
2796 if(gr_flag.eq.1.and.gr_frac_roof.gt.0.)then
2798 qr_tmp(il)=qr(id,iz,il)
2800 call flux_flat_roof(dz,z0v,ua_u(iz),va_u(iz),pt_u(iz),pt0_u(iz), &
2801 ptrv(id,iz),uhbv(id,iz), &
2802 vhbv(id,iz),sfrv(id,iz),lfrv(id,iz),ehbv(id,iz),da_u(iz),qv_u(iz),pr_u(iz),rs,qr_tmp,resg,rsveg,f1,f2,f3,f4,gr_type,pv_frac_roof)
2803 sfr(id,iz)=sfr(id,iz)+pv_frac_roof*sfrpv(id,iz)
2804 thb_u(id,iz)=-((1.-gr_frac_roof)*sfr(id,iz)+gr_frac_roof*sfrv(id,iz))/(da_u(iz)*cp_u)
2805 vhb_u(id,iz)=(1.-gr_frac_roof)*vhb(id,iz)+gr_frac_roof*vhbv(id,iz)
2806 uhb_u(id,iz)=(1.-gr_frac_roof)*uhb(id,iz)+gr_frac_roof*uhbv(id,iz)
2807 ehb_u(id,iz)=(1.-gr_frac_roof)*ehb(id,iz)+gr_frac_roof*ehbv(id,iz)
2808 qhb_u(id,iz)=-(gr_frac_roof*lfrv(id,iz)+(1.-gr_frac_roof)*lfr(id,iz))/(da_u(iz)*latent)
2809 sfr(id,iz)=sfr(id,iz)-pv_frac_roof*sfrpv(id,iz)
2811 sfr(id,iz)=sfr(id,iz)+pv_frac_roof*sfrpv(id,iz)
2812 thb_u(id,iz)=-sfr(id,iz)/(da_u(iz)*cp_u)
2813 vhb_u(id,iz)=vhb(id,iz)
2814 uhb_u(id,iz)=uhb(id,iz)
2815 ehb_u(id,iz)=ehb(id,iz)
2816 qhb_u(id,iz)=-lfr(id,iz)/(da_u(iz)*latent)
2817 sfr(id,iz)=sfr(id,iz)-pv_frac_roof*sfrpv(id,iz)
2830 ! Calculation at the wall surfaces
2835 call flux_wall(ua_u(iz),va_u(iz),pt_u(iz),da_u(iz), &
2836 ptw(2*id-1,iz,ibui),ptwin(2*id-1,iz,ibui), &
2839 sfw(2*id-1,iz,ibui),sfwin(2*id-1,iz,ibui), &
2840 evb_tmp,drst(id),dt,cdrag(iz))
2842 if (pb(iz+1).gt.0.) then
2844 uva_u(2*id-1,iz)=uva_u(2*id-1,iz)+d_urb(ibui)/pb(iz+1)*uva_tmp
2845 vva_u(2*id-1,iz)=vva_u(2*id-1,iz)+d_urb(ibui)/pb(iz+1)*vva_tmp
2846 uvb_u(2*id-1,iz)=uvb_u(2*id-1,iz)+d_urb(ibui)/pb(iz+1)*uvb_tmp
2847 vvb_u(2*id-1,iz)=vvb_u(2*id-1,iz)+d_urb(ibui)/pb(iz+1)*vvb_tmp
2848 evb_u(2*id-1,iz)=evb_u(2*id-1,iz)+d_urb(ibui)/pb(iz+1)*evb_tmp
2849 tvb_u(2*id-1,iz)=tvb_u(2*id-1,iz)-(d_urb(ibui)/pb(iz+1))* &
2850 (sfw(2*id-1,iz,ibui)*(1.-pwin)+sfwin(2*id-1,iz,ibui)*pwin)/ &
2851 da_u(iz)/cp_u-(1./4.)*(d_urb(ibui)/pb(iz+1))*(sfvlev(iz,ibui)-sflev(iz,ibui))/&
2852 (dz*bs_u(id,iurb))/da_u(iz)/cp_u
2853 tvb_ac(2*id-1,iz)=tvb_ac(2*id-1,iz)-(1./4.)*(d_urb(ibui)/pb(iz+1))*(-sflev(iz,ibui))/&
2854 (dz*bs_u(id,iurb))/da_u(iz)/cp_u
2855 qvb_u(2*id-1,iz)=qvb_u(2*id-1,iz)-(1./4.)*(d_urb(ibui)/pb(iz+1))*(lfvlev(iz,ibui)-lflev(iz,ibui))/&
2856 (dz*bs_u(id,iurb))/da_u(iz)/latent
2860 call flux_wall(ua_u(iz),va_u(iz),pt_u(iz),da_u(iz), &
2861 ptw(2*id,iz,ibui),ptwin(2*id,iz,ibui), &
2864 sfw(2*id,iz,ibui),sfwin(2*id,iz,ibui), &
2865 evb_tmp,drst(id),dt,cdrag(iz))
2867 if (pb(iz+1).gt.0.) then
2869 uva_u(2*id,iz)=uva_u(2*id,iz)+d_urb(ibui)/pb(iz+1)*uva_tmp
2870 vva_u(2*id,iz)=vva_u(2*id,iz)+d_urb(ibui)/pb(iz+1)*vva_tmp
2871 uvb_u(2*id,iz)=uvb_u(2*id,iz)+d_urb(ibui)/pb(iz+1)*uvb_tmp
2872 vvb_u(2*id,iz)=vvb_u(2*id,iz)+d_urb(ibui)/pb(iz+1)*vvb_tmp
2873 evb_u(2*id,iz)=evb_u(2*id,iz)+d_urb(ibui)/pb(iz+1)*evb_tmp
2874 tvb_u(2*id,iz)=tvb_u(2*id,iz)-(d_urb(ibui)/pb(iz+1))* &
2875 (sfw(2*id,iz,ibui)*(1.-pwin)+sfwin(2*id,iz,ibui)*pwin)/ &
2876 da_u(iz)/cp_u-(1./4.)*(d_urb(ibui)/pb(iz+1))*(sfvlev(iz,ibui)-sflev(iz,ibui))/&
2877 (dz*bs_u(id,iurb))/da_u(iz)/cp_u
2878 tvb_ac(2*id,iz)=tvb_ac(2*id,iz)-(1./4.)*(d_urb(ibui)/pb(iz+1))*(-sflev(iz,ibui))/&
2879 (dz*bs_u(id,iurb))/da_u(iz)/cp_u
2880 qvb_u(2*id,iz)=qvb_u(2*id,iz)-(1./4.)*(d_urb(ibui)/pb(iz+1))*(lfvlev(iz,ibui)-lflev(iz,ibui))/&
2881 (dz*bs_u(id,iurb))/da_u(iz)/latent
2891 end subroutine buildings
2894 ! ===6=8===============================================================72
2895 ! ===6=8===============================================================72
2897 subroutine urban_meso(nd,kms,kme,kts,kte,nz_u,z,dz,z_u,pb,ss,bs,ws,sf,vl, &
2898 uva_u,vva_u,uvb_u,vvb_u,tva_u,tvb_u,evb_u, &
2899 uhb_u,vhb_u,thb_u,ehb_u,qhb_u,qvb_u, &
2900 a_u,a_v,a_t,a_e,b_u,b_v,b_t,b_e,b_q,tvb_ac,b_ac)
2902 ! ----------------------------------------------------------------------
2903 ! This routine interpolates the parameters from the "urban grid" to the
2905 ! See p300-301 Appendix B.2 of the BLM paper.
2906 ! ----------------------------------------------------------------------
2910 ! ----------------------------------------------------------------------
2912 ! ----------------------------------------------------------------------
2913 ! Data relative to the "mesoscale grid"
2914 integer kms,kme,kts,kte
2915 real z(kms:kme) ! Altitude above the ground of the cell interface
2916 real dz(kms:kme) ! Vertical space steps
2918 ! Data relative to the "uban grid"
2919 integer nz_u ! Number of layer in the urban grid
2920 integer nd ! Number of street direction for the current urban class
2921 real bs(ndm) ! Building widths of the current urban class
2922 real ws(ndm) ! Street widths of the current urban class
2923 real z_u(nz_um) ! Height of the urban grid levels
2924 real pb(nz_um) ! Probability to have a building with an height equal
2925 real ss(nz_um) ! Probability to have a building with height h
2926 real uhb_u(ndm,nz_um) ! U (x-wind component) Horizontal surfaces, B (explicit) term
2927 real uva_u(2*ndm,nz_um) ! U (x-wind component) Vertical surfaces, A (implicit) term
2928 real uvb_u(2*ndm,nz_um) ! U (x-wind component) Vertical surfaces, B (explicit) term
2929 real vhb_u(ndm,nz_um) ! V (y-wind component) Horizontal surfaces, B (explicit) term
2930 real vva_u(2*ndm,nz_um) ! V (y-wind component) Vertical surfaces, A (implicit) term
2931 real vvb_u(2*ndm,nz_um) ! V (y-wind component) Vertical surfaces, B (explicit) term
2932 real thb_u(ndm,nz_um) ! Temperature Horizontal surfaces, B (explicit) term
2933 real tva_u(2*ndm,nz_um) ! Temperature Vertical surfaces, A (implicit) term
2934 real tvb_u(2*ndm,nz_um) ! Temperature Vertical surfaces, B (explicit) term
2935 real tvb_ac(2*ndm,nz_um)
2936 real ehb_u(ndm,nz_um) ! Energy (TKE) Horizontal surfaces, B (explicit) term
2937 real evb_u(2*ndm,nz_um) ! Energy (TKE) Vertical surfaces, B (explicit) term
2939 !New variables for BEM
2941 real qhb_u(ndm,nz_um)
2942 real qvb_u(2*ndm,nz_um)
2945 ! ----------------------------------------------------------------------
2947 ! ----------------------------------------------------------------------
2948 ! Data relative to the "mesoscale grid"
2949 real sf(kms:kme) ! Surface of the "mesoscale grid" cells taking into account the buildings
2950 real vl(kms:kme) ! Volume of the "mesoscale grid" cells taking into account the buildings
2951 real a_u(kms:kme) ! Implicit component of the momentum sources or sinks in the X-direction
2952 real a_v(kms:kme) ! Implicit component of the momentum sources or sinks in the Y-direction
2953 real a_t(kms:kme) ! Implicit component of the heat sources or sinks
2954 real a_e(kms:kme) ! Implicit component of the TKE sources or sinks
2955 real b_u(kms:kme) ! Explicit component of the momentum sources or sinks in the X-direction
2956 real b_v(kms:kme) ! Explicit component of the momentum sources or sinks in the Y-direction
2957 real b_t(kms:kme) ! Explicit component of the heat sources or sinks
2959 real b_e(kms:kme) ! Explicit component of the TKE sources or sinks
2960 real b_q(kms:kme) ! Explicit component of the humidity sources or sinks
2961 ! ----------------------------------------------------------------------
2963 ! ----------------------------------------------------------------------
2967 real se,sr,st,su,sv,sq
2968 real uet(kms:kme) ! Contribution to TKE due to walls
2969 real veb,vta,vtb,vte,vtot,vua,vub,vva,vvb,vqb,vtb_ac
2972 ! ----------------------------------------------------------------------
2973 ! END VARIABLES DEFINITIONS
2974 ! ----------------------------------------------------------------------
2992 ! horizontal surfaces
3003 if(z(iz).lt.z_u(iz_u).and.z(iz).ge.z_u(iz_u-1))then
3007 sf(iz)=sf(iz)+((ws(id)+(1.-sr)*bs(id))/(ws(id)+bs(id)))/nd
3016 dzz=max(min(z_u(iz_u+1),z(iz+1))-max(z_u(iz_u),z(iz)),0.)
3017 vtot=vtot+pb(iz_u+1)*dzz
3019 vtot=vtot/(z(iz+1)-z(iz))
3020 vl(iz)=vl(iz)+(1.-vtot*bs(id)/(ws(id)+bs(id)))/nd
3024 ! horizontal surface impact
3028 fact=1./vl(kts)/dz(kts)*ws(id)/(ws(id)+bs(id))/nd
3029 b_t(kts)=b_t(kts)+thb_u(id,1)*fact
3030 b_u(kts)=b_u(kts)+uhb_u(id,1)*fact
3031 b_v(kts)=b_v(kts)+vhb_u(id,1)*fact
3032 b_e(kts)=b_e(kts)+ehb_u(id,1)*fact*(z_u(2)-z_u(1))
3033 b_q(kts)=b_q(kts)+qhb_u(id,1)*fact
3042 if(z(iz).le.z_u(iz_u).and.z(iz+1).gt.z_u(iz_u))then
3043 st=st+ss(iz_u)*thb_u(id,iz_u)
3044 su=su+ss(iz_u)*uhb_u(id,iz_u)
3045 sv=sv+ss(iz_u)*vhb_u(id,iz_u)
3046 se=se+ss(iz_u)*ehb_u(id,iz_u)*(z_u(iz_u+1)-z_u(iz_u))
3047 sq=sq+ss(iz_u)*qhb_u(id,iz_u)
3051 fact=bs(id)/(ws(id)+bs(id))/vl(iz)/dz(iz)/nd
3052 b_t(iz)=b_t(iz)+st*fact
3053 b_u(iz)=b_u(iz)+su*fact
3054 b_v(iz)=b_v(iz)+sv*fact
3055 b_e(iz)=b_e(iz)+se*fact
3056 b_q(iz)=b_q(iz)+sq*fact
3060 ! vertical surface impact
3076 dzz=max(min(z_u(iz_u+1),z(iz+1))-max(z_u(iz_u),z(iz)),0.)
3077 fact=dzz/(ws(id)+bs(id))
3078 vtb=vtb+pb(iz_u+1)* &
3079 (tvb_u(2*id-1,iz_u)+tvb_u(2*id,iz_u))*fact
3080 vtb_ac=vtb_ac+pb(iz_u+1)* &
3081 (tvb_ac(2*id-1,iz_u)+tvb_ac(2*id,iz_u))*fact
3082 vta=vta+pb(iz_u+1)* &
3083 (tva_u(2*id-1,iz_u)+tva_u(2*id,iz_u))*fact
3084 vua=vua+pb(iz_u+1)* &
3085 (uva_u(2*id-1,iz_u)+uva_u(2*id,iz_u))*fact
3086 vva=vva+pb(iz_u+1)* &
3087 (vva_u(2*id-1,iz_u)+vva_u(2*id,iz_u))*fact
3088 vub=vub+pb(iz_u+1)* &
3089 (uvb_u(2*id-1,iz_u)+uvb_u(2*id,iz_u))*fact
3090 vvb=vvb+pb(iz_u+1)* &
3091 (vvb_u(2*id-1,iz_u)+vvb_u(2*id,iz_u))*fact
3092 veb=veb+pb(iz_u+1)* &
3093 (evb_u(2*id-1,iz_u)+evb_u(2*id,iz_u))*fact
3094 vqb=vqb+pb(iz_u+1)* &
3095 (qvb_u(2*id-1,iz_u)+qvb_u(2*id,iz_u))*fact
3098 fact=1./vl(iz)/dz(iz)/nd
3099 b_t(iz)=b_t(iz)+vtb*fact
3100 b_ac(iz)=b_ac(iz)+vtb_ac*fact
3101 a_t(iz)=a_t(iz)+vta*fact
3102 a_u(iz)=a_u(iz)+vua*fact
3103 a_v(iz)=a_v(iz)+vva*fact
3104 b_u(iz)=b_u(iz)+vub*fact
3105 b_v(iz)=b_v(iz)+vvb*fact
3106 b_e(iz)=b_e(iz)+veb*fact
3107 uet(iz)=uet(iz)+vte*fact
3108 b_q(iz)=b_q(iz)+vqb*fact
3115 end subroutine urban_meso
3117 ! ===6=8===============================================================72
3118 ! ===6=8===============================================================72
3120 subroutine interp_length(nd,kms,kme,kts,kte,nz_u,z_u,z,ss,ws,bs, &
3123 ! ----------------------------------------------------------------------
3124 ! Calculation of the length scales
3125 ! See p272-274 formula (22) and (24) of the BLM paper
3126 ! ----------------------------------------------------------------------
3131 ! ----------------------------------------------------------------------
3133 ! ----------------------------------------------------------------------
3134 integer kms,kme,kts,kte
3135 real z(kms:kme) ! Altitude above the ground of the cell interface
3136 integer nd ! Number of street direction for the current urban class
3137 integer nz_u ! Number of levels in the "urban grid"
3138 real z_u(nz_um) ! Height of the urban grid levels
3139 real bs(ndm) ! Building widths of the current urban class
3140 real ss(nz_um) ! Probability to have a building with height h
3141 real ws(ndm) ! Street widths of the current urban class
3144 ! ----------------------------------------------------------------------
3146 ! ----------------------------------------------------------------------
3147 real dlg(kms:kme) ! Height above ground (L_ground in formula (24) of the BLM paper).
3148 real dl_u(kms:kme) ! Length scale (lb in formula (22) ofthe BLM paper).
3150 ! ----------------------------------------------------------------------
3152 ! ----------------------------------------------------------------------
3158 ! ----------------------------------------------------------------------
3159 ! END VARIABLES DEFINITIONS
3160 ! ----------------------------------------------------------------------
3167 if(z_u(iz_u).gt.z(iz))then
3168 ulu=ulu+ss(iz_u)/z_u(iz_u)/nd
3186 dlgtmp=ws(id)/((z(iz)+z(iz+1))/2.)
3188 if((z(iz)+z(iz+1))/2..gt.z_u(iz_u))then
3189 dlgtmp=dlgtmp+ss(iz_u)*bs(id)/ &
3190 ((z(iz)+z(iz+1))/2.-z_u(iz_u))
3191 sftot=sftot+ss(iz_u)*bs(id)
3194 dlg(iz)=dlg(iz)+dlgtmp/sftot/nd
3200 end subroutine interp_length
3202 ! ===6=8===============================================================72
3203 ! ===6=8===============================================================72
3205 subroutine shadow_mas(nd,nz_u,zr,deltar,ah,drst,ws,ss,pb,z, &
3206 swddir,rsw,rsg,xlat)
3208 ! ----------------------------------------------------------------------
3209 ! Modification of short wave radiation to take into account
3210 ! the shadow produced by the buildings
3211 ! ----------------------------------------------------------------------
3215 ! ----------------------------------------------------------------------
3217 ! ----------------------------------------------------------------------
3218 integer nd ! Number of street direction for the current urban class
3219 integer nz_u ! number of vertical layers defined in the urban grid
3220 real ah ! Hour angle (it should come from the radiation routine)
3221 real deltar ! Declination of the sun
3222 real drst(ndm) ! street directions for the current urban class
3223 real swddir ! solar radiation
3224 real ss(nz_um) ! probability to have a building with height h
3225 real pb(nz_um) ! Probability that a building has an height greater or equal to h
3226 real ws(ndm) ! Street width of the current urban class
3227 real z(nz_um) ! Height of the urban grid levels
3228 real zr ! zenith angle
3231 ! ----------------------------------------------------------------------
3233 ! ----------------------------------------------------------------------
3234 real rsg(ndm) ! Short wave radiation at the ground
3235 real rsw(2*ndm,nz_um) ! Short wave radiation at the walls
3237 ! ----------------------------------------------------------------------
3239 ! ----------------------------------------------------------------------
3241 real aae,aaw,bbb,phix,rd,rtot,wsd
3243 ! ----------------------------------------------------------------------
3244 ! END VARIABLES DEFINITIONS
3245 ! ----------------------------------------------------------------------
3249 if(swddir.eq.0.or.sin(zr).eq.1)then
3260 if(abs(sin(zr)).gt.1.e-10)then
3261 if(cos(deltar)*sin(ah)/sin(zr).ge.1)then
3263 elseif(cos(deltar)*sin(ah)/sin(zr).le.-1)then
3266 bbb=asin(cos(deltar)*sin(ah)/sin(zr)) !
3267 if(sin(deltar).lt.(cos(zr)*sin(xlat_r)))then !
3272 if(cos(deltar)*sin(ah).ge.0)then
3274 elseif(cos(deltar)*sin(ah).lt.0)then
3290 if(pb(iz+1).gt.0.)then
3292 if(abs(sin(aae)).gt.1.e-10)then
3293 call shade_wall(z(iz),z(iz+1),z(jz+1),phix,aae, &
3295 rsw(2*id-1,iz)=rsw(2*id-1,iz)+swddir*rd*ss(jz+1)/pb(iz+1)
3298 if(abs(sin(aaw)).gt.1.e-10)then
3299 call shade_wall(z(iz),z(iz+1),z(jz+1),phix,aaw, &
3301 rsw(2*id,iz)=rsw(2*id,iz)+swddir*rd*ss(jz+1)/pb(iz+1)
3306 if(abs(sin(aae)).gt.1.e-10)then
3307 wsd=abs(ws(id)/sin(aae))
3310 rd=max(0.,wsd-z(jz+1)*tan(phix))
3311 rsg(id)=rsg(id)+swddir*rd*ss(jz+1)/wsd
3316 rtot=rtot+(rsw(2*id,iz)+rsw(2*id-1,iz))* &
3319 rtot=rtot+rsg(id)*ws(id)
3330 end subroutine shadow_mas
3336 ! ===6=8===============================================================72
3337 ! ===6=8===============================================================72
3339 subroutine shade_wall(z1,z2,hu,phix,aa,ws,rd)
3341 ! ----------------------------------------------------------------------
3342 ! This routine computes the effects of a shadow induced by a building of
3343 ! height hu, on a portion of wall between z1 and z2. See equation A10,
3344 ! and correction described below formula A11, and figure A1. Basically rd
3345 ! is the ratio between the horizontal surface illuminated and the portion
3346 ! of wall. Referring to figure A1, multiplying radiation flux density on
3347 ! a horizontal surface (rs) by x1-x2 we have the radiation energy per
3348 ! unit time. Dividing this by z2-z1, we obtain the radiation flux
3349 ! density reaching the portion of the wall between z2 and z1
3350 ! (everything is assumed in 2D)
3351 ! ----------------------------------------------------------------------
3355 ! ----------------------------------------------------------------------
3357 ! ----------------------------------------------------------------------
3358 real aa ! Angle between the sun direction and the face of the wall (A12)
3359 real hu ! Height of the building that generates the shadow
3360 real phix ! Solar zenith angle
3361 real ws ! Width of the street
3362 real z1 ! Height of the level z(iz)
3363 real z2 ! Height of the level z(iz+1)
3365 ! ----------------------------------------------------------------------
3367 ! ----------------------------------------------------------------------
3368 real rd ! Ratio between (x1-x2)/(z2-z1), see Fig. 1A.
3369 ! Multiplying rd by rs (radiation flux
3370 ! density on a horizontal surface) gives
3371 ! the radiation flux density on the
3372 ! portion of wall between z1 and z2.
3373 ! ----------------------------------------------------------------------
3375 ! ----------------------------------------------------------------------
3376 real x1,x2 ! x1,x2 see Fig. A1.
3378 ! ----------------------------------------------------------------------
3379 ! END VARIABLES DEFINITIONS
3380 ! ----------------------------------------------------------------------
3382 x1=min((hu-z1)*tan(phix),max(0.,ws/sin(aa)))
3384 x2=max((hu-z2)*tan(phix),0.)
3386 rd=max(0.,sin(aa)*(max(0.,x1-x2))/(z2-z1))
3389 end subroutine shade_wall
3391 ! ===6=8===============================================================72
3392 ! ===6=8===============================================================72
3394 subroutine long_rad(iurb,nz_u,id,emw,emg,emwin,pwin,twlev,&
3395 fwg,fww,fgw,fsw,fsg,tg_av,tw,rlg,rlw,rl,pb)
3397 ! ----------------------------------------------------------------------
3398 ! This routine computes the effects of the reflections of long-wave
3399 ! radiation in the street canyon by solving the system
3400 ! of 2*nz_u+1 eqn. in 2*nz_u+1
3401 ! unkonwn defined in A4, A5 and A6 of the paper (pages 295 and 296).
3402 ! The system is solved by solving A X= B,
3403 ! with A matrix B vector, and X solution.
3404 ! ----------------------------------------------------------------------
3410 ! ----------------------------------------------------------------------
3412 ! ----------------------------------------------------------------------
3413 real emg ! Emissivity of ground for the current urban class
3414 real emw ! Emissivity of wall for the current urban class
3415 real fgw(nz_um,ndm,nurbm) ! View factors from ground to wall
3416 real fsg(ndm,nurbm) ! View factors from sky to ground
3417 real fsw(nz_um,ndm,nurbm) ! View factors from sky to wall
3418 real fwg(nz_um,ndm,nurbm) ! View factors from wall to ground
3419 real fww(nz_um,nz_um,ndm,nurbm) ! View factors from wall to wall
3420 integer id ! Current street direction
3421 integer iurb ! Current urban class
3422 integer nz_u ! Number of layer in the urban grid
3423 real pb(nz_um) ! Probability to have a building with an height equal
3424 real rl ! Downward flux of the longwave radiation
3425 real tg_av(ndm) ! Temperature in each layer of the ground [K]
3426 real tw(2*ndm,nz_um) ! Temperature in each layer of the wall [K]
3428 !New Variables for BEM
3430 real twlev(2*ndm,nz_um) ! Window temperature in BEM [K]
3431 real emwin ! Emissivity of windows
3432 real pwin ! Coverage area fraction of windows in the walls of the buildings (BEM)
3435 ! ----------------------------------------------------------------------
3437 ! ----------------------------------------------------------------------
3438 real rlg(ndm) ! Long wave radiation at the ground
3439 real rlw(2*ndm,nz_um) ! Long wave radiation at the walls
3441 ! ----------------------------------------------------------------------
3443 ! ----------------------------------------------------------------------
3445 real aaa(2*nz_um+1,2*nz_um+1) ! terms of the matrix
3446 real bbb(2*nz_um+1) ! terms of the vector
3448 ! ----------------------------------------------------------------------
3449 ! END VARIABLES DEFINITIONS
3450 ! ----------------------------------------------------------------------
3464 aaa(i,j)=-(1.-emw*(1.-pwin)-emwin*pwin)* &
3465 fww(j-nz_u,i,id,iurb)*pb(j-nz_u+1)
3468 !! aaa(i,2*nz_u+1)=-(1.-emg)*fgw(i,id,iurb)*pb(i+1)
3469 aaa(i,2*nz_u+1)=-(1.-emg)*fgw(i,id,iurb)
3471 bbb(i)=fsw(i,id,iurb)*rl+emg*fgw(i,id,iurb)*sigma*tg_av(id)**4
3473 bbb(i)=bbb(i)+pb(j+1)*sigma*fww(j,i,id,iurb)* &
3474 (emw*(1.-pwin)*tw(2*id,j)**4+emwin*pwin*twlev(2*id,j)**4)+ &
3475 fww(j,i,id,iurb)*rl*(1.-pb(j+1))
3485 aaa(i,j)=-(1.-emw*(1.-pwin)-emwin*pwin)*fww(j,i-nz_u,id,iurb)*pb(j+1)
3494 !! aaa(i,2*nz_u+1)=-(1.-emg)*fgw(i-nz_u,id,iurb)*pb(i-nz_u+1)
3495 aaa(i,2*nz_u+1)=-(1.-emg)*fgw(i-nz_u,id,iurb)
3497 bbb(i)=fsw(i-nz_u,id,iurb)*rl+ &
3498 emg*fgw(i-nz_u,id,iurb)*sigma*tg_av(id)**4
3501 bbb(i)=bbb(i)+pb(j+1)*sigma*fww(j,i-nz_u,id,iurb)* &
3502 (emw*(1.-pwin)*tw(2*id-1,j)**4+emwin*pwin*twlev(2*id-1,j)**4)+&
3503 fww(j,i-nz_u,id,iurb)*rl*(1.-pb(j+1))
3510 aaa(2*nz_u+1,j)=-(1.-emw*(1.-pwin)-emwin*pwin)* &
3511 fwg(j,id,iurb)*pb(j+1)
3515 aaa(2*nz_u+1,j)=-(1.-emw*(1.-pwin)-emwin*pwin)* &
3516 fwg(j-nz_u,id,iurb)*pb(j-nz_u+1)
3519 aaa(2*nz_u+1,2*nz_u+1)=1.
3521 bbb(2*nz_u+1)=fsg(id,iurb)*rl
3524 bbb(2*nz_u+1)=bbb(2*nz_u+1)+sigma*fwg(i,id,iurb)*pb(i+1)* &
3525 (emw*(1.-pwin)*(tw(2*id-1,i)**4+tw(2*id,i)**4)+ &
3526 emwin*pwin*(twlev(2*id-1,i)**4+twlev(2*id,i)**4))+ &
3527 2.*fwg(i,id,iurb)*(1.-pb(i+1))*rl
3532 call gaussj(aaa,2*nz_u+1,bbb,2*nz_um+1)
3535 rlw(2*id-1,i)=bbb(i)
3539 rlw(2*id,i-nz_u)=bbb(i)
3542 rlg(id)=bbb(2*nz_u+1)
3545 end subroutine long_rad
3547 ! ===6=8===============================================================72
3548 ! ===6=8===============================================================72
3551 subroutine short_rad_dd(iurb,nz_u,id,albw, &
3552 albg,rsdif,fwg,fww,fgw,fsw,fsg,rsg,rsw,pb)
3554 ! ----------------------------------------------------------------------
3555 ! This routine computes the effects of the reflections of short-wave
3556 ! (solar) radiation in the street canyon by solving the system
3557 ! of 2*nz_u+1 eqn. in 2*nz_u+1
3558 ! unkonwn defined in A4, A5 and A6 of the paper (pages 295 and 296).
3559 ! The system is solved by solving A X= B,
3560 ! with A matrix B vector, and X solution.
3561 ! ----------------------------------------------------------------------
3567 ! ----------------------------------------------------------------------
3569 ! ----------------------------------------------------------------------
3570 real albg ! Albedo of the ground for the current urban class
3571 real albw ! Albedo of the wall for the current urban class
3572 real rsdif ! diffused short wave radiation
3573 real fgw(nz_um,ndm,nurbm) ! View factors from ground to wall
3574 real fwg(nz_um,ndm,nurbm) ! View factors from wall to ground
3575 real fww(nz_um,nz_um,ndm,nurbm) ! View factors from wall to wall
3576 real fsg(ndm,nurbm) ! View factors from sky to ground
3577 real fsw(nz_um,ndm,nurbm) ! View factors from sky to wall
3578 integer id ! current street direction
3579 integer iurb ! current urban class
3580 integer nz_u ! Number of layer in the urban grid
3581 real pb(nz_um) ! probability to have a building with an height equal
3583 ! ----------------------------------------------------------------------
3585 ! ----------------------------------------------------------------------
3586 real rsg(ndm) ! Short wave radiation at the ground
3587 real rsw(2*ndm,nz_um) ! Short wave radiation at the walls
3589 ! ----------------------------------------------------------------------
3591 ! ----------------------------------------------------------------------
3593 real aaa(2*nz_um+1,2*nz_um+1) ! terms of the matrix
3594 real bbb(2*nz_um+1) ! terms of the vector
3596 ! ----------------------------------------------------------------------
3597 ! END VARIABLES DEFINITIONS
3598 ! ----------------------------------------------------------------------
3612 aaa(i,j)=-albw*fww(j-nz_u,i,id,iurb)*pb(j-nz_u+1)
3615 aaa(i,2*nz_u+1)=-albg*fgw(i,id,iurb)
3616 bbb(i)=rsw(2*id-1,i)+fsw(i,id,iurb)*rsdif
3623 aaa(i,j)=-albw*fww(j,i-nz_u,id,iurb)*pb(j+1)
3631 aaa(i,2*nz_u+1)=-albg*fgw(i-nz_u,id,iurb)
3632 bbb(i)=rsw(2*id,i-nz_u)+fsw(i-nz_u,id,iurb)*rsdif
3639 aaa(2*nz_u+1,j)=-albw*fwg(j,id,iurb)*pb(j+1)
3643 aaa(2*nz_u+1,j)=-albw*fwg(j-nz_u,id,iurb)*pb(j-nz_u+1)
3646 aaa(2*nz_u+1,2*nz_u+1)=1.
3647 bbb(2*nz_u+1)=rsg(id)+fsg(id,iurb)*rsdif
3649 call gaussj(aaa,2*nz_u+1,bbb,2*nz_um+1)
3652 rsw(2*id-1,i)=bbb(i)
3656 rsw(2*id,i-nz_u)=bbb(i)
3659 rsg(id)=bbb(2*nz_u+1)
3663 end subroutine short_rad_dd
3667 ! ===6=8===============================================================72
3668 ! ===6=8===============================================================72
3670 subroutine gaussj(a,n,b,np)
3672 ! ----------------------------------------------------------------------
3673 ! This routine solve a linear system of n equations of the form
3675 ! where A is a matrix a(i,j)
3676 ! B a vector and X the solution
3677 ! In output b is replaced by the solution
3678 ! ----------------------------------------------------------------------
3682 ! ----------------------------------------------------------------------
3684 ! ----------------------------------------------------------------------
3688 ! ----------------------------------------------------------------------
3690 ! ----------------------------------------------------------------------
3693 ! ----------------------------------------------------------------------
3695 ! ----------------------------------------------------------------------
3697 parameter (nmax=150)
3705 ! ----------------------------------------------------------------------
3706 ! END VARIABLES DEFINITIONS
3707 ! ----------------------------------------------------------------------
3716 if(ipiv(j).ne.1)then
3718 if(ipiv(k).eq.0)then
3719 if(abs(a(j,k)).ge.big)then
3724 elseif(ipiv(k).gt.1)then
3725 FATAL_ERROR('singular matrix in gaussj')
3731 ipiv(icol)=ipiv(icol)+1
3733 if(irow.ne.icol)then
3746 if(a(icol,icol).eq.0) FATAL_ERROR('singular matrix in gaussj')
3748 pivinv=1./a(icol,icol)
3752 a(icol,l)=a(icol,l)*pivinv
3755 b(icol)=b(icol)*pivinv
3762 a(ll,l)=a(ll,l)-a(icol,l)*dum
3765 b(ll)=b(ll)-b(icol)*dum
3772 end subroutine gaussj
3776 ! ===6=8===============================================================72
3777 ! ===6=8===============================================================72
3779 subroutine soil_moist(nz,dz,qv,dt,lf,d,k,rainbl,drain,irri_now)
3781 ! ----------------------------------------------------------------------
3782 ! This routine solves the Fourier diffusion equation for heat in
3783 ! the material (wall, roof, or ground). Resolution is done implicitely.
3784 ! Boundary conditions are:
3785 ! - fixed temperature at the interior
3786 ! - energy budget at the surface
3787 ! ----------------------------------------------------------------------
3793 ! ----------------------------------------------------------------------
3795 ! ----------------------------------------------------------------------
3796 integer nz ! Number of layers
3798 real lf ! Latent heat flux at the surface
3799 real qv(nz) ! Moisture in each layer [K]
3800 real dz(nz) ! Layer sizes [m]
3801 real rainbl ! Rainfall [mm]
3802 real d(nz) ! Soil water diffusivity
3803 real k(nz) ! Hydraulic conductivity
3804 real gr ! Dummy variable
3807 ! ----------------------------------------------------------------------
3809 ! ----------------------------------------------------------------------
3812 ! ----------------------------------------------------------------------
3814 ! ----------------------------------------------------------------------
3820 real dw !water density Kg/m3
3822 !----------------------------------------------------------------------
3823 ! END VARIABLES DEFINITIONS
3824 ! ----------------------------------------------------------------------
3826 alpha=rainbl/(dw*dt)+lf/latent/dw+irri_now/dw
3829 cddz(iz)=2.*d(iz)/(dz(iz)+dz(iz-1))
3838 a(iz,1)=-cddz(iz)*dt/dz(iz)
3839 a(iz,2)=1.+dt*(cddz(iz)+cddz(iz+1))/dz(iz)
3840 a(iz,3)=-cddz(iz+1)*dt/dz(iz)
3841 c(iz)=qv(iz)+dt*(k(iz+1)-k(iz))/dz(iz)
3844 a(5,2)=1.+dt*(cddz(5+1))/dz(5)
3845 a(5,3)=-cddz(5+1)*dt/dz(5)
3846 c(5)=qv(5)+dt*(k(5+1)-drain)/dz(5)
3849 a(nz,1)=-dt*cddz(nz)/dz(nz)
3850 a(nz,2)=1.+dt*cddz(nz)/dz(nz)
3852 c(nz)=qv(nz)+dt*alpha/dz(nz)-dt*k(nz-1)/dz(nz)
3854 call invert(nz,a,c,qv)
3857 end subroutine soil_moist
3859 ! ===6=8===============================================================72
3860 ! ===6=8===============================================================72
3863 ! ===6=8===============================================================72
3864 ! ===6=8===============================================================72
3866 subroutine soil_temp_veg(heflro,nz,dz,temp,pt,ala,cs, &
3867 rs,rl,press,dt,em,alb,rt,sf,lf,gf,pv_frac_roof,tpv)
3869 ! ----------------------------------------------------------------------
3870 ! This routine solves the Fourier diffusion equation for heat in
3871 ! the material (wall, roof, or ground). Resolution is done implicitely.
3872 ! Boundary conditions are:
3873 ! - fixed temperature at the interior
3874 ! - energy budget at the surface
3875 ! ----------------------------------------------------------------------
3881 ! ----------------------------------------------------------------------
3883 ! ----------------------------------------------------------------------
3884 integer nz ! Number of layers
3885 real ala(nz) ! Thermal diffusivity in each layers [m^2 s^-1]
3886 real alb ! Albedo of the surface
3887 real cs(nz) ! Specific heat of the material [J m^3 K^-1]
3889 real em ! Emissivity of the surface
3890 real press ! Pressure at ground level
3891 real rl ! Downward flux of the longwave radiation
3892 real rs ! Solar radiation
3893 real sf ! Sensible heat flux at the surface
3894 real lf ! Latent heat flux at the surface
3895 real temp(nz) ! Temperature in each layer [K]
3896 real dz(nz) ! Layer sizes [m]
3897 real heflro ! Heat flux between roof and green roof
3902 ! ----------------------------------------------------------------------
3904 ! ----------------------------------------------------------------------
3905 real gf ! Heat flux transferred from the surface toward the interior
3906 real pt ! Potential temperature at the surface
3907 real rt ! Total radiation at the surface (solar+incoming long+outgoing long)
3909 ! ----------------------------------------------------------------------
3911 ! ----------------------------------------------------------------------
3919 ! ----------------------------------------------------------------------
3920 ! END VARIABLES DEFINITIONS
3921 ! ----------------------------------------------------------------------
3922 if(pv_frac_roof.gt.0)then
3923 rl_eff=(1-pv_frac_roof)*em*rl+em*sigma*tpv**4*pv_frac_roof
3924 rs_eff=(1.-pv_frac_roof)*rs
3930 alpha=(1.-alb)*rs_eff+rl_eff-em*sigma*(tsig**4)+sf+lf
3931 cddz(1)=ala(1)/dz(1)
3933 cddz(iz)=2.*ala(iz)/(dz(iz)+dz(iz-1))
3939 c(1)=temp(1)-heflro*dt/dz(1)
3941 a(iz,1)=-cddz(iz)*dt/dz(iz)
3942 a(iz,2)=1.+dt*(cddz(iz)+cddz(iz+1))/dz(iz)
3943 a(iz,3)=-cddz(iz+1)*dt/dz(iz)
3946 a(nz,1)=-dt*cddz(nz)/dz(nz)
3947 a(nz,2)=1.+dt*cddz(nz)/dz(nz)
3949 c(nz)=temp(nz)+dt*alpha/cs(nz)/dz(nz)
3951 call invert(nz,a,c,temp)
3953 pt=temp(nz)*(press/1.e+5)**(-rcp_u)
3955 rt=(1.-alb)*rs_eff+rl_eff-em*sigma*(tsig**4.)
3957 gf=(1.-alb)*rs_eff+rl_eff-em*sigma*(tsig**4.)+sf
3959 end subroutine soil_temp_veg
3961 ! ===6=8===============================================================72
3962 ! ===6=8===============================================================72
3964 subroutine soil_temp(nz,dz,temp,pt,ala,cs, &
3965 rs,rl,press,dt,em,alb,rt,sf,lf,gf)
3967 ! ----------------------------------------------------------------------
3968 ! This routine solves the Fourier diffusion equation for heat in
3969 ! the material (wall, roof, or ground). Resolution is done implicitely.
3970 ! Boundary conditions are:
3971 ! - fixed temperature at the interior
3972 ! - energy budget at the surface
3973 ! ----------------------------------------------------------------------
3979 ! ----------------------------------------------------------------------
3981 ! ----------------------------------------------------------------------
3982 integer nz ! Number of layers
3983 real ala(nz) ! Thermal diffusivity in each layers [m^2 s^-1]
3984 real alb ! Albedo of the surface
3985 real cs(nz) ! Specific heat of the material [J m^3 K^-1]
3987 real em ! Emissivity of the surface
3988 real press ! Pressure at ground level
3989 real rl ! Downward flux of the longwave radiation
3990 real rs ! Solar radiation
3991 real sf ! Sensible heat flux at the surface
3992 real lf ! Latent heat flux at the surface
3993 real temp(nz) ! Temperature in each layer [K]
3994 real dz(nz) ! Layer sizes [m]
3996 ! ----------------------------------------------------------------------
3998 ! ----------------------------------------------------------------------
3999 real gf ! Heat flux transferred from the surface toward the interior
4000 real pt ! Potential temperature at the surface
4001 real rt ! Total radiation at the surface (solar+incoming long+outgoing long)
4003 ! ----------------------------------------------------------------------
4005 ! ----------------------------------------------------------------------
4013 ! ----------------------------------------------------------------------
4014 ! END VARIABLES DEFINITIONS
4015 ! ----------------------------------------------------------------------
4018 alpha=(1.-alb)*rs+em*rl-em*sigma*(tsig**4)+sf+lf
4019 ! Compute cddz=2*cd/dz
4020 cddz(1)=ala(1)/dz(1)
4022 cddz(iz)=2.*ala(iz)/(dz(iz)+dz(iz-1))
4030 a(iz,1)=-cddz(iz)*dt/dz(iz)
4031 a(iz,2)=1.+dt*(cddz(iz)+cddz(iz+1))/dz(iz)
4032 a(iz,3)=-cddz(iz+1)*dt/dz(iz)
4035 a(nz,1)=-dt*cddz(nz)/dz(nz)
4036 a(nz,2)=1.+dt*cddz(nz)/dz(nz)
4038 c(nz)=temp(nz)+dt*alpha/cs(nz)/dz(nz)
4041 call invert(nz,a,c,temp)
4043 pt=temp(nz)*(press/1.e+5)**(-rcp_u)
4045 rt=(1.-alb)*rs+em*rl-em*sigma*(tsig**4.)
4047 gf=(1.-alb)*rs+em*rl-em*sigma*(tsig**4.)+sf
4049 end subroutine soil_temp
4052 ! ===6=8===============================================================72
4053 ! ===6=8===============================================================72
4056 subroutine invert(n,a,c,x)
4058 ! ----------------------------------------------------------------------
4059 ! Inversion and resolution of a tridiagonal matrix
4061 ! ----------------------------------------------------------------------
4065 ! ----------------------------------------------------------------------
4067 ! ----------------------------------------------------------------------
4069 real a(n,3) ! a(*,1) lower diagonal (Ai,i-1)
4070 ! a(*,2) principal diagonal (Ai,i)
4071 ! a(*,3) upper diagonal (Ai,i+1)
4074 ! ----------------------------------------------------------------------
4076 ! ----------------------------------------------------------------------
4079 ! ----------------------------------------------------------------------
4081 ! ----------------------------------------------------------------------
4084 ! ----------------------------------------------------------------------
4085 ! END VARIABLES DEFINITIONS
4086 ! ----------------------------------------------------------------------
4089 c(i)=c(i)-a(i,3)*c(i+1)/a(i+1,2)
4090 a(i,2)=a(i,2)-a(i,3)*a(i+1,1)/a(i+1,2)
4094 c(i)=c(i)-a(i,1)*c(i-1)/a(i-1,2)
4102 end subroutine invert
4105 ! ===6=8===============================================================72
4106 ! ===6=8===============================================================72
4108 subroutine flux_wall(ua,va,pt,da,ptw,ptwin,uva,vva,uvb,vvb, &
4109 sfw,sfwin,evb,drst,dt,cdrag)
4111 ! ----------------------------------------------------------------------
4112 ! This routine computes the surface sources or sinks of momentum, tke,
4113 ! and heat from vertical surfaces (walls).
4114 ! ----------------------------------------------------------------------
4119 real drst ! street directions for the current urban class
4120 real da ! air density
4121 real pt ! potential temperature
4122 real ptw ! Walls potential temperatures
4123 real ptwin ! Windows potential temperatures
4124 real ua ! wind speed
4125 real va ! wind speed
4130 ! Explicit and implicit component of the momentum, temperature and TKE sources or sinks on
4131 ! vertical surfaces (walls).
4132 ! The fluxes can be computed as follow: Fluxes of X = A*X + B
4133 ! Example: Momentum fluxes on vertical surfaces = uva_u * ua_u + uvb_u
4135 real uva ! U (wind component) Vertical surfaces, A (implicit) term
4136 real uvb ! U (wind component) Vertical surfaces, B (explicit) term
4137 real vva ! V (wind component) Vertical surfaces, A (implicit) term
4138 real vvb ! V (wind component) Vertical surfaces, B (explicit) term
4139 real tva ! Temperature Vertical surfaces, A (implicit) term
4140 real tvb ! Temperature Vertical surfaces, B (explicit) term
4141 real evb ! Energy (TKE) Vertical surfaces, B (explicit) term
4142 real sfw ! Surfaces fluxes from the walls
4143 real sfwin ! Surfaces fluxes from the windows
4153 ! -------------------------
4154 ! END VARIABLES DEFINITIONS
4155 ! -------------------------
4157 vett=(ua**2+va**2)**.5
4159 u_ort=abs((cos(drst)*ua-sin(drst)*va))
4161 uva=-cdrag*u_ort/2.*cos(drst)*cos(drst)
4162 vva=-cdrag*u_ort/2.*sin(drst)*sin(drst)
4164 uvb=cdrag*u_ort/2.*sin(drst)*cos(drst)*va
4165 vvb=cdrag*u_ort/2.*sin(drst)*cos(drst)*ua
4167 if (vett.lt.4.88) then
4168 hc=5.678*(1.09+0.23*(vett/0.3048))
4170 hc=5.678*0.53*((vett/0.3048)**0.78)
4173 if (hc.gt.da*cp_u/dt)then
4177 if (vett.lt.4.88) then
4178 hcwin=5.678*(0.99+0.21*(vett/0.3048))
4180 hcwin=5.678*0.50*((vett/0.3048)**0.78)
4183 if (hcwin.gt.da*cp_u/dt) then
4187 ! tvb=hc*ptw/da/cp_u
4189 !!!!!!!!!!!!!!!!!!!!
4193 sfwin=hcwin*(pt-ptwin)
4196 evb=cdrag*(abs(u_ort)**3.)/2.
4199 end subroutine flux_wall
4201 ! ===6=8===============================================================72
4202 ! ===6=8===============================================================72
4204 subroutine flux_flat_ground(dz,z0,ua,va,pt,pt0,ptg, &
4205 uhb,vhb,sf,ehb,da,qv,pr,rsg,qg,resg,rsveg,f1,f2,f3,f4,fh,ric,utot,gr_type)
4207 ! ----------------------------------------------------------------------
4208 ! Calculation of the flux at the ground
4209 ! Formulation of Louis (Louis, 1979)
4210 ! ----------------------------------------------------------------------
4214 real dz ! first vertical level
4215 real pt ! potential temperature
4216 real pt0 ! reference potential temperature
4217 real ptg ! ground potential temperature
4218 real ua ! wind speed
4219 real va ! wind speed
4220 real z0 ! Roughness length
4221 real da ! air density
4222 real qv ! specific humidity
4224 real rsg ! solar radiation
4225 real qg(ng_u) ! Ground Soil Moisture
4229 ! ----------------------------------------------------------------------
4231 ! ----------------------------------------------------------------------
4232 ! Explicit component of the momentum, temperature and TKE sources or sinks on horizontal
4233 ! surfaces (roofs and street)
4234 ! The fluxes can be computed as follow: Fluxes of X = B
4235 ! Example: Momentum fluxes on horizontal surfaces = uhb_u
4236 real uhb ! U (wind component) Horizontal surfaces, B (explicit) term
4237 real vhb ! V (wind component) Horizontal surfaces, B (explicit) term
4238 ! real thb ! Temperature Horizontal surfaces, B (explicit) term
4239 real tva ! Temperature Vertical surfaces, A (implicit) term
4240 real tvb ! Temperature Vertical surfaces, B (explicit) term
4241 real ehb ! Energy (TKE) Horizontal surfaces, B (explicit) term
4245 ! ----------------------------------------------------------------------
4247 ! ----------------------------------------------------------------------
4264 real qvsg,qvs,es,esa,fbqq
4266 parameter(b=9.4,cm=7.4,ch=5.3,rr=0.74,tol=.001)
4273 real ta ! surface air temperature
4274 real tmp ! ground temperature
4275 real rsveg ! Stomatal resistance
4277 real lai ! leaf area index
4278 real sdlim ! radiation limit at which photosyntesis start W/m2
4279 parameter(sdlim=100.)
4280 real rsmin ! Minimum stomatal resistance
4281 real rsmax ! Maximun stomatal resistance
4285 parameter(qref=0.37)
4289 real dzg_u(ng_u) ! Layer sizes in the ground
4291 data dzg_u /0.2,0.12,0.08,0.05,0.03,0.02,0.02,0.01,0.005,0.0025/
4295 ! ----------------------------------------------------------------------
4296 ! END VARIABLES DEFINITIONS
4297 ! ----------------------------------------------------------------------
4299 if(gr_type.eq.1)then
4303 elseif(gr_type.eq.2)then
4308 ! computation of the ground temperature
4310 utot=(ua**2.+va**2.)**.5
4313 !!!! Louis formulation
4315 ! compute the bulk Richardson Number
4319 ! if(tstar.lt.0.)then
4320 ! wstar=(-ustar*tstar*g*hii/pt)**(1./3.)
4325 ! if (utot.le.0.7*wstar) utot=max(0.7*wstar,0.00001)
4329 ric=2.*g_u*zz*(pt-ptg)/((pt+ptg)*(utot**2))
4334 ! determine the parameters fm and fh for stable, neutral and unstable conditions
4337 fm=1/(1+0.5*b*ric)**2.
4340 c=b*cm*aa*aa*(zz/z0)**.5
4341 fm=1-b*ric/(1+c*(-ric)**.5)
4342 c=b*cm*aa*ah*(zz/z0t)**.5
4344 fh=1-b*ric/(1+c*(-ric)**.5)
4347 fbuw=-aa*aa*utot*utot*fm
4348 fbpt=-aa*ah*utot*(pt-ptg)*fh/rr
4349 tmp=ptg*(pr/p0)**(rcp_u)-273.15
4350 es=6.11*(10.**(tmp*7.5/(237.7+tmp)))
4351 qvsg=0.62197*es/(0.01*pr-0.378*es)
4354 f=0.55*rsg/sdlim*2./lai
4356 f1=(f+rsmin/rsmax)/(1.+f)
4358 ta=pt*(pr/p0)**(rcp_u)-273.15
4359 esa=6.11*(10**(ta*7.5/(237.7+ta)))
4360 qvs=0.62197*esa/(0.01*pr-0.378*esa)
4362 f2= 1./(1.+hs*(qvs-qv))
4363 f3=1.-0.0016*(25.-ta)**2.
4367 gx=(qg(iz)-qw)/(qref-qw)
4371 dzg_tot=dzg_tot+dzg_u(iz)
4375 rsveg=min(rsmin/max(lai*f1*f2*f3*f4,1e-9),rsmax)
4376 resg= rr/(aa*aa*utot*fh)
4379 fbqq=-(qv-qvsg)/(resg+rsveg)
4386 al=(vk*g_u*tstar)/(pt*ustar*ustar)
4388 buu=-g_u/pt0*ustar*tstar
4390 uhb=-ustar*ustar*ua/utot
4391 vhb=-ustar*ustar*va/utot
4392 sf= ustar*tstar*da*cp_u
4393 lf= ustar*qstar*da*latent
4400 end subroutine flux_flat_ground
4402 ! ===6=8===============================================================72
4403 ! ===6=8===============================================================72
4404 subroutine flux_flat_roof(dz,z0,ua,va,pt,pt0,ptg, &
4405 uhb,vhb,sf,lf,ehb,da,qv,pr,rsg,qr,resg,rsveg,f1,f2,f3,f4,gr_type,pv_frac_roof)
4407 ! ----------------------------------------------------------------------
4408 ! Calculation of the flux at the ground
4409 ! Formulation of Louis (Louis, 1979)
4410 ! ----------------------------------------------------------------------
4414 real dz ! first vertical level
4415 real pt ! potential temperature
4416 real pt0 ! reference potential temperature
4417 real ptg ! ground potential temperature
4418 real ua ! wind speed
4419 real va ! wind speed
4420 real z0 ! Roughness length
4421 real da ! air density
4422 real qv ! specific humidity
4424 real rsg ! solar radiation
4425 real qr(ngr_u) ! Ground Soil Moisture
4429 ! ----------------------------------------------------------------------
4431 ! ----------------------------------------------------------------------
4432 ! Explicit component of the momentum, temperature and TKE sources or sinks on horizontal
4433 ! surfaces (roofs and street)
4434 ! The fluxes can be computed as follow: Fluxes of X = B
4435 ! Example: Momentum fluxes on horizontal surfaces = uhb_u
4436 real uhb ! U (wind component) Horizontal surfaces, B (explicit) term
4437 real vhb ! V (wind component) Horizontal surfaces, B (explicit) term
4438 ! real thb ! Temperature Horizontal surfaces, B (explicit) term
4439 real tva ! Temperature Vertical surfaces, A (implicit) term
4440 real tvb ! Temperature Vertical surfaces, B (explicit) term
4441 real ehb ! Energy (TKE) Horizontal surfaces, B (explicit) term
4445 ! ----------------------------------------------------------------------
4447 ! ----------------------------------------------------------------------
4464 real qvsg,qvs,es,esa,fbqq
4466 parameter(b=9.4,cm=7.4,ch=5.3,rr=0.74,tol=.001)
4473 real ta ! surface air temperature
4474 real tmp ! ground temperature
4475 real rsveg ! Stomatal resistance
4477 real lai ! leaft area index
4478 real sdlim ! radiation limit at which photosyntesis start W/m2
4479 parameter(sdlim=100.)
4481 real rsmax ! Maximun stomatal resistance
4482 real qw ! Wilting point
4484 real qref ! Field capacity
4485 parameter(qref=0.37)
4489 real dzgr_u(ngr_u) ! Layer sizes in the ground
4491 data dzgr_u /0.1,0.003,0.06,0.003,0.05,0.04,0.02,0.0125,0.005,0.0025/
4495 ! ----------------------------------------------------------------------
4496 ! END VARIABLES DEFINITIONS
4498 ! ----------------------------------------------------------------------
4500 if(gr_type.eq.1)then
4504 elseif(gr_type.eq.2)then
4509 rs_eff=(1-pv_frac_roof)*rsg
4510 ! computation of the ground temperature
4512 utot=(ua**2.+va**2.)**.5
4514 !!!! Louis formulation
4516 ! compute the bulk Richardson Number
4523 ric=2.*g_u*zz*(pt-ptg)/((pt+ptg)*(utot**2))
4529 fm=1./(1.+0.5*b*ric)**2.
4532 c=b*cm*aa*aa*(zz/z0)**.5
4533 fm=1.-b*ric/(1.+c*(-ric)**.5)
4534 c=b*cm*aa*ah*(zz/z0t)**.5
4536 fh=1.-b*ric/(1+c*(-ric)**.5)
4539 fbuw=-aa*aa*utot*utot*fm
4540 fbpt=-aa*ah*utot*(pt-ptg)*fh/rr
4541 tmp=ptg*(pr/p0)**(rcp_u)-273.15
4542 es=6.11*(10.**(tmp*7.5/(237.7+tmp)))
4543 qvsg=0.62197*es/(0.01*pr-0.378*es)
4546 f=0.55*rs_eff/sdlim*2./lai
4548 f1=(f+rsmin/rsmax)/(1.+f)
4550 ta=pt*(pr/p0)**(rcp_u)-273.15
4551 esa=6.11*(10**(ta*7.5/(237.7+ta)))
4552 qvs=0.62197*esa/(0.01*pr-0.378*esa)
4554 f2= 1./(1.+hs*(qvs-qv))
4555 f3=1.-0.0016*(25.-ta)**2.
4559 gx=(qr(iz)-qw)/(qref-qw)
4563 dzgr_tot=dzgr_tot+dzgr_u(iz)
4567 rsveg=min(rsmin/max(lai*f1*f2*f3*f4,1e-9),rsmax)
4570 resg= rr/(aa*aa*utot*fh)
4573 fbqq=-(qv-qvsg)/(resg+rsveg)
4579 al=(vk*g_u*tstar)/(pt*ustar*ustar)
4581 buu=-g_u/pt0*ustar*tstar
4583 uhb=-ustar*ustar*ua/utot
4584 vhb=-ustar*ustar*va/utot
4585 sf= ustar*tstar*da*cp_u
4586 lf= ustar*qstar*da*latent
4589 end subroutine flux_flat_roof
4591 !!!!!!!===============================
4593 ! ===6=8===============================================================72
4594 ! ===6=8===============================================================72
4596 subroutine flux_flat(dz,z0,ua,va,pt,pt0,ptg,qv, &
4597 uhb,vhb,sf,lf,ehb,da,pr)
4599 ! ----------------------------------------------------------------------
4600 ! Calculation of the flux at the ground
4601 ! Formulation of Louis (Louis, 1979)
4602 ! ----------------------------------------------------------------------
4606 real dz ! first vertical level
4607 real pt ! potential temperature
4608 real pt0 ! reference potential temperature
4609 real ptg ! ground potential temperature
4610 real ua ! wind speed
4611 real va ! wind speed
4612 real z0 ! Roughness length
4613 real da ! air density
4615 ! ----------------------------------------------------------------------
4617 ! ----------------------------------------------------------------------
4618 ! Explicit component of the momentum, temperature and TKE sources or sinks on horizontal
4619 ! surfaces (roofs and street)
4620 ! The fluxes can be computed as follow: Fluxes of X = B
4621 ! Example: Momentum fluxes on horizontal surfaces = uhb_u
4622 real uhb ! U (wind component) Horizontal surfaces, B (explicit) term
4623 real vhb ! V (wind component) Horizontal surfaces, B (explicit) term
4624 ! real thb ! Temperature Horizontal surfaces, B (explicit) term
4625 real tva ! Temperature Vertical surfaces, A (implicit) term
4626 real tvb ! Temperature Vertical surfaces, B (explicit) term
4627 real ehb ! Energy (TKE) Horizontal surfaces, B (explicit) term
4631 ! ----------------------------------------------------------------------
4633 ! ----------------------------------------------------------------------
4649 real qvsg,qvs,es,esa,fbqq,tmp,resg
4651 parameter(b=9.4,cm=7.4,ch=5.3,rr=0.74,tol=.001)
4653 ! ----------------------------------------------------------------------
4654 ! END VARIABLES DEFINITIONS
4655 ! ----------------------------------------------------------------------
4658 ! computation of the ground temperature
4660 utot=(ua**2+va**2)**.5
4663 !!!! Louis formulation
4665 ! compute the bulk Richardson Number
4672 ric=2.*g_u*zz*(pt-ptg)/((pt+ptg)*(utot**2))
4678 tmp=ptg*(pr/(1.e+5))**(rcp_u)-273.15
4679 es=6.11*(10**(tmp*7.5/(237.7+tmp)))
4680 qvsg=0.62197*es/(0.01*pr-0.378*es)
4684 ! determine the parameters fm and fh for stable, neutral and unstable conditions
4687 fm=1./(1.+0.5*b*ric)**2
4690 c=b*cm*aa*aa*(zz/z0)**.5
4691 fm=1.-b*ric/(1.+c*(-ric)**.5)
4693 fh=1.-b*ric/(1.+c*(-ric)**.5)
4696 resg= rr/(aa*aa*utot*fh)
4697 fbuw=-aa*aa*utot*utot*fm
4698 fbpt=-aa*aa*utot*(pt-ptg)*fh/rr
4699 fbqq=-(qv-qvsg)/(resg)
4704 al=(vk*g_u*tstar)/(pt*ustar*ustar)
4706 buu=-g_u/pt0*ustar*tstar
4708 uhb=-ustar*ustar*ua/utot
4709 vhb=-ustar*ustar*va/utot
4710 sf= ustar*tstar*da*cp_u
4711 lf= ustar*qstar*da*latent
4716 end subroutine flux_flat
4717 !!!!!!!!!!!!!================!!!!!!!!!!!!!!!!!!!
4718 ! ===6=8===============================================================72
4719 ! ===6=8===============================================================72
4721 subroutine icBEP (nd_u,h_b,d_b,ss_u,pb_u,nz_u,z_u)
4726 integer nd_u(nurbm) ! Number of street direction for each urban class
4727 real h_b(nz_um,nurbm) ! Bulding's heights [m]
4728 real d_b(nz_um,nurbm) ! The probability that a building has an height h_b
4729 ! -----------------------------------------------------------------------
4731 !------------------------------------------------------------------------
4733 real ss_u(nz_um,nurbm) ! The probability that a building has an height equal to z
4734 real pb_u(nz_um,nurbm) ! The probability that a building has an height greater or equal to z
4737 integer nz_u(nurbm) ! Number of layer in the urban grid
4738 real z_u(nz_um) ! Height of the urban grid levels
4741 ! -----------------------------------------------------------------------
4743 !------------------------------------------------------------------------
4745 integer iz_u,id,ilu,iurb
4750 ! -----------------------------------------------------------------------
4751 ! This routine initialise the urban paramters for the BEP module
4752 !------------------------------------------------------------------------
4754 !Initialize variables
4762 ! Computation of the urban levels height
4767 z_u(iz_u+1)=z_u(iz_u)+dz_u
4770 ! Normalisation of the building density
4775 dtot=dtot+d_b(ilu,iurb)
4778 d_b(ilu,iurb)=d_b(ilu,iurb)/dtot
4782 ! Compute the view factors, pb and ss
4788 if(h_b(ilu,iurb).gt.hbmax)hbmax=h_b(ilu,iurb)
4792 if(z_u(iz_u+1).gt.hbmax)go to 10
4800 do iz_u=1,nz_u(iurb)
4803 if(z_u(iz_u).le.h_b(ilu,iurb) &
4804 .and.z_u(iz_u+1).gt.h_b(ilu,iurb))then
4805 ss_u(iz_u,iurb)=ss_u(iz_u,iurb)+d_b(ilu,iurb)
4811 do iz_u=1,nz_u(iurb)
4812 pb_u(iz_u+1,iurb)=max(0.,pb_u(iz_u,iurb)-ss_u(iz_u,iurb))
4820 end subroutine icBEP
4822 ! ===6=8===============================================================72
4823 ! ===6=8===============================================================72
4826 subroutine view_factors(iurb,nz_u,id,dxy,z,ws,fww,fwg,fgw,fsg,fsw,fws)
4832 ! -----------------------------------------------------------------------
4834 !------------------------------------------------------------------------
4836 integer iurb ! Number of the urban class
4837 integer nz_u ! Number of levels in the urban grid
4838 integer id ! Street direction number
4839 real ws ! Street width
4840 real z(nz_um) ! Height of the urban grid levels
4841 real dxy ! Street lenght
4844 ! -----------------------------------------------------------------------
4846 !------------------------------------------------------------------------
4848 ! fww,fwg,fgw,fsw,fsg are the view factors used to compute the long wave
4849 ! and the short wave radation. They are the part of radiation from a surface
4850 ! or from the sky to another surface.
4852 real fww(nz_um,nz_um,ndm,nurbm) ! from wall to wall
4853 real fwg(nz_um,ndm,nurbm) ! from wall to ground
4854 real fgw(nz_um,ndm,nurbm) ! from ground to wall
4855 real fsw(nz_um,ndm,nurbm) ! from sky to wall
4856 real fws(nz_um,ndm,nurbm) ! from wall to sky
4857 real fsg(ndm,nurbm) ! from sky to ground
4860 ! -----------------------------------------------------------------------
4862 !------------------------------------------------------------------------
4867 real f1,f2,f12,f23,f123,ftot
4869 real a1,a2,a3,a4,a12,a23,a123
4871 ! -----------------------------------------------------------------------
4872 ! This routine calculates the view factors
4873 !------------------------------------------------------------------------
4879 ! radiation from wall to wall
4883 call fprls (fprl,dxy,abs(z(jz+1)-z(iz )),ws)
4885 call fprls (fprl,dxy,abs(z(jz+1)-z(iz+1)),ws)
4887 call fprls (fprl,dxy,abs(z(jz )-z(iz )),ws)
4889 call fprls (fprl,dxy,abs(z(jz )-z(iz+1)),ws)
4892 a123=dxy*(abs(z(jz+1)-z(iz )))
4893 a12 =dxy*(abs(z(jz )-z(iz )))
4894 a23 =dxy*(abs(z(jz+1)-z(iz+1)))
4895 a1 =dxy*(abs(z(iz+1)-z(iz )))
4896 a2 =dxy*(abs(z(jz )-z(iz+1)))
4897 a3 =dxy*(abs(z(jz+1)-z(jz )))
4899 ftot=0.5*(a123*f123-a23*f23-a12*f12+a2*f2)/a1
4901 fww(iz,jz,id,iurb)=ftot*a1/a3
4905 ! radiation from ground to wall
4907 call fnrms (fnrm,z(jz+1),dxy,ws)
4909 call fnrms (fnrm,z(jz) ,dxy,ws)
4916 a4=(z(jz+1)-z(jz))*dxy
4918 ftot=(a12*f12-a12*f1)/a1
4920 fgw(jz,id,iurb)=ftot*a1/a4
4922 ! radiation from sky to wall
4924 call fnrms(fnrm,hut-z(jz) ,dxy,ws)
4926 call fnrms (fnrm,hut-z(jz+1),dxy,ws)
4933 a4 = (z(jz+1)-z(jz))*dxy
4935 ftot=(a12*f12-a12*f1)/a1
4937 fsw(jz,id,iurb)=ftot*a1/a4
4941 ! radiation from wall to sky
4943 call fnrms(fnrm,ws,dxy,hut-z(iz))
4945 call fnrms(fnrm,ws,dxy,hut-z(iz+1))
4947 a1 = (z(iz+1)-z(iz))*dxy
4948 a2 = (hut-z(iz+1))*dxy
4949 a12= (hut-z(iz))*dxy
4951 ftot=(a12*f12-a2*f1)/a1
4952 fws(iz,id,iurb)=ftot*a1/a4
4960 ! radiation from wall to ground
4962 call fnrms (fnrm,ws,dxy,z(iz+1))
4964 call fnrms (fnrm,ws,dxy,z(iz ))
4967 a1= (z(iz+1)-z(iz) )*dxy
4973 ftot=(a12*f12-a2*f1)/a1
4975 fwg(iz,id,iurb)=ftot*a1/a4
4979 ! radiation from sky to ground
4981 call fprls (fprl,dxy,ws,hut)
4985 end subroutine view_factors
4987 ! ===6=8===============================================================72
4988 ! ===6=8===============================================================72
4991 SUBROUTINE fprls (fprl,a,b,c)
5005 if(a.eq.0.or.b.eq.0.)then
5008 fprl=log( ( (1.+x**2)*(1.+y**2)/(1.+x**2+y**2) )**.5)+ &
5009 y*((1.+x**2)**.5)*atan(y/((1.+x**2)**.5))+ &
5010 x*((1.+y**2)**.5)*atan(x/((1.+y**2)**.5))- &
5012 fprl=fprl*2./(pi*x*y)
5016 end subroutine fprls
5018 ! ===6=8===============================================================72
5019 ! ===6=8===============================================================72
5021 SUBROUTINE fnrms (fnrm,a,b,c)
5028 real x,y,z,a1,a2,a3,a4,a5,a6
5035 if(y.eq.0.or.x.eq.0)then
5038 a1=log( (1.+x*x)*(1.+y*y)/(1.+z) )
5039 a2=y*y*log(y*y*(1.+z)/z/(1.+y*y) )
5040 a3=x*x*log(x*x*(1.+z)/z/(1.+x*x) )
5043 a6=sqrt(z)*atan(1./sqrt(z))
5044 fnrm=0.25*(a1+a2+a3)+a4+a5-a6
5049 end subroutine fnrms
5050 ! ===6=8===============================================================72
5052 SUBROUTINE init_para(alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u,&
5053 twini_u,trini_u,tgini_u,albg_u,albw_u,albr_u,albwin_u,emg_u,emw_u,&
5054 emr_u,emwind_u,z0g_u,z0r_u,nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b, &
5055 cop_u,pwin_u,beta_u,sw_cond_u,time_on_u,time_off_u,targtemp_u, &
5056 bldac_frc_u,cooled_frc_u, &
5057 gaptemp_u, targhum_u,gaphum_u,perflo_u, &
5058 gr_frac_roof_u,pv_frac_roof_u, &
5059 hsesf_u,hsequip,irho,gr_flag_u,gr_type_u)
5062 ! initialization routine, where the variables from the table are read
5065 integer iurb ! urban class number
5066 ! Building parameters
5067 real alag_u(nurbm) ! Ground thermal diffusivity [m^2 s^-1]
5068 real alaw_u(nurbm) ! Wall thermal diffusivity [m^2 s^-1]
5069 real alar_u(nurbm) ! Roof thermal diffusivity [m^2 s^-1]
5070 real csg_u(nurbm) ! Specific heat of the ground material [J m^3 K^-1]
5071 real csw_u(nurbm) ! Specific heat of the wall material [J m^3 K^-1]
5072 real csr_u(nurbm) ! Specific heat of the roof material [J m^3 K^-1]
5073 real twini_u(nurbm) ! Temperature inside the buildings behind the wall [K]
5074 real trini_u(nurbm) ! Temperature inside the buildings behind the roof [K]
5075 real tgini_u(nurbm) ! Initial road temperature
5077 ! Radiation parameters
5078 real albg_u(nurbm) ! Albedo of the ground
5079 real albw_u(nurbm) ! Albedo of the wall
5080 real albr_u(nurbm) ! Albedo of the roof
5081 real albwin_u(nurbm) ! Albedo of the window
5082 real emg_u(nurbm) ! Emissivity of ground
5083 real emw_u(nurbm) ! Emissivity of wall
5084 real emr_u(nurbm) ! Emissivity of roof
5085 real emwind_u(nurbm) ! Emissivity of windows
5087 ! Roughness parameters
5088 real z0g_u(nurbm) ! The ground's roughness length
5089 real z0r_u(nurbm) ! The roof's roughness length
5092 integer nd_u(nurbm) ! Number of street direction for each urban class
5094 real strd_u(ndm,nurbm) ! Street length (fix to greater value to the horizontal length of the cells)
5095 real drst_u(ndm,nurbm) ! Street direction [degree]
5096 real ws_u(ndm,nurbm) ! Street width [m]
5097 real bs_u(ndm,nurbm) ! Building width [m]
5098 real h_b(nz_um,nurbm) ! Bulding's heights [m]
5099 real d_b(nz_um,nurbm) ! The probability that a building has an height h_b
5102 integer nurb ! number of urban classes used
5103 real, intent(out) :: bldac_frc_u(nurbm)
5104 real, intent(out) :: cooled_frc_u(nurbm)
5105 real, intent(out) :: cop_u(nurbm)
5106 real, intent(out) :: pwin_u(nurbm)
5107 real, intent(out) :: beta_u(nurbm)
5108 integer, intent(out) :: sw_cond_u(nurbm)
5109 real, intent(out) :: time_on_u(nurbm)
5110 real, intent(out) :: time_off_u(nurbm)
5111 real, intent(out) :: targtemp_u(nurbm)
5112 real, intent(out) :: gaptemp_u(nurbm)
5113 real, intent(out) :: targhum_u(nurbm)
5114 real, intent(out) :: gaphum_u(nurbm)
5115 real, intent(out) :: perflo_u(nurbm)
5116 real, intent(out) :: gr_frac_roof_u(nurbm)
5117 real, intent(out) :: pv_frac_roof_u(nurbm)
5118 real, intent(out) :: hsesf_u(nurbm)
5119 real, intent(out) :: hsequip(24)
5120 real, intent(out) :: irho(24)
5121 integer, intent(out) :: gr_flag_u,gr_type_u
5123 !Initialize some variables
5134 csw_u=CAPB_TBL / (( 1.0 / 4.1868 ) * 1.E-6)
5135 csr_u=CAPR_TBL / (( 1.0 / 4.1868 ) * 1.E-6)
5136 csg_u=CAPG_TBL / (( 1.0 / 4.1868 ) * 1.E-6)
5138 alaw_u(i)=AKSB_TBL(i) / csw_u(i) / (( 1.0 / 4.1868 ) * 1.E-2)
5139 alar_u(i)=AKSR_TBL(i) / csr_u(i) / (( 1.0 / 4.1868 ) * 1.E-2)
5140 alag_u(i)=AKSG_TBL(i) / csg_u(i) / (( 1.0 / 4.1868 ) * 1.E-2)
5155 ! print*, 'g alla call', gr_frac_roof_u(iurb)
5156 bldac_frc_u = bldac_frc_tbl
5157 cooled_frc_u = cooled_frc_tbl
5161 sw_cond_u = sw_cond_tbl
5162 time_on_u = time_on_tbl
5163 time_off_u = time_off_tbl
5164 targtemp_u = targtemp_tbl
5165 gaptemp_u = gaptemp_tbl
5166 targhum_u = targhum_tbl
5167 gaphum_u = gaphum_tbl
5168 perflo_u = perflo_tbl
5169 gr_frac_roof_u =gr_frac_roof_tbl
5170 gr_flag_u=gr_flag_tbl
5171 pv_frac_roof_u = pv_frac_roof_tbl
5173 hsequip = hsequip_tbl
5175 gr_type_u=gr_type_tbl
5177 if(ndm.lt.nd_u(iu))then
5178 write(*,*)'ndm too small in module_sf_bep_bem, please increase to at least ', nd_u(iu)
5179 write(*,*)'remember also that num_urban_layers should be equal or greater than nz_um*ndm*nwr-u!'
5183 drst_u(i,iu)=STREET_DIRECTION_TBL(i,iu) * pi/180.
5184 ws_u(i,iu)=STREET_WIDTH_TBL(i,iu)
5185 bs_u(i,iu)=BUILDING_WIDTH_TBL(i,iu)
5189 if(nz_um.lt.numhgt_tbl(iu)+3)then
5190 write(*,*)'nz_um too small in module_sf_bep, please increase to at least ',numhgt_tbl(iu)+3
5191 write(*,*)'remember also that num_urban_layers should be equal or greater than nz_um*ndm*nwr-u!'
5194 do i=1,NUMHGT_TBL(iu)
5195 h_b(i,iu)=HEIGHT_BIN_TBL(i,iu)
5196 d_b(i,iu)=HPERCENT_BIN_TBL(i,iu)
5202 strd_u(i,iu)=100000.
5208 call albwindow(albwin_u(iu))
5212 end subroutine init_para
5213 !==============================================================
5214 !==============================================================
5215 !====6=8===============================================================72
5216 !====6=8===============================================================72
5218 subroutine upward_rad(ndu,nzu,ws,bs,sigma,pb,ss, &
5219 tg_av,emg_u,albg_u,rlg,rsg,sfg,lfg, &
5220 tw,emw_u,albw_u,rlw,rsw,sfw, &
5221 tr_av,emr_u,albr_u,emwind,albwind,twlev,pwin, &
5222 sfwind,rld,rs, sfr,sfrv,lfr,lfrv, &
5223 rs_abs,rl_up,emiss,grdflx_urb,gr_frac_roof,tpvlev,pv_frac_roof)
5225 ! IN this surboutine we compute the upward longwave flux, and the albedo
5226 ! needed for the radiation scheme
5233 real rsw(2*ndm,nz_um) ! Short wave radiation at the wall for a given canyon direction [W/m2]
5234 real rlw(2*ndm,nz_um) ! Long wave radiation at the walls for a given canyon direction [W/m2]
5235 real rsg(ndm) ! Short wave radiation at the canyon for a given canyon direction [W/m2]
5236 real rlg(ndm) ! Long wave radiation at the ground for a given canyon direction [W/m2]
5237 real rs ! Short wave radiation at the horizontal surface from the sun [W/m2]
5238 real sfw(2*ndm,nz_um) ! Sensible heat flux from walls [W/m2]
5239 real sfg(ndm) ! Sensible heat flux from ground (road) [W/m2]
5241 real sfr(ndm,nz_um) ! Sensible heat flux from roofs [W/m2]
5243 real lfrv(ndm,nz_um)
5244 real sfrv(ndm,nz_um)
5246 real rld ! Long wave radiation from the sky [W/m2]
5247 real albg_u ! albedo of the ground/street
5248 real albw_u ! albedo of the walls
5249 real albr_u ! albedo of the roof
5250 real ws(ndm) ! width of the street
5253 real pb(nz_um) ! Probability to have a building with an height equal or higher
5255 real ss(nz_um) ! Probability to have a building of a given height
5257 real emg_u ! emissivity of the street
5258 real emw_u ! emissivity of the wall
5259 real emr_u ! emissivity of the roof
5260 real tw(2*ndm,nz_um) ! Temperature in each layer of the wall [K]
5261 real tr_av(ndm,nz_um) ! Temperature in each layer of the roof [K]
5262 real tpvlev(ndm,nz_um)
5264 real tg_av(ndm) ! Temperature in each layer of the ground [K]
5265 integer id ! street direction
5266 integer ndu ! number of street directions
5270 real emwind !Emissivity of the windows
5271 real albwind !Albedo of the windows
5272 real twlev(2*ndm,nz_um) !Averaged Temperature of the windows
5273 real pwin !Coverage area fraction of the windows
5274 real gflwin !Heat stored for the windows
5275 real sfwind(2*ndm,nz_um) !Sensible heat flux from windows [W/m2]
5278 real rs_abs ! absrobed solar radiationfor this street direction
5279 real rl_up ! upward longwave radiation for this street direction
5280 real emiss ! mean emissivity
5281 real grdflx_urb ! ground heat flux
5286 integer ix,iy,iwrong
5291 if(tr_av(id,iz).lt.100.)then
5292 write(203,*) tr_av(id,iz)
5293 write(*,*)'in upward_rad ',iz,id,iw,tr_av(id,iz)
5308 rl_emit=rl_emit-( emg_u*sigma*(tg_av(id)**4.)+(1-emg_u)*rlg(id))*ws(id)/(ws(id)+bs(id))/ndu
5309 rl_inc=rl_inc+rlg(id)*ws(id)/(ws(id)+bs(id))/ndu
5310 rs_abs=rs_abs+(1.-albg_u)*rsg(id)*ws(id)/(ws(id)+bs(id))/ndu
5311 gfl=(1.-albg_u)*rsg(id)+emg_u*rlg(id)-emg_u*sigma*(tg_av(id)**4.)+sfg(id)+lfg(id)
5312 grdflx_urb=grdflx_urb-gfl*ws(id)/(ws(id)+bs(id))/ndu
5315 rl_emit=rl_emit-(emr_u*sigma*(1.-pv_frac_roof)*tr_av(id,iz)**4.+0.79*sigma*pv_frac_roof*tpvlev(id,iz)**4+ &
5316 (1-emr_u)*rld*(1.-pv_frac_roof)+(1-0.79)*pv_frac_roof*rld)*ss(iz)*bs(id)/(ws(id)+bs(id))/ndu
5317 rl_inc=rl_inc+rld*ss(iz)*bs(id)/(ws(id)+bs(id))/ndu
5318 rs_abs=rs_abs+((1.-albr_u)*rs*(1.-pv_frac_roof)+(1.-0.11)*rs*pv_frac_roof)*ss(iz)*bs(id)/(ws(id)+bs(id))/ndu
5319 gfl=(1.-albr_u)*rs*(1-pv_frac_roof)+emr_u*rld*(1-pv_frac_roof)+pv_frac_roof*emr_u*sigma*tpvlev(id,iz)**4 &
5320 -emr_u*sigma*(tr_av(id,iz)**4.)+(1-gr_frac_roof)*sfr(id,iz)+(sfrv(id,iz)+lfrv(id,iz))*gr_frac_roof+(1.-gr_frac_roof)*lfr(id,iz)
5321 grdflx_urb=grdflx_urb-gfl*ss(iz)*bs(id)/(ws(id)+bs(id))/ndu
5326 rl_emit=rl_emit-(emw_u*(1.-pwin)*sigma*(tw(2*id-1,iz)**4.+tw(2*id,iz)**4.)+ &
5327 (emwind*pwin*sigma*(twlev(2*id-1,iz)**4.+twlev(2*id,iz)**4.))+ &
5328 ((1.-emw_u)*(1.-pwin)+pwin*(1.-emwind))*(rlw(2*id-1,iz)+rlw(2*id,iz)))* &
5329 dz_u*pb(iz+1)/(ws(id)+bs(id))/ndu
5331 rl_inc=rl_inc+((rlw(2*id-1,iz)+rlw(2*id,iz)))*dz_u*pb(iz+1)/(ws(id)+bs(id))/ndu
5333 rs_abs=rs_abs+(((1.-albw_u)*(1.-pwin)+(1.-albwind)*pwin)*(rsw(2*id-1,iz)+rsw(2*id,iz)))*&
5334 dz_u*pb(iz+1)/(ws(id)+bs(id))/ndu
5336 gfl=(1.-albw_u)*(rsw(2*id-1,iz)+rsw(2*id,iz)) +emw_u*( rlw(2*id-1,iz)+rlw(2*id,iz) ) &
5337 -emw_u*sigma*( tw(2*id-1,iz)**4.+tw(2*id,iz)**4. )+(sfw(2*id-1,iz)+sfw(2*id,iz))
5339 gflwin=(1.-albwind)*(rsw(2*id-1,iz)+rsw(2*id,iz)) +emwind*(rlw(2*id-1,iz)+rlw(2*id,iz)) &
5340 -emwind*sigma*( twlev(2*id-1,iz)**4.+twlev(2*id,iz)**4.)+(sfwind(2*id-1,iz)+sfwind(2*id,iz))
5343 grdflx_urb=grdflx_urb-(gfl*(1.-pwin)+pwin*gflwin)*dz_u*pb(iz+1)/(ws(id)+bs(id))/ndu
5348 emiss=(emg_u+emw_u+emr_u)/3.
5349 rl_up=(rl_inc+rl_emit)-rld
5354 END SUBROUTINE upward_rad
5356 !====6=8===============================================================72
5357 !====6=8===============================================================72
5358 ! ===6================================================================72
5359 ! ===6================================================================72
5361 subroutine albwindow(albwin)
5363 !-------------------------------------------------------------------
5367 ! -------------------------------------------------------------------
5369 !paper of J.Karlsson and A.Roos(2000):"modelling the angular behaviour
5370 !of the total solar energy transmittance of windows"
5371 !Solar Energy Vol.69,No.4,pp. 321-329.
5372 ! -------------------------------------------------------------------
5378 real albwin ! albedo of the window
5381 real a,b,c !Polynomial coefficients
5382 real alfa,delta,gama !Polynomial powers
5383 real g0 !transmittance when the angle
5384 !of incidence is normal to the surface.
5389 !--------------------
5391 real epsilon !accuracy of the integration
5392 parameter (epsilon=1.e-07)
5393 real n1,n2 !Index of refraction for glasses and air
5394 parameter(n1=1.,n2=1.5)
5396 !--------------------------------------------------------------------
5397 if (q_num.eq.0) then
5398 write(*,*) 'Category parameter of the windows no valid'
5402 g0=4.*n1*n2/((n1+n2)*(n1+n2))
5406 alfa =5.2 + (0.7*q_num)
5408 gama =(5.26+0.06*p_num)+(0.73+0.04*p_num)*q_num
5411 !----------------------------------------------------------------------
5418 call foncs(fonc,(pi*k/intg),a,b,c,alfa,delta,gama)
5419 asup=asup+(pi/intg)*fonc
5425 call foncs(fonc,(pi*k/intg),a,b,c,alfa,delta,gama)
5426 ainf=ainf+(pi/intg)*fonc
5429 if(abs(asup-ainf).lt.epsilon) then
5430 albwin=1-g0+(g0/2.)*asup
5435 !----------------------------------------------------------------------
5437 end subroutine albwindow
5438 !====================================================================72
5439 !====================================================================72
5441 subroutine foncs(fonc,x,aa,bb,cc,alf,delt,gam)
5449 fonc=(((aa*(x**alf))/(pi**alf))+ &
5450 ((bb*(x**delt))/(pi**delt))+ &
5451 ((cc*(x**gam))/(pi**gam)))*sin(x)
5454 end subroutine foncs
5455 !====================================================================72
5456 !====================================================================72
5458 subroutine icBEP_XY(iurb,fww_u,fwg_u,fgw_u,fsw_u, &
5459 fws_u,fsg_u,ndu,strd,ws,nzu,z_u)
5464 integer ndu ! Number of street direction for each urban class
5467 real strd(ndm) ! Street length (fix to greater value to the horizontal length of the cells)
5468 real ws(ndm) ! Street width [m]
5471 integer nzu ! Number of layer in the urban grid
5472 real z_u(nz_um) ! Height of the urban grid levels
5473 ! -----------------------------------------------------------------------
5475 !------------------------------------------------------------------------
5477 ! fww_u,fwg_u,fgw_u,fsw_u,fsg_u are the view factors used to compute the long wave
5478 ! and the short wave radation. They are the part of radiation from a surface
5479 ! or from the sky to another surface.
5481 real fww_u(nz_um,nz_um,ndm,nurbm) ! from wall to wall
5482 real fwg_u(nz_um,ndm,nurbm) ! from wall to ground
5483 real fgw_u(nz_um,ndm,nurbm) ! from ground to wall
5484 real fsw_u(nz_um,ndm,nurbm) ! from sky to wall
5485 real fws_u(nz_um,ndm,nurbm) ! from sky to wall
5486 real fsg_u(ndm,nurbm) ! from sky to ground
5488 ! -----------------------------------------------------------------------
5490 !------------------------------------------------------------------------
5494 ! -----------------------------------------------------------------------
5495 ! This routine compute the view factors
5496 !------------------------------------------------------------------------
5509 call view_factors(iurb,nzu,id,strd(id),z_u,ws(id), &
5510 fww_u,fwg_u,fgw_u,fsg_u,fsw_u,fws_u)
5514 end subroutine icBEP_XY
5515 !====================================================================72
5516 !====================================================================72
5517 subroutine icBEPHI_XY(iurb,hb_u,hi_urb1D,ss_u,pb_u,nzu,z_u)
5520 !-----------------------------------------------------------------------
5522 !-----------------------------------------------------------------------
5525 real hi_urb1D(nz_um) ! The probability that a building has an height h_b
5526 integer iurb ! Number of the urban class
5530 real z_u(nz_um) ! Height of the urban grid levels
5531 ! -----------------------------------------------------------------------
5533 !------------------------------------------------------------------------
5535 real ss_u(nz_um,nurbm) ! The probability that a building has an height equal to z
5536 real pb_u(nz_um) ! The probability that a building has an height greater or equal to z
5540 integer nzu ! Number of layer in the urban grid
5542 ! -----------------------------------------------------------------------
5544 !------------------------------------------------------------------------
5545 real hb_u(nz_um) ! Bulding's heights [m]
5551 !------------------------------------------------------------------------
5553 !Initialize variables
5560 ! Normalisation of the building density
5566 dtot=dtot+hi_urb1D(ilu)
5570 if (hi_urb1D(ilu)<0.) then
5571 ! write(*,*) 'WARNING, HI_URB1D(ilu) < 0 IN BEP_BEM'
5576 if (dtot.gt.0.) then
5579 ! write(*,*) 'WARNING, HI_URB1D <= 0 IN BEP_BEM'
5584 hi_urb1D(ilu)=hi_urb1D(ilu)/dtot
5589 hb_u(ilu)=dz_u+hb_u(ilu-1)
5599 if (hi_urb1D(ilu)>0.and.hi_urb1D(ilu)<=1.) then
5605 if(z_u(iz_u+1).gt.hbmax)go to 10
5612 if ((nzu+1).gt.nz_um) then
5613 write(*,*) 'error, nz_um has to be increased to at least',nzu+1
5620 if(z_u(iz_u).le.hb_u(ilu) &
5621 .and.z_u(iz_u+1).gt.hb_u(ilu))then
5622 ss_u(iz_u,iurb)=ss_u(iz_u,iurb)+hi_urb1D(ilu)
5629 pb_u(iz_u+1)=max(0.,pb_u(iz_u)-ss_u(iz_u,iurb))
5634 end subroutine icBEPHI_XY
5635 !====================================================================72
5636 !====================================================================72
5637 END MODULE module_sf_bep_bem
5639 ! ===6=8===============================================================72
5640 ! ===6=8===============================================================72
5642 FUNCTION bep_bem_nurbm () RESULT (bep_bem_val_nurbm)
5643 USE module_sf_bep_bem
5645 INTEGER :: bep_bem_val_nurbm
5646 bep_bem_val_nurbm = nurbm
5647 END FUNCTION bep_bem_nurbm
5649 FUNCTION bep_bem_ndm () RESULT (bep_bem_val_ndm)
5650 USE module_sf_bep_bem
5652 INTEGER :: bep_bem_val_ndm
5653 bep_bem_val_ndm = ndm
5654 END FUNCTION bep_bem_ndm
5656 FUNCTION bep_bem_nz_um () RESULT (bep_bem_val_nz_um)
5657 USE module_sf_bep_bem
5659 INTEGER :: bep_bem_val_nz_um
5660 bep_bem_val_nz_um = nz_um
5661 END FUNCTION bep_bem_nz_um
5663 FUNCTION bep_bem_ng_u () RESULT (bep_bem_val_ng_u)
5664 USE module_sf_bep_bem
5666 INTEGER :: bep_bem_val_ng_u
5667 bep_bem_val_ng_u = ng_u
5668 END FUNCTION bep_bem_ng_u
5670 FUNCTION bep_bem_nwr_u () RESULT (bep_bem_val_nwr_u)
5671 USE module_sf_bep_bem
5673 INTEGER :: bep_bem_val_nwr_u
5674 bep_bem_val_nwr_u = nwr_u
5675 END FUNCTION bep_bem_nwr_u
5677 FUNCTION bep_bem_nf_u () RESULT (bep_bem_val_nf_u)
5678 USE module_sf_bep_bem
5680 INTEGER :: bep_bem_val_nf_u
5681 bep_bem_val_nf_u = nf_u
5682 END FUNCTION bep_bem_nf_u
5685 FUNCTION bep_bem_ngb_u () RESULT (bep_bem_val_ngb_u)
5686 USE module_sf_bep_bem
5688 INTEGER :: bep_bem_val_ngb_u
5689 bep_bem_val_ngb_u = ngb_u
5690 END FUNCTION bep_bem_ngb_u
5692 FUNCTION bep_bem_nbui_max () RESULT (bep_bem_val_nbui_max)
5693 USE module_sf_bep_bem
5695 INTEGER :: bep_bem_val_nbui_max
5696 bep_bem_val_nbui_max = nbui_max
5697 END FUNCTION bep_bem_nbui_max
5700 FUNCTION bep_bem_ngr_u () RESULT (bep_bem_val_ngr_u)
5701 USE module_sf_bep_bem
5703 INTEGER :: bep_bem_val_ngr_u
5704 bep_bem_val_ngr_u = ngr_u
5705 END FUNCTION bep_bem_ngr_u