PageRenderTime 93ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/wrfv2_fire/phys/module_sf_bep_bem.F

http://github.com/jbeezley/wrf-fire
FORTRAN Legacy | 4101 lines | 2560 code | 730 blank | 811 comment | 59 complexity | 5fab623c5deab0dceb0cde135a58a9af MD5 | raw file
Possible License(s): AGPL-1.0
  1. MODULE module_sf_bep_bem
  2. !USE module_model_constants
  3. USE module_sf_urban
  4. USE module_sf_bem
  5. ! SGClarke 09/11/2008
  6. ! Access urban_param.tbl values through calling urban_param_init in module_physics_init
  7. ! for CASE (BEPSCHEME) select sf_urban_physics
  8. !
  9. ! -----------------------------------------------------------------------
  10. ! Dimension for the array used in the BEP module
  11. ! -----------------------------------------------------------------------
  12. integer nurbm ! Maximum number of urban classes
  13. parameter (nurbm=3)
  14. integer ndm ! Maximum number of street directions
  15. parameter (ndm=2)
  16. integer nz_um ! Maximum number of vertical levels in the urban grid
  17. parameter(nz_um=13)
  18. integer ng_u ! Number of grid levels in the ground
  19. parameter (ng_u=10)
  20. integer nwr_u ! Number of grid levels in the walls or roofs
  21. parameter (nwr_u=10)
  22. integer nf_u !Number of grid levels in the floors (BEM)
  23. parameter (nf_u=10)
  24. integer ngb_u !Number of grid levels in the ground below building (BEM)
  25. parameter (ngb_u=10)
  26. real dz_u ! Urban grid resolution
  27. parameter (dz_u=5.)
  28. integer nbui_max !maximum number of types of buildings in an urban class
  29. parameter (nbui_max=4) !must be less or equal than nz_um
  30. !---------------------------------------------------------------------------------
  31. !Parameters of the windows. The glasses of windows are considered without films -
  32. !Read the paper of J.Karlsson and A.Roos(2000):"modelling the angular behaviour -
  33. !of the total solar energy transmittance of windows".Solar Energy Vol.69,No.4, -
  34. !pp. 321-329, for more details. -
  35. !---------------------------------------------------------------------------------
  36. integer p_num !number of panes in the windows (1,2 or 3)
  37. parameter (p_num=2)
  38. integer q_num !category number for the windows (q_num= 4, standard glasses)
  39. parameter(q_num=4) !Possible values 1,2,...,10
  40. ! The change of ng_u, nwr_u should be done in agreement with the block data
  41. ! in the routine "surf_temp"
  42. ! -----------------------------------------------------------------------
  43. ! Constant used in the BEP module
  44. ! -----------------------------------------------------------------------
  45. real vk ! von Karman constant
  46. real g_u ! Gravity acceleration
  47. real pi !
  48. real r ! Perfect gas constant
  49. real cp_u ! Specific heat at constant pressure
  50. real rcp_u !
  51. real sigma !
  52. real p0 ! Reference pressure at the sea level
  53. real cdrag ! Drag force constant
  54. real latent ! Latent heat of vaporization [J/kg] (used in BEM)
  55. parameter(vk=0.40,g_u=9.81,pi=3.141592653,r=287.,cp_u=1004.)
  56. parameter(rcp_u=r/cp_u,sigma=5.67e-08,p0=1.e+5,cdrag=0.4,latent=2.45e+06)
  57. ! -----------------------------------------------------------------------
  58. CONTAINS
  59. subroutine BEP_BEM(FRC_URB2D,UTYPE_URB2D,itimestep,dz8w,dt,u_phy,v_phy, &
  60. th_phy,rho,p_phy,swdown,glw, &
  61. gmt,julday,xlong,xlat, &
  62. declin_urb,cosz_urb2d,omg_urb2d, &
  63. num_urban_layers, &
  64. trb_urb4d,tw1_urb4d,tw2_urb4d,tgb_urb4d, &
  65. tlev_urb3d,qlev_urb3d,tw1lev_urb3d,tw2lev_urb3d, &
  66. tglev_urb3d,tflev_urb3d,sf_ac_urb3d,lf_ac_urb3d, &
  67. cm_ac_urb3d,sfvent_urb3d,lfvent_urb3d, &
  68. sfwin1_urb3d,sfwin2_urb3d, &
  69. sfw1_urb3d,sfw2_urb3d,sfr_urb3d,sfg_urb3d, &
  70. a_u,a_v,a_t,a_e,b_u,b_v, &
  71. b_t,b_e,b_q,dlg,dl_u,sf,vl, &
  72. rl_up,rs_abs,emiss,grdflx_urb,qv_phy, &
  73. ids,ide, jds,jde, kds,kde, &
  74. ims,ime, jms,jme, kms,kme, &
  75. its,ite, jts,jte, kts,kte)
  76. implicit none
  77. !------------------------------------------------------------------------
  78. ! Input
  79. !------------------------------------------------------------------------
  80. INTEGER :: ids,ide, jds,jde, kds,kde, &
  81. ims,ime, jms,jme, kms,kme, &
  82. its,ite, jts,jte, kts,kte, &
  83. itimestep
  84. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: DZ8W
  85. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: P_PHY
  86. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: RHO
  87. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: TH_PHY
  88. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: T_PHY
  89. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: U_PHY
  90. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: V_PHY
  91. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: U
  92. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: V
  93. REAL, DIMENSION( ims:ime , jms:jme ) :: GLW
  94. REAL, DIMENSION( ims:ime , jms:jme ) :: swdown
  95. REAL, DIMENSION( ims:ime, jms:jme ) :: UST
  96. INTEGER, DIMENSION( ims:ime , jms:jme ), INTENT(IN ):: UTYPE_URB2D
  97. REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN ):: FRC_URB2D
  98. REAL, INTENT(IN ) :: GMT
  99. INTEGER, INTENT(IN ) :: JULDAY
  100. REAL, DIMENSION( ims:ime, jms:jme ), &
  101. INTENT(IN ) :: XLAT, XLONG
  102. REAL, INTENT(IN) :: DECLIN_URB
  103. REAL, DIMENSION( ims:ime, jms:jme ), INTENT(IN) :: COSZ_URB2D
  104. REAL, DIMENSION( ims:ime, jms:jme ), INTENT(IN) :: OMG_URB2D
  105. INTEGER, INTENT(IN ) :: num_urban_layers
  106. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: trb_urb4d
  107. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: tw1_urb4d
  108. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: tw2_urb4d
  109. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: tgb_urb4d
  110. !New variables used for BEM
  111. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: qv_phy
  112. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: tlev_urb3d
  113. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: qlev_urb3d
  114. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: tw1lev_urb3d
  115. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: tw2lev_urb3d
  116. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: tglev_urb3d
  117. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: tflev_urb3d
  118. REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) :: lf_ac_urb3d
  119. REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) :: sf_ac_urb3d
  120. REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) :: cm_ac_urb3d
  121. REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) :: sfvent_urb3d
  122. REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) :: lfvent_urb3d
  123. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: sfwin1_urb3d
  124. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: sfwin2_urb3d
  125. !End variables
  126. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: sfw1_urb3d
  127. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: sfw2_urb3d
  128. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: sfr_urb3d
  129. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: sfg_urb3d
  130. real z(ims:ime,kms:kme,jms:jme) ! Vertical coordinates
  131. REAL, INTENT(IN ):: DT ! Time step
  132. !
  133. !------------------------------------------------------------------------
  134. ! Output
  135. !------------------------------------------------------------------------
  136. !
  137. ! Implicit and explicit components of the source and sink terms at each levels,
  138. ! the fluxes can be computed as follow: FX = A*X + B example: t_fluxes = a_t * pt + b_t
  139. real a_u(ims:ime,kms:kme,jms:jme) ! Implicit component for the momemtum in X-direction (center)
  140. real a_v(ims:ime,kms:kme,jms:jme) ! Implicit component for the momemtum in Y-direction (center)
  141. real a_t(ims:ime,kms:kme,jms:jme) ! Implicit component for the temperature
  142. real a_e(ims:ime,kms:kme,jms:jme) ! Implicit component for the TKE
  143. real b_u(ims:ime,kms:kme,jms:jme) ! Explicit component for the momemtum in X-direction (center)
  144. real b_v(ims:ime,kms:kme,jms:jme) ! Explicit component for the momemtum in Y-direction (center)
  145. real b_t(ims:ime,kms:kme,jms:jme) ! Explicit component for the temperature
  146. real b_e(ims:ime,kms:kme,jms:jme) ! Explicit component for the TKE
  147. real b_q(ims:ime,kms:kme,jms:jme) ! Explicit component for the Humidity
  148. real dlg(ims:ime,kms:kme,jms:jme) ! Height above ground (L_ground in formula (24) of the BLM paper).
  149. real dl_u(ims:ime,kms:kme,jms:jme) ! Length scale (lb in formula (22) ofthe BLM paper).
  150. ! urban surface and volumes
  151. real sf(ims:ime,kms:kme,jms:jme) ! surface of the urban grid cells
  152. real vl(ims:ime,kms:kme,jms:jme) ! volume of the urban grid cells
  153. ! urban fluxes
  154. real rl_up(ims:ime,jms:jme) ! upward long wave radiation
  155. real rs_abs(ims:ime,jms:jme) ! absorbed short wave radiation
  156. real emiss(ims:ime,jms:jme) ! emissivity averaged for urban surfaces
  157. real grdflx_urb(ims:ime,jms:jme) ! ground heat flux for urban areas
  158. !------------------------------------------------------------------------
  159. ! Local
  160. !------------------------------------------------------------------------
  161. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  162. ! Building parameters
  163. real alag_u(nurbm) ! Ground thermal diffusivity [m^2 s^-1]
  164. real alaw_u(nurbm) ! Wall thermal diffusivity [m^2 s^-1]
  165. real alar_u(nurbm) ! Roof thermal diffusivity [m^2 s^-1]
  166. real csg_u(nurbm) ! Specific heat of the ground material [J m^3 K^-1]
  167. real csw_u(nurbm) ! Specific heat of the wall material [J m^3 K^-1]
  168. real csr_u(nurbm) ! Specific heat of the roof material [J m^3 K^-1]
  169. real twini_u(nurbm) ! Initial temperature inside the building's wall [K]
  170. real trini_u(nurbm) ! Initial temperature inside the building's roof [K]
  171. real tgini_u(nurbm) ! Initial road temperature
  172. !
  173. ! for twini_u, and trini_u the initial value at the deepest level is kept constant during the simulation
  174. !
  175. ! Radiation paramters
  176. real albg_u(nurbm) ! Albedo of the ground
  177. real albw_u(nurbm) ! Albedo of the wall
  178. real albr_u(nurbm) ! Albedo of the roof
  179. real albwin_u(nurbm) ! Albedo of the windows
  180. real emwind_u(nurbm) ! Emissivity of windows
  181. real emg_u(nurbm) ! Emissivity of ground
  182. real emw_u(nurbm) ! Emissivity of wall
  183. real emr_u(nurbm) ! Emissivity of roof
  184. ! fww,fwg,fgw,fsw,fsg are the view factors used to compute the long wave
  185. ! and the short wave radation.
  186. real fww(nz_um,nz_um,ndm,nurbm) ! from wall to wall
  187. real fwg(nz_um,ndm,nurbm) ! from wall to ground
  188. real fgw(nz_um,ndm,nurbm) ! from ground to wall
  189. real fsw(nz_um,ndm,nurbm) ! from sky to wall
  190. real fws(nz_um,ndm,nurbm) ! from sky to wall
  191. real fsg(ndm,nurbm) ! from sky to ground
  192. ! Roughness parameters
  193. real z0g_u(nurbm) ! The ground's roughness length
  194. real z0r_u(nurbm) ! The roof's roughness length
  195. ! Street parameters
  196. integer nd_u(nurbm) ! Number of street direction for each urban class
  197. real strd_u(ndm,nurbm) ! Street length (fix to greater value to the horizontal length of the cells)
  198. real drst_u(ndm,nurbm) ! Street direction
  199. real ws_u(ndm,nurbm) ! Street width
  200. real bs_u(ndm,nurbm) ! Building width
  201. real h_b(nz_um,nurbm) ! Bulding's heights
  202. real d_b(nz_um,nurbm) ! Probability that a building has an height h_b
  203. real ss_u(nz_um,nurbm) ! Probability that a building has an height equal to z
  204. real pb_u(nz_um,nurbm) ! Probability that a building has an height greater or equal to z
  205. ! Grid parameters
  206. integer nz_u(nurbm) ! Number of layer in the urban grid
  207. real z_u(nz_um) ! Height of the urban grid levels
  208. ! MT
  209. real cop_u(nurbm)
  210. real pwin_u(nurbm)
  211. real beta_u(nurbm)
  212. integer sw_cond_u(nurbm)
  213. real time_on_u(nurbm)
  214. real time_off_u(nurbm)
  215. real targtemp_u(nurbm)
  216. real gaptemp_u(nurbm)
  217. real targhum_u(nurbm)
  218. real gaphum_u(nurbm)
  219. real perflo_u(nurbm)
  220. real hsesf_u(nurbm)
  221. real hsequip(24)
  222. ! 1D array used for the input and output of the routine "urban"
  223. real z1D(kms:kme) ! vertical coordinates
  224. real ua1D(kms:kme) ! wind speed in the x directions
  225. real va1D(kms:kme) ! wind speed in the y directions
  226. real pt1D(kms:kme) ! potential temperature
  227. real da1D(kms:kme) ! air density
  228. real pr1D(kms:kme) ! air pressure
  229. real pt01D(kms:kme) ! reference potential temperature
  230. real zr1D ! zenith angle
  231. real deltar1D ! declination of the sun
  232. real ah1D ! hour angle (it should come from the radiation routine)
  233. real rs1D ! solar radiation
  234. real rld1D ! downward flux of the longwave radiation
  235. real tw1D(2*ndm,nz_um,nwr_u,nbui_max) ! temperature in each layer of the wall
  236. real tg1D(ndm,ng_u) ! temperature in each layer of the ground
  237. real tr1D(ndm,nz_um,nwr_u) ! temperature in each layer of the roof
  238. !
  239. !New variable for BEM
  240. !
  241. real tlev1D(nz_um,nbui_max) ! temperature in each floor and in each different type of building
  242. real qlev1D(nz_um,nbui_max) ! specific humidity in each floor and in each different type of building
  243. real twlev1D(2*ndm,nz_um,nbui_max) ! temperature in each window in each floor in each different type of building
  244. real tglev1D(ndm,ngb_u,nbui_max) ! temperature in each layer of the ground below of a type of building
  245. real tflev1D(ndm,nf_u,nz_um-1,nbui_max)! temperature in each layer of the floors in each building
  246. real lflev1D(nz_um,nz_um) ! latent heat flux due to the air conditioning systems
  247. real sflev1D(nz_um,nz_um) ! sensible heat flux due to the air conditioning systems
  248. real lfvlev1D(nz_um,nz_um) ! latent heat flux due to ventilation
  249. real sfvlev1D(nz_um,nz_um) ! sensible heat flux due to ventilation
  250. real sfwin1D(2*ndm,nz_um,nbui_max) ! sensible heat flux from windows
  251. real consumlev1D(nz_um,nz_um) ! consumption due to the air conditioning systems
  252. real qv1D(kms:kme) ! specific humidity
  253. real meso_urb ! constant to link meso and urban scales [m¯2]
  254. real d_urb(nz_um)
  255. real sf_ac
  256. integer ibui,nbui
  257. integer nlev(nz_um)
  258. !
  259. !End new variables
  260. !
  261. real sfw1D(2*ndm,nz_um,nbui_max) ! sensible heat flux from walls
  262. real sfg1D(ndm) ! sensible heat flux from ground (road)
  263. real sfr1D(ndm,nz_um) ! sensible heat flux from roofs
  264. real sf1D(kms:kme) ! surface of the urban grid cells
  265. real vl1D(kms:kme) ! volume of the urban grid cells
  266. real a_u1D(kms:kme) ! Implicit component of the momentum sources or sinks in the X-direction
  267. real a_v1D(kms:kme) ! Implicit component of the momentum sources or sinks in the Y-direction
  268. real a_t1D(kms:kme) ! Implicit component of the heat sources or sinks
  269. real a_e1D(kms:kme) ! Implicit component of the TKE sources or sinks
  270. real b_u1D(kms:kme) ! Explicit component of the momentum sources or sinks in the X-direction
  271. real b_v1D(kms:kme) ! Explicit component of the momentum sources or sinks in the Y-direction
  272. real b_t1D(kms:kme) ! Explicit component of the heat sources or sinks
  273. real b_ac1D(kms:kme)
  274. real b_e1D(kms:kme) ! Explicit component of the TKE sources or sinks
  275. real b_q1D(kms:kme) ! Explicit component of the Humidity sources or sinks
  276. real dlg1D(kms:kme) ! Height above ground (L_ground in formula (24) of the BLM paper).
  277. real dl_u1D(kms:kme) ! Length scale (lb in formula (22) ofthe BLM paper)
  278. real time_bep
  279. ! arrays used to collapse indexes
  280. integer ind_zwd(nbui_max,nz_um,nwr_u,ndm)
  281. integer ind_gd(ng_u,ndm)
  282. integer ind_zd(nbui_max,nz_um,ndm)
  283. integer ind_zdf(nz_um,ndm)
  284. integer ind_zrd(nz_um,nwr_u,ndm)
  285. !
  286. integer ind_bd(nbui_max,nz_um)
  287. integer ind_wd(nbui_max,nz_um,ndm)
  288. integer ind_gbd(nbui_max,ngb_u,ndm)
  289. integer ind_fbd(nbui_max,nf_u,nz_um-1,ndm)
  290. !
  291. integer ix,iy,iz,iurb,id,iz_u,iw,ig,ir,ix1,iy1,k
  292. integer it, nint
  293. integer iii
  294. real tempo
  295. logical first
  296. character(len=80) :: text
  297. data first/.true./
  298. save first,time_bep
  299. save alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u, &
  300. albg_u,albw_u,albr_u,emg_u,emw_u,emr_u,fww,fwg,fgw,fsw,fws,fsg, &
  301. z0g_u,z0r_u, nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b,ss_u,pb_u, &
  302. nz_u,z_u,albwin_u,emwind_u , &
  303. cop_u, pwin_u, beta_u, sw_cond_u, time_on_u, time_off_u, targtemp_u, &
  304. gaptemp_u, targhum_u, gaphum_u, perflo_u, hsesf_u, hsequip
  305. !------------------------------------------------------------------------
  306. ! Calculation of the momentum, heat and turbulent kinetic fluxes
  307. ! produced by buildings
  308. !
  309. ! Reference:
  310. ! Martilli, A., Clappier, A., Rotach, M.W.:2002, 'AN URBAN SURFACE EXCHANGE
  311. ! PARAMETERISATION FOR MESOSCALE MODELS', Boundary-Layer Meteorolgy 104:
  312. ! 261-304
  313. !
  314. ! F. Salamanca and A. Martilli, 2009: 'A new Building Energy Model coupled
  315. ! with an Urban Canopy Parameterization for urban climate simulations_part II.
  316. ! Validation with one dimension off-line simulations'. Theor Appl Climatol
  317. ! DOI 10.1007/s00704-009-0143-8
  318. !------------------------------------------------------------------------
  319. !prepare the arrays to collapse indexes
  320. if(num_urban_layers.lt.nbui_max*nz_um*ndm*max(nwr_u,ng_u))then
  321. write(*,*)'num_urban_layers too small, please increase to at least ', nbui_max*nz_um*ndm*max(nwr_u,ng_u)
  322. stop
  323. endif
  324. !
  325. !New conditions for BEM
  326. !
  327. if(num_urban_layers.lt.nbui_max*nz_um)then !limit for indoor temperature and indoor humidity
  328. write(*,*)'num_urban_layers too small, please increase to at least ', nbui_max*nz_um
  329. stop
  330. endif
  331. if(num_urban_layers.lt.nbui_max*nz_um*ndm)then !limit for window temperature
  332. write(*,*)'num_urban_layers too small, please increase to at least ', nbui_max*nz_um*ndm
  333. stop
  334. endif
  335. if(num_urban_layers.lt.nbui_max*ndm*ngb_u)then !limit for ground temperature below a building
  336. write(*,*)'num_urban_layers too small, please increase to at least ', nbui_max*ndm*ngb_u
  337. stop
  338. endif
  339. if(num_urban_layers.lt.(nz_um-1)*nbui_max*ndm*nf_u)then !limit for floor temperature
  340. write(*,*)'num_urban_layers too small, please increase to at least ', nbui_max*ndm*nf_u*(nz_um-1),num_urban_layers
  341. stop
  342. endif
  343. if (ndm.ne.2)then
  344. write(*,*) 'number of directions is not correct',ndm
  345. stop
  346. endif
  347. !
  348. !End of new conditions
  349. !
  350. !
  351. !Initialize collapse indexes
  352. !
  353. ind_zwd=0
  354. ind_gd=0
  355. ind_zd=0
  356. ind_zdf=0
  357. ind_zrd=0
  358. ind_bd=0
  359. ind_wd=0
  360. ind_gbd=0
  361. ind_fbd=0
  362. !
  363. !End initialization indexes
  364. !
  365. iii=0
  366. do ibui=1,nbui_max
  367. do iz_u=1,nz_um
  368. do iw=1,nwr_u
  369. do id=1,ndm
  370. iii=iii+1
  371. ind_zwd(ibui,iz_u,iw,id)=iii
  372. enddo
  373. enddo
  374. enddo
  375. enddo
  376. iii=0
  377. do ig=1,ng_u
  378. do id=1,ndm
  379. iii=iii+1
  380. ind_gd(ig,id)=iii
  381. enddo
  382. enddo
  383. iii=0
  384. do ibui=1,nbui_max
  385. do iz_u=1,nz_um
  386. do id=1,ndm
  387. iii=iii+1
  388. ind_zd(ibui,iz_u,id)=iii
  389. enddo
  390. enddo
  391. enddo
  392. iii=0
  393. do iz_u=1,nz_um
  394. do iw=1,nwr_u
  395. do id=1,ndm
  396. iii=iii+1
  397. ind_zrd(iz_u,iw,id)=iii
  398. enddo
  399. enddo
  400. enddo
  401. !
  402. !New indexes for BEM
  403. !
  404. iii=0
  405. do iz_u=1,nz_um
  406. do id=1,ndm
  407. iii=iii+1
  408. ind_zdf(iz_u,id)=iii
  409. enddo ! id
  410. enddo ! iz_u
  411. iii=0
  412. do ibui=1,nbui_max !Type of building
  413. do iz_u=1,nz_um !vertical levels
  414. iii=iii+1
  415. ind_bd(ibui,iz_u)=iii
  416. enddo !iz_u
  417. enddo !ibui
  418. iii=0
  419. do ibui=1,nbui_max !type of building
  420. do iz_u=1,nz_um !vertical levels
  421. do id=1,ndm !direction
  422. iii=iii+1
  423. ind_wd(ibui,iz_u,id)=iii
  424. enddo !id
  425. enddo !iz_u
  426. enddo !ibui
  427. iii=0
  428. do ibui=1,nbui_max!type of building
  429. do iw=1,ngb_u !layers in the wall (ground below a building)
  430. do id=1,ndm !direction
  431. iii=iii+1
  432. ind_gbd(ibui,iw,id)=iii
  433. enddo !id
  434. enddo !iw
  435. enddo !ibui
  436. iii=0
  437. do ibui=1,nbui_max !type of building
  438. do iw=1,nf_u !layers in the wall (floor)
  439. do iz_u=1,nz_um-1 !vertical levels
  440. do id=1,ndm !direction
  441. iii=iii+1
  442. ind_fbd(ibui,iw,iz_u,id)=iii
  443. enddo !id
  444. enddo !iz_u
  445. enddo !iw
  446. enddo !ibui
  447. !
  448. !End of new indexes
  449. !
  450. do ix=its,ite
  451. do iy=jts,jte
  452. z(ix,kts,iy)=0.
  453. do iz=kts+1,kte+1
  454. z(ix,iz,iy)=z(ix,iz-1,iy)+dz8w(ix,iz-1,iy)
  455. enddo
  456. enddo
  457. enddo
  458. if (first) then ! True only on first call
  459. call init_para(alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u,&
  460. twini_u,trini_u,tgini_u,albg_u,albw_u,albr_u,albwin_u,emg_u,emw_u,&
  461. emr_u,emwind_u,z0g_u,z0r_u,nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b,&
  462. cop_u, pwin_u, beta_u, sw_cond_u, time_on_u, time_off_u, &
  463. targtemp_u, gaptemp_u, targhum_u, gaphum_u, perflo_u, hsesf_u, hsequip)
  464. !Initialisation of the urban parameters and calculation of the view factor
  465. call icBEP(fww,fwg,fgw,fsw,fws,fsg, &
  466. z0g_u,z0r_u, &
  467. nd_u,strd_u,ws_u,bs_u,h_b,d_b,ss_u,pb_u, &
  468. nz_u,z_u)
  469. first=.false.
  470. endif ! first
  471. do ix=its,ite
  472. do iy=jts,jte
  473. if (FRC_URB2D(ix,iy).gt.0.) then ! Calling BEP only for existing urban classes.
  474. iurb=UTYPE_URB2D(ix,iy)
  475. ibui=0
  476. nlev=0
  477. nbui=0
  478. d_urb=0.
  479. do iz=1,nz_um
  480. if(ss_u(iz,iurb).gt.0) then
  481. ibui=ibui+1
  482. nlev(ibui)=iz-1
  483. d_urb(ibui)=ss_u(iz,iurb)
  484. nbui=ibui
  485. endif
  486. end do !iz
  487. if (nbui.gt.nbui_max) then
  488. write (*,*) 'nbui_max must be increased to',nbui
  489. stop
  490. endif
  491. do iz= kts,kte
  492. ua1D(iz)=u_phy(ix,iz,iy)
  493. va1D(iz)=v_phy(ix,iz,iy)
  494. pt1D(iz)=th_phy(ix,iz,iy)
  495. da1D(iz)=rho(ix,iz,iy)
  496. pr1D(iz)=p_phy(ix,iz,iy)
  497. ! pt01D(iz)=th_phy(ix,iz,iy)
  498. pt01D(iz)=300.
  499. z1D(iz)=z(ix,iz,iy)
  500. qv1D(iz)=qv_phy(ix,iz,iy)
  501. a_u1D(iz)=0.
  502. a_v1D(iz)=0.
  503. a_t1D(iz)=0.
  504. a_e1D(iz)=0.
  505. b_u1D(iz)=0.
  506. b_v1D(iz)=0.
  507. b_t1D(iz)=0.
  508. b_ac1D(iz)=0.
  509. b_e1D(iz)=0.
  510. enddo
  511. z1D(kte+1)=z(ix,kte+1,iy)
  512. do id=1,ndm
  513. do iz_u=1,nz_um
  514. do iw=1,nwr_u
  515. do ibui=1,nbui_max
  516. tw1D(2*id-1,iz_u,iw,ibui)=tw1_urb4d(ix,ind_zwd(ibui,iz_u,iw,id),iy)
  517. tw1D(2*id,iz_u,iw,ibui)=tw2_urb4d(ix,ind_zwd(ibui,iz_u,iw,id),iy)
  518. enddo
  519. enddo
  520. enddo
  521. enddo
  522. do id=1,ndm
  523. do ig=1,ng_u
  524. tg1D(id,ig)=tgb_urb4d(ix,ind_gd(ig,id),iy)
  525. enddo
  526. do iz_u=1,nz_um
  527. do ir=1,nwr_u
  528. tr1D(id,iz_u,ir)=trb_urb4d(ix,ind_zrd(iz_u,ir,id),iy)
  529. enddo
  530. enddo
  531. enddo
  532. !
  533. !Initialize variables for BEM
  534. !
  535. tlev1D=0. !Indoor temperature
  536. qlev1D=0. !Indoor humidity
  537. twlev1D=0. !Window temperature
  538. tglev1D=0. !Ground temperature
  539. tflev1D=0. !Floor temperature
  540. sflev1D=0. !Sensible heat flux from the a.c.
  541. lflev1D=0. !latent heat flux from the a.c.
  542. consumlev1D=0.!consumption of the a.c.
  543. sfvlev1D=0. !Sensible heat flux from natural ventilation
  544. lfvlev1D=0. !Latent heat flux from natural ventilation
  545. sfwin1D=0. !Sensible heat flux from windows
  546. sfw1D=0. !Sensible heat flux from walls
  547. do iz_u=1,nz_um !vertical levels
  548. do ibui=1,nbui_max !Type of building
  549. tlev1D(iz_u,ibui)= tlev_urb3d(ix,ind_bd(ibui,iz_u),iy)
  550. qlev1D(iz_u,ibui)= qlev_urb3d(ix,ind_bd(ibui,iz_u),iy)
  551. enddo !ibui
  552. enddo !iz_u
  553. do id=1,ndm !direction
  554. do iz_u=1,nz_um !vertical levels
  555. do ibui=1,nbui_max !type of building
  556. twlev1D(2*id-1,iz_u,ibui)=tw1lev_urb3d(ix,ind_wd(ibui,iz_u,id),iy)
  557. twlev1D(2*id,iz_u,ibui)=tw2lev_urb3d(ix,ind_wd(ibui,iz_u,id),iy)
  558. sfwin1D(2*id-1,iz_u,ibui)=sfwin1_urb3d(ix,ind_wd(ibui,iz_u,id),iy)
  559. sfwin1D(2*id,iz_u,ibui)=sfwin2_urb3d(ix,ind_wd(ibui,iz_u,id),iy)
  560. enddo !ibui
  561. enddo !iz_u
  562. enddo !id
  563. do id=1,ndm !direction
  564. do iw=1,ngb_u !layer in the wall
  565. do ibui=1,nbui_max !type of building
  566. tglev1D(id,iw,ibui)=tglev_urb3d(ix,ind_gbd(ibui,iw,id),iy)
  567. enddo !ibui
  568. enddo !iw
  569. enddo !id
  570. do id=1,ndm !direction
  571. do iw=1,nf_u !layer in the walls
  572. do iz_u=1,nz_um-1 !verticals levels
  573. do ibui=1,nbui_max !type of building
  574. tflev1D(id,iw,iz_u,ibui)=tflev_urb3d(ix,ind_fbd(ibui,iw,iz_u,id),iy)
  575. enddo !ibui
  576. enddo ! iz_u
  577. enddo !iw
  578. enddo !id
  579. !
  580. !End initialization for BEM
  581. !
  582. do id=1,ndm
  583. do iz=1,nz_um
  584. do ibui=1,nbui_max !type of building
  585. sfw1D(2*id-1,iz,ibui)=sfw1_urb3d(ix,ind_zd(ibui,iz,id),iy)
  586. sfw1D(2*id,iz,ibui)=sfw2_urb3d(ix,ind_zd(ibui,iz,id),iy)
  587. enddo
  588. enddo
  589. enddo
  590. do id=1,ndm
  591. sfg1D(id)=sfg_urb3d(ix,id,iy)
  592. enddo
  593. do id=1,ndm
  594. do iz=1,nz_um
  595. sfr1D(id,iz)=sfr_urb3d(ix,ind_zdf(iz,id),iy)
  596. enddo
  597. enddo
  598. rs1D=swdown(ix,iy)
  599. rld1D=glw(ix,iy)
  600. zr1D=acos(COSZ_URB2D(ix,iy))
  601. deltar1D=DECLIN_URB
  602. ah1D=OMG_URB2D(ix,iy)
  603. call BEP1D(iurb,kms,kme,kts,kte,z1D,dt,ua1D,va1D,pt1D,da1D,pr1D,pt01D, &
  604. zr1D,deltar1D,ah1D,rs1D,rld1D, &
  605. alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u, &
  606. albg_u,albw_u,albr_u,albwin_u,emg_u,emw_u,emr_u, &
  607. emwind_u,fww,fwg,fgw,fsw,fws,fsg, &
  608. z0g_u,z0r_u, &
  609. nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b,ss_u,pb_u, &
  610. nz_u,z_u, &
  611. cop_u,pwin_u,beta_u,sw_cond_u,time_on_u, &
  612. time_off_u,targtemp_u,gaptemp_u,targhum_u, &
  613. gaphum_u, perflo_u, hsesf_u, hsequip, &
  614. tw1D,tg1D,tr1D,sfw1D,sfg1D,sfr1D, &
  615. a_u1D,a_v1D,a_t1D,a_e1D, &
  616. b_u1D,b_v1D,b_t1D,b_ac1D,b_e1D,b_q1D, &
  617. dlg1D,dl_u1D,sf1D,vl1D,rl_up(ix,iy), &
  618. rs_abs(ix,iy),emiss(ix,iy),grdflx_urb(ix,iy), &
  619. qv1D,tlev1D,qlev1D,sflev1D,lflev1D,consumlev1D, &
  620. sfvlev1D,lfvlev1D,twlev1D,tglev1D,tflev1D,sfwin1D,&
  621. ix,iy)
  622. do id=1,ndm ! direction
  623. do iz=1,nz_um !vertical levels
  624. do ibui=1,nbui_max !type of building
  625. sfw1_urb3d(ix,ind_zd(ibui,iz,id),iy)=sfw1D(2*id-1,iz,ibui)
  626. sfw2_urb3d(ix,ind_zd(ibui,iz,id),iy)=sfw1D(2*id,iz,ibui)
  627. enddo
  628. enddo
  629. enddo
  630. do id=1,ndm
  631. sfg_urb3d(ix,id,iy)=sfg1D(id)
  632. enddo
  633. do id=1,ndm
  634. do iz=1,nz_um
  635. sfr_urb3d(ix,ind_zdf(iz,id),iy)=sfr1D(id,iz)
  636. enddo
  637. enddo
  638. do id=1,ndm
  639. do iz_u=1,nz_um
  640. do iw=1,nwr_u
  641. do ibui=1,nbui_max
  642. tw1_urb4d(ix,ind_zwd(ibui,iz_u,iw,id),iy)=tw1D(2*id-1,iz_u,iw,ibui)
  643. tw2_urb4d(ix,ind_zwd(ibui,iz_u,iw,id),iy)=tw1D(2*id,iz_u,iw,ibui)
  644. enddo
  645. enddo
  646. enddo
  647. enddo
  648. do id=1,ndm
  649. do ig=1,ng_u
  650. tgb_urb4d(ix,ind_gd(ig,id),iy)=tg1D(id,ig)
  651. enddo
  652. do iz_u=1,nz_um
  653. do ir=1,nwr_u
  654. trb_urb4d(ix,ind_zrd(iz_u,ir,id),iy)=tr1D(id,iz_u,ir)
  655. enddo
  656. enddo
  657. enddo
  658. !
  659. !Outputs of BEM
  660. !
  661. do ibui=1,nbui_max !type of building
  662. do iz_u=1,nz_um !vertical levels
  663. tlev_urb3d(ix,ind_bd(ibui,iz_u),iy)=tlev1D(iz_u,ibui)
  664. qlev_urb3d(ix,ind_bd(ibui,iz_u),iy)=qlev1D(iz_u,ibui)
  665. enddo !iz_u
  666. enddo !ibui
  667. do id=1,ndm !direction
  668. do iz_u=1,nz_um !vertical levels
  669. do ibui=1,nbui_max !type of building
  670. tw1lev_urb3d(ix,ind_wd(ibui,iz_u,id),iy)=twlev1D(2*id-1,iz_u,ibui)
  671. tw2lev_urb3d(ix,ind_wd(ibui,iz_u,id),iy)=twlev1D(2*id,iz_u,ibui)
  672. sfwin1_urb3d(ix,ind_wd(ibui,iz_u,id),iy)=sfwin1D(2*id-1,iz_u,ibui)
  673. sfwin2_urb3d(ix,ind_wd(ibui,iz_u,id),iy)=sfwin1D(2*id,iz_u,ibui)
  674. enddo !ibui
  675. enddo !iz_u
  676. enddo !id
  677. do id=1,ndm !direction
  678. do iw=1,ngb_u !layers in the walls
  679. do ibui=1,nbui_max !type of building
  680. tglev_urb3d(ix,ind_gbd(ibui,iw,id),iy)=tglev1D(id,iw,ibui)
  681. enddo !ibui
  682. enddo !iw
  683. enddo !id
  684. do id=1,ndm !direction
  685. do iw=1,nf_u !layer in the walls
  686. do iz_u=1,nz_um-1 !verticals levels
  687. do ibui=1,nbui_max !type of building
  688. tflev_urb3d(ix,ind_fbd(ibui,iw,iz_u,id),iy)=tflev1D(id,iw,iz_u,ibui)
  689. enddo !ibui
  690. enddo !iz_u
  691. enddo !iw
  692. enddo !id
  693. sf_ac_urb3d(ix,iy)=0.
  694. lf_ac_urb3d(ix,iy)=0.
  695. cm_ac_urb3d(ix,iy)=0.
  696. sfvent_urb3d(ix,iy)=0.
  697. lfvent_urb3d(ix,iy)=0.
  698. meso_urb=(1./4.)*FRC_URB2D(ix,iy)/((bs_u(1,iurb)+ws_u(1,iurb))*bs_u(2,iurb))+ &
  699. (1./4.)*FRC_URB2D(ix,iy)/((bs_u(2,iurb)+ws_u(2,iurb))*bs_u(1,iurb))
  700. ibui=0
  701. nlev=0
  702. nbui=0
  703. d_urb=0.
  704. do iz=1,nz_um
  705. if(ss_u(iz,iurb).gt.0) then
  706. ibui=ibui+1
  707. nlev(ibui)=iz-1
  708. d_urb(ibui)=ss_u(iz,iurb)
  709. nbui=ibui
  710. endif
  711. end do !iz
  712. do ibui=1,nbui !type of building
  713. do iz_u=1,nlev(ibui) !vertical levels
  714. sf_ac_urb3d(ix,iy)=sf_ac_urb3d(ix,iy)+meso_urb*d_urb(ibui)*sflev1D(iz_u,ibui)
  715. lf_ac_urb3d(ix,iy)=lf_ac_urb3d(ix,iy)+meso_urb*d_urb(ibui)*lflev1D(iz_u,ibui)
  716. cm_ac_urb3d(ix,iy)=cm_ac_urb3d(ix,iy)+meso_urb*d_urb(ibui)*consumlev1D(iz_u,ibui)
  717. sfvent_urb3d(ix,iy)=sfvent_urb3d(ix,iy)+meso_urb*d_urb(ibui)*sfvlev1D(iz_u,ibui)
  718. lfvent_urb3d(ix,iy)=lfvent_urb3d(ix,iy)+meso_urb*d_urb(ibui)*lfvlev1D(iz_u,ibui)
  719. enddo !iz_u
  720. enddo !ibui
  721. !
  722. !Add the latent heat exchanged throughout the ventilation in the lf_ac_urb3d output variable.
  723. !it is only a print variable
  724. !
  725. ! lf_ac_urb3d(ix,iy)=lf_ac_urb3d(ix,iy)+lfvent_urb3d(ix,iy)
  726. !
  727. lf_ac_urb3d(ix,iy)=lf_ac_urb3d(ix,iy)-lfvent_urb3d(ix,iy)
  728. !
  729. !End outputs of bem
  730. !
  731. sf_ac=0.
  732. do iz= kts,kte
  733. sf(ix,iz,iy)=sf1D(iz)
  734. vl(ix,iz,iy)=vl1D(iz)
  735. a_u(ix,iz,iy)=a_u1D(iz)
  736. a_v(ix,iz,iy)=a_v1D(iz)
  737. a_t(ix,iz,iy)=a_t1D(iz)
  738. a_e(ix,iz,iy)=a_e1D(iz)
  739. b_u(ix,iz,iy)=b_u1D(iz)
  740. b_v(ix,iz,iy)=b_v1D(iz)
  741. b_t(ix,iz,iy)=b_t1D(iz)
  742. sf_ac=sf_ac+b_ac1D(iz)*da1D(iz)*cp_u*dz8w(ix,iz,iy)*vl1D(iz)*FRC_URB2D(ix,iy)
  743. b_e(ix,iz,iy)=b_e1D(iz)
  744. b_q(ix,iz,iy)=b_q1D(iz)
  745. dlg(ix,iz,iy)=dlg1D(iz)
  746. dl_u(ix,iz,iy)=dl_u1D(iz)
  747. enddo
  748. sf(ix,kte+1,iy)=sf1D(kte+1)
  749. endif ! FRC_URB2D
  750. enddo ! iy
  751. enddo ! ix
  752. time_bep=time_bep+dt
  753. return
  754. end subroutine BEP_BEM
  755. ! ===6=8===============================================================72
  756. subroutine BEP1D(iurb,kms,kme,kts,kte,z,dt,ua,va,pt,da,pr,pt0, &
  757. zr,deltar,ah,rs,rld, &
  758. alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u, &
  759. albg_u,albw_u,albr_u,albwin_u,emg_u,emw_u,emr_u, &
  760. emwind_u,fww,fwg,fgw,fsw,fws,fsg, &
  761. z0g_u,z0r_u, &
  762. nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b,ss_u,pb_u, &
  763. nz_u,z_u, &
  764. cop_u,pwin_u,beta_u,sw_cond_u,time_on_u, &
  765. time_off_u,targtemp_u,gaptemp_u,targhum_u, &
  766. gaphum_u, perflo_u, hsesf_u, hsequip, &
  767. tw,tg,tr,sfw,sfg,sfr, &
  768. a_u,a_v,a_t,a_e, &
  769. b_u,b_v,b_t,b_ac,b_e,b_q, &
  770. dlg,dl_u,sf,vl,rl_up,rs_abs,emiss,grdflx_urb, &
  771. qv,tlev,qlev,sflev,lflev,consumlev, &
  772. sfvlev,lfvlev,twlev,tglev,tflev,sfwin,ix,iy)
  773. ! ----------------------------------------------------------------------
  774. ! This routine computes the effects of buildings on momentum, heat and
  775. ! TKE (turbulent kinetic energy) sources or sinks and on the mixing length.
  776. ! It provides momentum, heat and TKE sources or sinks at different levels of a
  777. ! mesoscale grid defined by the altitude of its cell interfaces "z" and
  778. ! its number of levels "nz".
  779. ! The meteorological input parameters (wind, temperature, solar radiation)
  780. ! are specified on the "mesoscale grid".
  781. ! The inputs concerning the building and street charateristics are defined
  782. ! on a "urban grid". The "urban grid" is defined with its number of levels
  783. ! "nz_u" and its space step "dz_u".
  784. ! The input parameters are interpolated on the "urban grid". The sources or sinks
  785. ! are calculated on the "urban grid". Finally the sources or sinks are
  786. ! interpolated on the "mesoscale grid".
  787. ! Mesoscale grid Urban grid Mesoscale grid
  788. !
  789. ! z(4) --- ---
  790. ! | |
  791. ! | |
  792. ! | Interpolation Interpolation |
  793. ! | Sources or sinks calculation |
  794. ! z(3) --- ---
  795. ! | ua ua_u --- uv_a a_u |
  796. ! | va va_u | uv_b b_u |
  797. ! | pt pt_u --- uh_b a_v |
  798. ! z(2) --- | etc... etc...---
  799. ! | z_u(1) --- |
  800. ! | | |
  801. ! z(1) ------------------------------------------------------------
  802. !
  803. ! Reference:
  804. ! Martilli, A., Clappier, A., Rotach, M.W.:2002, 'AN URBAN SURFACE EXCHANGE
  805. ! PARAMETERISATION FOR MESOSCALE MODELS', Boundary-Layer Meteorolgy 104:
  806. ! 261-304
  807. ! ----------------------------------------------------------------------
  808. implicit none
  809. ! ----------------------------------------------------------------------
  810. ! INPUT:
  811. ! ----------------------------------------------------------------------
  812. ! Data relative to the "mesoscale grid"
  813. integer kms,kme,kts,kte
  814. real z(kms:kme) ! Altitude above the ground of the cell interfaces.
  815. real ua(kms:kme) ! Wind speed in the x direction
  816. real va(kms:kme) ! Wind speed in the y direction
  817. real pt(kms:kme) ! Potential temperature
  818. real da(kms:kme) ! Air density
  819. real pr(kms:kme) ! Air pressure
  820. real pt0(kms:kme) ! Reference potential temperature (could be equal to "pt")
  821. real qv(kms:kme) ! Specific humidity
  822. real dt ! Time step
  823. real zr ! Zenith angle
  824. real deltar ! Declination of the sun
  825. real ah ! Hour angle
  826. real rs ! Solar radiation
  827. real rld ! Downward flux of the longwave radiation
  828. ! Data relative to the "urban grid"
  829. integer iurb ! Current urban class
  830. ! Building parameters
  831. real alag_u(nurbm) ! Ground thermal diffusivity [m^2 s^-1]
  832. real alaw_u(nurbm) ! Wall thermal diffusivity [m^2 s^-1]
  833. real alar_u(nurbm) ! Roof thermal diffusivity [m^2 s^-1]
  834. real csg_u(nurbm) ! Specific heat of the ground material [J m^3 K^-1]
  835. real csw_u(nurbm) ! Specific heat of the wall material [J m^3 K^-1]
  836. real csr_u(nurbm) ! Specific heat of the roof material [J m^3 K^-1]
  837. ! Radiation parameters
  838. real albg_u(nurbm) ! Albedo of the ground
  839. real albw_u(nurbm) ! Albedo of the wall
  840. real albr_u(nurbm) ! Albedo of the roof
  841. real albwin_u(nurbm) ! Albedo of the windows
  842. real emwind_u(nurbm) ! Emissivity of windows
  843. real emg_u(nurbm) ! Emissivity of ground
  844. real emw_u(nurbm) ! Emissivity of wall
  845. real emr_u(nurbm) ! Emissivity of roof
  846. ! fww,fwg,fgw,fsw,fsg are the view factors used to compute the long and
  847. ! short wave radation.
  848. ! The calculation of these factor is explained in the Appendix A of the BLM paper
  849. real fww(nz_um,nz_um,ndm,nurbm) ! from wall to wall
  850. real fwg(nz_um,ndm,nurbm) ! from wall to ground
  851. real fgw(nz_um,ndm,nurbm) ! from ground to wall
  852. real fsw(nz_um,ndm,nurbm) ! from sky to wall
  853. real fws(nz_um,ndm,nurbm) ! from wall to sky
  854. real fsg(ndm,nurbm) ! from sky to ground
  855. ! Roughness parameters
  856. real z0g_u(nurbm) ! The ground's roughness length
  857. real z0r_u(nurbm) ! The roof's roughness length
  858. ! Street parameters
  859. integer nd_u(nurbm) ! Number of street direction for each urban class
  860. real strd_u(ndm,nurbm) ! Street length (set to a greater value then the horizontal length of the cells)
  861. real drst_u(ndm,nurbm) ! Street direction
  862. real ws_u(ndm,nurbm) ! Street width
  863. real bs_u(ndm,nurbm) ! Building width
  864. real h_b(nz_um,nurbm) ! Bulding's heights
  865. real d_b(nz_um,nurbm) ! The probability that a building has an height "h_b"
  866. real ss_u(nz_um,nurbm) ! The probability that a building has an height equal to "z"
  867. real pb_u(nz_um,nurbm) ! The probability that a building has an height greater or equal to "z"
  868. ! Grid parameters
  869. integer nz_u(nurbm) ! Number of layer in the urban grid
  870. real z_u(nz_um) ! Height of the urban grid levels
  871. ! MT
  872. real cop_u(nurbm)
  873. real pwin_u(nurbm)
  874. real beta_u(nurbm)
  875. integer sw_cond_u(nurbm)
  876. real time_on_u(nurbm)
  877. real time_off_u(nurbm)
  878. real targtemp_u(nurbm)
  879. real gaptemp_u(nurbm)
  880. real targhum_u(nurbm)
  881. real gaphum_u(nurbm)
  882. real perflo_u(nurbm)
  883. real hsesf_u(nurbm)
  884. real hsequip(24)
  885. ! ----------------------------------------------------------------------
  886. ! INPUT-OUTPUT
  887. ! ----------------------------------------------------------------------
  888. ! Data relative to the "urban grid" which should be stored from the current time step to the next one
  889. real tw(2*ndm,nz_um,nwr_u,nbui_max) ! Temperature in each layer of the wall [K]
  890. real tr(ndm,nz_um,nwr_u) ! Temperature in each layer of the roof [K]
  891. real tg(ndm,ng_u) ! Temperature in each layer of the ground [K]
  892. real sfw(2*ndm,nz_um,nbui_max) ! Sensible heat flux from walls
  893. real sfg(ndm) ! Sensible heat flux from ground (road)
  894. real sfr(ndm,nz_um) ! Sensible heat flux from roofs
  895. real gfg(ndm) ! Heat flux transferred from the surface of the ground (road) towards the interior
  896. real gfr(ndm,nz_um) ! Heat flux transferred from the surface of the roof towards the interior
  897. real gfw(2*ndm,nz_um,nbui_max) ! Heat flux transfered from the surface of the walls towards the interior
  898. ! ----------------------------------------------------------------------
  899. ! OUTPUT:
  900. ! ----------------------------------------------------------------------
  901. ! Data relative to the "mesoscale grid"
  902. real sf(kms:kme) ! Surface of the "mesoscale grid" cells taking into account the buildings
  903. real vl(kms:kme) ! Volume of the "mesoscale grid" cells taking into account the buildings
  904. ! Implicit and explicit components of the source and sink terms at each levels,
  905. ! the fluxes can be computed as follow: FX = A*X + B example: Heat fluxes = a_t * pt + b_t
  906. real a_u(kms:kme) ! Implicit component of the momentum sources or sinks in the X-direction
  907. real a_v(kms:kme) ! Implicit component of the momentum sources or sinks in the Y-direction
  908. real a_t(kms:kme) ! Implicit component of the heat sources or sinks
  909. real a_e(kms:kme) ! Implicit component of the TKE sources or sinks
  910. real b_u(kms:kme) ! Explicit component of the momentum sources or sinks in the X-direction
  911. real b_v(kms:kme) ! Explicit component of the momentum sources or sinks in the Y-direction
  912. real b_t(kms:kme) ! Explicit component of the heat sources or sinks
  913. real b_ac(kms:kme)
  914. real b_e(kms:kme) ! Explicit component of the TKE sources or sinks
  915. real b_q(kms:kme) ! Explicit component of the humidity sources or sinks
  916. real dlg(kms:kme) ! Height above ground (L_ground in formula (24) of the BLM paper).
  917. real dl_u(kms:kme) ! Length scale (lb in formula (22) ofthe BLM paper).
  918. ! ----------------------------------------------------------------------
  919. ! LOCAL:
  920. ! ----------------------------------------------------------------------
  921. real dz(kms:kme) ! vertical space steps of the "mesoscale grid"
  922. ! Data interpolated from the "mesoscale grid" to the "urban grid"
  923. real ua_u(nz_um) ! Wind speed in the x direction
  924. real va_u(nz_um) ! Wind speed in the y direction
  925. real pt_u(nz_um) ! Potential temperature
  926. real da_u(nz_um) ! Air density
  927. real pt0_u(nz_um) ! Reference potential temperature
  928. real pr_u(nz_um) ! Air pressure
  929. real qv_u(nz_um) !Specific humidity
  930. ! Data defining the building and street charateristics
  931. real alag(ng_u) ! Ground thermal diffusivity for the current urban class [m^2 s^-1]
  932. real csg(ng_u) ! Specific heat of the ground material of the current urban class [J m^3 K^-1]
  933. real csr(nwr_u) ! Specific heat of the roof material for the current urban class [J m^3 K^-1]
  934. real csw(nwr_u) ! Specific heat of the wall material for the current urban class [J m^3 K^-1]
  935. real z0(ndm,nz_um) ! Roughness lengths "profiles"
  936. real ws(ndm) ! Street widths of the current urban class
  937. real bs(ndm) ! Building widths of the current urban class
  938. real strd(ndm) ! Street lengths for the current urban class
  939. real drst(ndm) ! Street directions for the current urban class
  940. real ss(nz_um) ! Probability to have a building with height h
  941. real pb(nz_um) ! Probability to have a building with an height equal
  942. ! Solar radiation at each level of the "urban grid"
  943. real rsg(ndm) ! Short wave radiation from the ground
  944. real rsw(2*ndm,nz_um) ! Short wave radiation from the walls
  945. real rlg(ndm) ! Long wave radiation from the ground
  946. real rlw(2*ndm,nz_um) ! Long wave radiation from the walls
  947. ! Potential temperature of the surfaces at each level of the "urban grid"
  948. real ptg(ndm) ! Ground potential temperatures
  949. real ptr(ndm,nz_um) ! Roof potential temperatures
  950. real ptw(2*ndm,nz_um,nbui_max) ! Walls potential temperatures
  951. ! Explicit and implicit component of the momentum, temperature and TKE sources or sinks on
  952. ! vertical surfaces (walls) ans horizontal surfaces (roofs and street)
  953. ! The fluxes can be computed as follow: Fluxes of X = A*X + B
  954. ! Example: Momentum fluxes on vertical surfaces = uva_u * ua_u + uvb_u
  955. real uhb_u(ndm,nz_um) ! U (wind component) Horizontal surfaces, B (explicit) term
  956. real uva_u(2*ndm,nz_um) ! U (wind component) Vertical surfaces, A (implicit) term
  957. real uvb_u(2*ndm,nz_um) ! U (wind component) Vertical surfaces, B (explicit) term
  958. real vhb_u(ndm,nz_um) ! V (wind component) Horizontal surfaces, B (explicit) term
  959. real vva_u(2*ndm,nz_um) ! V (wind component) Vertical surfaces, A (implicit) term
  960. real vvb_u(2*ndm,nz_um) ! V (wind component) Vertical surfaces, B (explicit) term
  961. real thb_u(ndm,nz_um) ! Temperature Horizontal surfaces, B (explicit) term
  962. real tva_u(2*ndm,nz_um) ! Temperature Vertical surfaces, A (implicit) term
  963. real tvb_u(2*ndm,nz_um) ! Temperature Vertical surfaces, B (explicit) term
  964. real tvb_ac(2*ndm,nz_um)
  965. real ehb_u(ndm,nz_um) ! Energy (TKE) Horizontal surfaces, B (explicit) term
  966. real evb_u(2*ndm,nz_um) ! Energy (TKE) Vertical surfaces, B (explicit) term
  967. real qhb_u(ndm,nz_um) ! Humidity Horizontal surfaces, B (explicit) term
  968. real qvb_u(2*ndm,nz_um) ! Humidity Vertical surfaces, B (explicit) term
  969. !
  970. real rs_abs ! solar radiation absorbed by urban surfaces
  971. real rl_up ! longwave radiation emitted by urban surface to the atmosphere
  972. real emiss ! mean emissivity of the urban surface
  973. real grdflx_urb ! ground heat flux
  974. real dt_int ! internal time step
  975. integer nt_int ! number of internal time step
  976. integer iz,id, it_int
  977. integer iw,ix,iy
  978. !---------------------------------------
  979. !New variables uses in BEM
  980. !----------------------------------------
  981. real tmp_u(nz_um) !Air Temperature [K]
  982. real dzw(nwr_u) !Layer sizes in the walls
  983. real dzr(nwr_u) !Layer sizes in the roofs
  984. real dzf(nf_u) !Layer sizes in the floors
  985. real dzgb(ngb_u) !Layer sizes in the ground below the buildings
  986. real csgb(ngb_u) !Specific heat of the ground material below the buildings
  987. !of the current urban class at each ground levels[J m^3 K^-1]
  988. real csf(nf_u) !Specific heat of the floors materials in the buildings
  989. !of the current urban class at each levels[J m^3 K^-1]
  990. real alar(nwr_u+1) ! Roof thermal diffusivity for the current urban class [W/m K]
  991. real alaw(nwr_u+1) ! Walls thermal diffusivity for the current urban class [W/m K]
  992. real alaf(nf_u+1) ! Floor thermal diffusivity at each wall layers [W/m K]
  993. real alagb(ngb_u+1) ! Ground thermal diffusivity below the building at each wall layer [W/m K]
  994. real sfrb(ndm,nbui_max) ! Sensible heat flux from roofs [W/m²]
  995. real gfrb(ndm,nbui_max) ! Heat flux flowing inside the roofs [W/m²]
  996. real sfwb1D(2*ndm,nz_um) !Sensible heat flux from the walls [W/m²]
  997. real sfwin(2*ndm,nz_um,nbui_max)!Sensible heat flux from windows [W/m²]
  998. real sfwinb1D(2*ndm,nz_um) !Sensible heat flux from windows [W/m²]
  999. real gfwb1D(2*ndm,nz_um) !Heat flux flowing inside the walls [W/m²]
  1000. real qlev(nz_um,nbui_max) !specific humidity [kg/kg]
  1001. real qlevb1D(nz_um) !specific humidity [kg/kg]
  1002. real tlev(nz_um,nbui_max) !Indoor temperature [K]
  1003. real tlevb1D(nz_um) !Indoor temperature [K]
  1004. real twb1D(2*ndm,nwr_u,nz_um) !Wall temperature in BEM [K]
  1005. real twlev(2*ndm,nz_um,nbui_max) !Window temperature in BEM [K]
  1006. real twlevb1D(2*ndm,nz_um) !Window temperature in BEM [K]
  1007. real tglev(ndm,ngb_u,nbui_max) !Ground temperature below a building in BEM [K]
  1008. real tglevb1D(ngb_u) !Ground temperature below a building in BEM [K]
  1009. real tflev(ndm,nf_u,nz_um-1,nbui_max)!Floor temperature in BEM[K]
  1010. real tflevb1D(nf_u,nz_um-1) !Floor temperature in BEM[K]
  1011. real trb(ndm,nwr_u,nbui_max) !Roof temperature in BEM [K]
  1012. real trb1D(nwr_u) !Roof temperature in BEM [K]
  1013. real sflev(nz_um,nz_um) ! sensible heat flux due to the air conditioning systems [W]
  1014. real lflev(nz_um,nz_um) ! latent heat flux due to the air conditioning systems [W]
  1015. real consumlev(nz_um,nz_um) ! consumption due to the air conditioning systems [W]
  1016. real sflev1D(nz_um) ! sensible heat flux due to the air conditioning systems [W]
  1017. real lflev1D(nz_um) ! latent heat flux due to the air conditioning systems [W]
  1018. real consumlev1D(nz_um) ! consumption due to the air conditioning systems [W]
  1019. real sfvlev(nz_um,nz_um) ! sensible heat flux due to ventilation [W]
  1020. real lfvlev(nz_um,nz_um) ! latent heat flux due to ventilation [W]
  1021. real sfvlev1D(nz_um) ! sensible heat flux due to ventilation [W]
  1022. real lfvlev1D(nz_um) ! Latent heat flux due to ventilation [W]
  1023. real ptwin(2*ndm,nz_um,nbui_max) ! window potential temperature
  1024. real tw_av(2*ndm,nz_um) ! Averaged temperature of the wall surfaces
  1025. real twlev_av(2*ndm,nz_um) ! Averaged temperature of the windows
  1026. real sfw_av(2*ndm,nz_um) ! Averaged sensible heat from walls
  1027. real sfwind_av(2*ndm,nz_um) ! Averaged sensible heat from windows
  1028. integer nbui !Total number of different type of buildings in an urban class
  1029. integer nlev(nz_um) !Number of levels in each different type of buildings in an urban class
  1030. integer ibui,ily
  1031. real :: nhourday ! Number of hours from midnight, local time
  1032. ! ----------------------------------------------------------------------
  1033. ! END VARIABLES DEFINITIONS
  1034. ! ----------------------------------------------------------------------
  1035. ! Fix some usefull parameters for the computation of the sources or sinks
  1036. !
  1037. !initialize inside param
  1038. !
  1039. ! ss=0.
  1040. ! pb=0.
  1041. do iz=kts,kte
  1042. dz(iz)=z(iz+1)-z(iz)
  1043. end do
  1044. call param(iurb,nz_u(iurb),nd_u(iurb), &
  1045. csg_u,csg,alag_u,alag,csr_u,csr, &
  1046. alar_u,alar,csw_u,csw,alaw_u,alaw, &
  1047. ws_u,ws,bs_u,bs,z0g_u,z0r_u,z0, &
  1048. strd_u,strd,drst_u,drst,ss_u,ss,pb_u,pb, &
  1049. dzw,dzr,dzf,csf,alaf,dzgb,csgb,alagb)
  1050. ! Interpolation on the "urban grid"
  1051. call interpol(kms,kme,kts,kte,nz_u(iurb),z,z_u,ua,ua_u)
  1052. call interpol(kms,kme,kts,kte,nz_u(iurb),z,z_u,va,va_u)
  1053. call interpol(kms,kme,kts,kte,nz_u(iurb),z,z_u,pt,pt_u)
  1054. call interpol(kms,kme,kts,kte,nz_u(iurb),z,z_u,pt0,pt0_u)
  1055. call interpol(kms,kme,kts,kte,nz_u(iurb),z,z_u,pr,pr_u)
  1056. call interpol(kms,kme,kts,kte,nz_u(iurb),z,z_u,da,da_u)
  1057. call interpol(kms,kme,kts,kte,nz_u(iurb),z,z_u,qv,qv_u)
  1058. ! Compute the modification of the radiation due to the buildings
  1059. call averaging_temp(tw,twlev,ss,pb,tw_av,twlev_av, &
  1060. sfw_av,sfwind_av,sfw,sfwin)
  1061. call modif_rad(iurb,nd_u(iurb),nz_u(iurb),z_u,ws, &
  1062. drst,strd,ss,pb, &
  1063. tw_av,tg,twlev_av,albg_u(iurb),albw_u(iurb), &
  1064. emw_u(iurb),emg_u(iurb),pwin_u(iurb),albwin_u(iurb), &
  1065. emwind_u(iurb),fww,fwg,fgw,fsw,fsg, &
  1066. zr,deltar,ah, &
  1067. rs,rld,rsw,rsg,rlw,rlg)
  1068. ! calculation of the urban albedo and the upward long wave radiation
  1069. call upward_rad(nd_u(iurb),nz_u(iurb),ws,bs,sigma,pb,ss, &
  1070. tg,emg_u(iurb),albg_u(iurb),rlg,rsg,sfg, &
  1071. tw_av,emw_u(iurb),albw_u(iurb),rlw,rsw,sfw_av, &
  1072. tr,emr_u(iurb),albr_u(iurb),emwind_u(iurb), &
  1073. albwin_u(iurb),twlev_av,pwin_u(iurb),sfwind_av,rld,rs,sfr, &
  1074. rs_abs,rl_up,emiss,grdflx_urb)
  1075. ! Compute the surface temperatures
  1076. call surf_temp(nd_u(iurb),pr_u,dt, &
  1077. rld,rsg,rlg, &
  1078. tg,alag,csg,emg_u(iurb),albg_u(iurb),ptg,sfg,gfg)
  1079. ! Call the BEM (Building Energy Model) routine
  1080. do iz=1,nz_um !Compute the outdoor temperature
  1081. tmp_u(iz)=pt_u(iz)*(pr_u(iz)/p0)**(rcp_u)
  1082. end do
  1083. ibui=0
  1084. nlev=0
  1085. nbui=0
  1086. sfrb=0. !Sensible heat flux from roof
  1087. gfrb=0. !Heat flux flowing inside the roof
  1088. sfwb1D=0. !Sensible heat flux from walls
  1089. sfwinb1D=0. !Sensible heat flux from windows
  1090. gfwb1D=0. !Heat flux flowing inside the walls[W/m²]
  1091. twb1D=0. !Wall temperature
  1092. twlevb1D=0. !Window temperature
  1093. tglevb1D=0. !Ground temperature below a building
  1094. tflevb1D=0. !Floor temperature
  1095. trb=0. !Roof temperature
  1096. trb1D=0. !Roof temperature
  1097. qlevb1D=0. !Indoor humidity
  1098. tlevb1D=0. !indoor temperature
  1099. sflev1D=0. !Sensible heat flux from the a.c.
  1100. lflev1D=0. !Latent heat flux from the a.c.
  1101. consumlev1D=0.!Consumption from the a.c.
  1102. sfvlev1D=0. !Sensible heat flux from the natural ventilation
  1103. lfvlev1D=0. !Latent heat flux from natural ventilation
  1104. ptw=0. !Wall potential temperature
  1105. ptwin=0. !Window potential temperature
  1106. ptr=0. !Roof potential temperature
  1107. do iz=1,nz_um
  1108. if(ss(iz).gt.0) then
  1109. ibui=ibui+1
  1110. nlev(ibui)=iz-1
  1111. nbui=ibui
  1112. do id=1,ndm
  1113. sfrb(id,ibui)=sfr(id,iz)
  1114. do ily=1,nwr_u
  1115. trb(id,ily,ibui)=tr(id,iz,ily)
  1116. enddo
  1117. enddo
  1118. endif
  1119. end do !iz
  1120. !--------------------------------------------------------------------------------
  1121. !Loop over BEM -----------------------------------------------------------------
  1122. !--------------------------------------------------------------------------------
  1123. !--------------------------------------------------------------------------------
  1124. nhourday=ah/PI*180./15.+12.
  1125. if (nhourday >= 24) nhourday = nhourday - 24
  1126. if (nhourday < 0) nhourday = nhourday + 24
  1127. do ibui=1,nbui
  1128. do iz=1,nz_um
  1129. qlevb1D(iz)=qlev(iz,ibui)
  1130. tlevb1D(iz)=tlev(iz,ibui)
  1131. enddo
  1132. do id=1,ndm
  1133. do ily=1,nwr_u
  1134. trb1D(ily)=trb(id,ily,ibui)
  1135. enddo
  1136. do ily=1,ngb_u
  1137. tglevb1D(ily)=tglev(id,ily,ibui)
  1138. enddo
  1139. do ily=1,nf_u
  1140. do iz=1,nz_um-1
  1141. tflevb1D(ily,iz)=tflev(id,ily,iz,ibui)
  1142. enddo
  1143. enddo
  1144. do iz=1,nz_um
  1145. sfwinb1D(2*id-1,iz)=sfwin(2*id-1,iz,ibui)
  1146. sfwinb1D(2*id,iz)=sfwin(2*id,iz,ibui)
  1147. enddo
  1148. do iz=1,nz_um
  1149. do ily=1,nwr_u
  1150. twb1D(2*id-1,ily,iz)=tw(2*id-1,iz,ily,ibui)
  1151. twb1D(2*id,ily,iz)=tw(2*id,iz,ily,ibui)
  1152. enddo
  1153. sfwb1D(2*id-1,iz)=sfw(2*id-1,iz,ibui)
  1154. sfwb1D(2*id,iz)=sfw(2*id,iz,ibui)
  1155. twlevb1D(2*id-1,iz)=twlev(2*id-1,iz,ibui)
  1156. twlevb1D(2*id,iz)=twlev(2*id,iz,ibui)
  1157. enddo
  1158. enddo
  1159. call BEM(nz_um,nlev(ibui),nhourday,dt,bs_u(1,iurb), &
  1160. bs_u(2,iurb),dz_u,nwr_u,nf_u,nwr_u,ngb_u,sfwb1D,gfwb1D, &
  1161. sfwinb1D,sfrb(1,ibui),gfrb(1,ibui), &
  1162. latent,sigma,albw_u(iurb),albwin_u(iurb),albr_u(iurb), &
  1163. emr_u(iurb),emw_u(iurb),emwind_u(iurb),rsw,rlw,r,cp_u, &
  1164. da_u,tmp_u,qv_u,pr_u,rs,rld,dzw,csw,alaw,pwin_u(iurb), &
  1165. cop_u(iurb),beta_u(iurb),sw_cond_u(iurb),time_on_u(iurb), &
  1166. time_off_u(iurb),targtemp_u(iurb),gaptemp_u(iurb), &
  1167. targhum_u(iurb),gaphum_u(iurb),perflo_u(iurb),hsesf_u(iurb), &
  1168. hsequip, &
  1169. dzf,csf,alaf,dzgb,csgb,alagb,dzr,csr, &
  1170. alar,tlevb1D,qlevb1D,twb1D,twlevb1D,tflevb1D,tglevb1D, &
  1171. trb1D,sflev1D,lflev1D,consumlev1D,sfvlev1D,lfvlev1D)
  1172. !
  1173. !Temporal modifications
  1174. !
  1175. sfrb(2,ibui)=sfrb(1,ibui)
  1176. gfrb(2,ibui)=gfrb(1,ibui)
  1177. !
  1178. !End temporal modifications
  1179. !
  1180. do iz=1,nz_um
  1181. qlev(iz,ibui)=qlevb1D(iz)
  1182. tlev(iz,ibui)=tlevb1D(iz)
  1183. sflev(iz,ibui)=sflev1D(iz)
  1184. lflev(iz,ibui)=lflev1D(iz)
  1185. consumlev(iz,ibui)=consumlev1D(iz)
  1186. sfvlev(iz,ibui)=sfvlev1D(iz)
  1187. lfvlev(iz,ibui)=lfvlev1D(iz)
  1188. enddo
  1189. do id=1,ndm
  1190. do ily=1,nwr_u
  1191. trb(id,ily,ibui)=trb1D(ily)
  1192. enddo
  1193. do ily=1,ngb_u
  1194. tglev(id,ily,ibui)=tglevb1D(ily)
  1195. enddo
  1196. do ily=1,nf_u
  1197. do iz=1,nz_um-1
  1198. tflev(id,ily,iz,ibui)=tflevb1D(ily,iz)
  1199. enddo
  1200. enddo
  1201. do iz=1,nz_um
  1202. do ily=1,nwr_u
  1203. tw(2*id-1,iz,ily,ibui)=twb1D(2*id-1,ily,iz)
  1204. tw(2*id,iz,ily,ibui)=twb1D(2*id,ily,iz)
  1205. enddo
  1206. gfw(2*id-1,iz,ibui)=gfwb1D(2*id-1,iz)
  1207. gfw(2*id,iz,ibui)=gfwb1D(2*id,iz)
  1208. twlev(2*id-1,iz,ibui)=twlevb1D(2*id-1,iz)
  1209. twlev(2*id,iz,ibui)=twlevb1D(2*id,iz)
  1210. enddo
  1211. enddo
  1212. enddo !ibui
  1213. !-----------------------------------------------------------------------------
  1214. !End loop over BEM -----------------------------------------------------------
  1215. !-----------------------------------------------------------------------------
  1216. !-----------------------------------------------------------------------------
  1217. ibui=0
  1218. do iz=1,nz_um
  1219. if(ss(iz).gt.0) then
  1220. ibui=ibui+1
  1221. do id=1,ndm
  1222. gfr(id,iz)=gfrb(id,ibui)
  1223. sfr(id,iz)=sfrb(id,ibui)
  1224. do ily=1,nwr_u
  1225. tr(id,iz,ily)=trb(id,ily,ibui)
  1226. enddo
  1227. ptr(id,iz)=tr(id,iz,nwr_u)*(pr_u(iz)/p0)**(-rcp_u)
  1228. enddo
  1229. endif
  1230. enddo !iz
  1231. !Compute the potential temperature for the vertical surfaces of the buildings
  1232. do id=1,ndm
  1233. do iz=1,nz_um
  1234. do ibui=1,nbui
  1235. ptw(2*id-1,iz,ibui)=tw(2*id-1,iz,nwr_u,ibui)*(pr_u(iz)/p0)**(-rcp_u)
  1236. ptw(2*id,iz,ibui)=tw(2*id,iz,nwr_u,ibui)*(pr_u(iz)/p0)**(-rcp_u)
  1237. ptwin(2*id-1,iz,ibui)=twlev(2*id-1,iz,ibui)*(pr_u(iz)/p0)**(-rcp_u)
  1238. ptwin(2*id,iz,ibui)=twlev(2*id,iz,ibui)*(pr_u(iz)/p0)**(-rcp_u)
  1239. enddo
  1240. enddo
  1241. enddo
  1242. ! Compute the implicit and explicit components of the sources or sinks on the "urban grid"
  1243. call buildings(iurb,nd_u(iurb),nz_u(iurb),z0,ua_u,va_u, &
  1244. pt_u,pt0_u,ptg,ptr,da_u,ptw,ptwin,pwin_u(iurb),drst, &
  1245. uva_u,vva_u,uvb_u,vvb_u,tva_u,tvb_u,evb_u,qvb_u,qhb_u, &
  1246. uhb_u,vhb_u,thb_u,ehb_u,ss,dt,sfw,sfg,sfr, &
  1247. sfwin,pb,bs_u,dz_u,sflev,lflev,sfvlev,lfvlev,tvb_ac)
  1248. ! Calculation of the sensible heat fluxes for the ground, the wall and roof
  1249. ! Sensible Heat Flux = density * Cp_U * ( A* potential temperature + B )
  1250. ! where A and B are the implicit and explicit components of the heat sources or sinks.
  1251. ! Interpolation on the "mesoscale grid"
  1252. call urban_meso(nd_u(iurb),kms,kme,kts,kte,nz_u(iurb),z,dz,z_u,pb,ss,bs,ws,sf, &
  1253. vl,uva_u,vva_u,uvb_u,vvb_u,tva_u,tvb_u,evb_u, &
  1254. uhb_u,vhb_u,thb_u,ehb_u,qhb_u,qvb_u, &
  1255. a_u,a_v,a_t,a_e,b_u,b_v,b_t,b_e,b_q,tvb_ac,b_ac)
  1256. ! Calculation of the length scale taking into account the buildings effects
  1257. call interp_length(nd_u(iurb),kms,kme,kts,kte,nz_u(iurb),z_u,z,ss,ws,bs,dlg,dl_u)
  1258. return
  1259. end subroutine BEP1D
  1260. ! ===6=8===============================================================72
  1261. ! ===6=8===============================================================72
  1262. subroutine param(iurb,nz,nd, &
  1263. csg_u,csg,alag_u,alag,csr_u,csr, &
  1264. alar_u,alar,csw_u,csw,alaw_u,alaw, &
  1265. ws_u,ws,bs_u,bs,z0g_u,z0r_u,z0, &
  1266. strd_u,strd,drst_u,drst,ss_u,ss,pb_u,pb, &
  1267. dzw,dzr,dzf,csf,alaf,dzgb,csgb,alagb)
  1268. ! ----------------------------------------------------------------------
  1269. ! This routine prepare some usefull parameters
  1270. ! ----------------------------------------------------------------------
  1271. implicit none
  1272. ! ----------------------------------------------------------------------
  1273. ! INPUT:
  1274. ! ----------------------------------------------------------------------
  1275. integer iurb ! Current urban class
  1276. integer nz ! Number of vertical urban levels in the current class
  1277. integer nd ! Number of street direction for the current urban class
  1278. real alag_u(nurbm) ! Ground thermal diffusivity [m^2 s^-1]
  1279. real alar_u(nurbm) ! Roof thermal diffusivity [m^2 s^-1]
  1280. real alaw_u(nurbm) ! Wall thermal diffusivity [m^2 s^-1]
  1281. real bs_u(ndm,nurbm) ! Building width
  1282. real csg_u(nurbm) ! Specific heat of the ground material [J m^3 K^-1]
  1283. real csr_u(nurbm) ! Specific heat of the roof material [J m^3 K^-1]
  1284. real csw_u(nurbm) ! Specific heat of the wall material [J m^3 K^-1]
  1285. real drst_u(ndm,nurbm) ! Street direction
  1286. real strd_u(ndm,nurbm) ! Street length
  1287. real ws_u(ndm,nurbm) ! Street width
  1288. real z0g_u(nurbm) ! The ground's roughness length
  1289. real z0r_u(nurbm) ! The roof's roughness length
  1290. real ss_u(nz_um,nurbm) ! The probability that a building has an height equal to "z"
  1291. real pb_u(nz_um,nurbm) ! The probability that a building has an height greater or equal to "z"
  1292. ! ----------------------------------------------------------------------
  1293. ! OUTPUT:
  1294. ! ----------------------------------------------------------------------
  1295. real alag(ng_u) ! Ground thermal diffusivity at each ground levels
  1296. real csg(ng_u) ! Specific heat of the ground material at each ground levels
  1297. real bs(ndm) ! Building width for the current urban class
  1298. real drst(ndm) ! street directions for the current urban class
  1299. real strd(ndm) ! Street lengths for the current urban class
  1300. real ws(ndm) ! Street widths of the current urban class
  1301. real z0(ndm,nz_um) ! Roughness lengths "profiles"
  1302. real ss(nz_um) ! Probability to have a building with height h
  1303. real pb(nz_um) ! Probability to have a building with an height greater or equal to "z"
  1304. !-----------------------------------------------------------------------------
  1305. !INPUT/OUTPUT
  1306. !-----------------------------------------------------------------------------
  1307. real dzw(nwr_u) !Layer sizes in the walls [m]
  1308. real dzr(nwr_u) !Layer sizes in the roofs [m]
  1309. real dzf(nf_u) !Layer sizes in the floors [m]
  1310. real dzgb(ngb_u) !layer sizes in the ground below the buildings [m]
  1311. real csr(nwr_u) ! Specific heat of the roof material at each roof levels
  1312. real csw(nwr_u) ! Specific heat of the wall material at each wall levels
  1313. real csf(nf_u) !Specific heat of the floors materials in the buildings
  1314. !of the current urban class [J m^3 K^-1]
  1315. real csgb(ngb_u) !Specific heat of the ground material below the buildings
  1316. !of the current urban class [J m^3 K^-1]
  1317. real alar(nwr_u+1) ! Roof thermal diffusivity at each roof levels [W/ m K]
  1318. real alaw(nwr_u+1) ! Wall thermal diffusivity at each wall levels [W/ m K]
  1319. real alaf(nf_u+1) ! Floor thermal diffusivity at each wall levels [W/m K]
  1320. real alagb(ngb_u+1) ! Ground thermal diffusivity below the building at each wall levels [W/m K]
  1321. ! ----------------------------------------------------------------------
  1322. ! LOCAL:
  1323. ! ----------------------------------------------------------------------
  1324. integer id,ig,ir,iw,iz,iflo
  1325. ! ----------------------------------------------------------------------
  1326. ! END VARIABLES DEFINITIONS
  1327. ! ----------------------------------------------------------------------
  1328. !Define the layer sizes in the walls
  1329. ss=0.
  1330. pb=0.
  1331. csg=0.
  1332. alag=0.
  1333. csr=0.
  1334. alar=0.
  1335. csw=0.
  1336. alaw=0.
  1337. z0=0.
  1338. ws=0.
  1339. bs=0.
  1340. strd=0.
  1341. drst=0.
  1342. csgb=0.
  1343. alagb=0.
  1344. csf=0.
  1345. alaf=0.
  1346. dzgb=(/0.2,0.12,0.08,0.05,0.03,0.02,0.02,0.01,0.005,0.0025/)
  1347. dzr=(/0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.01,0.005,0.0025/)
  1348. dzw=(/0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.01,0.005,0.0025/)
  1349. dzf=(/0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02/)
  1350. do ig=1,ngb_u
  1351. csgb(ig) = csg_u(iurb)
  1352. alagb(ig)= csg_u(iurb)*alag_u(iurb)
  1353. enddo
  1354. alagb(ngb_u+1)= csg_u(iurb)*alag_u(iurb)
  1355. do iflo=1,nf_u
  1356. csf(iflo) = csw_u(iurb)
  1357. alaf(iflo)= csw_u(iurb)*alaw_u(iurb)
  1358. enddo
  1359. alaf(nf_u+1)= csw_u(iurb)*alaw_u(iurb)
  1360. do ir=1,nwr_u
  1361. csr(ir) = csr_u(iurb)
  1362. alar(ir)= csr_u(iurb)*alar_u(iurb)
  1363. enddo
  1364. alar(nwr_u+1)= csr_u(iurb)*alar_u(iurb)
  1365. do iw=1,nwr_u
  1366. csw(iw) = csw_u(iurb)
  1367. alaw(iw)= csw_u(iurb)*alaw_u(iurb)
  1368. enddo
  1369. alaw(nwr_u+1)=csw_u(iurb)*alaw_u(iurb)
  1370. !------------------------------------------------------------------------
  1371. do iz=1,nz+1
  1372. ss(iz)=ss_u(iz,iurb)
  1373. pb(iz)=pb_u(iz,iurb)
  1374. end do
  1375. do ig=1,ng_u
  1376. csg(ig)=csg_u(iurb)
  1377. alag(ig)=alag_u(iurb)
  1378. enddo
  1379. do id=1,nd
  1380. z0(id,1)=z0g_u(iurb)
  1381. do iz=2,nz+1
  1382. z0(id,iz)=z0r_u(iurb)
  1383. enddo
  1384. enddo
  1385. do id=1,nd
  1386. ws(id)=ws_u(id,iurb)
  1387. bs(id)=bs_u(id,iurb)
  1388. strd(id)=strd_u(id,iurb)
  1389. drst(id)=drst_u(id,iurb)
  1390. enddo
  1391. return
  1392. end subroutine param
  1393. ! ===6=8===============================================================72
  1394. ! ===6=8===============================================================72
  1395. subroutine interpol(kms,kme,kts,kte,nz_u,z,z_u,c,c_u)
  1396. ! ----------------------------------------------------------------------
  1397. ! This routine interpolate para
  1398. ! meters from the "mesoscale grid" to
  1399. ! the "urban grid".
  1400. ! See p300 Appendix B.1 of the BLM paper.
  1401. ! ----------------------------------------------------------------------
  1402. implicit none
  1403. ! ----------------------------------------------------------------------
  1404. ! INPUT:
  1405. ! ----------------------------------------------------------------------
  1406. ! Data relative to the "mesoscale grid"
  1407. integer kts,kte,kms,kme
  1408. real z(kms:kme) ! Altitude of the cell interface
  1409. real c(kms:kme) ! Parameter which has to be interpolated
  1410. ! Data relative to the "urban grid"
  1411. integer nz_u ! Number of levels
  1412. real z_u(nz_um) ! Altitude of the cell interface
  1413. ! ----------------------------------------------------------------------
  1414. ! OUTPUT:
  1415. ! ----------------------------------------------------------------------
  1416. real c_u(nz_um) ! Interpolated paramters in the "urban grid"
  1417. ! LOCAL:
  1418. ! ----------------------------------------------------------------------
  1419. integer iz_u,iz
  1420. real ctot,dz
  1421. ! ----------------------------------------------------------------------
  1422. ! END VARIABLES DEFINITIONS
  1423. ! ----------------------------------------------------------------------
  1424. do iz_u=1,nz_u
  1425. ctot=0.
  1426. do iz=kts,kte
  1427. dz=max(min(z(iz+1),z_u(iz_u+1))-max(z(iz),z_u(iz_u)),0.)
  1428. ctot=ctot+c(iz)*dz
  1429. enddo
  1430. c_u(iz_u)=ctot/(z_u(iz_u+1)-z_u(iz_u))
  1431. enddo
  1432. return
  1433. end subroutine interpol
  1434. ! ===6=8===============================================================72
  1435. ! ===6=8===============================================================72
  1436. subroutine averaging_temp(tw,twlev,ss,pb,tw_av,twlev_av,&
  1437. sfw_av,sfwind_av,sfw,sfwin)
  1438. implicit none
  1439. !
  1440. !INPUT VARIABLES
  1441. !
  1442. real tw(2*ndm,nz_um,nwr_u,nbui_max) ! Temperature in each layer of the wall [K]
  1443. real twlev(2*ndm,nz_um,nbui_max) ! Window temperature in BEM [K]
  1444. real pb(nz_um) ! Probability to have a building with an height equal or greater h
  1445. real ss(nz_um) ! Probability to have a building with height h
  1446. real sfw(2*ndm,nz_um,nbui_max) ! Surface fluxes from the walls
  1447. real sfwin(2*ndm,nz_um,nbui_max) ! Surface fluxes from the windows
  1448. !
  1449. !OUTPUT VARIABLES
  1450. !
  1451. real tw_av(2*ndm,nz_um) ! Averaged temperature of the wall surfaces
  1452. real twlev_av(2*ndm,nz_um) ! Averaged temperature of the windows
  1453. real sfw_av(2*ndm,nz_um) ! Averaged sensible heat from walls
  1454. real sfwind_av(2*ndm,nz_um) ! Averaged sensible heat from windows
  1455. !
  1456. !LOCAL VARIABLES
  1457. !
  1458. real d_urb(nz_um)
  1459. integer nlev(nz_um)
  1460. integer id,iz
  1461. integer nbui,ibui
  1462. !
  1463. !Initialize Variables
  1464. !
  1465. tw_av=0.
  1466. twlev_av=0.
  1467. sfw_av=0.
  1468. sfwind_av=0.
  1469. ibui=0
  1470. nbui=0
  1471. nlev=0
  1472. d_urb=0.
  1473. do iz=1,nz_um
  1474. if(ss(iz).gt.0) then
  1475. ibui=ibui+1
  1476. d_urb(ibui)=ss(iz)
  1477. nlev(ibui)=iz-1
  1478. nbui=ibui
  1479. endif
  1480. enddo
  1481. do id=1,ndm
  1482. do iz=1,nz_um-1
  1483. if (pb(iz+1).gt.0) then
  1484. do ibui=1,nbui
  1485. if (iz.le.nlev(ibui)) then
  1486. tw_av(2*id-1,iz)=tw_av(2*id-1,iz)+(d_urb(ibui)/pb(iz+1))*&
  1487. tw(2*id-1,iz,nwr_u,ibui)**4
  1488. tw_av(2*id,iz)=tw_av(2*id,iz)+(d_urb(ibui)/pb(iz+1))*&
  1489. tw(2*id,iz,nwr_u,ibui)**4
  1490. twlev_av(2*id-1,iz)=twlev_av(2*id-1,iz)+(d_urb(ibui)/pb(iz+1))*&
  1491. twlev(2*id-1,iz,ibui)**4
  1492. twlev_av(2*id,iz)=twlev_av(2*id,iz)+(d_urb(ibui)/pb(iz+1))*&
  1493. twlev(2*id,iz,ibui)**4
  1494. sfw_av(2*id-1,iz)=sfw_av(2*id-1,iz)+(d_urb(ibui)/pb(iz+1))*sfw(2*id-1,iz,ibui)
  1495. sfw_av(2*id,iz)=sfw_av(2*id,iz)+(d_urb(ibui)/pb(iz+1))*sfw(2*id,iz,ibui)
  1496. sfwind_av(2*id-1,iz)=sfwind_av(2*id-1,iz)+(d_urb(ibui)/pb(iz+1))*sfwin(2*id-1,iz,ibui)
  1497. sfwind_av(2*id,iz)=sfwind_av(2*id,iz)+(d_urb(ibui)/pb(iz+1))*sfwin(2*id,iz,ibui)
  1498. endif
  1499. enddo
  1500. tw_av(2*id-1,iz)=tw_av(2*id-1,iz)**(1./4.)
  1501. tw_av(2*id,iz)=tw_av(2*id,iz)**(1./4.)
  1502. twlev_av(2*id-1,iz)=twlev_av(2*id-1,iz)**(1./4.)
  1503. twlev_av(2*id,iz)=twlev_av(2*id,iz)**(1./4.)
  1504. endif
  1505. enddo !iz
  1506. enddo !id
  1507. return
  1508. end subroutine averaging_temp
  1509. ! ===6=8===============================================================72
  1510. ! ===6=8===============================================================72
  1511. subroutine modif_rad(iurb,nd,nz_u,z,ws,drst,strd,ss,pb, &
  1512. tw,tg,twlev,albg,albw,emw,emg,pwin,albwin, &
  1513. emwin,fww,fwg,fgw,fsw,fsg, &
  1514. zr,deltar,ah, &
  1515. rs,rl,rsw,rsg,rlw,rlg)
  1516. ! ----------------------------------------------------------------------
  1517. ! This routine computes the modification of the short wave and
  1518. ! long wave radiation due to the buildings.
  1519. ! ----------------------------------------------------------------------
  1520. implicit none
  1521. ! ----------------------------------------------------------------------
  1522. ! INPUT:
  1523. ! ----------------------------------------------------------------------
  1524. integer iurb ! current urban class
  1525. integer nd ! Number of street direction for the current urban class
  1526. integer nz_u ! Number of layer in the urban grid
  1527. real z(nz_um) ! Height of the urban grid levels
  1528. real ws(ndm) ! Street widths of the current urban class
  1529. real drst(ndm) ! street directions for the current urban class
  1530. real strd(ndm) ! Street lengths for the current urban class
  1531. real ss(nz_um) ! probability to have a building with height h
  1532. real pb(nz_um) ! probability to have a building with an height equal
  1533. real tw(2*ndm,nz_um) ! Temperature in each layer of the wall [K]
  1534. real tg(ndm,ng_u) ! Temperature in each layer of the ground [K]
  1535. real albg ! Albedo of the ground for the current urban class
  1536. real albw ! Albedo of the wall for the current urban class
  1537. real emg ! Emissivity of ground for the current urban class
  1538. real emw ! Emissivity of wall for the current urban class
  1539. real fgw(nz_um,ndm,nurbm) ! View factors from ground to wall
  1540. real fsg(ndm,nurbm) ! View factors from sky to ground
  1541. real fsw(nz_um,ndm,nurbm) ! View factors from sky to wall
  1542. real fws(nz_um,ndm,nurbm) ! View factors from wall to sky
  1543. real fwg(nz_um,ndm,nurbm) ! View factors from wall to ground
  1544. real fww(nz_um,nz_um,ndm,nurbm) ! View factors from wall to wall
  1545. real ah ! Hour angle (it should come from the radiation routine)
  1546. real zr ! zenith angle
  1547. real deltar ! Declination of the sun
  1548. real rs ! solar radiation
  1549. real rl ! downward flux of the longwave radiation
  1550. !
  1551. !New variables BEM
  1552. !
  1553. real twlev(2*ndm,nz_um) ! Window temperature in BEM [K]
  1554. real pwin ! Coverage area fraction of windows in the walls of the buildings
  1555. real albwin ! Albedo of the windows for the current urban class
  1556. real emwin ! Emissivity of the windows for the current urban class
  1557. real alb_av ! Averaged albedo (window and wall)
  1558. ! ----------------------------------------------------------------------
  1559. ! OUTPUT:
  1560. ! ----------------------------------------------------------------------
  1561. real rlg(ndm) ! Long wave radiation at the ground
  1562. real rlw(2*ndm,nz_um) ! Long wave radiation at the walls
  1563. real rsg(ndm) ! Short wave radiation at the ground
  1564. real rsw(2*ndm,nz_um) ! Short wave radiation at the walls
  1565. ! ----------------------------------------------------------------------
  1566. ! LOCAL:
  1567. ! ----------------------------------------------------------------------
  1568. integer id,iz
  1569. ! Calculation of the shadow effects
  1570. call shadow_mas(nd,nz_u,zr,deltar,ah,drst,ws,ss,pb,z, &
  1571. rs,rsw,rsg)
  1572. ! Calculation of the reflection effects
  1573. do id=1,nd
  1574. call long_rad(iurb,nz_u,id,emw,emg,emwin,pwin,twlev, &
  1575. fwg,fww,fgw,fsw,fsg,tg,tw,rlg,rlw,rl,pb)
  1576. alb_av=pwin*albwin+(1.-pwin)*albw
  1577. call short_rad(iurb,nz_u,id,alb_av,albg,fwg,fww,fgw,rsg,rsw,pb)
  1578. enddo
  1579. return
  1580. end subroutine modif_rad
  1581. ! ===6=8===============================================================72
  1582. ! ===6=8===============================================================72
  1583. subroutine surf_temp(nd,pr,dt,rl,rsg,rlg, &
  1584. tg,alag,csg,emg,albg,ptg,sfg,gfg)
  1585. ! ----------------------------------------------------------------------
  1586. ! Computation of the surface temperatures for walls, ground and roofs
  1587. ! ----------------------------------------------------------------------
  1588. implicit none
  1589. ! ----------------------------------------------------------------------
  1590. ! INPUT:
  1591. ! ----------------------------------------------------------------------
  1592. integer nd ! Number of street direction for the current urban class
  1593. real alag(ng_u) ! Ground thermal diffusivity for the current urban class [m^2 s^-1]
  1594. real albg ! Albedo of the ground for the current urban class
  1595. real csg(ng_u) ! Specific heat of the ground material of the current urban class [J m^3 K^-1]
  1596. real dt ! Time step
  1597. real emg ! Emissivity of ground for the current urban class
  1598. real pr(nz_um) ! Air pressure
  1599. real rl ! Downward flux of the longwave radiation
  1600. real rlg(ndm) ! Long wave radiation at the ground
  1601. real rsg(ndm) ! Short wave radiation at the ground
  1602. real sfg(ndm) ! Sensible heat flux from ground (road)
  1603. real gfg(ndm) ! Heat flux transferred from the surface of the ground (road) toward the interior
  1604. real tg(ndm,ng_u) ! Temperature in each layer of the ground [K]
  1605. ! ----------------------------------------------------------------------
  1606. ! OUTPUT:
  1607. ! ----------------------------------------------------------------------
  1608. real ptg(ndm) ! Ground potential temperatures
  1609. ! ----------------------------------------------------------------------
  1610. ! LOCAL:
  1611. ! ----------------------------------------------------------------------
  1612. integer id,ig,ir,iw,iz
  1613. real rtg(ndm) ! Total radiation at ground(road) surface (solar+incoming long+outgoing long)
  1614. real tg_tmp(ng_u)
  1615. real dzg_u(ng_u) ! Layer sizes in the ground
  1616. data dzg_u /0.2,0.12,0.08,0.05,0.03,0.02,0.02,0.01,0.005,0.0025/
  1617. ! ----------------------------------------------------------------------
  1618. ! END VARIABLES DEFINITIONS
  1619. ! ----------------------------------------------------------------------
  1620. do id=1,nd
  1621. ! Calculation for the ground surfaces
  1622. do ig=1,ng_u
  1623. tg_tmp(ig)=tg(id,ig)
  1624. end do
  1625. !
  1626. call soil_temp(ng_u,dzg_u,tg_tmp,ptg(id),alag,csg, &
  1627. rsg(id),rlg(id),pr(1), &
  1628. dt,emg,albg, &
  1629. rtg(id),sfg(id),gfg(id))
  1630. do ig=1,ng_u
  1631. tg(id,ig)=tg_tmp(ig)
  1632. end do
  1633. end do !id
  1634. return
  1635. end subroutine surf_temp
  1636. ! ===6=8===============================================================72
  1637. ! ===6=8===============================================================72
  1638. subroutine buildings(iurb,nd,nz,z0,ua_u,va_u,pt_u,pt0_u, &
  1639. ptg,ptr,da_u,ptw,ptwin,pwin, &
  1640. drst,uva_u,vva_u,uvb_u,vvb_u, &
  1641. tva_u,tvb_u,evb_u,qvb_u,qhb_u, &
  1642. uhb_u,vhb_u,thb_u,ehb_u,ss,dt,sfw,sfg,sfr, &
  1643. sfwin,pb,bs_u,dz_u,sflev,lflev,sfvlev,lfvlev,tvb_ac)
  1644. ! ----------------------------------------------------------------------
  1645. ! This routine computes the sources or sinks of the different quantities
  1646. ! on the urban grid. The actual calculation is done in the subroutines
  1647. ! called flux_wall, and flux_flat.
  1648. ! ----------------------------------------------------------------------
  1649. implicit none
  1650. ! ----------------------------------------------------------------------
  1651. ! INPUT:
  1652. ! ----------------------------------------------------------------------
  1653. integer nd ! Number of street direction for the current urban class
  1654. integer nz ! number of vertical space steps
  1655. real ua_u(nz_um) ! Wind speed in the x direction on the urban grid
  1656. real va_u(nz_um) ! Wind speed in the y direction on the urban grid
  1657. real da_u(nz_um) ! air density on the urban grid
  1658. real drst(ndm) ! Street directions for the current urban class
  1659. real dz
  1660. real pt_u(nz_um) ! Potential temperature on the urban grid
  1661. real pt0_u(nz_um) ! reference potential temperature on the urban grid
  1662. real ptg(ndm) ! Ground potential temperatures
  1663. real ptr(ndm,nz_um) ! Roof potential temperatures
  1664. real ptw(2*ndm,nz_um,nbui_max) ! Walls potential temperatures
  1665. real ss(nz_um) ! probability to have a building with height h
  1666. real pb(nz_um)
  1667. real z0(ndm,nz_um) ! Roughness lengths "profiles"
  1668. real dt ! time step
  1669. integer iurb !Urban class
  1670. !
  1671. !New variables (BEM)
  1672. !
  1673. real bs_u(ndm,nurbm) ! Building width [m]
  1674. real dz_u ! Urban grid resolution
  1675. real sflev(nz_um,nz_um) ! sensible heat flux due to the air conditioning systems [W]
  1676. real lflev(nz_um,nz_um) ! latent heat flux due to the air conditioning systems [W]
  1677. real sfvlev(nz_um,nz_um) ! sensible heat flux due to ventilation [W]
  1678. real lfvlev(nz_um,nz_um) ! latent heat flux due to ventilation [W]
  1679. real qvb_u(2*ndm,nz_um)
  1680. real qhb_u(ndm,nz_um)
  1681. real ptwin(2*ndm,nz_um,nbui_max) ! window potential temperature
  1682. real pwin
  1683. real tvb_ac(2*ndm,nz_um)
  1684. ! ----------------------------------------------------------------------
  1685. ! OUTPUT:
  1686. ! ----------------------------------------------------------------------
  1687. ! Explicit and implicit component of the momentum, temperature and TKE sources or sinks on
  1688. ! vertical surfaces (walls) and horizontal surfaces (roofs and street)
  1689. ! The fluxes can be computed as follow: Fluxes of X = A*X + B
  1690. ! Example: Momentum fluxes on vertical surfaces = uva_u * ua_u + uvb_u
  1691. real uhb_u(ndm,nz_um) ! U (wind component) Horizontal surfaces, B (explicit) term
  1692. real uva_u(2*ndm,nz_um) ! U (wind component) Vertical surfaces, A (implicit) term
  1693. real uvb_u(2*ndm,nz_um) ! U (wind component) Vertical surfaces, B (explicit) term
  1694. real vhb_u(ndm,nz_um) ! V (wind component) Horizontal surfaces, B (explicit) term
  1695. real vva_u(2*ndm,nz_um) ! V (wind component) Vertical surfaces, A (implicit) term
  1696. real vvb_u(2*ndm,nz_um) ! V (wind component) Vertical surfaces, B (explicit) term
  1697. real thb_u(ndm,nz_um) ! Temperature Horizontal surfaces, B (explicit) term
  1698. real tva_u(2*ndm,nz_um) ! Temperature Vertical surfaces, A (implicit) term
  1699. real tvb_u(2*ndm,nz_um) ! Temperature Vertical surfaces, B (explicit) term
  1700. real ehb_u(ndm,nz_um) ! Energy (TKE) Horizontal surfaces, B (explicit) term
  1701. real evb_u(2*ndm,nz_um) ! Energy (TKE) Vertical surfaces, B (explicit) term
  1702. real sfw(2*ndm,nz_um,nbui_max) ! sensible heat flux from walls
  1703. real sfwin(2*ndm,nz_um,nbui_max) ! sensible heat flux form windows
  1704. real sfr(ndm,nz_um) ! sensible heat flux from roof
  1705. real sfg(ndm) ! sensible heat flux from street
  1706. ! ----------------------------------------------------------------------
  1707. ! LOCAL:
  1708. ! ----------------------------------------------------------------------
  1709. real d_urb(nz_um)
  1710. real uva_tmp
  1711. real vva_tmp
  1712. real uvb_tmp
  1713. real vvb_tmp
  1714. real evb_tmp
  1715. integer nlev(nz_um)
  1716. integer id,iz,ibui,nbui
  1717. ! ----------------------------------------------------------------------
  1718. ! END VARIABLES DEFINITIONS
  1719. ! ----------------------------------------------------------------------
  1720. dz=dz_u
  1721. ibui=0
  1722. nbui=0
  1723. nlev=0
  1724. d_urb=0.
  1725. uva_u=0.
  1726. uvb_u=0.
  1727. vhb_u=0.
  1728. vva_u=0.
  1729. vvb_u=0.
  1730. thb_u=0.
  1731. tva_u=0.
  1732. tvb_u=0.
  1733. tvb_ac=0.
  1734. ehb_u=0.
  1735. evb_u=0.
  1736. qvb_u=0.
  1737. qhb_u=0.
  1738. do iz=1,nz_um
  1739. if(ss(iz).gt.0) then
  1740. ibui=ibui+1
  1741. d_urb(ibui)=ss(iz)
  1742. nlev(ibui)=iz-1
  1743. nbui=ibui
  1744. endif
  1745. enddo
  1746. if (nbui.gt.nbui_max) then
  1747. write(*,*) 'nbui_max must be increased to',nbui
  1748. stop
  1749. endif
  1750. do id=1,nd
  1751. ! Calculation at the ground surfaces
  1752. call flux_flat(dz,z0(id,1),ua_u(1),va_u(1),pt_u(1),pt0_u(1), &
  1753. ptg(id),uhb_u(id,1), &
  1754. vhb_u(id,1),sfg(id),ehb_u(id,1),da_u(1))
  1755. thb_u(id,1)=- sfg(id)/(da_u(1)*cp_u)
  1756. ! Calculation at the roof surfaces
  1757. do iz=2,nz
  1758. if(ss(iz).gt.0)then
  1759. call flux_flat(dz,z0(id,iz),ua_u(iz), &
  1760. va_u(iz),pt_u(iz),pt0_u(iz), &
  1761. ptr(id,iz),uhb_u(id,iz), &
  1762. vhb_u(id,iz),sfr(id,iz),ehb_u(id,iz),da_u(iz))
  1763. thb_u(id,iz)=- sfr(id,iz)/(da_u(iz)*cp_u)
  1764. else
  1765. uhb_u(id,iz) = 0.0
  1766. vhb_u(id,iz) = 0.0
  1767. thb_u(id,iz) = 0.0
  1768. ehb_u(id,iz) = 0.0
  1769. endif
  1770. end do
  1771. ! Calculation at the wall surfaces
  1772. do ibui=1,nbui
  1773. do iz=1,nlev(ibui)
  1774. call flux_wall(ua_u(iz),va_u(iz),pt_u(iz),da_u(iz), &
  1775. ptw(2*id-1,iz,ibui),ptwin(2*id-1,iz,ibui), &
  1776. uva_tmp,vva_tmp, &
  1777. uvb_tmp,vvb_tmp, &
  1778. sfw(2*id-1,iz,ibui),sfwin(2*id-1,iz,ibui), &
  1779. evb_tmp,drst(id),dt)
  1780. if (pb(iz+1).gt.0.) then
  1781. uva_u(2*id-1,iz)=uva_u(2*id-1,iz)+d_urb(ibui)/pb(iz+1)*uva_tmp
  1782. vva_u(2*id-1,iz)=vva_u(2*id-1,iz)+d_urb(ibui)/pb(iz+1)*vva_tmp
  1783. uvb_u(2*id-1,iz)=uvb_u(2*id-1,iz)+d_urb(ibui)/pb(iz+1)*uvb_tmp
  1784. vvb_u(2*id-1,iz)=vvb_u(2*id-1,iz)+d_urb(ibui)/pb(iz+1)*vvb_tmp
  1785. evb_u(2*id-1,iz)=evb_u(2*id-1,iz)+d_urb(ibui)/pb(iz+1)*evb_tmp
  1786. tvb_u(2*id-1,iz)=tvb_u(2*id-1,iz)-(d_urb(ibui)/pb(iz+1))* &
  1787. (sfw(2*id-1,iz,ibui)*(1.-pwin)+sfwin(2*id-1,iz,ibui)*pwin)/ &
  1788. da_u(iz)/cp_u-(1./4.)*(d_urb(ibui)/pb(iz+1))*(sfvlev(iz,ibui)-sflev(iz,ibui))/&
  1789. (dz*bs_u(id,iurb))/da_u(iz)/cp_u
  1790. tvb_ac(2*id-1,iz)=tvb_ac(2*id-1,iz)-(1./4.)*(d_urb(ibui)/pb(iz+1))*(-sflev(iz,ibui))/&
  1791. (dz*bs_u(id,iurb))/da_u(iz)/cp_u
  1792. 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))/&
  1793. (dz*bs_u(id,iurb))/da_u(iz)/latent
  1794. endif
  1795. call flux_wall(ua_u(iz),va_u(iz),pt_u(iz),da_u(iz), &
  1796. ptw(2*id,iz,ibui),ptwin(2*id,iz,ibui), &
  1797. uva_tmp,vva_tmp, &
  1798. uvb_tmp,vvb_tmp, &
  1799. sfw(2*id,iz,ibui),sfwin(2*id,iz,ibui), &
  1800. evb_tmp,drst(id),dt)
  1801. if (pb(iz+1).gt.0.) then
  1802. uva_u(2*id,iz)=uva_u(2*id,iz)+d_urb(ibui)/pb(iz+1)*uva_tmp
  1803. vva_u(2*id,iz)=vva_u(2*id,iz)+d_urb(ibui)/pb(iz+1)*vva_tmp
  1804. uvb_u(2*id,iz)=uvb_u(2*id,iz)+d_urb(ibui)/pb(iz+1)*uvb_tmp
  1805. vvb_u(2*id,iz)=vvb_u(2*id,iz)+d_urb(ibui)/pb(iz+1)*vvb_tmp
  1806. evb_u(2*id,iz)=evb_u(2*id,iz)+d_urb(ibui)/pb(iz+1)*evb_tmp
  1807. tvb_u(2*id,iz)=tvb_u(2*id,iz)-(d_urb(ibui)/pb(iz+1))* &
  1808. (sfw(2*id,iz,ibui)*(1.-pwin)+sfwin(2*id,iz,ibui)*pwin)/ &
  1809. da_u(iz)/cp_u-(1./4.)*(d_urb(ibui)/pb(iz+1))*(sfvlev(iz,ibui)-sflev(iz,ibui))/&
  1810. (dz*bs_u(id,iurb))/da_u(iz)/cp_u
  1811. tvb_ac(2*id,iz)=tvb_ac(2*id,iz)-(1./4.)*(d_urb(ibui)/pb(iz+1))*(-sflev(iz,ibui))/&
  1812. (dz*bs_u(id,iurb))/da_u(iz)/cp_u
  1813. qvb_u(2*id,iz)=qvb_u(2*id,iz)-(1./4.)*(d_urb(ibui)/pb(iz+1))*(lfvlev(iz,ibui)-lflev(iz,ibui))/&
  1814. (dz*bs_u(id,iurb))/da_u(iz)/latent
  1815. endif
  1816. !
  1817. enddo !iz
  1818. enddo !ibui
  1819. end do !id
  1820. return
  1821. end subroutine buildings
  1822. ! ===6=8===============================================================72
  1823. ! ===6=8===============================================================72
  1824. subroutine urban_meso(nd,kms,kme,kts,kte,nz_u,z,dz,z_u,pb,ss,bs,ws,sf,vl, &
  1825. uva_u,vva_u,uvb_u,vvb_u,tva_u,tvb_u,evb_u, &
  1826. uhb_u,vhb_u,thb_u,ehb_u,qhb_u,qvb_u, &
  1827. a_u,a_v,a_t,a_e,b_u,b_v,b_t,b_e,b_q,tvb_ac,b_ac)
  1828. ! ----------------------------------------------------------------------
  1829. ! This routine interpolates the parameters from the "urban grid" to the
  1830. ! "mesoscale grid".
  1831. ! See p300-301 Appendix B.2 of the BLM paper.
  1832. ! ----------------------------------------------------------------------
  1833. implicit none
  1834. ! ----------------------------------------------------------------------
  1835. ! INPUT:
  1836. ! ----------------------------------------------------------------------
  1837. ! Data relative to the "mesoscale grid"
  1838. integer kms,kme,kts,kte
  1839. real z(kms:kme) ! Altitude above the ground of the cell interface
  1840. real dz(kms:kme) ! Vertical space steps
  1841. ! Data relative to the "uban grid"
  1842. integer nz_u ! Number of layer in the urban grid
  1843. integer nd ! Number of street direction for the current urban class
  1844. real bs(ndm) ! Building widths of the current urban class
  1845. real ws(ndm) ! Street widths of the current urban class
  1846. real z_u(nz_um) ! Height of the urban grid levels
  1847. real pb(nz_um) ! Probability to have a building with an height equal
  1848. real ss(nz_um) ! Probability to have a building with height h
  1849. real uhb_u(ndm,nz_um) ! U (x-wind component) Horizontal surfaces, B (explicit) term
  1850. real uva_u(2*ndm,nz_um) ! U (x-wind component) Vertical surfaces, A (implicit) term
  1851. real uvb_u(2*ndm,nz_um) ! U (x-wind component) Vertical surfaces, B (explicit) term
  1852. real vhb_u(ndm,nz_um) ! V (y-wind component) Horizontal surfaces, B (explicit) term
  1853. real vva_u(2*ndm,nz_um) ! V (y-wind component) Vertical surfaces, A (implicit) term
  1854. real vvb_u(2*ndm,nz_um) ! V (y-wind component) Vertical surfaces, B (explicit) term
  1855. real thb_u(ndm,nz_um) ! Temperature Horizontal surfaces, B (explicit) term
  1856. real tva_u(2*ndm,nz_um) ! Temperature Vertical surfaces, A (implicit) term
  1857. real tvb_u(2*ndm,nz_um) ! Temperature Vertical surfaces, B (explicit) term
  1858. real tvb_ac(2*ndm,nz_um)
  1859. real ehb_u(ndm,nz_um) ! Energy (TKE) Horizontal surfaces, B (explicit) term
  1860. real evb_u(2*ndm,nz_um) ! Energy (TKE) Vertical surfaces, B (explicit) term
  1861. !
  1862. !New variables for BEM
  1863. !
  1864. real qhb_u(ndm,nz_um)
  1865. real qvb_u(2*ndm,nz_um)
  1866. ! ----------------------------------------------------------------------
  1867. ! OUTPUT:
  1868. ! ----------------------------------------------------------------------
  1869. ! Data relative to the "mesoscale grid"
  1870. real sf(kms:kme) ! Surface of the "mesoscale grid" cells taking into account the buildings
  1871. real vl(kms:kme) ! Volume of the "mesoscale grid" cells taking into account the buildings
  1872. real a_u(kms:kme) ! Implicit component of the momentum sources or sinks in the X-direction
  1873. real a_v(kms:kme) ! Implicit component of the momentum sources or sinks in the Y-direction
  1874. real a_t(kms:kme) ! Implicit component of the heat sources or sinks
  1875. real a_e(kms:kme) ! Implicit component of the TKE sources or sinks
  1876. real b_u(kms:kme) ! Explicit component of the momentum sources or sinks in the X-direction
  1877. real b_v(kms:kme) ! Explicit component of the momentum sources or sinks in the Y-direction
  1878. real b_t(kms:kme) ! Explicit component of the heat sources or sinks
  1879. real b_ac(kms:kme)
  1880. real b_e(kms:kme) ! Explicit component of the TKE sources or sinks
  1881. real b_q(kms:kme) ! Explicit component of the humidity sources or sinks
  1882. ! ----------------------------------------------------------------------
  1883. ! LOCAL:
  1884. ! ----------------------------------------------------------------------
  1885. real dzz
  1886. real fact
  1887. integer id,iz,iz_u
  1888. real se,sr,st,su,sv,sq
  1889. real uet(kms:kme) ! Contribution to TKE due to walls
  1890. real veb,vta,vtb,vte,vtot,vua,vub,vva,vvb,vqb,vtb_ac
  1891. ! ----------------------------------------------------------------------
  1892. ! END VARIABLES DEFINITIONS
  1893. ! ----------------------------------------------------------------------
  1894. ! initialisation
  1895. do iz=kts,kte
  1896. a_u(iz)=0.
  1897. a_v(iz)=0.
  1898. a_t(iz)=0.
  1899. a_e(iz)=0.
  1900. b_u(iz)=0.
  1901. b_v(iz)=0.
  1902. b_e(iz)=0.
  1903. b_t(iz)=0.
  1904. b_ac(iz)=0.
  1905. uet(iz)=0.
  1906. b_q(iz)=0.
  1907. end do
  1908. ! horizontal surfaces
  1909. do iz=kts,kte
  1910. sf(iz)=0.
  1911. vl(iz)=0.
  1912. enddo
  1913. sf(kte+1)=0.
  1914. do id=1,nd
  1915. do iz=kts+1,kte+1
  1916. sr=0.
  1917. do iz_u=2,nz_u
  1918. if(z(iz).lt.z_u(iz_u).and.z(iz).ge.z_u(iz_u-1))then
  1919. sr=pb(iz_u)
  1920. endif
  1921. enddo
  1922. sf(iz)=sf(iz)+((ws(id)+(1.-sr)*bs(id))/(ws(id)+bs(id)))/nd
  1923. enddo
  1924. enddo
  1925. ! volume
  1926. do iz=kts,kte
  1927. do id=1,nd
  1928. vtot=0.
  1929. do iz_u=1,nz_u
  1930. dzz=max(min(z_u(iz_u+1),z(iz+1))-max(z_u(iz_u),z(iz)),0.)
  1931. vtot=vtot+pb(iz_u+1)*dzz
  1932. enddo
  1933. vtot=vtot/(z(iz+1)-z(iz))
  1934. vl(iz)=vl(iz)+(1.-vtot*bs(id)/(ws(id)+bs(id)))/nd
  1935. enddo
  1936. enddo
  1937. ! horizontal surface impact
  1938. do id=1,nd
  1939. fact=1./vl(kts)/dz(kts)*ws(id)/(ws(id)+bs(id))/nd
  1940. b_t(kts)=b_t(kts)+thb_u(id,1)*fact
  1941. b_u(kts)=b_u(kts)+uhb_u(id,1)*fact
  1942. b_v(kts)=b_v(kts)+vhb_u(id,1)*fact
  1943. b_e(kts)=b_e(kts)+ehb_u(id,1)*fact*(z_u(2)-z_u(1))
  1944. b_q(kts)=b_q(kts)+qhb_u(id,1)*fact
  1945. do iz=kts,kte
  1946. st=0.
  1947. su=0.
  1948. sv=0.
  1949. se=0.
  1950. sq=0.
  1951. do iz_u=2,nz_u
  1952. if(z(iz).le.z_u(iz_u).and.z(iz+1).gt.z_u(iz_u))then
  1953. st=st+ss(iz_u)*thb_u(id,iz_u)
  1954. su=su+ss(iz_u)*uhb_u(id,iz_u)
  1955. sv=sv+ss(iz_u)*vhb_u(id,iz_u)
  1956. se=se+ss(iz_u)*ehb_u(id,iz_u)*(z_u(iz_u+1)-z_u(iz_u))
  1957. sq=sq+ss(iz_u)*qhb_u(id,iz_u)
  1958. endif
  1959. enddo
  1960. fact=bs(id)/(ws(id)+bs(id))/vl(iz)/dz(iz)/nd
  1961. b_t(iz)=b_t(iz)+st*fact
  1962. b_u(iz)=b_u(iz)+su*fact
  1963. b_v(iz)=b_v(iz)+sv*fact
  1964. b_e(iz)=b_e(iz)+se*fact
  1965. b_q(iz)=b_q(iz)+sq*fact
  1966. enddo
  1967. enddo
  1968. ! vertical surface impact
  1969. do iz=kts,kte
  1970. uet(iz)=0.
  1971. do id=1,nd
  1972. vtb=0.
  1973. vtb_ac=0.
  1974. vta=0.
  1975. vua=0.
  1976. vub=0.
  1977. vva=0.
  1978. vvb=0.
  1979. veb=0.
  1980. vte=0.
  1981. vqb=0.
  1982. do iz_u=1,nz_u
  1983. dzz=max(min(z_u(iz_u+1),z(iz+1))-max(z_u(iz_u),z(iz)),0.)
  1984. fact=dzz/(ws(id)+bs(id))
  1985. vtb=vtb+pb(iz_u+1)* &
  1986. (tvb_u(2*id-1,iz_u)+tvb_u(2*id,iz_u))*fact
  1987. vtb_ac=vtb_ac+pb(iz_u+1)* &
  1988. (tvb_ac(2*id-1,iz_u)+tvb_ac(2*id,iz_u))*fact
  1989. vta=vta+pb(iz_u+1)* &
  1990. (tva_u(2*id-1,iz_u)+tva_u(2*id,iz_u))*fact
  1991. vua=vua+pb(iz_u+1)* &
  1992. (uva_u(2*id-1,iz_u)+uva_u(2*id,iz_u))*fact
  1993. vva=vva+pb(iz_u+1)* &
  1994. (vva_u(2*id-1,iz_u)+vva_u(2*id,iz_u))*fact
  1995. vub=vub+pb(iz_u+1)* &
  1996. (uvb_u(2*id-1,iz_u)+uvb_u(2*id,iz_u))*fact
  1997. vvb=vvb+pb(iz_u+1)* &
  1998. (vvb_u(2*id-1,iz_u)+vvb_u(2*id,iz_u))*fact
  1999. veb=veb+pb(iz_u+1)* &
  2000. (evb_u(2*id-1,iz_u)+evb_u(2*id,iz_u))*fact
  2001. vqb=vqb+pb(iz_u+1)* &
  2002. (qvb_u(2*id-1,iz_u)+qvb_u(2*id,iz_u))*fact
  2003. enddo
  2004. fact=1./vl(iz)/dz(iz)/nd
  2005. b_t(iz)=b_t(iz)+vtb*fact
  2006. b_ac(iz)=b_ac(iz)+vtb_ac*fact
  2007. a_t(iz)=a_t(iz)+vta*fact
  2008. a_u(iz)=a_u(iz)+vua*fact
  2009. a_v(iz)=a_v(iz)+vva*fact
  2010. b_u(iz)=b_u(iz)+vub*fact
  2011. b_v(iz)=b_v(iz)+vvb*fact
  2012. b_e(iz)=b_e(iz)+veb*fact
  2013. uet(iz)=uet(iz)+vte*fact
  2014. b_q(iz)=b_q(iz)+vqb*fact
  2015. enddo
  2016. enddo
  2017. return
  2018. end subroutine urban_meso
  2019. ! ===6=8===============================================================72
  2020. ! ===6=8===============================================================72
  2021. subroutine interp_length(nd,kms,kme,kts,kte,nz_u,z_u,z,ss,ws,bs, &
  2022. dlg,dl_u)
  2023. ! ----------------------------------------------------------------------
  2024. ! Calculation of the length scales
  2025. ! See p272-274 formula (22) and (24) of the BLM paper
  2026. ! ----------------------------------------------------------------------
  2027. implicit none
  2028. ! ----------------------------------------------------------------------
  2029. ! INPUT:
  2030. ! ----------------------------------------------------------------------
  2031. integer kms,kme,kts,kte
  2032. real z(kms:kme) ! Altitude above the ground of the cell interface
  2033. integer nd ! Number of street direction for the current urban class
  2034. integer nz_u ! Number of levels in the "urban grid"
  2035. real z_u(nz_um) ! Height of the urban grid levels
  2036. real bs(ndm) ! Building widths of the current urban class
  2037. real ss(nz_um) ! Probability to have a building with height h
  2038. real ws(ndm) ! Street widths of the current urban class
  2039. ! ----------------------------------------------------------------------
  2040. ! OUTPUT:
  2041. ! ----------------------------------------------------------------------
  2042. real dlg(kms:kme) ! Height above ground (L_ground in formula (24) of the BLM paper).
  2043. real dl_u(kms:kme) ! Length scale (lb in formula (22) ofthe BLM paper).
  2044. ! ----------------------------------------------------------------------
  2045. ! LOCAL:
  2046. ! ----------------------------------------------------------------------
  2047. real dlgtmp
  2048. integer id,iz,iz_u
  2049. real sftot
  2050. real ulu,ssl
  2051. ! ----------------------------------------------------------------------
  2052. ! END VARIABLES DEFINITIONS
  2053. ! ----------------------------------------------------------------------
  2054. do iz=kts,kte
  2055. ulu=0.
  2056. ssl=0.
  2057. do id=1,nd
  2058. do iz_u=2,nz_u
  2059. if(z_u(iz_u).gt.z(iz))then
  2060. ulu=ulu+ss(iz_u)/z_u(iz_u)/nd
  2061. ssl=ssl+ss(iz_u)/nd
  2062. endif
  2063. enddo
  2064. enddo
  2065. if(ulu.ne.0)then
  2066. dl_u(iz)=ssl/ulu
  2067. else
  2068. dl_u(iz)=0.
  2069. endif
  2070. enddo
  2071. do iz=kts,kte
  2072. dlg(iz)=0.
  2073. do id=1,nd
  2074. sftot=ws(id)
  2075. dlgtmp=ws(id)/((z(iz)+z(iz+1))/2.)
  2076. do iz_u=1,nz_u
  2077. if((z(iz)+z(iz+1))/2..gt.z_u(iz_u))then
  2078. dlgtmp=dlgtmp+ss(iz_u)*bs(id)/ &
  2079. ((z(iz)+z(iz+1))/2.-z_u(iz_u))
  2080. sftot=sftot+ss(iz_u)*bs(id)
  2081. endif
  2082. enddo
  2083. dlg(iz)=dlg(iz)+dlgtmp/sftot/nd
  2084. enddo
  2085. dlg(iz)=1./dlg(iz)
  2086. enddo
  2087. return
  2088. end subroutine interp_length
  2089. ! ===6=8===============================================================72
  2090. ! ===6=8===============================================================72
  2091. subroutine shadow_mas(nd,nz_u,zr,deltar,ah,drst,ws,ss,pb,z, &
  2092. rs,rsw,rsg)
  2093. ! ----------------------------------------------------------------------
  2094. ! Modification of short wave radiation to take into account
  2095. ! the shadow produced by the buildings
  2096. ! ----------------------------------------------------------------------
  2097. implicit none
  2098. ! ----------------------------------------------------------------------
  2099. ! INPUT:
  2100. ! ----------------------------------------------------------------------
  2101. integer nd ! Number of street direction for the current urban class
  2102. integer nz_u ! number of vertical layers defined in the urban grid
  2103. real ah ! Hour angle (it should come from the radiation routine)
  2104. real deltar ! Declination of the sun
  2105. real drst(ndm) ! street directions for the current urban class
  2106. real rs ! solar radiation
  2107. real ss(nz_um) ! probability to have a building with height h
  2108. real pb(nz_um) ! Probability that a building has an height greater or equal to h
  2109. real ws(ndm) ! Street width of the current urban class
  2110. real z(nz_um) ! Height of the urban grid levels
  2111. real zr ! zenith angle
  2112. ! ----------------------------------------------------------------------
  2113. ! OUTPUT:
  2114. ! ----------------------------------------------------------------------
  2115. real rsg(ndm) ! Short wave radiation at the ground
  2116. real rsw(2*ndm,nz_um) ! Short wave radiation at the walls
  2117. ! ----------------------------------------------------------------------
  2118. ! LOCAL:
  2119. ! ----------------------------------------------------------------------
  2120. integer id,iz,jz
  2121. real aae,aaw,bbb,phix,rd,rtot,wsd
  2122. ! ----------------------------------------------------------------------
  2123. ! END VARIABLES DEFINITIONS
  2124. ! ----------------------------------------------------------------------
  2125. if(rs.eq.0.or.sin(zr).eq.1)then
  2126. do id=1,nd
  2127. rsg(id)=0.
  2128. do iz=1,nz_u
  2129. rsw(2*id-1,iz)=0.
  2130. rsw(2*id,iz)=0.
  2131. enddo
  2132. enddo
  2133. else
  2134. !test
  2135. if(abs(sin(zr)).gt.1.e-10)then
  2136. if(cos(deltar)*sin(ah)/sin(zr).ge.1)then
  2137. bbb=pi/2.
  2138. elseif(cos(deltar)*sin(ah)/sin(zr).le.-1)then
  2139. bbb=-pi/2.
  2140. else
  2141. bbb=asin(cos(deltar)*sin(ah)/sin(zr))
  2142. endif
  2143. else
  2144. if(cos(deltar)*sin(ah).ge.0)then
  2145. bbb=pi/2.
  2146. elseif(cos(deltar)*sin(ah).lt.0)then
  2147. bbb=-pi/2.
  2148. endif
  2149. endif
  2150. phix=zr
  2151. do id=1,nd
  2152. rsg(id)=0.
  2153. aae=bbb-drst(id)
  2154. aaw=bbb-drst(id)+pi
  2155. do iz=1,nz_u
  2156. rsw(2*id-1,iz)=0.
  2157. rsw(2*id,iz)=0.
  2158. if (pb(iz+1).gt.0.) then
  2159. do jz=1,nz_u
  2160. if(abs(sin(aae)).gt.1.e-10)then
  2161. call shade_wall(z(iz),z(iz+1),z(jz+1),phix,aae, &
  2162. ws(id),rd)
  2163. rsw(2*id-1,iz)=rsw(2*id-1,iz)+rs*rd*ss(jz+1)/pb(iz+1)
  2164. endif
  2165. if(abs(sin(aaw)).gt.1.e-10)then
  2166. call shade_wall(z(iz),z(iz+1),z(jz+1),phix,aaw, &
  2167. ws(id),rd)
  2168. rsw(2*id,iz)=rsw(2*id,iz)+rs*rd*ss(jz+1)/pb(iz+1)
  2169. endif
  2170. enddo
  2171. endif
  2172. enddo
  2173. if(abs(sin(aae)).gt.1.e-10)then
  2174. wsd=abs(ws(id)/sin(aae))
  2175. do jz=1,nz_u
  2176. rd=max(0.,wsd-z(jz+1)*tan(phix))
  2177. rsg(id)=rsg(id)+rs*rd*ss(jz+1)/wsd
  2178. enddo
  2179. rtot=0.
  2180. do iz=1,nz_u
  2181. rtot=rtot+(rsw(2*id,iz)+rsw(2*id-1,iz))* &
  2182. (z(iz+1)-z(iz))
  2183. enddo
  2184. rtot=rtot+rsg(id)*ws(id)
  2185. else
  2186. rsg(id)=rs
  2187. endif
  2188. enddo
  2189. endif
  2190. return
  2191. end subroutine shadow_mas
  2192. ! ===6=8===============================================================72
  2193. ! ===6=8===============================================================72
  2194. subroutine shade_wall(z1,z2,hu,phix,aa,ws,rd)
  2195. ! ----------------------------------------------------------------------
  2196. ! This routine computes the effects of a shadow induced by a building of
  2197. ! height hu, on a portion of wall between z1 and z2. See equation A10,
  2198. ! and correction described below formula A11, and figure A1. Basically rd
  2199. ! is the ratio between the horizontal surface illuminated and the portion
  2200. ! of wall. Referring to figure A1, multiplying radiation flux density on
  2201. ! a horizontal surface (rs) by x1-x2 we have the radiation energy per
  2202. ! unit time. Dividing this by z2-z1, we obtain the radiation flux
  2203. ! density reaching the portion of the wall between z2 and z1
  2204. ! (everything is assumed in 2D)
  2205. ! ----------------------------------------------------------------------
  2206. implicit none
  2207. ! ----------------------------------------------------------------------
  2208. ! INPUT:
  2209. ! ----------------------------------------------------------------------
  2210. real aa ! Angle between the sun direction and the face of the wall (A12)
  2211. real hu ! Height of the building that generates the shadow
  2212. real phix ! Solar zenith angle
  2213. real ws ! Width of the street
  2214. real z1 ! Height of the level z(iz)
  2215. real z2 ! Height of the level z(iz+1)
  2216. ! ----------------------------------------------------------------------
  2217. ! OUTPUT:
  2218. ! ----------------------------------------------------------------------
  2219. real rd ! Ratio between (x1-x2)/(z2-z1), see Fig. 1A.
  2220. ! Multiplying rd by rs (radiation flux
  2221. ! density on a horizontal surface) gives
  2222. ! the radiation flux density on the
  2223. ! portion of wall between z1 and z2.
  2224. ! ----------------------------------------------------------------------
  2225. ! LOCAL:
  2226. ! ----------------------------------------------------------------------
  2227. real x1,x2 ! x1,x2 see Fig. A1.
  2228. ! ----------------------------------------------------------------------
  2229. ! END VARIABLES DEFINITIONS
  2230. ! ----------------------------------------------------------------------
  2231. x1=min((hu-z1)*tan(phix),max(0.,ws/sin(aa)))
  2232. x2=max((hu-z2)*tan(phix),0.)
  2233. rd=max(0.,sin(aa)*(max(0.,x1-x2))/(z2-z1))
  2234. return
  2235. end subroutine shade_wall
  2236. ! ===6=8===============================================================72
  2237. ! ===6=8===============================================================72
  2238. subroutine long_rad(iurb,nz_u,id,emw,emg,emwin,pwin,twlev,&
  2239. fwg,fww,fgw,fsw,fsg,tg,tw,rlg,rlw,rl,pb)
  2240. ! ----------------------------------------------------------------------
  2241. ! This routine computes the effects of the reflections of long-wave
  2242. ! radiation in the street canyon by solving the system
  2243. ! of 2*nz_u+1 eqn. in 2*nz_u+1
  2244. ! unkonwn defined in A4, A5 and A6 of the paper (pages 295 and 296).
  2245. ! The system is solved by solving A X= B,
  2246. ! with A matrix B vector, and X solution.
  2247. ! ----------------------------------------------------------------------
  2248. implicit none
  2249. ! ----------------------------------------------------------------------
  2250. ! INPUT:
  2251. ! ----------------------------------------------------------------------
  2252. real emg ! Emissivity of ground for the current urban class
  2253. real emw ! Emissivity of wall for the current urban class
  2254. real fgw(nz_um,ndm,nurbm) ! View factors from ground to wall
  2255. real fsg(ndm,nurbm) ! View factors from sky to ground
  2256. real fsw(nz_um,ndm,nurbm) ! View factors from sky to wall
  2257. real fwg(nz_um,ndm,nurbm) ! View factors from wall to ground
  2258. real fww(nz_um,nz_um,ndm,nurbm) ! View factors from wall to wall
  2259. integer id ! Current street direction
  2260. integer iurb ! Current urban class
  2261. integer nz_u ! Number of layer in the urban grid
  2262. real pb(nz_um) ! Probability to have a building with an height equal
  2263. real rl ! Downward flux of the longwave radiation
  2264. real tg(ndm,ng_u) ! Temperature in each layer of the ground [K]
  2265. real tw(2*ndm,nz_um) ! Temperature in each layer of the wall [K]
  2266. !
  2267. !New Variables for BEM
  2268. !
  2269. real twlev(2*ndm,nz_um) ! Window temperature in BEM [K]
  2270. real emwin ! Emissivity of windows
  2271. real pwin ! Coverage area fraction of windows in the walls of the buildings (BEM)
  2272. ! ----------------------------------------------------------------------
  2273. ! OUTPUT:
  2274. ! ----------------------------------------------------------------------
  2275. real rlg(ndm) ! Long wave radiation at the ground
  2276. real rlw(2*ndm,nz_um) ! Long wave radiation at the walls
  2277. ! ----------------------------------------------------------------------
  2278. ! LOCAL:
  2279. ! ----------------------------------------------------------------------
  2280. integer i,j
  2281. real aaa(2*nz_um+1,2*nz_um+1) ! terms of the matrix
  2282. real bbb(2*nz_um+1) ! terms of the vector
  2283. ! ----------------------------------------------------------------------
  2284. ! END VARIABLES DEFINITIONS
  2285. ! ----------------------------------------------------------------------
  2286. ! west wall
  2287. do i=1,nz_u
  2288. do j=1,nz_u
  2289. aaa(i,j)=0.
  2290. enddo
  2291. aaa(i,i)=1.
  2292. do j=nz_u+1,2*nz_u
  2293. aaa(i,j)=-(1.-emw*(1.-pwin)-emwin*pwin)* &
  2294. fww(j-nz_u,i,id,iurb)*pb(j-nz_u+1)
  2295. enddo
  2296. aaa(i,2*nz_u+1)=-(1.-emg)*fgw(i,id,iurb)
  2297. bbb(i)=fsw(i,id,iurb)*rl+emg*fgw(i,id,iurb)*sigma*tg(id,ng_u)**4
  2298. do j=1,nz_u
  2299. bbb(i)=bbb(i)+pb(j+1)*sigma*fww(j,i,id,iurb)* &
  2300. (emw*(1.-pwin)*tw(2*id,j)**4+emwin*pwin*twlev(2*id,j)**4)+ &
  2301. fww(j,i,id,iurb)*rl*(1.-pb(j+1))
  2302. enddo
  2303. enddo
  2304. ! east wall
  2305. do i=1+nz_u,2*nz_u
  2306. do j=1,nz_u
  2307. aaa(i,j)=-(1.-emw*(1.-pwin)-emwin*pwin)*fww(j,i-nz_u,id,iurb)*pb(j+1)
  2308. enddo
  2309. do j=1+nz_u,2*nz_u
  2310. aaa(i,j)=0.
  2311. enddo
  2312. aaa(i,i)=1.
  2313. aaa(i,2*nz_u+1)=-(1.-emg)*fgw(i-nz_u,id,iurb)
  2314. bbb(i)=fsw(i-nz_u,id,iurb)*rl+ &
  2315. emg*fgw(i-nz_u,id,iurb)*sigma*tg(id,ng_u)**4
  2316. do j=1,nz_u
  2317. bbb(i)=bbb(i)+pb(j+1)*sigma*fww(j,i-nz_u,id,iurb)* &
  2318. (emw*(1.-pwin)*tw(2*id-1,j)**4+emwin*pwin*twlev(2*id-1,j)**4)+&
  2319. fww(j,i-nz_u,id,iurb)*rl*(1.-pb(j+1))
  2320. enddo
  2321. enddo
  2322. ! ground
  2323. do j=1,nz_u
  2324. aaa(2*nz_u+1,j)=-(1.-emw*(1.-pwin)-emwin*pwin)* &
  2325. fwg(j,id,iurb)*pb(j+1)
  2326. enddo
  2327. do j=nz_u+1,2*nz_u
  2328. aaa(2*nz_u+1,j)=-(1.-emw*(1.-pwin)-emwin*pwin)* &
  2329. fwg(j-nz_u,id,iurb)*pb(j-nz_u+1)
  2330. enddo
  2331. aaa(2*nz_u+1,2*nz_u+1)=1.
  2332. bbb(2*nz_u+1)=fsg(id,iurb)*rl
  2333. do i=1,nz_u
  2334. bbb(2*nz_u+1)=bbb(2*nz_u+1)+sigma*fwg(i,id,iurb)*pb(i+1)* &
  2335. (emw*(1.-pwin)*(tw(2*id-1,i)**4+tw(2*id,i)**4)+ &
  2336. emwin*pwin*(twlev(2*id-1,i)**4+twlev(2*id,i)**4))+ &
  2337. 2.*fwg(i,id,iurb)*(1.-pb(i+1))*rl
  2338. enddo
  2339. call gaussj(aaa,2*nz_u+1,bbb,2*nz_um+1)
  2340. do i=1,nz_u
  2341. rlw(2*id-1,i)=bbb(i)
  2342. enddo
  2343. do i=nz_u+1,2*nz_u
  2344. rlw(2*id,i-nz_u)=bbb(i)
  2345. enddo
  2346. rlg(id)=bbb(2*nz_u+1)
  2347. return
  2348. end subroutine long_rad
  2349. ! ===6=8===============================================================72
  2350. ! ===6=8===============================================================72
  2351. subroutine short_rad(iurb,nz_u,id,albw, &
  2352. albg,fwg,fww,fgw,rsg,rsw,pb)
  2353. ! ----------------------------------------------------------------------
  2354. ! This routine computes the effects of the reflections of short-wave
  2355. ! (solar) radiation in the street canyon by solving the system
  2356. ! of 2*nz_u+1 eqn. in 2*nz_u+1
  2357. ! unkonwn defined in A4, A5 and A6 of the paper (pages 295 and 296).
  2358. ! The system is solved by solving A X= B,
  2359. ! with A matrix B vector, and X solution.
  2360. ! ----------------------------------------------------------------------
  2361. implicit none
  2362. ! ----------------------------------------------------------------------
  2363. ! INPUT:
  2364. ! ----------------------------------------------------------------------
  2365. real albg ! Albedo of the ground for the current urban class
  2366. real albw ! Albedo of the wall for the current urban class
  2367. real fgw(nz_um,ndm,nurbm) ! View factors from ground to wall
  2368. real fwg(nz_um,ndm,nurbm) ! View factors from wall to ground
  2369. real fww(nz_um,nz_um,ndm,nurbm) ! View factors from wall to wall
  2370. integer id ! current street direction
  2371. integer iurb ! current urban class
  2372. integer nz_u ! Number of layer in the urban grid
  2373. real pb(nz_um) ! probability to have a building with an height equal
  2374. ! ----------------------------------------------------------------------
  2375. ! OUTPUT:
  2376. ! ----------------------------------------------------------------------
  2377. real rsg(ndm) ! Short wave radiation at the ground
  2378. real rsw(2*ndm,nz_um) ! Short wave radiation at the walls
  2379. ! ----------------------------------------------------------------------
  2380. ! LOCAL:
  2381. ! ----------------------------------------------------------------------
  2382. integer i,j
  2383. real aaa(2*nz_um+1,2*nz_um+1) ! terms of the matrix
  2384. real bbb(2*nz_um+1) ! terms of the vector
  2385. ! ----------------------------------------------------------------------
  2386. ! END VARIABLES DEFINITIONS
  2387. ! ----------------------------------------------------------------------
  2388. ! west wall
  2389. do i=1,nz_u
  2390. do j=1,nz_u
  2391. aaa(i,j)=0.
  2392. enddo
  2393. aaa(i,i)=1.
  2394. do j=nz_u+1,2*nz_u
  2395. aaa(i,j)=-albw*fww(j-nz_u,i,id,iurb)*pb(j-nz_u+1)
  2396. enddo
  2397. aaa(i,2*nz_u+1)=-albg*fgw(i,id,iurb)
  2398. bbb(i)=rsw(2*id-1,i)
  2399. enddo
  2400. ! east wall
  2401. do i=1+nz_u,2*nz_u
  2402. do j=1,nz_u
  2403. aaa(i,j)=-albw*fww(j,i-nz_u,id,iurb)*pb(j+1)
  2404. enddo
  2405. do j=1+nz_u,2*nz_u
  2406. aaa(i,j)=0.
  2407. enddo
  2408. aaa(i,i)=1.
  2409. aaa(i,2*nz_u+1)=-albg*fgw(i-nz_u,id,iurb)
  2410. bbb(i)=rsw(2*id,i-nz_u)
  2411. enddo
  2412. ! ground
  2413. do j=1,nz_u
  2414. aaa(2*nz_u+1,j)=-albw*fwg(j,id,iurb)*pb(j+1)
  2415. enddo
  2416. do j=nz_u+1,2*nz_u
  2417. aaa(2*nz_u+1,j)=-albw*fwg(j-nz_u,id,iurb)*pb(j-nz_u+1)
  2418. enddo
  2419. aaa(2*nz_u+1,2*nz_u+1)=1.
  2420. bbb(2*nz_u+1)=rsg(id)
  2421. call gaussj(aaa,2*nz_u+1,bbb,2*nz_um+1)
  2422. do i=1,nz_u
  2423. rsw(2*id-1,i)=bbb(i)
  2424. enddo
  2425. do i=nz_u+1,2*nz_u
  2426. rsw(2*id,i-nz_u)=bbb(i)
  2427. enddo
  2428. rsg(id)=bbb(2*nz_u+1)
  2429. return
  2430. end subroutine short_rad
  2431. ! ===6=8===============================================================72
  2432. ! ===6=8===============================================================72
  2433. subroutine gaussj(a,n,b,np)
  2434. ! ----------------------------------------------------------------------
  2435. ! This routine solve a linear system of n equations of the form
  2436. ! A X = B
  2437. ! where A is a matrix a(i,j)
  2438. ! B a vector and X the solution
  2439. ! In output b is replaced by the solution
  2440. ! ----------------------------------------------------------------------
  2441. implicit none
  2442. ! ----------------------------------------------------------------------
  2443. ! INPUT:
  2444. ! ----------------------------------------------------------------------
  2445. integer np
  2446. real a(np,np)
  2447. ! ----------------------------------------------------------------------
  2448. ! OUTPUT:
  2449. ! ----------------------------------------------------------------------
  2450. real b(np)
  2451. ! ----------------------------------------------------------------------
  2452. ! LOCAL:
  2453. ! ----------------------------------------------------------------------
  2454. integer nmax
  2455. parameter (nmax=150)
  2456. real big,dum
  2457. integer i,icol,irow
  2458. integer j,k,l,ll,n
  2459. integer ipiv(nmax)
  2460. real pivinv
  2461. ! ----------------------------------------------------------------------
  2462. ! END VARIABLES DEFINITIONS
  2463. ! ----------------------------------------------------------------------
  2464. do j=1,n
  2465. ipiv(j)=0.
  2466. enddo
  2467. do i=1,n
  2468. big=0.
  2469. do j=1,n
  2470. if(ipiv(j).ne.1)then
  2471. do k=1,n
  2472. if(ipiv(k).eq.0)then
  2473. if(abs(a(j,k)).ge.big)then
  2474. big=abs(a(j,k))
  2475. irow=j
  2476. icol=k
  2477. endif
  2478. elseif(ipiv(k).gt.1)then
  2479. pause 'singular matrix in gaussj'
  2480. endif
  2481. enddo
  2482. endif
  2483. enddo
  2484. ipiv(icol)=ipiv(icol)+1
  2485. if(irow.ne.icol)then
  2486. do l=1,n
  2487. dum=a(irow,l)
  2488. a(irow,l)=a(icol,l)
  2489. a(icol,l)=dum
  2490. enddo
  2491. dum=b(irow)
  2492. b(irow)=b(icol)
  2493. b(icol)=dum
  2494. endif
  2495. if(a(icol,icol).eq.0)pause 'singular matrix in gaussj'
  2496. pivinv=1./a(icol,icol)
  2497. a(icol,icol)=1
  2498. do l=1,n
  2499. a(icol,l)=a(icol,l)*pivinv
  2500. enddo
  2501. b(icol)=b(icol)*pivinv
  2502. do ll=1,n
  2503. if(ll.ne.icol)then
  2504. dum=a(ll,icol)
  2505. a(ll,icol)=0.
  2506. do l=1,n
  2507. a(ll,l)=a(ll,l)-a(icol,l)*dum
  2508. enddo
  2509. b(ll)=b(ll)-b(icol)*dum
  2510. endif
  2511. enddo
  2512. enddo
  2513. return
  2514. end subroutine gaussj
  2515. ! ===6=8===============================================================72
  2516. ! ===6=8===============================================================72
  2517. subroutine soil_temp(nz,dz,temp,pt,ala,cs, &
  2518. rs,rl,press,dt,em,alb,rt,sf,gf)
  2519. ! ----------------------------------------------------------------------
  2520. ! This routine solves the Fourier diffusion equation for heat in
  2521. ! the material (wall, roof, or ground). Resolution is done implicitely.
  2522. ! Boundary conditions are:
  2523. ! - fixed temperature at the interior
  2524. ! - energy budget at the surface
  2525. ! ----------------------------------------------------------------------
  2526. implicit none
  2527. ! ----------------------------------------------------------------------
  2528. ! INPUT:
  2529. ! ----------------------------------------------------------------------
  2530. integer nz ! Number of layers
  2531. real ala(nz) ! Thermal diffusivity in each layers [m^2 s^-1]
  2532. real alb ! Albedo of the surface
  2533. real cs(nz) ! Specific heat of the material [J m^3 K^-1]
  2534. real dt ! Time step
  2535. real em ! Emissivity of the surface
  2536. real press ! Pressure at ground level
  2537. real rl ! Downward flux of the longwave radiation
  2538. real rs ! Solar radiation
  2539. real sf ! Sensible heat flux at the surface
  2540. real temp(nz) ! Temperature in each layer [K]
  2541. real dz(nz) ! Layer sizes [m]
  2542. ! ----------------------------------------------------------------------
  2543. ! OUTPUT:
  2544. ! ----------------------------------------------------------------------
  2545. real gf ! Heat flux transferred from the surface toward the interior
  2546. real pt ! Potential temperature at the surface
  2547. real rt ! Total radiation at the surface (solar+incoming long+outgoing long)
  2548. ! ----------------------------------------------------------------------
  2549. ! LOCAL:
  2550. ! ----------------------------------------------------------------------
  2551. integer iz
  2552. real a(nz,3)
  2553. real alpha
  2554. real c(nz)
  2555. real cddz(nz+2)
  2556. real tsig
  2557. ! ----------------------------------------------------------------------
  2558. ! END VARIABLES DEFINITIONS
  2559. ! ----------------------------------------------------------------------
  2560. tsig=temp(nz)
  2561. alpha=(1.-alb)*rs+em*rl-em*sigma*(tsig**4)+sf
  2562. ! Compute cddz=2*cd/dz
  2563. cddz(1)=ala(1)/dz(1)
  2564. do iz=2,nz
  2565. cddz(iz)=2.*ala(iz)/(dz(iz)+dz(iz-1))
  2566. enddo
  2567. a(1,1)=0.
  2568. a(1,2)=1.
  2569. a(1,3)=0.
  2570. c(1)=temp(1)
  2571. do iz=2,nz-1
  2572. a(iz,1)=-cddz(iz)*dt/dz(iz)
  2573. a(iz,2)=1+dt*(cddz(iz)+cddz(iz+1))/dz(iz)
  2574. a(iz,3)=-cddz(iz+1)*dt/dz(iz)
  2575. c(iz)=temp(iz)
  2576. enddo
  2577. a(nz,1)=-dt*cddz(nz)/dz(nz)
  2578. a(nz,2)=1.+dt*cddz(nz)/dz(nz)
  2579. a(nz,3)=0.
  2580. c(nz)=temp(nz)+dt*alpha/cs(nz)/dz(nz)
  2581. call invert(nz,a,c,temp)
  2582. pt=temp(nz)*(press/1.e+5)**(-rcp_u)
  2583. rt=(1.-alb)*rs+em*rl-em*sigma*(tsig**4)
  2584. gf=(1.-alb)*rs+em*rl-em*sigma*(tsig**4)+sf
  2585. return
  2586. end subroutine soil_temp
  2587. ! ===6=8===============================================================72
  2588. ! ===6=8===============================================================72
  2589. subroutine invert(n,a,c,x)
  2590. ! ----------------------------------------------------------------------
  2591. ! Inversion and resolution of a tridiagonal matrix
  2592. ! A X = C
  2593. ! ----------------------------------------------------------------------
  2594. implicit none
  2595. ! ----------------------------------------------------------------------
  2596. ! INPUT:
  2597. ! ----------------------------------------------------------------------
  2598. integer n
  2599. real a(n,3) ! a(*,1) lower diagonal (Ai,i-1)
  2600. ! a(*,2) principal diagonal (Ai,i)
  2601. ! a(*,3) upper diagonal (Ai,i+1)
  2602. real c(n)
  2603. ! ----------------------------------------------------------------------
  2604. ! OUTPUT:
  2605. ! ----------------------------------------------------------------------
  2606. real x(n)
  2607. ! ----------------------------------------------------------------------
  2608. ! LOCAL:
  2609. ! ----------------------------------------------------------------------
  2610. integer i
  2611. ! ----------------------------------------------------------------------
  2612. ! END VARIABLES DEFINITIONS
  2613. ! ----------------------------------------------------------------------
  2614. do i=n-1,1,-1
  2615. c(i)=c(i)-a(i,3)*c(i+1)/a(i+1,2)
  2616. a(i,2)=a(i,2)-a(i,3)*a(i+1,1)/a(i+1,2)
  2617. enddo
  2618. do i=2,n
  2619. c(i)=c(i)-a(i,1)*c(i-1)/a(i-1,2)
  2620. enddo
  2621. do i=1,n
  2622. x(i)=c(i)/a(i,2)
  2623. enddo
  2624. return
  2625. end subroutine invert
  2626. ! ===6=8===============================================================72
  2627. ! ===6=8===============================================================72
  2628. subroutine flux_wall(ua,va,pt,da,ptw,ptwin,uva,vva,uvb,vvb, &
  2629. sfw,sfwin,evb,drst,dt)
  2630. ! ----------------------------------------------------------------------
  2631. ! This routine computes the surface sources or sinks of momentum, tke,
  2632. ! and heat from vertical surfaces (walls).
  2633. ! ----------------------------------------------------------------------
  2634. implicit none
  2635. ! INPUT:
  2636. ! -----
  2637. real drst ! street directions for the current urban class
  2638. real da ! air density
  2639. real pt ! potential temperature
  2640. real ptw ! Walls potential temperatures
  2641. real ptwin ! Windows potential temperatures
  2642. real ua ! wind speed
  2643. real va ! wind speed
  2644. real dt !time step
  2645. ! OUTPUT:
  2646. ! ------
  2647. ! Explicit and implicit component of the momentum, temperature and TKE sources or sinks on
  2648. ! vertical surfaces (walls).
  2649. ! The fluxes can be computed as follow: Fluxes of X = A*X + B
  2650. ! Example: Momentum fluxes on vertical surfaces = uva_u * ua_u + uvb_u
  2651. real uva ! U (wind component) Vertical surfaces, A (implicit) term
  2652. real uvb ! U (wind component) Vertical surfaces, B (explicit) term
  2653. real vva ! V (wind component) Vertical surfaces, A (implicit) term
  2654. real vvb ! V (wind component) Vertical surfaces, B (explicit) term
  2655. ! real tva ! Temperature Vertical surfaces, A (implicit) term
  2656. ! real tvb ! Temperature Vertical surfaces, B (explicit) term
  2657. real evb ! Energy (TKE) Vertical surfaces, B (explicit) term
  2658. real sfw ! Surfaces fluxes from the walls
  2659. real sfwin ! Surfaces fluxes from the windows
  2660. ! LOCAL:
  2661. ! -----
  2662. real hc
  2663. real hcwin
  2664. real u_ort
  2665. real vett
  2666. ! -------------------------
  2667. ! END VARIABLES DEFINITIONS
  2668. ! -------------------------
  2669. vett=(ua**2+va**2)**.5
  2670. u_ort=abs((cos(drst)*ua-sin(drst)*va))
  2671. uva=-cdrag*u_ort/2.*cos(drst)*cos(drst)
  2672. vva=-cdrag*u_ort/2.*sin(drst)*sin(drst)
  2673. uvb=cdrag*u_ort/2.*sin(drst)*cos(drst)*va
  2674. vvb=cdrag*u_ort/2.*sin(drst)*cos(drst)*ua
  2675. if (vett.lt.4.88) then
  2676. hc=5.678*(1.09+0.23*(vett/0.3048))
  2677. else
  2678. hc=5.678*0.53*((vett/0.3048)**0.78)
  2679. endif
  2680. if (hc.gt.da*cp_u/dt)then
  2681. hc=da*cp_u/dt
  2682. endif
  2683. if (vett.lt.4.88) then
  2684. hcwin=5.678*(0.99+0.21*(vett/0.3048))
  2685. else
  2686. hcwin=5.678*0.50*((vett/0.3048)**0.78)
  2687. endif
  2688. if (hcwin.gt.da*cp_u/dt) then
  2689. hcwin=da*cp_u/dt
  2690. endif
  2691. ! tvb=hc*ptw/da/cp_u
  2692. ! tva=-hc/da/cp_u
  2693. !!!!!!!!!!!!!!!!!!!!
  2694. ! explicit
  2695. sfw=hc*(pt-ptw)
  2696. sfwin=hcwin*(pt-ptwin)
  2697. evb=cdrag*(abs(u_ort)**3.)/2.
  2698. return
  2699. end subroutine flux_wall
  2700. ! ===6=8===============================================================72
  2701. ! ===6=8===============================================================72
  2702. subroutine flux_flat(dz,z0,ua,va,pt,pt0,ptg, &
  2703. uhb,vhb,sf,ehb,da)
  2704. ! ----------------------------------------------------------------------
  2705. ! Calculation of the flux at the ground
  2706. ! Formulation of Louis (Louis, 1979)
  2707. ! ----------------------------------------------------------------------
  2708. implicit none
  2709. real dz ! first vertical level
  2710. real pt ! potential temperature
  2711. real pt0 ! reference potential temperature
  2712. real ptg ! ground potential temperature
  2713. real ua ! wind speed
  2714. real va ! wind speed
  2715. real z0 ! Roughness length
  2716. real da ! air density
  2717. ! ----------------------------------------------------------------------
  2718. ! OUTPUT:
  2719. ! ----------------------------------------------------------------------
  2720. ! Explicit component of the momentum, temperature and TKE sources or sinks on horizontal
  2721. ! surfaces (roofs and street)
  2722. ! The fluxes can be computed as follow: Fluxes of X = B
  2723. ! Example: Momentum fluxes on horizontal surfaces = uhb_u
  2724. real uhb ! U (wind component) Horizontal surfaces, B (explicit) term
  2725. real vhb ! V (wind component) Horizontal surfaces, B (explicit) term
  2726. ! real thb ! Temperature Horizontal surfaces, B (explicit) term
  2727. ! real tva ! Temperature Vertical surfaces, A (implicit) term
  2728. ! real tvb ! Temperature Vertical surfaces, B (explicit) term
  2729. real ehb ! Energy (TKE) Horizontal surfaces, B (explicit) term
  2730. real sf
  2731. ! ----------------------------------------------------------------------
  2732. ! LOCAL:
  2733. ! ----------------------------------------------------------------------
  2734. real aa
  2735. real al
  2736. real buu
  2737. real c
  2738. real fbuw
  2739. real fbpt
  2740. real fh
  2741. real fm
  2742. real ric
  2743. real tstar
  2744. real ustar
  2745. real utot
  2746. real wstar
  2747. real zz
  2748. real b,cm,ch,rr,tol
  2749. parameter(b=9.4,cm=7.4,ch=5.3,rr=0.74,tol=.001)
  2750. ! ----------------------------------------------------------------------
  2751. ! END VARIABLES DEFINITIONS
  2752. ! ----------------------------------------------------------------------
  2753. ! computation of the ground temperature
  2754. utot=(ua**2+va**2)**.5
  2755. !!!! Louis formulation
  2756. !
  2757. ! compute the bulk Richardson Number
  2758. zz=dz/2.
  2759. utot=max(utot,0.01)
  2760. ric=2.*g_u*zz*(pt-ptg)/((pt+ptg)*(utot**2))
  2761. aa=vk/log(zz/z0)
  2762. ! determine the parameters fm and fh for stable, neutral and unstable conditions
  2763. if(ric.gt.0)then
  2764. fm=1/(1+0.5*b*ric)**2
  2765. fh=fm
  2766. else
  2767. c=b*cm*aa*aa*(zz/z0)**.5
  2768. fm=1-b*ric/(1+c*(-ric)**.5)
  2769. c=c*ch/cm
  2770. fh=1-b*ric/(1+c*(-ric)**.5)
  2771. endif
  2772. fbuw=-aa*aa*utot*utot*fm
  2773. fbpt=-aa*aa*utot*(pt-ptg)*fh/rr
  2774. ustar=(-fbuw)**.5
  2775. tstar=-fbpt/ustar
  2776. al=(vk*g_u*tstar)/(pt*ustar*ustar)
  2777. buu=-g_u/pt0*ustar*tstar
  2778. uhb=-ustar*ustar*ua/utot
  2779. vhb=-ustar*ustar*va/utot
  2780. sf= ustar*tstar*da*cp_u
  2781. ! thb= 0.
  2782. ehb=buu
  2783. !!!!!!!!!!!!!!!
  2784. return
  2785. end subroutine flux_flat
  2786. ! ===6=8===============================================================72
  2787. ! ===6=8===============================================================72
  2788. subroutine icBEP (fww,fwg,fgw,fsw,fws,fsg, &
  2789. z0g_u,z0r_u, &
  2790. nd_u,strd_u,ws_u,bs_u,h_b,d_b,ss_u,pb_u, &
  2791. nz_u,z_u)
  2792. implicit none
  2793. ! Building parameters
  2794. ! Radiation parameters
  2795. ! Roughness parameters
  2796. real z0g_u(nurbm) ! The ground's roughness length
  2797. real z0r_u(nurbm) ! The roof's roughness length
  2798. ! Street parameters
  2799. integer nd_u(nurbm) ! Number of street direction for each urban class
  2800. real strd_u(ndm,nurbm) ! Street length (fix to greater value to the horizontal length of the cells)
  2801. real ws_u(ndm,nurbm) ! Street width [m]
  2802. real bs_u(ndm,nurbm) ! Building width [m]
  2803. real h_b(nz_um,nurbm) ! Bulding's heights [m]
  2804. real d_b(nz_um,nurbm) ! The probability that a building has an height h_b
  2805. ! -----------------------------------------------------------------------
  2806. ! Output
  2807. !------------------------------------------------------------------------
  2808. ! fww,fwg,fgw,fsw,fsg are the view factors used to compute the long wave
  2809. ! and the short wave radation. They are the part of radiation from a surface
  2810. ! or from the sky to another surface.
  2811. real fww(nz_um,nz_um,ndm,nurbm) ! from wall to wall
  2812. real fwg(nz_um,ndm,nurbm) ! from wall to ground
  2813. real fgw(nz_um,ndm,nurbm) ! from ground to wall
  2814. real fsw(nz_um,ndm,nurbm) ! from sky to wall
  2815. real fws(nz_um,ndm,nurbm) ! from wall to sky
  2816. real fsg(ndm,nurbm) ! from sky to ground
  2817. real ss_u(nz_um,nurbm) ! The probability that a building has an height equal to z
  2818. real pb_u(nz_um,nurbm) ! The probability that a building has an height greater or equal to z
  2819. ! Grid parameters
  2820. integer nz_u(nurbm) ! Number of layer in the urban grid
  2821. real z_u(nz_um) ! Height of the urban grid levels
  2822. ! -----------------------------------------------------------------------
  2823. ! Local
  2824. !------------------------------------------------------------------------
  2825. integer iz_u,id,ilu,iurb
  2826. real dtot
  2827. real hbmax
  2828. !------------------------------------------------------------------------
  2829. ! -----------------------------------------------------------------------
  2830. ! This routine initialise the urban paramters for the BEP module
  2831. !------------------------------------------------------------------------
  2832. !
  2833. !Initialize some variables
  2834. !
  2835. nz_u=0
  2836. z_u=0.
  2837. ss_u=0.
  2838. pb_u=0.
  2839. fww=0.
  2840. fwg=0.
  2841. fgw=0.
  2842. fsw=0.
  2843. fws=0.
  2844. fsg=0.
  2845. ! Computation of the urban levels height
  2846. z_u(1)=0.
  2847. do iz_u=1,nz_um-1
  2848. z_u(iz_u+1)=z_u(iz_u)+dz_u
  2849. enddo
  2850. ! Normalisation of the building density
  2851. do iurb=1,nurbm
  2852. dtot=0.
  2853. do ilu=1,nz_um
  2854. dtot=dtot+d_b(ilu,iurb)
  2855. enddo
  2856. do ilu=1,nz_um
  2857. d_b(ilu,iurb)=d_b(ilu,iurb)/dtot
  2858. enddo
  2859. enddo
  2860. ! Compute the view factors, pb and ss
  2861. do iurb=1,nurbm
  2862. hbmax=0.
  2863. nz_u(iurb)=0
  2864. do ilu=1,nz_um
  2865. if(h_b(ilu,iurb).gt.hbmax)hbmax=h_b(ilu,iurb)
  2866. enddo
  2867. do iz_u=1,nz_um-1
  2868. if(z_u(iz_u+1).gt.hbmax)go to 10
  2869. enddo
  2870. 10 continue
  2871. nz_u(iurb)=iz_u+1
  2872. do id=1,nd_u(iurb)
  2873. call view_factors(iurb,nz_u(iurb),id,strd_u(id,iurb), &
  2874. z_u,ws_u(id,iurb), &
  2875. fww,fwg,fgw,fsg,fsw,fws)
  2876. do iz_u=1,nz_u(iurb)
  2877. ss_u(iz_u,iurb)=0.
  2878. do ilu=1,nz_um
  2879. if(z_u(iz_u).le.h_b(ilu,iurb) &
  2880. .and.z_u(iz_u+1).gt.h_b(ilu,iurb))then
  2881. ss_u(iz_u,iurb)=ss_u(iz_u,iurb)+d_b(ilu,iurb)
  2882. endif
  2883. enddo
  2884. enddo
  2885. pb_u(1,iurb)=1.
  2886. do iz_u=1,nz_u(iurb)
  2887. pb_u(iz_u+1,iurb)=max(0.,pb_u(iz_u,iurb)-ss_u(iz_u,iurb))
  2888. enddo
  2889. enddo
  2890. end do
  2891. return
  2892. end subroutine icBEP
  2893. ! ===6=8===============================================================72
  2894. ! ===6=8===============================================================72
  2895. subroutine view_factors(iurb,nz_u,id,dxy,z,ws,fww,fwg,fgw,fsg,fsw,fws)
  2896. implicit none
  2897. ! -----------------------------------------------------------------------
  2898. ! Input
  2899. !------------------------------------------------------------------------
  2900. integer iurb ! Number of the urban class
  2901. integer nz_u ! Number of levels in the urban grid
  2902. integer id ! Street direction number
  2903. real ws ! Street width
  2904. real z(nz_um) ! Height of the urban grid levels
  2905. real dxy ! Street lenght
  2906. ! -----------------------------------------------------------------------
  2907. ! Output
  2908. !------------------------------------------------------------------------
  2909. ! fww,fwg,fgw,fsw,fsg are the view factors used to compute the long wave
  2910. ! and the short wave radation. They are the part of radiation from a surface
  2911. ! or from the sky to another surface.
  2912. real fww(nz_um,nz_um,ndm,nurbm) ! from wall to wall
  2913. real fwg(nz_um,ndm,nurbm) ! from wall to ground
  2914. real fgw(nz_um,ndm,nurbm) ! from ground to wall
  2915. real fsw(nz_um,ndm,nurbm) ! from sky to wall
  2916. real fws(nz_um,ndm,nurbm) ! from wall to sky
  2917. real fsg(ndm,nurbm) ! from sky to ground
  2918. ! -----------------------------------------------------------------------
  2919. ! Local
  2920. !------------------------------------------------------------------------
  2921. integer jz,iz
  2922. real hut
  2923. real f1,f2,f12,f23,f123,ftot
  2924. real fprl,fnrm
  2925. real a1,a2,a3,a4,a12,a23,a123
  2926. ! -----------------------------------------------------------------------
  2927. ! This routine calculates the view factors
  2928. !------------------------------------------------------------------------
  2929. hut=z(nz_u+1)
  2930. do jz=1,nz_u
  2931. ! radiation from wall to wall
  2932. do iz=1,nz_u
  2933. call fprls (fprl,dxy,abs(z(jz+1)-z(iz )),ws)
  2934. f123=fprl
  2935. call fprls (fprl,dxy,abs(z(jz+1)-z(iz+1)),ws)
  2936. f23=fprl
  2937. call fprls (fprl,dxy,abs(z(jz )-z(iz )),ws)
  2938. f12=fprl
  2939. call fprls (fprl,dxy,abs(z(jz )-z(iz+1)),ws)
  2940. f2 = fprl
  2941. a123=dxy*(abs(z(jz+1)-z(iz )))
  2942. a12 =dxy*(abs(z(jz )-z(iz )))
  2943. a23 =dxy*(abs(z(jz+1)-z(iz+1)))
  2944. a1 =dxy*(abs(z(iz+1)-z(iz )))
  2945. a2 =dxy*(abs(z(jz )-z(iz+1)))
  2946. a3 =dxy*(abs(z(jz+1)-z(jz )))
  2947. ftot=0.5*(a123*f123-a23*f23-a12*f12+a2*f2)/a1
  2948. fww(iz,jz,id,iurb)=ftot*a1/a3
  2949. enddo
  2950. ! radiation from ground to wall
  2951. call fnrms (fnrm,z(jz+1),dxy,ws)
  2952. f12=fnrm
  2953. call fnrms (fnrm,z(jz) ,dxy,ws)
  2954. f1=fnrm
  2955. a1 = ws*dxy
  2956. a12= ws*dxy
  2957. a4=(z(jz+1)-z(jz))*dxy
  2958. ftot=(a12*f12-a12*f1)/a1
  2959. fgw(jz,id,iurb)=ftot*a1/a4
  2960. ! radiation from sky to wall
  2961. call fnrms(fnrm,hut-z(jz) ,dxy,ws)
  2962. f12 = fnrm
  2963. call fnrms (fnrm,hut-z(jz+1),dxy,ws)
  2964. f1 =fnrm
  2965. a1 = ws*dxy
  2966. a12= ws*dxy
  2967. a4 = (z(jz+1)-z(jz))*dxy
  2968. ftot=(a12*f12-a12*f1)/a1
  2969. fsw(jz,id,iurb)=ftot*a1/a4
  2970. enddo
  2971. ! radiation from wall to sky
  2972. do iz=1,nz_u
  2973. call fnrms(fnrm,ws,dxy,hut-z(iz))
  2974. f12=fnrm
  2975. call fnrms(fnrm,ws,dxy,hut-z(iz+1))
  2976. f1=fnrm
  2977. a1 = (z(iz+1)-z(iz))*dxy
  2978. a2 = (hut-z(iz+1))*dxy
  2979. a12= (hut-z(iz))*dxy
  2980. a4 = ws*dxy
  2981. ftot=(a12*f12-a2*f1)/a1
  2982. fws(iz,id,iurb)=ftot*a1/a4
  2983. enddo
  2984. !!!!!!!!!!!!!
  2985. do iz=1,nz_u
  2986. ! radiation from wall to ground
  2987. call fnrms (fnrm,ws,dxy,z(iz+1))
  2988. f12=fnrm
  2989. call fnrms (fnrm,ws,dxy,z(iz ))
  2990. f1 =fnrm
  2991. a1= (z(iz+1)-z(iz) )*dxy
  2992. a2 = z(iz)*dxy
  2993. a12= z(iz+1)*dxy
  2994. a4 = ws*dxy
  2995. ftot=(a12*f12-a2*f1)/a1
  2996. fwg(iz,id,iurb)=ftot*a1/a4
  2997. enddo
  2998. ! radiation from sky to ground
  2999. call fprls (fprl,dxy,ws,hut)
  3000. fsg(id,iurb)=fprl
  3001. return
  3002. end subroutine view_factors
  3003. ! ===6=8===============================================================72
  3004. ! ===6=8===============================================================72
  3005. SUBROUTINE fprls (fprl,a,b,c)
  3006. implicit none
  3007. real a,b,c
  3008. real x,y
  3009. real fprl
  3010. x=a/c
  3011. y=b/c
  3012. if(a.eq.0.or.b.eq.0.)then
  3013. fprl=0.
  3014. else
  3015. fprl=log( ( (1.+x**2)*(1.+y**2)/(1.+x**2+y**2) )**.5)+ &
  3016. y*((1.+x**2)**.5)*atan(y/((1.+x**2)**.5))+ &
  3017. x*((1.+y**2)**.5)*atan(x/((1.+y**2)**.5))- &
  3018. y*atan(y)-x*atan(x)
  3019. fprl=fprl*2./(pi*x*y)
  3020. endif
  3021. return
  3022. end subroutine fprls
  3023. ! ===6=8===============================================================72
  3024. ! ===6=8===============================================================72
  3025. SUBROUTINE fnrms (fnrm,a,b,c)
  3026. implicit none
  3027. real a,b,c
  3028. real x,y,z,a1,a2,a3,a4,a5,a6
  3029. real fnrm
  3030. x=a/b
  3031. y=c/b
  3032. z=x**2+y**2
  3033. if(y.eq.0.or.x.eq.0)then
  3034. fnrm=0.
  3035. else
  3036. a1=log( (1.+x*x)*(1.+y*y)/(1.+z) )
  3037. a2=y*y*log(y*y*(1.+z)/z/(1.+y*y) )
  3038. a3=x*x*log(x*x*(1.+z)/z/(1.+x*x) )
  3039. a4=y*atan(1./y)
  3040. a5=x*atan(1./x)
  3041. a6=sqrt(z)*atan(1./sqrt(z))
  3042. fnrm=0.25*(a1+a2+a3)+a4+a5-a6
  3043. fnrm=fnrm/(pi*y)
  3044. endif
  3045. return
  3046. end subroutine fnrms
  3047. ! ===6=8===============================================================72
  3048. SUBROUTINE init_para(alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u,&
  3049. twini_u,trini_u,tgini_u,albg_u,albw_u,albr_u,albwin_u,emg_u,emw_u,&
  3050. emr_u,emwind_u,z0g_u,z0r_u,nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b, &
  3051. cop_u, pwin_u, beta_u, sw_cond_u, time_on_u, time_off_u, &
  3052. targtemp_u, gaptemp_u, targhum_u, gaphum_u, perflo_u, hsesf_u, hsequip)
  3053. ! initialization routine, where the variables from the table are read
  3054. implicit none
  3055. integer iurb ! urban class number
  3056. ! Building parameters
  3057. real alag_u(nurbm) ! Ground thermal diffusivity [m^2 s^-1]
  3058. real alaw_u(nurbm) ! Wall thermal diffusivity [m^2 s^-1]
  3059. real alar_u(nurbm) ! Roof thermal diffusivity [m^2 s^-1]
  3060. real csg_u(nurbm) ! Specific heat of the ground material [J m^3 K^-1]
  3061. real csw_u(nurbm) ! Specific heat of the wall material [J m^3 K^-1]
  3062. real csr_u(nurbm) ! Specific heat of the roof material [J m^3 K^-1]
  3063. real twini_u(nurbm) ! Temperature inside the buildings behind the wall [K]
  3064. real trini_u(nurbm) ! Temperature inside the buildings behind the roof [K]
  3065. real tgini_u(nurbm) ! Initial road temperature
  3066. ! Radiation parameters
  3067. real albg_u(nurbm) ! Albedo of the ground
  3068. real albw_u(nurbm) ! Albedo of the wall
  3069. real albr_u(nurbm) ! Albedo of the roof
  3070. real albwin_u(nurbm) ! Albedo of the window
  3071. real emg_u(nurbm) ! Emissivity of ground
  3072. real emw_u(nurbm) ! Emissivity of wall
  3073. real emr_u(nurbm) ! Emissivity of roof
  3074. real emwind_u(nurbm) ! Emissivity of windows
  3075. ! Roughness parameters
  3076. real z0g_u(nurbm) ! The ground's roughness length
  3077. real z0r_u(nurbm) ! The roof's roughness length
  3078. ! Street parameters
  3079. integer nd_u(nurbm) ! Number of street direction for each urban class
  3080. real strd_u(ndm,nurbm) ! Street length (fix to greater value to the horizontal length of the cells)
  3081. real drst_u(ndm,nurbm) ! Street direction [degree]
  3082. real ws_u(ndm,nurbm) ! Street width [m]
  3083. real bs_u(ndm,nurbm) ! Building width [m]
  3084. real h_b(nz_um,nurbm) ! Bulding's heights [m]
  3085. real d_b(nz_um,nurbm) ! The probability that a building has an height h_b
  3086. integer i,iu
  3087. integer nurb ! number of urban classes used
  3088. real, intent(out) :: cop_u(nurbm)
  3089. real, intent(out) :: pwin_u(nurbm)
  3090. real, intent(out) :: beta_u(nurbm)
  3091. integer, intent(out) :: sw_cond_u(nurbm)
  3092. real, intent(out) :: time_on_u(nurbm)
  3093. real, intent(out) :: time_off_u(nurbm)
  3094. real, intent(out) :: targtemp_u(nurbm)
  3095. real, intent(out) :: gaptemp_u(nurbm)
  3096. real, intent(out) :: targhum_u(nurbm)
  3097. real, intent(out) :: gaphum_u(nurbm)
  3098. real, intent(out) :: perflo_u(nurbm)
  3099. real, intent(out) :: hsesf_u(nurbm)
  3100. real, intent(out) :: hsequip(24)
  3101. !
  3102. !We initialize
  3103. !
  3104. h_b=0.
  3105. d_b=0.
  3106. nurb=ICATE
  3107. do iu=1,nurb
  3108. nd_u(iu)=0
  3109. enddo
  3110. csw_u=CAPB_TBL / (( 1.0 / 4.1868 ) * 1.E-6)
  3111. csr_u=CAPR_TBL / (( 1.0 / 4.1868 ) * 1.E-6)
  3112. csg_u=CAPG_TBL / (( 1.0 / 4.1868 ) * 1.E-6)
  3113. do i=1,icate
  3114. alaw_u(i)=AKSB_TBL(i) / csw_u(i) / (( 1.0 / 4.1868 ) * 1.E-2)
  3115. alar_u(i)=AKSR_TBL(i) / csr_u(i) / (( 1.0 / 4.1868 ) * 1.E-2)
  3116. alag_u(i)=AKSG_TBL(i) / csg_u(i) / (( 1.0 / 4.1868 ) * 1.E-2)
  3117. enddo
  3118. twini_u=TBLEND_TBL
  3119. trini_u=TRLEND_TBL
  3120. tgini_u=TGLEND_TBL
  3121. albw_u=ALBB_TBL
  3122. albr_u=ALBR_TBL
  3123. albg_u=ALBG_TBL
  3124. emw_u=EPSB_TBL
  3125. emr_u=EPSR_TBL
  3126. emg_u=EPSG_TBL
  3127. z0r_u=Z0R_TBL
  3128. z0g_u=Z0G_TBL
  3129. nd_u=NUMDIR_TBL
  3130. !MT BEM
  3131. cop_u = cop_tbl
  3132. pwin_u = pwin_tbl
  3133. beta_u = beta_tbl
  3134. sw_cond_u = sw_cond_tbl
  3135. time_on_u = time_on_tbl
  3136. time_off_u = time_off_tbl
  3137. targtemp_u = targtemp_tbl
  3138. gaptemp_u = gaptemp_tbl
  3139. targhum_u = targhum_tbl
  3140. gaphum_u = gaphum_tbl
  3141. perflo_u = perflo_tbl
  3142. hsesf_u = hsesf_tbl
  3143. hsequip = hsequip_tbl
  3144. do iu=1,icate
  3145. if(ndm.lt.nd_u(iu))then
  3146. write(*,*)'ndm too small in module_sf_bep, please increase to at least ', nd_u(iu)
  3147. write(*,*)'remember also that num_urban_layers should be equal or greater than nz_um*ndm*nwr-u!'
  3148. stop
  3149. endif
  3150. do i=1,nd_u(iu)
  3151. drst_u(i,iu)=STREET_DIRECTION_TBL(i,iu) * pi/180.
  3152. ws_u(i,iu)=STREET_WIDTH_TBL(i,iu)
  3153. bs_u(i,iu)=BUILDING_WIDTH_TBL(i,iu)
  3154. enddo
  3155. enddo
  3156. do iu=1,ICATE
  3157. if(nz_um.lt.numhgt_tbl(iu)+3)then
  3158. write(*,*)'nz_um too small in module_sf_bep, please increase to at least ',numhgt_tbl(iu)+3
  3159. write(*,*)'remember also that num_urban_layers should be equal or greater than nz_um*ndm*nwr-u!'
  3160. stop
  3161. endif
  3162. do i=1,NUMHGT_TBL(iu)
  3163. h_b(i,iu)=HEIGHT_BIN_TBL(i,iu)
  3164. d_b(i,iu)=HPERCENT_BIN_TBL(i,iu)
  3165. enddo
  3166. enddo
  3167. do i=1,ndm
  3168. do iu=1,nurbm
  3169. strd_u(i,iu)=100000.
  3170. enddo
  3171. enddo
  3172. do iu=1,nurb
  3173. emwind_u(iu)=0.9
  3174. call albwindow(albwin_u(iu))
  3175. enddo
  3176. return
  3177. end subroutine init_para
  3178. ! ===6================================================================72
  3179. ! ===6================================================================72
  3180. subroutine upward_rad(nd_u,nz_u,ws,bs,sigma,pb,ss, &
  3181. tg,emg_u,albg_u,rlg,rsg,sfg, &
  3182. tw,emw_u,albw_u,rlw,rsw,sfw, &
  3183. tr,emr_u,albr_u,emwind,albwind,twlev,pwin, &
  3184. sfwind,rld,rs, sfr, &
  3185. rs_abs,rl_up,emiss,grdflx_urb)
  3186. !
  3187. ! IN this surboutine we compute the upward longwave flux, and the albedo
  3188. ! needed for the radiation scheme
  3189. !
  3190. implicit none
  3191. !
  3192. !INPUT VARIABLES
  3193. !
  3194. real rsw(2*ndm,nz_um) ! Short wave radiation at the wall for a given canyon direction [W/m2]
  3195. real rlw(2*ndm,nz_um) ! Long wave radiation at the walls for a given canyon direction [W/m2]
  3196. real rsg(ndm) ! Short wave radiation at the canyon for a given canyon direction [W/m2]
  3197. real rlg(ndm) ! Long wave radiation at the ground for a given canyon direction [W/m2]
  3198. real rs ! Short wave radiation at the horizontal surface from the sun [W/m²]
  3199. real sfw(2*ndm,nz_um) ! Sensible heat flux from walls [W/m²]
  3200. real sfg(ndm) ! Sensible heat flux from ground (road) [W/m²]
  3201. real sfr(ndm,nz_um) ! Sensible heat flux from roofs [W/m²]
  3202. real rld ! Long wave radiation from the sky [W/m²]
  3203. real albg_u ! albedo of the ground/street
  3204. real albw_u ! albedo of the walls
  3205. real albr_u ! albedo of the roof
  3206. real ws(ndm) ! width of the street
  3207. real bs(ndm)
  3208. ! building size
  3209. real pb(nz_um) ! Probability to have a building with an height equal or higher
  3210. integer nz_u
  3211. real ss(nz_um) ! Probability to have a building of a given height
  3212. real sigma
  3213. real emg_u ! emissivity of the street
  3214. real emw_u ! emissivity of the wall
  3215. real emr_u ! emissivity of the roof
  3216. real tw(2*ndm,nz_um) ! Temperature in each layer of the wall [K]
  3217. real tr(ndm,nz_um,nwr_u) ! Temperature in each layer of the roof [K]
  3218. real tg(ndm,ng_u) ! Temperature in each layer of the ground [K]
  3219. integer id ! street direction
  3220. integer nd_u ! number of street directions
  3221. !
  3222. !New variables BEM
  3223. !
  3224. real emwind !Emissivity of the windows
  3225. real albwind !Albedo of the windows
  3226. real twlev(2*ndm,nz_um) !Averaged Temperature of the windows
  3227. real pwin !Coverage area fraction of the windows
  3228. real gflwin !Heat stored for the windows
  3229. real sfwind(2*ndm,nz_um) !Sensible heat flux from windows [W/m²]
  3230. !OUTPUT/INPUT
  3231. real rs_abs ! absrobed solar radiationfor this street direction
  3232. real rl_up ! upward longwave radiation for this street direction
  3233. real emiss ! mean emissivity
  3234. real grdflx_urb ! ground heat flux
  3235. !LOCAL
  3236. integer iz,iw
  3237. real rl_inc,rl_emit
  3238. real gfl
  3239. integer ix,iy,iwrong
  3240. iwrong=1
  3241. do iz=1,nz_u+1
  3242. do id=1,nd_u
  3243. do iw=1,nwr_u
  3244. if(tr(id,iz,iw).lt.100.)then
  3245. write(*,*)'in upward_rad ',iz,id,iw,tr(id,iz,iw)
  3246. iwrong=0
  3247. endif
  3248. enddo
  3249. enddo
  3250. enddo
  3251. if(iwrong.eq.0)stop
  3252. rl_up=0.
  3253. rs_abs=0.
  3254. rl_inc=0.
  3255. emiss=0.
  3256. rl_emit=0.
  3257. grdflx_urb=0.
  3258. do id=1,nd_u
  3259. rl_emit=rl_emit-( emg_u*sigma*(tg(id,ng_u)**4.)+(1-emg_u)*rlg(id))*ws(id)/(ws(id)+bs(id))/nd_u
  3260. rl_inc=rl_inc+rlg(id)*ws(id)/(ws(id)+bs(id))/nd_u
  3261. rs_abs=rs_abs+(1.-albg_u)*rsg(id)*ws(id)/(ws(id)+bs(id))/nd_u
  3262. gfl=(1.-albg_u)*rsg(id)+emg_u*rlg(id)-emg_u*sigma*(tg(id,ng_u)**4.)+sfg(id)
  3263. grdflx_urb=grdflx_urb-gfl*ws(id)/(ws(id)+bs(id))/nd_u
  3264. do iz=2,nz_u
  3265. rl_emit=rl_emit-(emr_u*sigma*(tr(id,iz,nwr_u)**4.)+(1-emr_u)*rld)*ss(iz)*bs(id)/(ws(id)+bs(id))/nd_u
  3266. rl_inc=rl_inc+rld*ss(iz)*bs(id)/(ws(id)+bs(id))/nd_u
  3267. rs_abs=rs_abs+(1.-albr_u)*rs*ss(iz)*bs(id)/(ws(id)+bs(id))/nd_u
  3268. gfl=(1.-albr_u)*rs+emr_u*rld-emr_u*sigma*(tr(id,iz,nwr_u)**4.)+sfr(id,iz)
  3269. grdflx_urb=grdflx_urb-gfl*ss(iz)*bs(id)/(ws(id)+bs(id))/nd_u
  3270. enddo
  3271. do iz=1,nz_u
  3272. rl_emit=rl_emit-(emw_u*(1.-pwin)*sigma*(tw(2*id-1,iz)**4.+tw(2*id,iz)**4.)+ &
  3273. (emwind*pwin*sigma*(twlev(2*id-1,iz)**4.+twlev(2*id,iz)**4.))+ &
  3274. ((1.-emw_u)*(1.-pwin)+pwin*(1.-emwind))*(rlw(2*id-1,iz)+rlw(2*id,iz)))* &
  3275. dz_u*pb(iz+1)/(ws(id)+bs(id))/nd_u
  3276. rl_inc=rl_inc+((rlw(2*id-1,iz)+rlw(2*id,iz)))*dz_u*pb(iz+1)/(ws(id)+bs(id))/nd_u
  3277. rs_abs=rs_abs+(((1.-albw_u)*(1.-pwin)+(1.-albwind)*pwin)*(rsw(2*id-1,iz)+rsw(2*id,iz)))*&
  3278. dz_u*pb(iz+1)/(ws(id)+bs(id))/nd_u
  3279. gfl=(1.-albw_u)*(rsw(2*id-1,iz)+rsw(2*id,iz)) +emw_u*( rlw(2*id-1,iz)+rlw(2*id,iz) ) &
  3280. -emw_u*sigma*( tw(2*id-1,iz)**4.+tw(2*id,iz)**4. )+(sfw(2*id-1,iz)+sfw(2*id,iz))
  3281. gflwin=(1.-albwind)*(rsw(2*id-1,iz)+rsw(2*id,iz)) +emwind*(rlw(2*id-1,iz)+rlw(2*id,iz)) &
  3282. -emwind*sigma*( twlev(2*id-1,iz)**4.+twlev(2*id,iz)**4.)+(sfwind(2*id-1,iz)+sfwind(2*id,iz))
  3283. grdflx_urb=grdflx_urb-(gfl*(1.-pwin)+pwin*gflwin)*dz_u*pb(iz+1)/(ws(id)+bs(id))/nd_u
  3284. enddo
  3285. enddo
  3286. emiss=(emg_u+emw_u+emr_u)/3.
  3287. rl_up=(rl_inc+rl_emit)-rld
  3288. return
  3289. END SUBROUTINE upward_rad
  3290. !====6=8===============================================================72
  3291. !====6=8===============================================================72
  3292. ! ===6================================================================72
  3293. ! ===6================================================================72
  3294. subroutine albwindow(albwin)
  3295. !-------------------------------------------------------------------
  3296. implicit none
  3297. ! -------------------------------------------------------------------
  3298. !Based on the
  3299. !paper of J.Karlsson and A.Roos(2000):"modelling the angular behaviour
  3300. !of the total solar energy transmittance of windows"
  3301. !Solar Energy Vol.69,No.4,pp. 321-329.
  3302. ! -------------------------------------------------------------------
  3303. !Input
  3304. !-----
  3305. !Output
  3306. !------
  3307. real albwin ! albedo of the window
  3308. !Local
  3309. !-----
  3310. real a,b,c !Polynomial coefficients
  3311. real alfa,delta,gama !Polynomial powers
  3312. real g0 !transmittance when the angle
  3313. !of incidence is normal to the surface.
  3314. real asup,ainf
  3315. real fonc
  3316. !Constants
  3317. !--------------------
  3318. real epsilon !accuracy of the integration
  3319. parameter (epsilon=1.e-07)
  3320. real n1,n2 !Index of refraction for glasses and air
  3321. parameter(n1=1.,n2=1.5)
  3322. integer intg,k
  3323. !--------------------------------------------------------------------
  3324. if (q_num.eq.0) then
  3325. write(*,*) 'Category parameter of the windows no valid'
  3326. stop
  3327. endif
  3328. g0=4.*n1*n2/((n1+n2)*(n1+n2))
  3329. a=8.
  3330. b=0.25/q_num
  3331. c=1.-a-b
  3332. alfa =5.2 + (0.7*q_num)
  3333. delta =2.
  3334. gama =(5.26+0.06*p_num)+(0.73+0.04*p_num)*q_num
  3335. intg=1
  3336. !----------------------------------------------------------------------
  3337. 100 asup=0.
  3338. ainf=0.
  3339. do k=1,intg
  3340. call foncs(fonc,(pi*k/intg),a,b,c,alfa,delta,gama)
  3341. asup=asup+(pi/intg)*fonc
  3342. enddo
  3343. intg=intg+1
  3344. do k=1,intg
  3345. call foncs(fonc,(pi*k/intg),a,b,c,alfa,delta,gama)
  3346. ainf=ainf+(pi/intg)*fonc
  3347. enddo
  3348. if(abs(asup-ainf).lt.epsilon) then
  3349. albwin=1-g0+(g0/2.)*asup
  3350. else
  3351. goto 100
  3352. endif
  3353. !----------------------------------------------------------------------
  3354. return
  3355. end subroutine albwindow
  3356. !====================================================================72
  3357. !====================================================================72
  3358. subroutine foncs(fonc,x,aa,bb,cc,alf,delt,gam)
  3359. implicit none
  3360. !
  3361. real x,aa,bb,cc
  3362. real alf,delt,gam
  3363. real fonc
  3364. fonc=(((aa*(x**alf))/(pi**alf))+ &
  3365. ((bb*(x**delt))/(pi**delt))+ &
  3366. ((cc*(x**gam))/(pi**gam)))*sin(x)
  3367. return
  3368. end subroutine foncs
  3369. !====================================================================72
  3370. !====================================================================72
  3371. END MODULE module_sf_bep_bem