PageRenderTime 37ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 1ms

/wrfv2_fire/phys/module_sf_bep.F

http://github.com/jbeezley/wrf-fire
FORTRAN Legacy | 3239 lines | 1873 code | 634 blank | 732 comment | 38 complexity | 0c3989f4b2ba6aaa590bea8e69427a24 MD5 | raw file
Possible License(s): AGPL-1.0
  1. MODULE module_sf_bep
  2. !USE module_model_constants
  3. USE module_sf_urban
  4. ! SGClarke 09/11/2008
  5. ! Access urban_param.tbl values through calling urban_param_init in module_physics_init
  6. ! for CASE (BEPSCHEME) select sf_urban_physics
  7. !
  8. ! -----------------------------------------------------------------------
  9. ! Dimension for the array used in the BEP module
  10. ! -----------------------------------------------------------------------
  11. integer nurbm ! Maximum number of urban classes
  12. parameter (nurbm=3)
  13. integer ndm ! Maximum number of street directions
  14. parameter (ndm=2)
  15. integer nz_um ! Maximum number of vertical levels in the urban grid
  16. parameter(nz_um=13)
  17. integer ng_u ! Number of grid levels in the ground
  18. parameter (ng_u=10)
  19. integer nwr_u ! Number of grid levels in the walls or roofs
  20. parameter (nwr_u=10)
  21. real dz_u ! Urban grid resolution
  22. parameter (dz_u=5.)
  23. ! The change of ng_u, nwr_u should be done in agreement with the block data
  24. ! in the routine "surf_temp"
  25. ! -----------------------------------------------------------------------
  26. ! Constant used in the BEP module
  27. ! -----------------------------------------------------------------------
  28. real vk ! von Karman constant
  29. real g_u ! Gravity acceleration
  30. real pi !
  31. real r ! Perfect gas constant
  32. real cp_u ! Specific heat at constant pressure
  33. real rcp_u !
  34. real sigma !
  35. real p0 ! Reference pressure at the sea level
  36. real cdrag ! Drag force constant
  37. parameter(vk=0.40,g_u=9.81,pi=3.141592653,r=287.,cp_u=1004.)
  38. parameter(rcp_u=r/cp_u,sigma=5.67e-08,p0=1.e+5,cdrag=0.4)
  39. ! -----------------------------------------------------------------------
  40. CONTAINS
  41. subroutine BEP(FRC_URB2D,UTYPE_URB2D,itimestep,dz8w,dt,u_phy,v_phy, &
  42. th_phy,rho,p_phy,swdown,glw, &
  43. gmt,julday,xlong,xlat, &
  44. declin_urb,cosz_urb2d,omg_urb2d, &
  45. num_urban_layers, &
  46. trb_urb4d,tw1_urb4d,tw2_urb4d,tgb_urb4d, &
  47. sfw1_urb3d,sfw2_urb3d,sfr_urb3d,sfg_urb3d, &
  48. a_u,a_v,a_t,a_e,b_u,b_v, &
  49. b_t,b_e,dlg,dl_u,sf,vl, &
  50. rl_up,rs_abs,emiss,grdflx_urb, &
  51. ids,ide, jds,jde, kds,kde, &
  52. ims,ime, jms,jme, kms,kme, &
  53. its,ite, jts,jte, kts,kte)
  54. implicit none
  55. !------------------------------------------------------------------------
  56. ! Input
  57. !------------------------------------------------------------------------
  58. INTEGER :: ids,ide, jds,jde, kds,kde, &
  59. ims,ime, jms,jme, kms,kme, &
  60. its,ite, jts,jte, kts,kte, &
  61. itimestep
  62. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: DZ8W
  63. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: P_PHY
  64. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: RHO
  65. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: TH_PHY
  66. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: T_PHY
  67. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: U_PHY
  68. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: V_PHY
  69. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: U
  70. REAL, DIMENSION( ims:ime, kms:kme, jms:jme ):: V
  71. REAL, DIMENSION( ims:ime , jms:jme ) :: GLW
  72. REAL, DIMENSION( ims:ime , jms:jme ) :: swdown
  73. REAL, DIMENSION( ims:ime, jms:jme ) :: UST
  74. INTEGER, DIMENSION( ims:ime , jms:jme ), INTENT(IN ):: UTYPE_URB2D
  75. REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN ):: FRC_URB2D
  76. REAL, INTENT(IN ) :: GMT
  77. INTEGER, INTENT(IN ) :: JULDAY
  78. REAL, DIMENSION( ims:ime, jms:jme ), &
  79. INTENT(IN ) :: XLAT, XLONG
  80. REAL, INTENT(IN) :: DECLIN_URB
  81. REAL, DIMENSION( ims:ime, jms:jme ), INTENT(IN) :: COSZ_URB2D
  82. REAL, DIMENSION( ims:ime, jms:jme ), INTENT(IN) :: OMG_URB2D
  83. INTEGER, INTENT(IN ) :: num_urban_layers
  84. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: trb_urb4d
  85. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: tw1_urb4d
  86. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: tw2_urb4d
  87. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: tgb_urb4d
  88. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: sfw1_urb3d
  89. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: sfw2_urb3d
  90. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: sfr_urb3d
  91. REAL, DIMENSION( ims:ime, 1:num_urban_layers, jms:jme ), INTENT(INOUT) :: sfg_urb3d
  92. ! integer nx,ny,nz ! Number of points in the mesocsale grid
  93. real z(ims:ime,kms:kme,jms:jme) ! Vertical coordinates
  94. REAL, INTENT(IN ):: DT ! Time step
  95. ! real zr(ims:ime,jms:jme) ! Solar zenith angle
  96. ! real deltar(ims:ime,jms:jme) ! Declination of the sun
  97. ! real ah(ims:ime,jms:jme) ! Hour angle
  98. ! real rs(ims:ime,jms:jme) ! Solar radiation
  99. !------------------------------------------------------------------------
  100. ! Output
  101. !------------------------------------------------------------------------
  102. ! real tsk(ims:ime,jms:jme) ! Average of surface temperatures (roads and roofs)
  103. !
  104. ! Implicit and explicit components of the source and sink terms at each levels,
  105. ! the fluxes can be computed as follow: FX = A*X + B example: t_fluxes = a_t * pt + b_t
  106. real a_u(ims:ime,kms:kme,jms:jme) ! Implicit component for the momemtum in X-direction (center)
  107. real a_v(ims:ime,kms:kme,jms:jme) ! Implicit component for the momemtum in Y-direction (center)
  108. real a_t(ims:ime,kms:kme,jms:jme) ! Implicit component for the temperature
  109. real a_e(ims:ime,kms:kme,jms:jme) ! Implicit component for the TKE
  110. real b_u(ims:ime,kms:kme,jms:jme) ! Explicit component for the momemtum in X-direction (center)
  111. real b_v(ims:ime,kms:kme,jms:jme) ! Explicit component for the momemtum in Y-direction (center)
  112. real b_t(ims:ime,kms:kme,jms:jme) ! Explicit component for the temperature
  113. real b_e(ims:ime,kms:kme,jms:jme) ! Explicit component for the TKE
  114. real dlg(ims:ime,kms:kme,jms:jme) ! Height above ground (L_ground in formula (24) of the BLM paper).
  115. real dl_u(ims:ime,kms:kme,jms:jme) ! Length scale (lb in formula (22) ofthe BLM paper).
  116. ! urban surface and volumes
  117. real sf(ims:ime,kms:kme,jms:jme) ! surface of the urban grid cells
  118. real vl(ims:ime,kms:kme,jms:jme) ! volume of the urban grid cells
  119. ! urban fluxes
  120. real rl_up(ims:ime,jms:jme) ! upward long wave radiation
  121. real rs_abs(ims:ime,jms:jme) ! absorbed short wave radiation
  122. real emiss(ims:ime,jms:jme) ! emissivity averaged for urban surfaces
  123. real grdflx_urb(ims:ime,jms:jme) ! ground heat flux for urban areas
  124. !------------------------------------------------------------------------
  125. ! Local
  126. !------------------------------------------------------------------------
  127. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  128. ! Building parameters
  129. real alag_u(nurbm) ! Ground thermal diffusivity [m^2 s^-1]
  130. real alaw_u(nurbm) ! Wall thermal diffusivity [m^2 s^-1]
  131. real alar_u(nurbm) ! Roof thermal diffusivity [m^2 s^-1]
  132. real csg_u(nurbm) ! Specific heat of the ground material [J m^3 K^-1]
  133. real csw_u(nurbm) ! Specific heat of the wall material [J m^3 K^-1]
  134. real csr_u(nurbm) ! Specific heat of the roof material [J m^3 K^-1]
  135. real twini_u(nurbm) ! Initial temperature inside the building's wall [K]
  136. real trini_u(nurbm) ! Initial temperature inside the building's roof [K]
  137. real tgini_u(nurbm) ! Initial road temperature
  138. !
  139. ! for twini_u, and trini_u the initial value at the deepest level is kept constant during the simulation
  140. !
  141. ! Radiation paramters
  142. real albg_u(nurbm) ! Albedo of the ground
  143. real albw_u(nurbm) ! Albedo of the wall
  144. real albr_u(nurbm) ! Albedo of the roof
  145. real emg_u(nurbm) ! Emissivity of ground
  146. real emw_u(nurbm) ! Emissivity of wall
  147. real emr_u(nurbm) ! Emissivity of roof
  148. ! fww,fwg,fgw,fsw,fsg are the view factors used to compute the long wave
  149. ! and the short wave radation.
  150. real fww(nz_um,nz_um,ndm,nurbm) ! from wall to wall
  151. real fwg(nz_um,ndm,nurbm) ! from wall to ground
  152. real fgw(nz_um,ndm,nurbm) ! from ground to wall
  153. real fsw(nz_um,ndm,nurbm) ! from sky to wall
  154. real fws(nz_um,ndm,nurbm) ! from sky to wall
  155. real fsg(ndm,nurbm) ! from sky to ground
  156. ! Roughness parameters
  157. real z0g_u(nurbm) ! The ground's roughness length
  158. real z0r_u(nurbm) ! The roof's roughness length
  159. ! Street parameters
  160. integer nd_u(nurbm) ! Number of street direction for each urban class
  161. real strd_u(ndm,nurbm) ! Street length (fix to greater value to the horizontal length of the cells)
  162. real drst_u(ndm,nurbm) ! Street direction
  163. real ws_u(ndm,nurbm) ! Street width
  164. real bs_u(ndm,nurbm) ! Building width
  165. real h_b(nz_um,nurbm) ! Bulding's heights
  166. real d_b(nz_um,nurbm) ! Probability that a building has an height h_b
  167. real ss_u(nz_um,nurbm) ! Probability that a building has an height equal to z
  168. real pb_u(nz_um,nurbm) ! Probability that a building has an height greater or equal to z
  169. ! Grid parameters
  170. integer nz_u(nurbm) ! Number of layer in the urban grid
  171. real z_u(nz_um) ! Height of the urban grid levels
  172. ! 1D array used for the input and output of the routine "urban"
  173. real z1D(kms:kme) ! vertical coordinates
  174. real ua1D(kms:kme) ! wind speed in the x directions
  175. real va1D(kms:kme) ! wind speed in the y directions
  176. real pt1D(kms:kme) ! potential temperature
  177. real da1D(kms:kme) ! air density
  178. real pr1D(kms:kme) ! air pressure
  179. real pt01D(kms:kme) ! reference potential temperature
  180. real zr1D ! zenith angle
  181. real deltar1D ! declination of the sun
  182. real ah1D ! hour angle (it should come from the radiation routine)
  183. real rs1D ! solar radiation
  184. real rld1D ! downward flux of the longwave radiation
  185. real tw1D(2*ndm,nz_um,nwr_u) ! temperature in each layer of the wall
  186. real tg1D(ndm,ng_u) ! temperature in each layer of the ground
  187. real tr1D(ndm,nz_um,nwr_u) ! temperature in each layer of the roof
  188. real sfw1D(2*ndm,nz_um) ! sensible heat flux from walls
  189. real sfg1D(ndm) ! sensible heat flux from ground (road)
  190. real sfr1D(ndm,nz_um) ! sensible heat flux from roofs
  191. real sf1D(kms:kme) ! surface of the urban grid cells
  192. real vl1D(kms:kme) ! volume of the urban grid cells
  193. real a_u1D(kms:kme) ! Implicit component of the momentum sources or sinks in the X-direction
  194. real a_v1D(kms:kme) ! Implicit component of the momentum sources or sinks in the Y-direction
  195. real a_t1D(kms:kme) ! Implicit component of the heat sources or sinks
  196. real a_e1D(kms:kme) ! Implicit component of the TKE sources or sinks
  197. real b_u1D(kms:kme) ! Explicit component of the momentum sources or sinks in the X-direction
  198. real b_v1D(kms:kme) ! Explicit component of the momentum sources or sinks in the Y-direction
  199. real b_t1D(kms:kme) ! Explicit component of the heat sources or sinks
  200. real b_e1D(kms:kme) ! Explicit component of the TKE sources or sinks
  201. real dlg1D(kms:kme) ! Height above ground (L_ground in formula (24) of the BLM paper).
  202. real dl_u1D(kms:kme) ! Length scale (lb in formula (22) ofthe BLM paper)
  203. real tsk1D ! Average of the road surface temperatures
  204. real time_bep
  205. ! arrays used to collapse indexes
  206. integer ind_zwd(nz_um,nwr_u,ndm)
  207. integer ind_gd(ng_u,ndm)
  208. integer ind_zd(nz_um,ndm)
  209. !
  210. integer ix,iy,iz,iurb,id,iz_u,iw,ig,ir,ix1,iy1,k
  211. integer it, nint
  212. integer iii
  213. real time_h,tempo,shtot
  214. logical first
  215. character(len=80) :: text
  216. data first/.true./
  217. save first,time_bep
  218. save alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u, &
  219. albg_u,albw_u,albr_u,emg_u,emw_u,emr_u,fww,fwg,fgw,fsw,fws,fsg, &
  220. z0g_u,z0r_u, nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b,ss_u,pb_u, &
  221. nz_u,z_u
  222. !------------------------------------------------------------------------
  223. ! Calculation of the momentum, heat and turbulent kinetic fluxes
  224. ! produced by buildings
  225. !
  226. ! Reference:
  227. ! Martilli, A., Clappier, A., Rotach, M.W.:2002, 'AN URBAN SURFACE EXCHANGE
  228. ! PARAMETERISATION FOR MESOSCALE MODELS', Boundary-Layer Meteorolgy 104:
  229. ! 261-304
  230. !------------------------------------------------------------------------
  231. !prepare the arrays to collapse indexes
  232. if(num_urban_layers.lt.nz_um*ndm*nwr_u)then
  233. write(*,*)'num_urban_layers too small, please increase to at least ', nz_um*ndm*nwr_u
  234. stop
  235. endif
  236. iii=0
  237. do iz_u=1,nz_um
  238. do iw=1,nwr_u
  239. do id=1,ndm
  240. iii=iii+1
  241. ind_zwd(iz_u,iw,id)=iii
  242. enddo
  243. enddo
  244. enddo
  245. iii=0
  246. do ig=1,ng_u
  247. do id=1,ndm
  248. iii=iii+1
  249. ind_gd(ig,id)=iii
  250. enddo
  251. enddo
  252. iii=0
  253. do iz_u=1,nz_um
  254. do id=1,ndm
  255. iii=iii+1
  256. ind_zd(iz_u,id)=iii
  257. enddo
  258. enddo
  259. do ix=its,ite
  260. do iy=jts,jte
  261. z(ix,kts,iy)=0.
  262. do iz=kts+1,kte+1
  263. z(ix,iz,iy)=z(ix,iz-1,iy)+dz8w(ix,iz-1,iy)
  264. enddo
  265. enddo
  266. enddo
  267. if (first) then ! True only on first call
  268. call init_para(alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u,&
  269. twini_u,trini_u,tgini_u,albg_u,albw_u,albr_u,emg_u,emw_u,&
  270. emr_u,z0g_u,z0r_u,nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b)
  271. ! Initialisation of the urban parameters and calculation of the view factors
  272. call icBEP(alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u, &
  273. albg_u,albw_u,albr_u,emg_u,emw_u,emr_u, &
  274. fww,fwg,fgw,fsw,fws,fsg, &
  275. z0g_u,z0r_u, &
  276. nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b,ss_u,pb_u, &
  277. nz_u,z_u, &
  278. twini_u,trini_u)
  279. first=.false.
  280. endif ! first
  281. do ix=its,ite
  282. do iy=jts,jte
  283. if (FRC_URB2D(ix,iy).gt.0.) then ! Calling BEP only for existing urban classes.
  284. iurb=UTYPE_URB2D(ix,iy)
  285. do iz= kts,kte
  286. ua1D(iz)=u_phy(ix,iz,iy)
  287. va1D(iz)=v_phy(ix,iz,iy)
  288. pt1D(iz)=th_phy(ix,iz,iy)
  289. da1D(iz)=rho(ix,iz,iy)
  290. pr1D(iz)=p_phy(ix,iz,iy)
  291. ! pt01D(iz)=th_phy(ix,iz,iy)
  292. pt01D(iz)=300.
  293. z1D(iz)=z(ix,iz,iy)
  294. a_u1D(iz)=0.
  295. a_v1D(iz)=0.
  296. a_t1D(iz)=0.
  297. a_e1D(iz)=0.
  298. b_u1D(iz)=0.
  299. b_v1D(iz)=0.
  300. b_t1D(iz)=0.
  301. b_e1D(iz)=0.
  302. enddo
  303. z1D(kte+1)=z(ix,kte+1,iy)
  304. do id=1,ndm
  305. do iz_u=1,nz_um
  306. do iw=1,nwr_u
  307. ! tw1D(2*id-1,iz_u,iw)=tw1_u(ix,iy,ind_zwd(iz_u,iw,id))
  308. ! tw1D(2*id,iz_u,iw)=tw2_u(ix,iy,ind_zwd(iz_u,iw,id))
  309. if(ind_zwd(iz_u,iw,id).gt.num_urban_layers)write(*,*)'ind_zwd too big w',ind_zwd(iz_u,iw,id)
  310. tw1D(2*id-1,iz_u,iw)=tw1_urb4d(ix,ind_zwd(iz_u,iw,id),iy)
  311. tw1D(2*id,iz_u,iw)=tw2_urb4d(ix,ind_zwd(iz_u,iw,id),iy)
  312. enddo
  313. enddo
  314. enddo
  315. do id=1,ndm
  316. do ig=1,ng_u
  317. ! tg1D(id,ig)=tg_u(ix,iy,ind_gd(ig,id))
  318. tg1D(id,ig)=tgb_urb4d(ix,ind_gd(ig,id),iy)
  319. enddo
  320. do iz_u=1,nz_um
  321. do ir=1,nwr_u
  322. ! tr1D(id,iz_u,ir)=tr_u(ix,iy,ind_zwd(iz_u,ir,id))
  323. if(ind_zwd(iz_u,ir,id).gt.num_urban_layers)write(*,*)'ind_zwd too big r',ind_zwd(iz_u,ir,id)
  324. tr1D(id,iz_u,ir)=trb_urb4d(ix,ind_zwd(iz_u,ir,id),iy)
  325. enddo
  326. enddo
  327. enddo
  328. do id=1,ndm
  329. do iz=1,nz_um
  330. ! sfw1D(2*id-1,iz)=sfw1(ix,iy,ind_zd(iz,id))
  331. ! sfw1D(2*id,iz)=sfw2(ix,iy,ind_zd(iz,id))
  332. sfw1D(2*id-1,iz)=sfw1_urb3d(ix,ind_zd(iz,id),iy)
  333. sfw1D(2*id,iz)=sfw2_urb3d(ix,ind_zd(iz,id),iy)
  334. enddo
  335. enddo
  336. do id=1,ndm
  337. ! sfg1D(id)=sfg(ix,iy,id)
  338. sfg1D(id)=sfg_urb3d(ix,id,iy)
  339. enddo
  340. do id=1,ndm
  341. do iz=1,nz_um
  342. ! sfr1D(id,iz)=sfr(ix,iy,ind_zd(iz,id))
  343. sfr1D(id,iz)=sfr_urb3d(ix,ind_zd(iz,id),iy)
  344. enddo
  345. enddo
  346. rs1D=swdown(ix,iy)
  347. rld1D=glw(ix,iy)
  348. time_h=(itimestep*dt)/3600.+gmt
  349. zr1D=acos(COSZ_URB2D(ix,iy))
  350. deltar1D=DECLIN_URB
  351. ah1D=OMG_URB2D(ix,iy)
  352. ! call angle(xlong(ix,iy),xlat(ix,iy),julday,time_h,zr1D,deltar1D,ah1D)
  353. call BEP1D(iurb,kms,kme,kts,kte,z1D,dt,ua1D,va1D,pt1D,da1D,pr1D,pt01D, &
  354. zr1D,deltar1D,ah1D,rs1D,rld1D, &
  355. alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u, &
  356. albg_u,albw_u,albr_u,emg_u,emw_u,emr_u, &
  357. fww,fwg,fgw,fsw,fws,fsg, &
  358. z0g_u,z0r_u, &
  359. nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b,ss_u,pb_u, &
  360. nz_u,z_u, &
  361. tw1D,tg1D,tr1D,sfw1D,sfg1D,sfr1D, &
  362. a_u1D,a_v1D,a_t1D,a_e1D, &
  363. b_u1D,b_v1D,b_t1D,b_e1D, &
  364. dlg1D,dl_u1D,tsk1D,sf1D,vl1D,rl_up(ix,iy), &
  365. rs_abs(ix,iy),emiss(ix,iy),grdflx_urb(ix,iy))
  366. do id=1,ndm
  367. do iz=1,nz_um
  368. sfw1_urb3d(ix,ind_zd(iz,id),iy)=sfw1D(2*id-1,iz)
  369. sfw2_urb3d(ix,ind_zd(iz,id),iy)=sfw1D(2*id,iz)
  370. enddo
  371. enddo
  372. do id=1,ndm
  373. sfg_urb3d(ix,id,iy)=sfg1D(id)
  374. enddo
  375. do id=1,ndm
  376. do iz=1,nz_um
  377. sfr_urb3d(ix,ind_zd(iz,id),iy)=sfr1D(id,iz)
  378. enddo
  379. enddo
  380. !
  381. do id=1,ndm
  382. do iz_u=1,nz_um
  383. do iw=1,nwr_u
  384. tw1_urb4d(ix,ind_zwd(iz_u,iw,id),iy)=tw1D(2*id-1,iz_u,iw)
  385. tw2_urb4d(ix,ind_zwd(iz_u,iw,id),iy)=tw1D(2*id,iz_u,iw)
  386. enddo
  387. enddo
  388. enddo
  389. do id=1,ndm
  390. do ig=1,ng_u
  391. tgb_urb4d(ix,ind_gd(ig,id),iy)=tg1D(id,ig)
  392. enddo
  393. do iz_u=1,nz_um
  394. do ir=1,nwr_u
  395. trb_urb4d(ix,ind_zwd(iz_u,ir,id),iy)=tr1D(id,iz_u,ir)
  396. enddo
  397. enddo
  398. enddo
  399. do iz= kts,kte
  400. sf(ix,iz,iy)=sf1D(iz)
  401. vl(ix,iz,iy)=vl1D(iz)
  402. a_u(ix,iz,iy)=a_u1D(iz)
  403. a_v(ix,iz,iy)=a_v1D(iz)
  404. a_t(ix,iz,iy)=a_t1D(iz)
  405. a_e(ix,iz,iy)=a_e1D(iz)
  406. b_u(ix,iz,iy)=b_u1D(iz)
  407. b_v(ix,iz,iy)=b_v1D(iz)
  408. b_t(ix,iz,iy)=b_t1D(iz)
  409. b_e(ix,iz,iy)=b_e1D(iz)
  410. dlg(ix,iz,iy)=dlg1D(iz)
  411. dl_u(ix,iz,iy)=dl_u1D(iz)
  412. enddo
  413. sf(ix,kte+1,iy)=sf1D(kte+1)
  414. ! tsk(ix,iy)=tsk1D
  415. !
  416. endif ! FRC_URB2D
  417. enddo ! iy
  418. enddo ! ix
  419. time_bep=time_bep+dt
  420. return
  421. end subroutine BEP
  422. ! ===6=8===============================================================72
  423. subroutine BEP1D(iurb,kms,kme,kts,kte,z,dt,ua,va,pt,da,pr,pt0, &
  424. zr,deltar,ah,rs,rld, &
  425. alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u, &
  426. albg_u,albw_u,albr_u,emg_u,emw_u,emr_u, &
  427. fww,fwg,fgw,fsw,fws,fsg, &
  428. z0g_u,z0r_u, &
  429. nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b,ss_u,pb_u, &
  430. nz_u,z_u, &
  431. tw,tg,tr,sfw,sfg,sfr, &
  432. a_u,a_v,a_t,a_e, &
  433. b_u,b_v,b_t,b_e, &
  434. dlg,dl_u,tsk,sf,vl,rl_up,rs_abs,emiss,grdflx_urb)
  435. ! ----------------------------------------------------------------------
  436. ! This routine computes the effects of buildings on momentum, heat and
  437. ! TKE (turbulent kinetic energy) sources or sinks and on the mixing length.
  438. ! It provides momentum, heat and TKE sources or sinks at different levels of a
  439. ! mesoscale grid defined by the altitude of its cell interfaces "z" and
  440. ! its number of levels "nz".
  441. ! The meteorological input parameters (wind, temperature, solar radiation)
  442. ! are specified on the "mesoscale grid".
  443. ! The inputs concerning the building and street charateristics are defined
  444. ! on a "urban grid". The "urban grid" is defined with its number of levels
  445. ! "nz_u" and its space step "dz_u".
  446. ! The input parameters are interpolated on the "urban grid". The sources or sinks
  447. ! are calculated on the "urban grid". Finally the sources or sinks are
  448. ! interpolated on the "mesoscale grid".
  449. ! Mesoscale grid Urban grid Mesoscale grid
  450. !
  451. ! z(4) --- ---
  452. ! | |
  453. ! | |
  454. ! | Interpolation Interpolation |
  455. ! | Sources or sinks calculation |
  456. ! z(3) --- ---
  457. ! | ua ua_u --- uv_a a_u |
  458. ! | va va_u | uv_b b_u |
  459. ! | pt pt_u --- uh_b a_v |
  460. ! z(2) --- | etc... etc...---
  461. ! | z_u(1) --- |
  462. ! | | |
  463. ! z(1) ------------------------------------------------------------
  464. !
  465. ! Reference:
  466. ! Martilli, A., Clappier, A., Rotach, M.W.:2002, 'AN URBAN SURFACE EXCHANGE
  467. ! PARAMETERISATION FOR MESOSCALE MODELS', Boundary-Layer Meteorolgy 104:
  468. ! 261-304
  469. ! ----------------------------------------------------------------------
  470. implicit none
  471. ! ----------------------------------------------------------------------
  472. ! INPUT:
  473. ! ----------------------------------------------------------------------
  474. ! Data relative to the "mesoscale grid"
  475. ! integer nz ! Number of vertical levels
  476. integer kms,kme,kts,kte
  477. real z(kms:kme) ! Altitude above the ground of the cell interfaces.
  478. real ua(kms:kme) ! Wind speed in the x direction
  479. real va(kms:kme) ! Wind speed in the y direction
  480. real pt(kms:kme) ! Potential temperature
  481. real da(kms:kme) ! Air density
  482. real pr(kms:kme) ! Air pressure
  483. real pt0(kms:kme) ! Reference potential temperature (could be equal to "pt")
  484. real dt ! Time step
  485. real zr ! Zenith angle
  486. real deltar ! Declination of the sun
  487. real ah ! Hour angle
  488. real rs ! Solar radiation
  489. real rld ! Downward flux of the longwave radiation
  490. ! Data relative to the "urban grid"
  491. integer iurb ! Current urban class
  492. ! Building parameters
  493. real alag_u(nurbm) ! Ground thermal diffusivity [m^2 s^-1]
  494. real alaw_u(nurbm) ! Wall thermal diffusivity [m^2 s^-1]
  495. real alar_u(nurbm) ! Roof thermal diffusivity [m^2 s^-1]
  496. real csg_u(nurbm) ! Specific heat of the ground material [J m^3 K^-1]
  497. real csw_u(nurbm) ! Specific heat of the wall material [J m^3 K^-1]
  498. real csr_u(nurbm) ! Specific heat of the roof material [J m^3 K^-1]
  499. ! Radiation parameters
  500. real albg_u(nurbm) ! Albedo of the ground
  501. real albw_u(nurbm) ! Albedo of the wall
  502. real albr_u(nurbm) ! Albedo of the roof
  503. real emg_u(nurbm) ! Emissivity of ground
  504. real emw_u(nurbm) ! Emissivity of wall
  505. real emr_u(nurbm) ! Emissivity of roof
  506. ! fww,fwg,fgw,fsw,fsg are the view factors used to compute the long and
  507. ! short wave radation.
  508. ! The calculation of these factor is explained in the Appendix A of the BLM paper
  509. real fww(nz_um,nz_um,ndm,nurbm) ! from wall to wall
  510. real fwg(nz_um,ndm,nurbm) ! from wall to ground
  511. real fgw(nz_um,ndm,nurbm) ! from ground to wall
  512. real fsw(nz_um,ndm,nurbm) ! from sky to wall
  513. real fws(nz_um,ndm,nurbm) ! from wall to sky
  514. real fsg(ndm,nurbm) ! from sky to ground
  515. ! Roughness parameters
  516. real z0g_u(nurbm) ! The ground's roughness length
  517. real z0r_u(nurbm) ! The roof's roughness length
  518. ! Street parameters
  519. integer nd_u(nurbm) ! Number of street direction for each urban class
  520. real strd_u(ndm,nurbm) ! Street length (set to a greater value then the horizontal length of the cells)
  521. real drst_u(ndm,nurbm) ! Street direction
  522. real ws_u(ndm,nurbm) ! Street width
  523. real bs_u(ndm,nurbm) ! Building width
  524. real h_b(nz_um,nurbm) ! Bulding's heights
  525. real d_b(nz_um,nurbm) ! The probability that a building has an height "h_b"
  526. real ss_u(nz_um,nurbm) ! The probability that a building has an height equal to "z"
  527. real pb_u(nz_um,nurbm) ! The probability that a building has an height greater or equal to "z"
  528. ! Grid parameters
  529. integer nz_u(nurbm) ! Number of layer in the urban grid
  530. ! real dz_u ! Urban grid resolution
  531. real z_u(nz_um) ! Height of the urban grid levels
  532. ! ----------------------------------------------------------------------
  533. ! INPUT-OUTPUT
  534. ! ----------------------------------------------------------------------
  535. ! Data relative to the "urban grid" which should be stored from the current time step to the next one
  536. real tw(2*ndm,nz_um,nwr_u) ! Temperature in each layer of the wall [K]
  537. real tr(ndm,nz_um,nwr_u) ! Temperature in each layer of the roof [K]
  538. real tg(ndm,ng_u) ! Temperature in each layer of the ground [K]
  539. real sfw(2*ndm,nz_um) ! Sensible heat flux from walls
  540. real sfg(ndm) ! Sensible heat flux from ground (road)
  541. real sfr(ndm,nz_um) ! Sensible heat flux from roofs
  542. real gfg(ndm) ! Heat flux transferred from the surface of the ground (road) towards the interior
  543. real gfr(ndm,nz_um) ! Heat flux transferred from the surface of the roof towards the interior
  544. real gfw(2*ndm,nz_um) ! Heat flux transfered from the surface of the walls towards the interior
  545. ! ----------------------------------------------------------------------
  546. ! OUTPUT:
  547. ! ----------------------------------------------------------------------
  548. ! Data relative to the "mesoscale grid"
  549. real sf(kms:kme) ! Surface of the "mesoscale grid" cells taking into account the buildings
  550. real vl(kms:kme) ! Volume of the "mesoscale grid" cells taking into account the buildings
  551. ! Implicit and explicit components of the source and sink terms at each levels,
  552. ! the fluxes can be computed as follow: FX = A*X + B example: Heat fluxes = a_t * pt + b_t
  553. real a_u(kms:kme) ! Implicit component of the momentum sources or sinks in the X-direction
  554. real a_v(kms:kme) ! Implicit component of the momentum sources or sinks in the Y-direction
  555. real a_t(kms:kme) ! Implicit component of the heat sources or sinks
  556. real a_e(kms:kme) ! Implicit component of the TKE sources or sinks
  557. real b_u(kms:kme) ! Explicit component of the momentum sources or sinks in the X-direction
  558. real b_v(kms:kme) ! Explicit component of the momentum sources or sinks in the Y-direction
  559. real b_t(kms:kme) ! Explicit component of the heat sources or sinks
  560. real b_e(kms:kme) ! Explicit component of the TKE sources or sinks
  561. real dlg(kms:kme) ! Height above ground (L_ground in formula (24) of the BLM paper).
  562. real dl_u(kms:kme) ! Length scale (lb in formula (22) ofthe BLM paper).
  563. real tsk ! Average of the road surface temperatures
  564. ! ----------------------------------------------------------------------
  565. ! LOCAL:
  566. ! ----------------------------------------------------------------------
  567. real dz(kms:kme) ! vertical space steps of the "mesoscale grid"
  568. ! Data interpolated from the "mesoscale grid" to the "urban grid"
  569. real ua_u(nz_um) ! Wind speed in the x direction
  570. real va_u(nz_um) ! Wind speed in the y direction
  571. real pt_u(nz_um) ! Potential temperature
  572. real da_u(nz_um) ! Air density
  573. real pt0_u(nz_um) ! Reference potential temperature
  574. real pr_u(nz_um) ! Air pressure
  575. ! Data defining the building and street charateristics
  576. integer nd ! Number of street direction for the current urban class
  577. real alag(ng_u) ! Ground thermal diffusivity for the current urban class [m^2 s^-1]
  578. real alar(nwr_u) ! Roof thermal diffusivity for the current urban class [m^2 s^-1]
  579. real alaw(nwr_u) ! Walls thermal diffusivity for the current urban class [m^2 s^-1]
  580. real csg(ng_u) ! Specific heat of the ground material of the current urban class [J m^3 K^-1]
  581. real csr(nwr_u) ! Specific heat of the roof material for the current urban class [J m^3 K^-1]
  582. real csw(nwr_u) ! Specific heat of the wall material for the current urban class [J m^3 K^-1]
  583. real z0(ndm,nz_um) ! Roughness lengths "profiles"
  584. real ws(ndm) ! Street widths of the current urban class
  585. real bs(ndm) ! Building widths of the current urban class
  586. real strd(ndm) ! Street lengths for the current urban class
  587. real drst(ndm) ! Street directions for the current urban class
  588. real ss(nz_um) ! Probability to have a building with height h
  589. real pb(nz_um) ! Probability to have a building with an height equal
  590. ! Solar radiation at each level of the "urban grid"
  591. real rsg(ndm) ! Short wave radiation from the ground
  592. real rsw(2*ndm,nz_um) ! Short wave radiation from the walls
  593. real rlg(ndm) ! Long wave radiation from the ground
  594. real rlw(2*ndm,nz_um) ! Long wave radiation from the walls
  595. ! Potential temperature of the surfaces at each level of the "urban grid"
  596. real ptg(ndm) ! Ground potential temperatures
  597. real ptr(ndm,nz_um) ! Roof potential temperatures
  598. real ptw(2*ndm,nz_um) ! Walls potential temperatures
  599. ! Explicit and implicit component of the momentum, temperature and TKE sources or sinks on
  600. ! vertical surfaces (walls) ans horizontal surfaces (roofs and street)
  601. ! The fluxes can be computed as follow: Fluxes of X = A*X + B
  602. ! Example: Momentum fluxes on vertical surfaces = uva_u * ua_u + uvb_u
  603. real uhb_u(ndm,nz_um) ! U (wind component) Horizontal surfaces, B (explicit) term
  604. real uva_u(2*ndm,nz_um) ! U (wind component) Vertical surfaces, A (implicit) term
  605. real uvb_u(2*ndm,nz_um) ! U (wind component) Vertical surfaces, B (explicit) term
  606. real vhb_u(ndm,nz_um) ! V (wind component) Horizontal surfaces, B (explicit) term
  607. real vva_u(2*ndm,nz_um) ! V (wind component) Vertical surfaces, A (implicit) term
  608. real vvb_u(2*ndm,nz_um) ! V (wind component) Vertical surfaces, B (explicit) term
  609. real thb_u(ndm,nz_um) ! Temperature Horizontal surfaces, B (explicit) term
  610. real tva_u(2*ndm,nz_um) ! Temperature Vertical surfaces, A (implicit) term
  611. real tvb_u(2*ndm,nz_um) ! Temperature Vertical surfaces, B (explicit) term
  612. real ehb_u(ndm,nz_um) ! Energy (TKE) Horizontal surfaces, B (explicit) term
  613. real evb_u(2*ndm,nz_um) ! Energy (TKE) Vertical surfaces, B (explicit) term
  614. !
  615. real rs_abs ! solar radiation absorbed by urban surfaces
  616. real rl_up ! longwave radiation emitted by urban surface to the atmosphere
  617. real emiss ! mean emissivity of the urban surface
  618. real grdflx_urb ! ground heat flux
  619. real shtot,aaa
  620. real dt_int ! internal time step
  621. integer nt_int ! number of internal time step
  622. integer iz,id, it_int
  623. integer iwrong,iw,ix,iy
  624. ! ----------------------------------------------------------------------
  625. ! END VARIABLES DEFINITIONS
  626. ! ----------------------------------------------------------------------
  627. ! Fix some usefull parameters for the computation of the sources or sinks
  628. do iz=kts,kte
  629. dz(iz)=z(iz+1)-z(iz)
  630. end do
  631. call param(iurb,nz_u(iurb),nd_u(iurb), &
  632. csg_u,csg,alag_u,alag,csr_u,csr, &
  633. alar_u,alar,csw_u,csw,alaw_u,alaw, &
  634. ws_u,ws,bs_u,bs,z0g_u,z0r_u,z0, &
  635. strd_u,strd,drst_u,drst,ss_u,ss,pb_u,pb)
  636. ! Interpolation on the "urban grid"
  637. call interpol(kms,kme,kts,kte,nz_u(iurb),z,z_u,ua,ua_u)
  638. call interpol(kms,kme,kts,kte,nz_u(iurb),z,z_u,va,va_u)
  639. call interpol(kms,kme,kts,kte,nz_u(iurb),z,z_u,pt,pt_u)
  640. call interpol(kms,kme,kts,kte,nz_u(iurb),z,z_u,pt0,pt0_u)
  641. call interpol(kms,kme,kts,kte,nz_u(iurb),z,z_u,pr,pr_u)
  642. call interpol(kms,kme,kts,kte,nz_u(iurb),z,z_u,da,da_u)
  643. ! Compute the modification of the radiation due to the buildings
  644. call modif_rad(iurb,nd_u(iurb),nz_u(iurb),z_u,ws, &
  645. drst,strd,ss,pb, &
  646. tw,tg,albg_u(iurb),albw_u(iurb), &
  647. emw_u(iurb),emg_u(iurb), &
  648. fww,fwg,fgw,fsw,fsg, &
  649. zr,deltar,ah, &
  650. rs,rld,rsw,rsg,rlw,rlg)
  651. ! calculation of the urban albedo and the upward long wave radiation
  652. call upward_rad(nd_u(iurb),iurb,nz_u(iurb),ws,bs,sigma,fsw,fsg,pb,ss, &
  653. tg,emg_u(iurb),albg_u(iurb),rlg,rsg,sfg, &
  654. tw,emw_u(iurb),albw_u(iurb),rlw,rsw,sfw, &
  655. tr,emr_u(iurb),albr_u(iurb),rld,rs,sfr, &
  656. rs_abs,rl_up,emiss,grdflx_urb)
  657. ! Compute the surface temperatures
  658. call surf_temp(nz_u(iurb),nd_u(iurb),pr_u,dt,ss, &
  659. rs,rld,rsg,rlg,rsw,rlw, &
  660. tg,alag,csg,emg_u(iurb),albg_u(iurb),ptg,sfg,gfg, &
  661. tr,alar,csr,emr_u(iurb),albr_u(iurb),ptr,sfr,gfr, &
  662. tw,alaw,csw,emw_u(iurb),albw_u(iurb),ptw,sfw,gfw)
  663. ! Compute the implicit and explicit components of the sources or sinks on the "urban grid"
  664. call buildings(nd_u(iurb),nz_u(iurb),z0,ua_u,va_u, &
  665. pt_u,pt0_u,ptg,ptr,da_u,ptw,drst, &
  666. uva_u,vva_u,uvb_u,vvb_u,tva_u,tvb_u,evb_u, &
  667. uhb_u,vhb_u,thb_u,ehb_u,ss,dt)
  668. ! Calculation of the sensible heat fluxes for the ground, the wall and roof
  669. ! Sensible Heat Flux = density * Cp_U * ( A* potential temperature + B )
  670. ! where A and B are the implicit and explicit components of the heat sources or sinks.
  671. !
  672. !
  673. do id=1,nd_u(iurb)
  674. sfg(id)=-da_u(1)*cp_u*thb_u(id,1)
  675. do iz=2,nz_u(iurb)
  676. sfr(id,iz)=-da_u(iz)*cp_u*thb_u(id,iz)
  677. enddo
  678. do iz=1,nz_u(iurb)
  679. sfw(2*id-1,iz)=-da_u(iz)*cp_u*(tvb_u(2*id-1,iz)+ &
  680. tva_u(2*id-1,iz)*pt_u(iz))
  681. sfw(2*id,iz)=-da_u(iz)*cp_u*(tvb_u(2*id,iz)+ &
  682. tva_u(2*id,iz)*pt_u(iz))
  683. enddo
  684. enddo
  685. ! calculation of the urban albedo and the upward long wave radiation
  686. ! call upward_rad(nd_u(iurb),iurb,nz_u(iurb),ws,bs,sigma,fsw,fsg,pb,ss, &
  687. ! tg,emg_u(iurb),albg_u(iurb),rlg,rsg, &
  688. ! tw,emw_u(iurb),albw_u(iurb),rlw,rsw, &
  689. ! tr,emr_u(iurb),albr_u(iurb),rld,rs, &
  690. ! rs_abs,rl_up,emiss)
  691. ! Interpolation on the "mesoscale grid"
  692. call urban_meso(nd_u(iurb),kms,kme,kts,kte,nz_u(iurb),z,dz,z_u,pb,ss,bs,ws,sf, &
  693. vl,uva_u,vva_u,uvb_u,vvb_u,tva_u,tvb_u,evb_u, &
  694. uhb_u,vhb_u,thb_u,ehb_u, &
  695. a_u,a_v,a_t,a_e,b_u,b_v,b_t,b_e)
  696. ! computation of the mean road temperature tsk (this value could be used
  697. ! to replace the surface temperature in the radiation routines, if needed).
  698. ! tsk=0.
  699. ! do id=1,nd_u(iurb)
  700. ! tsk=tsk+tg(id,ng_u)/nd_u(iurb)
  701. ! enddo
  702. ! Calculation of the length scale taking into account the buildings effects
  703. call interp_length(nd_u(iurb),kms,kme,kts,kte,nz_u(iurb),z_u,z,ss,ws,bs,dlg,dl_u)
  704. return
  705. end subroutine BEP1D
  706. ! ===6=8===============================================================72
  707. ! ===6=8===============================================================72
  708. subroutine param(iurb,nz,nd, &
  709. csg_u,csg,alag_u,alag,csr_u,csr, &
  710. alar_u,alar,csw_u,csw,alaw_u,alaw, &
  711. ws_u,ws,bs_u,bs,z0g_u,z0r_u,z0, &
  712. strd_u,strd,drst_u,drst,ss_u,ss,pb_u,pb)
  713. ! ----------------------------------------------------------------------
  714. ! This routine prepare some usefull parameters
  715. ! ----------------------------------------------------------------------
  716. implicit none
  717. ! ----------------------------------------------------------------------
  718. ! INPUT:
  719. ! ----------------------------------------------------------------------
  720. integer iurb ! Current urban class
  721. integer nz ! Number of vertical urban levels in the current class
  722. integer nd ! Number of street direction for the current urban class
  723. real alag_u(nurbm) ! Ground thermal diffusivity [m^2 s^-1]
  724. real alar_u(nurbm) ! Roof thermal diffusivity [m^2 s^-1]
  725. real alaw_u(nurbm) ! Wall thermal diffusivity [m^2 s^-1]
  726. real bs_u(ndm,nurbm) ! Building width
  727. real csg_u(nurbm) ! Specific heat of the ground material [J m^3 K^-1]
  728. real csr_u(nurbm) ! Specific heat of the roof material [J m^3 K^-1]
  729. real csw_u(nurbm) ! Specific heat of the wall material [J m^3 K^-1]
  730. real drst_u(ndm,nurbm) ! Street direction
  731. real strd_u(ndm,nurbm) ! Street length
  732. real ws_u(ndm,nurbm) ! Street width
  733. real z0g_u(nurbm) ! The ground's roughness length
  734. real z0r_u(nurbm) ! The roof's roughness length
  735. real ss_u(nz_um,nurbm) ! The probability that a building has an height equal to "z"
  736. real pb_u(nz_um,nurbm) ! The probability that a building has an height greater or equal to "z"
  737. ! ----------------------------------------------------------------------
  738. ! OUTPUT:
  739. ! ----------------------------------------------------------------------
  740. real alag(ng_u) ! Ground thermal diffusivity at each ground levels
  741. real alar(nwr_u) ! Roof thermal diffusivity at each roof levels
  742. real alaw(nwr_u) ! Wall thermal diffusivity at each wall levels
  743. real csg(ng_u) ! Specific heat of the ground material at each ground levels
  744. real csr(nwr_u) ! Specific heat of the roof material at each roof levels
  745. real csw(nwr_u) ! Specific heat of the wall material at each wall levels
  746. real bs(ndm) ! Building width for the current urban class
  747. real drst(ndm) ! street directions for the current urban class
  748. real strd(ndm) ! Street lengths for the current urban class
  749. real ws(ndm) ! Street widths of the current urban class
  750. real z0(ndm,nz_um) ! Roughness lengths "profiles"
  751. real ss(nz_um) ! Probability to have a building with height h
  752. real pb(nz_um) ! Probability to have a building with an height equal
  753. ! ----------------------------------------------------------------------
  754. ! LOCAL:
  755. ! ----------------------------------------------------------------------
  756. integer id,ig,ir,iw,iz
  757. ! ----------------------------------------------------------------------
  758. ! END VARIABLES DEFINITIONS
  759. ! ----------------------------------------------------------------------
  760. !
  761. !Initialize the variables
  762. !
  763. ss=0.
  764. pb=0.
  765. csg=0.
  766. alag=0.
  767. csr=0.
  768. alar=0.
  769. csw=0.
  770. alaw=0.
  771. z0=0.
  772. ws=0.
  773. bs=0.
  774. strd=0.
  775. drst=0.
  776. do iz=1,nz+1
  777. ss(iz)=ss_u(iz,iurb)
  778. pb(iz)=pb_u(iz,iurb)
  779. end do
  780. do ig=1,ng_u
  781. csg(ig)=csg_u(iurb)
  782. alag(ig)=alag_u(iurb)
  783. enddo
  784. do ir=1,nwr_u
  785. csr(ir)=csr_u(iurb)
  786. alar(ir)=alar_u(iurb)
  787. enddo
  788. do iw=1,nwr_u
  789. csw(iw)=csw_u(iurb)
  790. alaw(iw)=alaw_u(iurb)
  791. enddo
  792. do id=1,nd
  793. z0(id,1)=z0g_u(iurb)
  794. do iz=2,nz+1
  795. z0(id,iz)=z0r_u(iurb)
  796. enddo
  797. enddo
  798. do id=1,nd
  799. ws(id)=ws_u(id,iurb)
  800. bs(id)=bs_u(id,iurb)
  801. strd(id)=strd_u(id,iurb)
  802. drst(id)=drst_u(id,iurb)
  803. enddo
  804. return
  805. end subroutine param
  806. ! ===6=8===============================================================72
  807. ! ===6=8===============================================================72
  808. subroutine interpol(kms,kme,kts,kte,nz_u,z,z_u,c,c_u)
  809. ! ----------------------------------------------------------------------
  810. ! This routine interpolate para
  811. ! meters from the "mesoscale grid" to
  812. ! the "urban grid".
  813. ! See p300 Appendix B.1 of the BLM paper.
  814. ! ----------------------------------------------------------------------
  815. implicit none
  816. ! ----------------------------------------------------------------------
  817. ! INPUT:
  818. ! ----------------------------------------------------------------------
  819. ! Data relative to the "mesoscale grid"
  820. integer kts,kte,kms,kme
  821. real z(kms:kme) ! Altitude of the cell interface
  822. real c(kms:kme) ! Parameter which has to be interpolated
  823. ! Data relative to the "urban grid"
  824. integer nz_u ! Number of levels
  825. !! real z_u(nz_u+1) ! Altitude of the cell interface
  826. real z_u(nz_um) ! Altitude of the cell interface
  827. ! ----------------------------------------------------------------------
  828. ! OUTPUT:
  829. ! ----------------------------------------------------------------------
  830. !! real c_u(nz_u) ! Interpolated paramters in the "urban grid"
  831. real c_u(nz_um) ! Interpolated paramters in the "urban grid"
  832. ! LOCAL:
  833. ! ----------------------------------------------------------------------
  834. integer iz_u,iz
  835. real ctot,dz
  836. ! ----------------------------------------------------------------------
  837. ! END VARIABLES DEFINITIONS
  838. ! ----------------------------------------------------------------------
  839. do iz_u=1,nz_u
  840. ctot=0.
  841. do iz=kts,kte
  842. dz=max(min(z(iz+1),z_u(iz_u+1))-max(z(iz),z_u(iz_u)),0.)
  843. ctot=ctot+c(iz)*dz
  844. enddo
  845. c_u(iz_u)=ctot/(z_u(iz_u+1)-z_u(iz_u))
  846. enddo
  847. return
  848. end subroutine interpol
  849. ! ===6=8===============================================================72
  850. ! ===6=8===============================================================72
  851. subroutine modif_rad(iurb,nd,nz_u,z,ws,drst,strd,ss,pb, &
  852. tw,tg,albg,albw,emw,emg, &
  853. fww,fwg,fgw,fsw,fsg, &
  854. zr,deltar,ah, &
  855. rs,rl,rsw,rsg,rlw,rlg)
  856. ! ----------------------------------------------------------------------
  857. ! This routine computes the modification of the short wave and
  858. ! long wave radiation due to the buildings.
  859. ! ----------------------------------------------------------------------
  860. implicit none
  861. ! ----------------------------------------------------------------------
  862. ! INPUT:
  863. ! ----------------------------------------------------------------------
  864. integer iurb ! current urban class
  865. integer nd ! Number of street direction for the current urban class
  866. integer nz_u ! Number of layer in the urban grid
  867. real z(nz_um) ! Height of the urban grid levels
  868. real ws(ndm) ! Street widths of the current urban class
  869. real drst(ndm) ! street directions for the current urban class
  870. real strd(ndm) ! Street lengths for the current urban class
  871. real ss(nz_um) ! probability to have a building with height h
  872. real pb(nz_um) ! probability to have a building with an height equal
  873. real tw(2*ndm,nz_um,nwr_u) ! Temperature in each layer of the wall [K]
  874. real tg(ndm,ng_u) ! Temperature in each layer of the ground [K]
  875. real albg ! Albedo of the ground for the current urban class
  876. real albw ! Albedo of the wall for the current urban class
  877. real emg ! Emissivity of ground for the current urban class
  878. real emw ! Emissivity of wall for the current urban class
  879. real fgw(nz_um,ndm,nurbm) ! View factors from ground to wall
  880. real fsg(ndm,nurbm) ! View factors from sky to ground
  881. real fsw(nz_um,ndm,nurbm) ! View factors from sky to wall
  882. real fws(nz_um,ndm,nurbm) ! View factors from wall to sky
  883. real fwg(nz_um,ndm,nurbm) ! View factors from wall to ground
  884. real fww(nz_um,nz_um,ndm,nurbm) ! View factors from wall to wall
  885. real ah ! Hour angle (it should come from the radiation routine)
  886. real zr ! zenith angle
  887. real deltar ! Declination of the sun
  888. real rs ! solar radiation
  889. real rl ! downward flux of the longwave radiation
  890. ! ----------------------------------------------------------------------
  891. ! OUTPUT:
  892. ! ----------------------------------------------------------------------
  893. real rlg(ndm) ! Long wave radiation at the ground
  894. real rlw(2*ndm,nz_um) ! Long wave radiation at the walls
  895. real rsg(ndm) ! Short wave radiation at the ground
  896. real rsw(2*ndm,nz_um) ! Short wave radiation at the walls
  897. ! ----------------------------------------------------------------------
  898. ! LOCAL:
  899. ! ----------------------------------------------------------------------
  900. integer id,iz
  901. ! Calculation of the shadow effects
  902. call shadow_mas(nd,nz_u,zr,deltar,ah,drst,ws,ss,pb,z, &
  903. rs,rsw,rsg)
  904. ! Calculation of the reflection effects
  905. do id=1,nd
  906. call long_rad(iurb,nz_u,id,emw,emg, &
  907. fwg,fww,fgw,fsw,fsg,tg,tw,rlg,rlw,rl,pb)
  908. call short_rad(iurb,nz_u,id,albw,albg,fwg,fww,fgw,rsg,rsw,pb)
  909. enddo
  910. return
  911. end subroutine modif_rad
  912. ! ===6=8===============================================================72
  913. ! ===6=8===============================================================72
  914. subroutine surf_temp(nz_u,nd,pr,dt,ss,rs,rl,rsg,rlg,rsw,rlw, &
  915. tg,alag,csg,emg,albg,ptg,sfg,gfg, &
  916. tr,alar,csr,emr,albr,ptr,sfr,gfr, &
  917. tw,alaw,csw,emw,albw,ptw,sfw,gfw)
  918. ! ----------------------------------------------------------------------
  919. ! Computation of the surface temperatures for walls, ground and roofs
  920. ! ----------------------------------------------------------------------
  921. implicit none
  922. ! ----------------------------------------------------------------------
  923. ! INPUT:
  924. ! ----------------------------------------------------------------------
  925. integer nz_u ! Number of vertical layers defined in the urban grid
  926. integer nd ! Number of street direction for the current urban class
  927. real alag(ng_u) ! Ground thermal diffusivity for the current urban class [m^2 s^-1]
  928. real alar(nwr_u) ! Roof thermal diffusivity for the current urban class [m^2 s^-1]
  929. real alaw(nwr_u) ! Wall thermal diffusivity for the current urban class [m^2 s^-1]
  930. real albg ! Albedo of the ground for the current urban class
  931. real albr ! Albedo of the roof for the current urban class
  932. real albw ! Albedo of the wall for the current urban class
  933. real csg(ng_u) ! Specific heat of the ground material of the current urban class [J m^3 K^-1]
  934. real csr(nwr_u) ! Specific heat of the roof material for the current urban class [J m^3 K^-1]
  935. real csw(nwr_u) ! Specific heat of the wall material for the current urban class [J m^3 K^-1]
  936. real dt ! Time step
  937. real emg ! Emissivity of ground for the current urban class
  938. real emr ! Emissivity of roof for the current urban class
  939. real emw ! Emissivity of wall for the current urban class
  940. real pr(nz_um) ! Air pressure
  941. real rs ! Solar radiation
  942. real rl ! Downward flux of the longwave radiation
  943. real rlg(ndm) ! Long wave radiation at the ground
  944. real rlw(2*ndm,nz_um) ! Long wave radiation at the walls
  945. real rsg(ndm) ! Short wave radiation at the ground
  946. real rsw(2*ndm,nz_um) ! Short wave radiation at the walls
  947. real sfg(ndm) ! Sensible heat flux from ground (road)
  948. real sfr(ndm,nz_um) ! Sensible heat flux from roofs
  949. real sfw(2*ndm,nz_um) ! Sensible heat flux from walls
  950. real gfg(ndm) ! Heat flux transferred from the surface of the ground (road) toward the interior
  951. real gfr(ndm,nz_um) ! Heat flux transferred from the surface of the roof toward the interior
  952. real gfw(2*ndm,nz_um) ! Heat flux transfered from the surface of the walls toward the interior
  953. real ss(nz_um) ! Probability to have a building with height h
  954. real tg(ndm,ng_u) ! Temperature in each layer of the ground [K]
  955. real tr(ndm,nz_um,nwr_u) ! Temperature in each layer of the roof [K]
  956. real tw(2*ndm,nz_um,nwr_u) ! Temperature in each layer of the wall [K]
  957. ! ----------------------------------------------------------------------
  958. ! OUTPUT:
  959. ! ----------------------------------------------------------------------
  960. real ptg(ndm) ! Ground potential temperatures
  961. real ptr(ndm,nz_um) ! Roof potential temperatures
  962. real ptw(2*ndm,nz_um) ! Walls potential temperatures
  963. ! ----------------------------------------------------------------------
  964. ! LOCAL:
  965. ! ----------------------------------------------------------------------
  966. integer id,ig,ir,iw,iz
  967. real rtg(ndm) ! Total radiation at ground(road) surface (solar+incoming long+outgoing long)
  968. real rtr(ndm,nz_um) ! Total radiation at roof surface (solar+incoming long+outgoing long)
  969. real rtw(2*ndm,nz_um) ! Radiation at walls surface (solar+incoming long+outgoing long)
  970. real tg_tmp(ng_u)
  971. real tr_tmp(nwr_u)
  972. real tw_tmp(nwr_u)
  973. real dzg_u(ng_u) ! Layer sizes in the ground
  974. real dzr_u(nwr_u) ! Layers sizes in the roof
  975. real dzw_u(nwr_u) ! Layer sizes in the wall
  976. data dzg_u /0.2,0.12,0.08,0.05,0.03,0.02,0.02,0.01,0.005,0.0025/
  977. data dzr_u /0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.01,0.005,0.0025/
  978. data dzw_u /0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.01,0.005,0.0025/
  979. ! ----------------------------------------------------------------------
  980. ! END VARIABLES DEFINITIONS
  981. ! ----------------------------------------------------------------------
  982. do id=1,nd
  983. ! Calculation for the ground surfaces
  984. do ig=1,ng_u
  985. tg_tmp(ig)=tg(id,ig)
  986. end do
  987. !
  988. call soil_temp(ng_u,dzg_u,tg_tmp,ptg(id),alag,csg, &
  989. rsg(id),rlg(id),pr(1), &
  990. dt,emg,albg, &
  991. rtg(id),sfg(id),gfg(id))
  992. do ig=1,ng_u
  993. tg(id,ig)=tg_tmp(ig)
  994. end do
  995. ! Calculation for the roofs surfaces
  996. do iz=2,nz_u
  997. if(ss(iz).gt.0.)then
  998. do ir=1,nwr_u
  999. tr_tmp(ir)=tr(id,iz,ir)
  1000. end do
  1001. call soil_temp(nwr_u,dzr_u,tr_tmp,ptr(id,iz), &
  1002. alar,csr,rs,rl,pr(iz),dt,emr,albr, &
  1003. rtr(id,iz),sfr(id,iz),gfr(id,iz))
  1004. do ir=1,nwr_u
  1005. tr(id,iz,ir)=tr_tmp(ir)
  1006. end do
  1007. end if
  1008. end do !iz
  1009. ! Calculation for the walls surfaces
  1010. do iz=1,nz_u
  1011. do iw=1,nwr_u
  1012. tw_tmp(iw)=tw(2*id-1,iz,iw)
  1013. end do
  1014. call soil_temp(nwr_u,dzw_u,tw_tmp,ptw(2*id-1,iz),alaw, &
  1015. csw, &
  1016. rsw(2*id-1,iz),rlw(2*id-1,iz), &
  1017. pr(iz),dt,emw, &
  1018. albw,rtw(2*id-1,iz),sfw(2*id-1,iz),gfw(2*id-1,iz))
  1019. do iw=1,nwr_u
  1020. tw(2*id-1,iz,iw)=tw_tmp(iw)
  1021. end do
  1022. do iw=1,nwr_u
  1023. tw_tmp(iw)=tw(2*id,iz,iw)
  1024. end do
  1025. call soil_temp(nwr_u,dzw_u,tw_tmp,ptw(2*id,iz),alaw, &
  1026. csw, &
  1027. rsw(2*id,iz),rlw(2*id,iz), &
  1028. pr(iz),dt,emw, &
  1029. albw,rtw(2*id,iz),sfw(2*id,iz),gfw(2*id,iz))
  1030. do iw=1,nwr_u
  1031. tw(2*id,iz,iw)=tw_tmp(iw)
  1032. end do
  1033. end do !iz
  1034. end do !id
  1035. return
  1036. end subroutine surf_temp
  1037. ! ===6=8===============================================================72
  1038. ! ===6=8===============================================================72
  1039. subroutine buildings(nd,nz,z0,ua_u,va_u,pt_u,pt0_u, &
  1040. ptg,ptr,da_u,ptw, &
  1041. drst,uva_u,vva_u,uvb_u,vvb_u, &
  1042. tva_u,tvb_u,evb_u, &
  1043. uhb_u,vhb_u,thb_u,ehb_u,ss,dt)
  1044. ! ----------------------------------------------------------------------
  1045. ! This routine computes the sources or sinks of the different quantities
  1046. ! on the urban grid. The actual calculation is done in the subroutines
  1047. ! called flux_wall, and flux_flat.
  1048. ! ----------------------------------------------------------------------
  1049. implicit none
  1050. ! ----------------------------------------------------------------------
  1051. ! INPUT:
  1052. ! ----------------------------------------------------------------------
  1053. integer nd ! Number of street direction for the current urban class
  1054. integer nz ! number of vertical space steps
  1055. real ua_u(nz_um) ! Wind speed in the x direction on the urban grid
  1056. real va_u(nz_um) ! Wind speed in the y direction on the urban grid
  1057. real da_u(nz_um) ! air density on the urban grid
  1058. real drst(ndm) ! Street directions for the current urban class
  1059. real dz
  1060. real pt_u(nz_um) ! Potential temperature on the urban grid
  1061. real pt0_u(nz_um) ! reference potential temperature on the urban grid
  1062. real ptg(ndm) ! Ground potential temperatures
  1063. real ptr(ndm,nz_um) ! Roof potential temperatures
  1064. real ptw(2*ndm,nz_um) ! Walls potential temperatures
  1065. real ss(nz_um) ! probability to have a building with height h
  1066. real z0(ndm,nz_um) ! Roughness lengths "profiles"
  1067. real dt ! time step
  1068. ! ----------------------------------------------------------------------
  1069. ! OUTPUT:
  1070. ! ----------------------------------------------------------------------
  1071. ! Explicit and implicit component of the momentum, temperature and TKE sources or sinks on
  1072. ! vertical surfaces (walls) and horizontal surfaces (roofs and street)
  1073. ! The fluxes can be computed as follow: Fluxes of X = A*X + B
  1074. ! Example: Momentum fluxes on vertical surfaces = uva_u * ua_u + uvb_u
  1075. real uhb_u(ndm,nz_um) ! U (wind component) Horizontal surfaces, B (explicit) term
  1076. real uva_u(2*ndm,nz_um) ! U (wind component) Vertical surfaces, A (implicit) term
  1077. real uvb_u(2*ndm,nz_um) ! U (wind component) Vertical surfaces, B (explicit) term
  1078. real vhb_u(ndm,nz_um) ! V (wind component) Horizontal surfaces, B (explicit) term
  1079. real vva_u(2*ndm,nz_um) ! V (wind component) Vertical surfaces, A (implicit) term
  1080. real vvb_u(2*ndm,nz_um) ! V (wind component) Vertical surfaces, B (explicit) term
  1081. real thb_u(ndm,nz_um) ! Temperature Horizontal surfaces, B (explicit) term
  1082. real tva_u(2*ndm,nz_um) ! Temperature Vertical surfaces, A (implicit) term
  1083. real tvb_u(2*ndm,nz_um) ! Temperature Vertical surfaces, B (explicit) term
  1084. real ehb_u(ndm,nz_um) ! Energy (TKE) Horizontal surfaces, B (explicit) term
  1085. real evb_u(2*ndm,nz_um) ! Energy (TKE) Vertical surfaces, B (explicit) term
  1086. ! ----------------------------------------------------------------------
  1087. ! LOCAL:
  1088. ! ----------------------------------------------------------------------
  1089. integer id,iz
  1090. ! ----------------------------------------------------------------------
  1091. ! END VARIABLES DEFINITIONS
  1092. ! ----------------------------------------------------------------------
  1093. dz=dz_u
  1094. do id=1,nd
  1095. ! Calculation at the ground surfaces
  1096. call flux_flat(dz,z0(id,1),ua_u(1),va_u(1),pt_u(1),pt0_u(1), &
  1097. ptg(id),uhb_u(id,1), &
  1098. vhb_u(id,1),thb_u(id,1),ehb_u(id,1))
  1099. ! Calculation at the roof surfaces
  1100. do iz=2,nz
  1101. if(ss(iz).gt.0)then
  1102. call flux_flat(dz,z0(id,iz),ua_u(iz), &
  1103. va_u(iz),pt_u(iz),pt0_u(iz), &
  1104. ptr(id,iz),uhb_u(id,iz), &
  1105. vhb_u(id,iz),thb_u(id,iz),ehb_u(id,iz))
  1106. else
  1107. uhb_u(id,iz) = 0.0
  1108. vhb_u(id,iz) = 0.0
  1109. thb_u(id,iz) = 0.0
  1110. ehb_u(id,iz) = 0.0
  1111. endif
  1112. end do
  1113. ! Calculation at the wall surfaces
  1114. do iz=1,nz
  1115. call flux_wall(ua_u(iz),va_u(iz),pt_u(iz),da_u(iz), &
  1116. ptw(2*id-1,iz), &
  1117. uva_u(2*id-1,iz),vva_u(2*id-1,iz), &
  1118. uvb_u(2*id-1,iz),vvb_u(2*id-1,iz), &
  1119. tva_u(2*id-1,iz),tvb_u(2*id-1,iz), &
  1120. evb_u(2*id-1,iz),drst(id),dt)
  1121. call flux_wall(ua_u(iz),va_u(iz),pt_u(iz),da_u(iz), &
  1122. ptw(2*id,iz), &
  1123. uva_u(2*id,iz),vva_u(2*id,iz), &
  1124. uvb_u(2*id,iz),vvb_u(2*id,iz), &
  1125. tva_u(2*id,iz),tvb_u(2*id,iz), &
  1126. evb_u(2*id,iz),drst(id),dt)
  1127. !
  1128. end do
  1129. end do
  1130. return
  1131. end subroutine buildings
  1132. ! ===6=8===============================================================72
  1133. ! ===6=8===============================================================72
  1134. subroutine urban_meso(nd,kms,kme,kts,kte,nz_u,z,dz,z_u,pb,ss,bs,ws,sf,vl, &
  1135. uva_u,vva_u,uvb_u,vvb_u,tva_u,tvb_u,evb_u, &
  1136. uhb_u,vhb_u,thb_u,ehb_u, &
  1137. a_u,a_v,a_t,a_e,b_u,b_v,b_t,b_e)
  1138. ! ----------------------------------------------------------------------
  1139. ! This routine interpolates the parameters from the "urban grid" to the
  1140. ! "mesoscale grid".
  1141. ! See p300-301 Appendix B.2 of the BLM paper.
  1142. ! ----------------------------------------------------------------------
  1143. implicit none
  1144. ! ----------------------------------------------------------------------
  1145. ! INPUT:
  1146. ! ----------------------------------------------------------------------
  1147. ! Data relative to the "mesoscale grid"
  1148. integer kms,kme,kts,kte
  1149. real z(kms:kme) ! Altitude above the ground of the cell interface
  1150. real dz(kms:kme) ! Vertical space steps
  1151. ! Data relative to the "uban grid"
  1152. integer nz_u ! Number of layer in the urban grid
  1153. integer nd ! Number of street direction for the current urban class
  1154. real bs(ndm) ! Building widths of the current urban class
  1155. real ws(ndm) ! Street widths of the current urban class
  1156. real z_u(nz_um) ! Height of the urban grid levels
  1157. real pb(nz_um) ! Probability to have a building with an height equal
  1158. real ss(nz_um) ! Probability to have a building with height h
  1159. real uhb_u(ndm,nz_um) ! U (x-wind component) Horizontal surfaces, B (explicit) term
  1160. real uva_u(2*ndm,nz_um) ! U (x-wind component) Vertical surfaces, A (implicit) term
  1161. real uvb_u(2*ndm,nz_um) ! U (x-wind component) Vertical surfaces, B (explicit) term
  1162. real vhb_u(ndm,nz_um) ! V (y-wind component) Horizontal surfaces, B (explicit) term
  1163. real vva_u(2*ndm,nz_um) ! V (y-wind component) Vertical surfaces, A (implicit) term
  1164. real vvb_u(2*ndm,nz_um) ! V (y-wind component) Vertical surfaces, B (explicit) term
  1165. real thb_u(ndm,nz_um) ! Temperature Horizontal surfaces, B (explicit) term
  1166. real tva_u(2*ndm,nz_um) ! Temperature Vertical surfaces, A (implicit) term
  1167. real tvb_u(2*ndm,nz_um) ! Temperature Vertical surfaces, B (explicit) term
  1168. real ehb_u(ndm,nz_um) ! Energy (TKE) Horizontal surfaces, B (explicit) term
  1169. real evb_u(2*ndm,nz_um) ! Energy (TKE) Vertical surfaces, B (explicit) term
  1170. ! ----------------------------------------------------------------------
  1171. ! OUTPUT:
  1172. ! ----------------------------------------------------------------------
  1173. ! Data relative to the "mesoscale grid"
  1174. real sf(kms:kme) ! Surface of the "mesoscale grid" cells taking into account the buildings
  1175. real vl(kms:kme) ! Volume of the "mesoscale grid" cells taking into account the buildings
  1176. real a_u(kms:kme) ! Implicit component of the momentum sources or sinks in the X-direction
  1177. real a_v(kms:kme) ! Implicit component of the momentum sources or sinks in the Y-direction
  1178. real a_t(kms:kme) ! Implicit component of the heat sources or sinks
  1179. real a_e(kms:kme) ! Implicit component of the TKE sources or sinks
  1180. real b_u(kms:kme) ! Explicit component of the momentum sources or sinks in the X-direction
  1181. real b_v(kms:kme) ! Explicit component of the momentum sources or sinks in the Y-direction
  1182. real b_t(kms:kme) ! Explicit component of the heat sources or sinks
  1183. real b_e(kms:kme) ! Explicit component of the TKE sources or sinks
  1184. ! ----------------------------------------------------------------------
  1185. ! LOCAL:
  1186. ! ----------------------------------------------------------------------
  1187. real dzz
  1188. real fact
  1189. integer id,iz,iz_u
  1190. real se,sr,st,su,sv
  1191. real uet(kms:kme) ! Contribution to TKE due to walls
  1192. real veb,vta,vtb,vte,vtot,vua,vub,vva,vvb
  1193. ! ----------------------------------------------------------------------
  1194. ! END VARIABLES DEFINITIONS
  1195. ! ----------------------------------------------------------------------
  1196. ! initialisation
  1197. do iz=kts,kte
  1198. a_u(iz)=0.
  1199. a_v(iz)=0.
  1200. a_t(iz)=0.
  1201. a_e(iz)=0.
  1202. b_u(iz)=0.
  1203. b_v(iz)=0.
  1204. b_e(iz)=0.
  1205. b_t(iz)=0.
  1206. uet(iz)=0.
  1207. end do
  1208. ! horizontal surfaces
  1209. do iz=kts,kte
  1210. sf(iz)=0.
  1211. vl(iz)=0.
  1212. enddo
  1213. sf(kte+1)=0.
  1214. do id=1,nd
  1215. do iz=kts+1,kte+1
  1216. sr=0.
  1217. do iz_u=2,nz_u
  1218. if(z(iz).lt.z_u(iz_u).and.z(iz).ge.z_u(iz_u-1))then
  1219. sr=pb(iz_u)
  1220. endif
  1221. enddo
  1222. sf(iz)=sf(iz)+((ws(id)+(1.-sr)*bs(id))/(ws(id)+bs(id)))/nd
  1223. enddo
  1224. enddo
  1225. ! volume
  1226. do iz=kts,kte
  1227. do id=1,nd
  1228. vtot=0.
  1229. do iz_u=1,nz_u
  1230. dzz=max(min(z_u(iz_u+1),z(iz+1))-max(z_u(iz_u),z(iz)),0.)
  1231. vtot=vtot+pb(iz_u+1)*dzz
  1232. enddo
  1233. vtot=vtot/(z(iz+1)-z(iz))
  1234. vl(iz)=vl(iz)+(1.-vtot*bs(id)/(ws(id)+bs(id)))/nd
  1235. enddo
  1236. enddo
  1237. ! horizontal surface impact
  1238. do id=1,nd
  1239. fact=1./vl(kts)/dz(kts)*ws(id)/(ws(id)+bs(id))/nd
  1240. b_t(kts)=b_t(kts)+thb_u(id,1)*fact
  1241. b_u(kts)=b_u(kts)+uhb_u(id,1)*fact
  1242. b_v(kts)=b_v(kts)+vhb_u(id,1)*fact
  1243. b_e(kts)=b_e(kts)+ehb_u(id,1)*fact*(z_u(2)-z_u(1))
  1244. do iz=kts,kte
  1245. st=0.
  1246. su=0.
  1247. sv=0.
  1248. se=0.
  1249. do iz_u=2,nz_u
  1250. if(z(iz).le.z_u(iz_u).and.z(iz+1).gt.z_u(iz_u))then
  1251. st=st+ss(iz_u)*thb_u(id,iz_u)
  1252. su=su+ss(iz_u)*uhb_u(id,iz_u)
  1253. sv=sv+ss(iz_u)*vhb_u(id,iz_u)
  1254. se=se+ss(iz_u)*ehb_u(id,iz_u)*(z_u(iz_u+1)-z_u(iz_u))
  1255. endif
  1256. enddo
  1257. fact=bs(id)/(ws(id)+bs(id))/vl(iz)/dz(iz)/nd
  1258. b_t(iz)=b_t(iz)+st*fact
  1259. b_u(iz)=b_u(iz)+su*fact
  1260. b_v(iz)=b_v(iz)+sv*fact
  1261. b_e(iz)=b_e(iz)+se*fact
  1262. enddo
  1263. enddo
  1264. ! vertical surface impact
  1265. do iz=kts,kte
  1266. uet(iz)=0.
  1267. do id=1,nd
  1268. vtb=0.
  1269. vta=0.
  1270. vua=0.
  1271. vub=0.
  1272. vva=0.
  1273. vvb=0.
  1274. veb=0.
  1275. vte=0.
  1276. do iz_u=1,nz_u
  1277. dzz=max(min(z_u(iz_u+1),z(iz+1))-max(z_u(iz_u),z(iz)),0.)
  1278. fact=dzz/(ws(id)+bs(id))
  1279. vtb=vtb+pb(iz_u+1)* &
  1280. (tvb_u(2*id-1,iz_u)+tvb_u(2*id,iz_u))*fact
  1281. vta=vta+pb(iz_u+1)* &
  1282. (tva_u(2*id-1,iz_u)+tva_u(2*id,iz_u))*fact
  1283. vua=vua+pb(iz_u+1)* &
  1284. (uva_u(2*id-1,iz_u)+uva_u(2*id,iz_u))*fact
  1285. vva=vva+pb(iz_u+1)* &
  1286. (vva_u(2*id-1,iz_u)+vva_u(2*id,iz_u))*fact
  1287. vub=vub+pb(iz_u+1)* &
  1288. (uvb_u(2*id-1,iz_u)+uvb_u(2*id,iz_u))*fact
  1289. vvb=vvb+pb(iz_u+1)* &
  1290. (vvb_u(2*id-1,iz_u)+vvb_u(2*id,iz_u))*fact
  1291. veb=veb+pb(iz_u+1)* &
  1292. (evb_u(2*id-1,iz_u)+evb_u(2*id,iz_u))*fact
  1293. enddo
  1294. fact=1./vl(iz)/dz(iz)/nd
  1295. b_t(iz)=b_t(iz)+vtb*fact
  1296. a_t(iz)=a_t(iz)+vta*fact
  1297. a_u(iz)=a_u(iz)+vua*fact
  1298. a_v(iz)=a_v(iz)+vva*fact
  1299. b_u(iz)=b_u(iz)+vub*fact
  1300. b_v(iz)=b_v(iz)+vvb*fact
  1301. b_e(iz)=b_e(iz)+veb*fact
  1302. uet(iz)=uet(iz)+vte*fact
  1303. enddo
  1304. enddo
  1305. return
  1306. end subroutine urban_meso
  1307. ! ===6=8===============================================================72
  1308. ! ===6=8===============================================================72
  1309. subroutine interp_length(nd,kms,kme,kts,kte,nz_u,z_u,z,ss,ws,bs, &
  1310. dlg,dl_u)
  1311. ! ----------------------------------------------------------------------
  1312. ! Calculation of the length scales
  1313. ! See p272-274 formula (22) and (24) of the BLM paper
  1314. ! ----------------------------------------------------------------------
  1315. implicit none
  1316. ! ----------------------------------------------------------------------
  1317. ! INPUT:
  1318. ! ----------------------------------------------------------------------
  1319. integer kms,kme,kts,kte
  1320. real z(kms:kme) ! Altitude above the ground of the cell interface
  1321. integer nd ! Number of street direction for the current urban class
  1322. integer nz_u ! Number of levels in the "urban grid"
  1323. real z_u(nz_um) ! Height of the urban grid levels
  1324. real bs(ndm) ! Building widths of the current urban class
  1325. real ss(nz_um) ! Probability to have a building with height h
  1326. real ws(ndm) ! Street widths of the current urban class
  1327. ! ----------------------------------------------------------------------
  1328. ! OUTPUT:
  1329. ! ----------------------------------------------------------------------
  1330. real dlg(kms:kme) ! Height above ground (L_ground in formula (24) of the BLM paper).
  1331. real dl_u(kms:kme) ! Length scale (lb in formula (22) ofthe BLM paper).
  1332. ! ----------------------------------------------------------------------
  1333. ! LOCAL:
  1334. ! ----------------------------------------------------------------------
  1335. real dlgtmp
  1336. integer id,iz,iz_u
  1337. real sftot
  1338. real ulu,ssl
  1339. ! ----------------------------------------------------------------------
  1340. ! END VARIABLES DEFINITIONS
  1341. ! ----------------------------------------------------------------------
  1342. do iz=kts,kte
  1343. ulu=0.
  1344. ssl=0.
  1345. do id=1,nd
  1346. do iz_u=2,nz_u
  1347. if(z_u(iz_u).gt.z(iz))then
  1348. ulu=ulu+ss(iz_u)/z_u(iz_u)/nd
  1349. ssl=ssl+ss(iz_u)/nd
  1350. endif
  1351. enddo
  1352. enddo
  1353. if(ulu.ne.0)then
  1354. dl_u(iz)=ssl/ulu
  1355. else
  1356. dl_u(iz)=0.
  1357. endif
  1358. enddo
  1359. do iz=kts,kte
  1360. dlg(iz)=0.
  1361. do id=1,nd
  1362. sftot=ws(id)
  1363. dlgtmp=ws(id)/((z(iz)+z(iz+1))/2.)
  1364. do iz_u=1,nz_u
  1365. if((z(iz)+z(iz+1))/2..gt.z_u(iz_u))then
  1366. dlgtmp=dlgtmp+ss(iz_u)*bs(id)/ &
  1367. ((z(iz)+z(iz+1))/2.-z_u(iz_u))
  1368. sftot=sftot+ss(iz_u)*bs(id)
  1369. endif
  1370. enddo
  1371. dlg(iz)=dlg(iz)+dlgtmp/sftot/nd
  1372. enddo
  1373. dlg(iz)=1./dlg(iz)
  1374. enddo
  1375. return
  1376. end subroutine interp_length
  1377. ! ===6=8===============================================================72
  1378. ! ===6=8===============================================================72
  1379. subroutine shadow_mas(nd,nz_u,zr,deltar,ah,drst,ws,ss,pb,z, &
  1380. rs,rsw,rsg)
  1381. ! ----------------------------------------------------------------------
  1382. ! Modification of short wave radiation to take into account
  1383. ! the shadow produced by the buildings
  1384. ! ----------------------------------------------------------------------
  1385. implicit none
  1386. ! ----------------------------------------------------------------------
  1387. ! INPUT:
  1388. ! ----------------------------------------------------------------------
  1389. integer nd ! Number of street direction for the current urban class
  1390. integer nz_u ! number of vertical layers defined in the urban grid
  1391. real ah ! Hour angle (it should come from the radiation routine)
  1392. real deltar ! Declination of the sun
  1393. real drst(ndm) ! street directions for the current urban class
  1394. real rs ! solar radiation
  1395. real ss(nz_um) ! probability to have a building with height h
  1396. real pb(nz_um) ! Probability that a building has an height greater or equal to h
  1397. real ws(ndm) ! Street width of the current urban class
  1398. real z(nz_um) ! Height of the urban grid levels
  1399. real zr ! zenith angle
  1400. ! ----------------------------------------------------------------------
  1401. ! OUTPUT:
  1402. ! ----------------------------------------------------------------------
  1403. real rsg(ndm) ! Short wave radiation at the ground
  1404. real rsw(2*ndm,nz_um) ! Short wave radiation at the walls
  1405. ! ----------------------------------------------------------------------
  1406. ! LOCAL:
  1407. ! ----------------------------------------------------------------------
  1408. integer id,iz,jz
  1409. real aae,aaw,bbb,phix,rd,rtot,wsd
  1410. ! ----------------------------------------------------------------------
  1411. ! END VARIABLES DEFINITIONS
  1412. ! ----------------------------------------------------------------------
  1413. if(rs.eq.0.or.sin(zr).eq.1)then
  1414. do id=1,nd
  1415. rsg(id)=0.
  1416. do iz=1,nz_u
  1417. rsw(2*id-1,iz)=0.
  1418. rsw(2*id,iz)=0.
  1419. enddo
  1420. enddo
  1421. else
  1422. !test
  1423. if(abs(sin(zr)).gt.1.e-10)then
  1424. if(cos(deltar)*sin(ah)/sin(zr).ge.1)then
  1425. bbb=pi/2.
  1426. elseif(cos(deltar)*sin(ah)/sin(zr).le.-1)then
  1427. bbb=-pi/2.
  1428. else
  1429. bbb=asin(cos(deltar)*sin(ah)/sin(zr))
  1430. endif
  1431. else
  1432. if(cos(deltar)*sin(ah).ge.0)then
  1433. bbb=pi/2.
  1434. elseif(cos(deltar)*sin(ah).lt.0)then
  1435. bbb=-pi/2.
  1436. endif
  1437. endif
  1438. phix=zr
  1439. do id=1,nd
  1440. rsg(id)=0.
  1441. aae=bbb-drst(id)
  1442. aaw=bbb-drst(id)+pi
  1443. do iz=1,nz_u
  1444. rsw(2*id-1,iz)=0.
  1445. rsw(2*id,iz)=0.
  1446. if(pb(iz+1).gt.0.)then
  1447. do jz=1,nz_u
  1448. if(abs(sin(aae)).gt.1.e-10)then
  1449. call shade_wall(z(iz),z(iz+1),z(jz+1),phix,aae, &
  1450. ws(id),rd)
  1451. rsw(2*id-1,iz)=rsw(2*id-1,iz)+rs*rd*ss(jz+1)/pb(iz+1)
  1452. endif
  1453. if(abs(sin(aaw)).gt.1.e-10)then
  1454. call shade_wall(z(iz),z(iz+1),z(jz+1),phix,aaw, &
  1455. ws(id),rd)
  1456. rsw(2*id,iz)=rsw(2*id,iz)+rs*rd*ss(jz+1)/pb(iz+1)
  1457. endif
  1458. enddo
  1459. endif
  1460. enddo
  1461. if(abs(sin(aae)).gt.1.e-10)then
  1462. wsd=abs(ws(id)/sin(aae))
  1463. do jz=1,nz_u
  1464. rd=max(0.,wsd-z(jz+1)*tan(phix))
  1465. rsg(id)=rsg(id)+rs*rd*ss(jz+1)/wsd
  1466. enddo
  1467. rtot=0.
  1468. do iz=1,nz_u
  1469. rtot=rtot+(rsw(2*id,iz)+rsw(2*id-1,iz))* &
  1470. (z(iz+1)-z(iz))
  1471. enddo
  1472. rtot=rtot+rsg(id)*ws(id)
  1473. else
  1474. rsg(id)=rs
  1475. endif
  1476. enddo
  1477. endif
  1478. return
  1479. end subroutine shadow_mas
  1480. ! ===6=8===============================================================72
  1481. ! ===6=8===============================================================72
  1482. subroutine shade_wall(z1,z2,hu,phix,aa,ws,rd)
  1483. ! ----------------------------------------------------------------------
  1484. ! This routine computes the effects of a shadow induced by a building of
  1485. ! height hu, on a portion of wall between z1 and z2. See equation A10,
  1486. ! and correction described below formula A11, and figure A1. Basically rd
  1487. ! is the ratio between the horizontal surface illuminated and the portion
  1488. ! of wall. Referring to figure A1, multiplying radiation flux density on
  1489. ! a horizontal surface (rs) by x1-x2 we have the radiation energy per
  1490. ! unit time. Dividing this by z2-z1, we obtain the radiation flux
  1491. ! density reaching the portion of the wall between z2 and z1
  1492. ! (everything is assumed in 2D)
  1493. ! ----------------------------------------------------------------------
  1494. implicit none
  1495. ! ----------------------------------------------------------------------
  1496. ! INPUT:
  1497. ! ----------------------------------------------------------------------
  1498. real aa ! Angle between the sun direction and the face of the wall (A12)
  1499. real hu ! Height of the building that generates the shadow
  1500. real phix ! Solar zenith angle
  1501. real ws ! Width of the street
  1502. real z1 ! Height of the level z(iz)
  1503. real z2 ! Height of the level z(iz+1)
  1504. ! ----------------------------------------------------------------------
  1505. ! OUTPUT:
  1506. ! ----------------------------------------------------------------------
  1507. real rd ! Ratio between (x1-x2)/(z2-z1), see Fig. 1A.
  1508. ! Multiplying rd by rs (radiation flux
  1509. ! density on a horizontal surface) gives
  1510. ! the radiation flux density on the
  1511. ! portion of wall between z1 and z2.
  1512. ! ----------------------------------------------------------------------
  1513. ! LOCAL:
  1514. ! ----------------------------------------------------------------------
  1515. real x1,x2 ! x1,x2 see Fig. A1.
  1516. ! ----------------------------------------------------------------------
  1517. ! END VARIABLES DEFINITIONS
  1518. ! ----------------------------------------------------------------------
  1519. x1=min((hu-z1)*tan(phix),max(0.,ws/sin(aa)))
  1520. x2=max((hu-z2)*tan(phix),0.)
  1521. rd=max(0.,sin(aa)*(max(0.,x1-x2))/(z2-z1))
  1522. return
  1523. end subroutine shade_wall
  1524. ! ===6=8===============================================================72
  1525. ! ===6=8===============================================================72
  1526. subroutine long_rad(iurb,nz_u,id,emw,emg, &
  1527. fwg,fww,fgw,fsw,fsg,tg,tw,rlg,rlw,rl,pb)
  1528. ! ----------------------------------------------------------------------
  1529. ! This routine computes the effects of the reflections of long-wave
  1530. ! radiation in the street canyon by solving the system
  1531. ! of 2*nz_u+1 eqn. in 2*nz_u+1
  1532. ! unkonwn defined in A4, A5 and A6 of the paper (pages 295 and 296).
  1533. ! The system is solved by solving A X= B,
  1534. ! with A matrix B vector, and X solution.
  1535. ! ----------------------------------------------------------------------
  1536. implicit none
  1537. ! ----------------------------------------------------------------------
  1538. ! INPUT:
  1539. ! ----------------------------------------------------------------------
  1540. real emg ! Emissivity of ground for the current urban class
  1541. real emw ! Emissivity of wall for the current urban class
  1542. real fgw(nz_um,ndm,nurbm) ! View factors from ground to wall
  1543. real fsg(ndm,nurbm) ! View factors from sky to ground
  1544. real fsw(nz_um,ndm,nurbm) ! View factors from sky to wall
  1545. real fwg(nz_um,ndm,nurbm) ! View factors from wall to ground
  1546. real fww(nz_um,nz_um,ndm,nurbm) ! View factors from wall to wall
  1547. integer id ! Current street direction
  1548. integer iurb ! Current urban class
  1549. integer nz_u ! Number of layer in the urban grid
  1550. real pb(nz_um) ! Probability to have a building with an height equal
  1551. real rl ! Downward flux of the longwave radiation
  1552. real tg(ndm,ng_u) ! Temperature in each layer of the ground [K]
  1553. real tw(2*ndm,nz_um,nwr_u) ! Temperature in each layer of the wall [K]
  1554. ! ----------------------------------------------------------------------
  1555. ! OUTPUT:
  1556. ! ----------------------------------------------------------------------
  1557. real rlg(ndm) ! Long wave radiation at the ground
  1558. real rlw(2*ndm,nz_um) ! Long wave radiation at the walls
  1559. ! ----------------------------------------------------------------------
  1560. ! LOCAL:
  1561. ! ----------------------------------------------------------------------
  1562. integer i,j
  1563. real aaa(2*nz_um+1,2*nz_um+1) ! terms of the matrix
  1564. real bbb(2*nz_um+1) ! terms of the vector
  1565. ! ----------------------------------------------------------------------
  1566. ! END VARIABLES DEFINITIONS
  1567. ! ----------------------------------------------------------------------
  1568. ! west wall
  1569. do i=1,nz_u
  1570. do j=1,nz_u
  1571. aaa(i,j)=0.
  1572. enddo
  1573. aaa(i,i)=1.
  1574. do j=nz_u+1,2*nz_u
  1575. aaa(i,j)=-(1.-emw)*fww(j-nz_u,i,id,iurb)*pb(j-nz_u+1)
  1576. enddo
  1577. !! aaa(i,2*nz_u+1)=-(1.-emg)*fgw(i,id,iurb)*pb(i+1)
  1578. aaa(i,2*nz_u+1)=-(1.-emg)*fgw(i,id,iurb)
  1579. bbb(i)=fsw(i,id,iurb)*rl+emg*fgw(i,id,iurb)*sigma*tg(id,ng_u)**4
  1580. do j=1,nz_u
  1581. bbb(i)=bbb(i)+pb(j+1)*emw*sigma*fww(j,i,id,iurb)* &
  1582. tw(2*id,j,nwr_u)**4+ &
  1583. fww(j,i,id,iurb)*rl*(1.-pb(j+1))
  1584. enddo
  1585. enddo
  1586. ! east wall
  1587. do i=1+nz_u,2*nz_u
  1588. do j=1,nz_u
  1589. aaa(i,j)=-(1.-emw)*fww(j,i-nz_u,id,iurb)*pb(j+1)
  1590. enddo
  1591. do j=1+nz_u,2*nz_u
  1592. aaa(i,j)=0.
  1593. enddo
  1594. aaa(i,i)=1.
  1595. !! aaa(i,2*nz_u+1)=-(1.-emg)*fgw(i-nz_u,id,iurb)*pb(i-nz_u+1)
  1596. aaa(i,2*nz_u+1)=-(1.-emg)*fgw(i-nz_u,id,iurb)
  1597. bbb(i)=fsw(i-nz_u,id,iurb)*rl+ &
  1598. emg*fgw(i-nz_u,id,iurb)*sigma*tg(id,ng_u)**4
  1599. do j=1,nz_u
  1600. bbb(i)=bbb(i)+pb(j+1)*emw*sigma*fww(j,i-nz_u,id,iurb)* &
  1601. tw(2*id-1,j,nwr_u)**4+ &
  1602. fww(j,i-nz_u,id,iurb)*rl*(1.-pb(j+1))
  1603. enddo
  1604. enddo
  1605. ! ground
  1606. do j=1,nz_u
  1607. aaa(2*nz_u+1,j)=-(1.-emw)*fwg(j,id,iurb)*pb(j+1)
  1608. enddo
  1609. do j=nz_u+1,2*nz_u
  1610. aaa(2*nz_u+1,j)=-(1.-emw)*fwg(j-nz_u,id,iurb)*pb(j-nz_u+1)
  1611. enddo
  1612. aaa(2*nz_u+1,2*nz_u+1)=1.
  1613. bbb(2*nz_u+1)=fsg(id,iurb)*rl
  1614. do i=1,nz_u
  1615. bbb(2*nz_u+1)=bbb(2*nz_u+1)+emw*sigma*fwg(i,id,iurb)*pb(i+1)* &
  1616. (tw(2*id-1,i,nwr_u)**4+tw(2*id,i,nwr_u)**4)+ &
  1617. 2.*fwg(i,id,iurb)*(1.-pb(i+1))*rl
  1618. enddo
  1619. call gaussj(aaa,2*nz_u+1,bbb,2*nz_um+1)
  1620. do i=1,nz_u
  1621. rlw(2*id-1,i)=bbb(i)
  1622. enddo
  1623. do i=nz_u+1,2*nz_u
  1624. rlw(2*id,i-nz_u)=bbb(i)
  1625. enddo
  1626. rlg(id)=bbb(2*nz_u+1)
  1627. return
  1628. end subroutine long_rad
  1629. ! ===6=8===============================================================72
  1630. ! ===6=8===============================================================72
  1631. subroutine short_rad(iurb,nz_u,id,albw, &
  1632. albg,fwg,fww,fgw,rsg,rsw,pb)
  1633. ! ----------------------------------------------------------------------
  1634. ! This routine computes the effects of the reflections of short-wave
  1635. ! (solar) radiation in the street canyon by solving the system
  1636. ! of 2*nz_u+1 eqn. in 2*nz_u+1
  1637. ! unkonwn defined in A4, A5 and A6 of the paper (pages 295 and 296).
  1638. ! The system is solved by solving A X= B,
  1639. ! with A matrix B vector, and X solution.
  1640. ! ----------------------------------------------------------------------
  1641. implicit none
  1642. ! ----------------------------------------------------------------------
  1643. ! INPUT:
  1644. ! ----------------------------------------------------------------------
  1645. real albg ! Albedo of the ground for the current urban class
  1646. real albw ! Albedo of the wall for the current urban class
  1647. real fgw(nz_um,ndm,nurbm) ! View factors from ground to wall
  1648. real fwg(nz_um,ndm,nurbm) ! View factors from wall to ground
  1649. real fww(nz_um,nz_um,ndm,nurbm) ! View factors from wall to wall
  1650. integer id ! current street direction
  1651. integer iurb ! current urban class
  1652. integer nz_u ! Number of layer in the urban grid
  1653. real pb(nz_um) ! probability to have a building with an height equal
  1654. ! ----------------------------------------------------------------------
  1655. ! OUTPUT:
  1656. ! ----------------------------------------------------------------------
  1657. real rsg(ndm) ! Short wave radiation at the ground
  1658. real rsw(2*ndm,nz_um) ! Short wave radiation at the walls
  1659. ! ----------------------------------------------------------------------
  1660. ! LOCAL:
  1661. ! ----------------------------------------------------------------------
  1662. integer i,j
  1663. real aaa(2*nz_um+1,2*nz_um+1) ! terms of the matrix
  1664. real bbb(2*nz_um+1) ! terms of the vector
  1665. ! ----------------------------------------------------------------------
  1666. ! END VARIABLES DEFINITIONS
  1667. ! ----------------------------------------------------------------------
  1668. ! west wall
  1669. do i=1,nz_u
  1670. do j=1,nz_u
  1671. aaa(i,j)=0.
  1672. enddo
  1673. aaa(i,i)=1.
  1674. do j=nz_u+1,2*nz_u
  1675. aaa(i,j)=-albw*fww(j-nz_u,i,id,iurb)*pb(j-nz_u+1)
  1676. enddo
  1677. aaa(i,2*nz_u+1)=-albg*fgw(i,id,iurb)
  1678. bbb(i)=rsw(2*id-1,i)
  1679. enddo
  1680. ! east wall
  1681. do i=1+nz_u,2*nz_u
  1682. do j=1,nz_u
  1683. aaa(i,j)=-albw*fww(j,i-nz_u,id,iurb)*pb(j+1)
  1684. enddo
  1685. do j=1+nz_u,2*nz_u
  1686. aaa(i,j)=0.
  1687. enddo
  1688. aaa(i,i)=1.
  1689. aaa(i,2*nz_u+1)=-albg*fgw(i-nz_u,id,iurb)
  1690. bbb(i)=rsw(2*id,i-nz_u)
  1691. enddo
  1692. ! ground
  1693. do j=1,nz_u
  1694. aaa(2*nz_u+1,j)=-albw*fwg(j,id,iurb)*pb(j+1)
  1695. enddo
  1696. do j=nz_u+1,2*nz_u
  1697. aaa(2*nz_u+1,j)=-albw*fwg(j-nz_u,id,iurb)*pb(j-nz_u+1)
  1698. enddo
  1699. aaa(2*nz_u+1,2*nz_u+1)=1.
  1700. bbb(2*nz_u+1)=rsg(id)
  1701. call gaussj(aaa,2*nz_u+1,bbb,2*nz_um+1)
  1702. do i=1,nz_u
  1703. rsw(2*id-1,i)=bbb(i)
  1704. enddo
  1705. do i=nz_u+1,2*nz_u
  1706. rsw(2*id,i-nz_u)=bbb(i)
  1707. enddo
  1708. rsg(id)=bbb(2*nz_u+1)
  1709. return
  1710. end subroutine short_rad
  1711. ! ===6=8===============================================================72
  1712. ! ===6=8===============================================================72
  1713. subroutine gaussj(a,n,b,np)
  1714. ! ----------------------------------------------------------------------
  1715. ! This routine solve a linear system of n equations of the form
  1716. ! A X = B
  1717. ! where A is a matrix a(i,j)
  1718. ! B a vector and X the solution
  1719. ! In output b is replaced by the solution
  1720. ! ----------------------------------------------------------------------
  1721. implicit none
  1722. ! ----------------------------------------------------------------------
  1723. ! INPUT:
  1724. ! ----------------------------------------------------------------------
  1725. integer np
  1726. real a(np,np)
  1727. ! ----------------------------------------------------------------------
  1728. ! OUTPUT:
  1729. ! ----------------------------------------------------------------------
  1730. real b(np)
  1731. ! ----------------------------------------------------------------------
  1732. ! LOCAL:
  1733. ! ----------------------------------------------------------------------
  1734. integer nmax
  1735. parameter (nmax=150)
  1736. real big,dum
  1737. integer i,icol,irow
  1738. integer j,k,l,ll,n
  1739. integer ipiv(nmax)
  1740. real pivinv
  1741. ! ----------------------------------------------------------------------
  1742. ! END VARIABLES DEFINITIONS
  1743. ! ----------------------------------------------------------------------
  1744. do j=1,n
  1745. ipiv(j)=0.
  1746. enddo
  1747. do i=1,n
  1748. big=0.
  1749. do j=1,n
  1750. if(ipiv(j).ne.1)then
  1751. do k=1,n
  1752. if(ipiv(k).eq.0)then
  1753. if(abs(a(j,k)).ge.big)then
  1754. big=abs(a(j,k))
  1755. irow=j
  1756. icol=k
  1757. endif
  1758. elseif(ipiv(k).gt.1)then
  1759. pause 'singular matrix in gaussj'
  1760. endif
  1761. enddo
  1762. endif
  1763. enddo
  1764. ipiv(icol)=ipiv(icol)+1
  1765. if(irow.ne.icol)then
  1766. do l=1,n
  1767. dum=a(irow,l)
  1768. a(irow,l)=a(icol,l)
  1769. a(icol,l)=dum
  1770. enddo
  1771. dum=b(irow)
  1772. b(irow)=b(icol)
  1773. b(icol)=dum
  1774. endif
  1775. if(a(icol,icol).eq.0)pause 'singular matrix in gaussj'
  1776. pivinv=1./a(icol,icol)
  1777. a(icol,icol)=1
  1778. do l=1,n
  1779. a(icol,l)=a(icol,l)*pivinv
  1780. enddo
  1781. b(icol)=b(icol)*pivinv
  1782. do ll=1,n
  1783. if(ll.ne.icol)then
  1784. dum=a(ll,icol)
  1785. a(ll,icol)=0.
  1786. do l=1,n
  1787. a(ll,l)=a(ll,l)-a(icol,l)*dum
  1788. enddo
  1789. b(ll)=b(ll)-b(icol)*dum
  1790. endif
  1791. enddo
  1792. enddo
  1793. return
  1794. end subroutine gaussj
  1795. ! ===6=8===============================================================72
  1796. ! ===6=8===============================================================72
  1797. subroutine soil_temp(nz,dz,temp,pt,ala,cs, &
  1798. rs,rl,press,dt,em,alb,rt,sf,gf)
  1799. ! ----------------------------------------------------------------------
  1800. ! This routine solves the Fourier diffusion equation for heat in
  1801. ! the material (wall, roof, or ground). Resolution is done implicitely.
  1802. ! Boundary conditions are:
  1803. ! - fixed temperature at the interior
  1804. ! - energy budget at the surface
  1805. ! ----------------------------------------------------------------------
  1806. implicit none
  1807. ! ----------------------------------------------------------------------
  1808. ! INPUT:
  1809. ! ----------------------------------------------------------------------
  1810. integer nz ! Number of layers
  1811. real ala(nz) ! Thermal diffusivity in each layers [m^2 s^-1]
  1812. real alb ! Albedo of the surface
  1813. real cs(nz) ! Specific heat of the material [J m^3 K^-1]
  1814. real dt ! Time step
  1815. real em ! Emissivity of the surface
  1816. real press ! Pressure at ground level
  1817. real rl ! Downward flux of the longwave radiation
  1818. real rs ! Solar radiation
  1819. real sf ! Sensible heat flux at the surface
  1820. real temp(nz) ! Temperature in each layer [K]
  1821. real dz(nz) ! Layer sizes [m]
  1822. ! ----------------------------------------------------------------------
  1823. ! OUTPUT:
  1824. ! ----------------------------------------------------------------------
  1825. real gf ! Heat flux transferred from the surface toward the interior
  1826. real pt ! Potential temperature at the surface
  1827. real rt ! Total radiation at the surface (solar+incoming long+outgoing long)
  1828. ! ----------------------------------------------------------------------
  1829. ! LOCAL:
  1830. ! ----------------------------------------------------------------------
  1831. integer iz
  1832. real a(nz,3)
  1833. real alpha
  1834. real c(nz)
  1835. real cddz(nz+2)
  1836. real tsig
  1837. ! ----------------------------------------------------------------------
  1838. ! END VARIABLES DEFINITIONS
  1839. ! ----------------------------------------------------------------------
  1840. tsig=temp(nz)
  1841. alpha=(1.-alb)*rs+em*rl-em*sigma*(tsig**4)+sf
  1842. ! Compute cddz=2*cd/dz
  1843. cddz(1)=ala(1)/dz(1)
  1844. do iz=2,nz
  1845. cddz(iz)=2.*ala(iz)/(dz(iz)+dz(iz-1))
  1846. enddo
  1847. ! cddz(nz+1)=ala(nz+1)/dz(nz)
  1848. a(1,1)=0.
  1849. a(1,2)=1.
  1850. a(1,3)=0.
  1851. c(1)=temp(1)
  1852. do iz=2,nz-1
  1853. a(iz,1)=-cddz(iz)*dt/dz(iz)
  1854. a(iz,2)=1+dt*(cddz(iz)+cddz(iz+1))/dz(iz)
  1855. a(iz,3)=-cddz(iz+1)*dt/dz(iz)
  1856. c(iz)=temp(iz)
  1857. enddo
  1858. a(nz,1)=-dt*cddz(nz)/dz(nz)
  1859. a(nz,2)=1.+dt*cddz(nz)/dz(nz)
  1860. a(nz,3)=0.
  1861. c(nz)=temp(nz)+dt*alpha/cs(nz)/dz(nz)
  1862. call invert(nz,a,c,temp)
  1863. pt=temp(nz)*(press/1.e+5)**(-rcp_u)
  1864. rt=(1.-alb)*rs+em*rl-em*sigma*(tsig**4)
  1865. ! gf=-cddz(nz)*(temp(nz)-temp(nz-1))*cs(nz)
  1866. gf=(1.-alb)*rs+em*rl-em*sigma*(tsig**4)+sf
  1867. return
  1868. end subroutine soil_temp
  1869. ! ===6=8===============================================================72
  1870. ! ===6=8===============================================================72
  1871. subroutine invert(n,a,c,x)
  1872. ! ----------------------------------------------------------------------
  1873. ! Inversion and resolution of a tridiagonal matrix
  1874. ! A X = C
  1875. ! ----------------------------------------------------------------------
  1876. implicit none
  1877. ! ----------------------------------------------------------------------
  1878. ! INPUT:
  1879. ! ----------------------------------------------------------------------
  1880. integer n
  1881. real a(n,3) ! a(*,1) lower diagonal (Ai,i-1)
  1882. ! a(*,2) principal diagonal (Ai,i)
  1883. ! a(*,3) upper diagonal (Ai,i+1)
  1884. real c(n)
  1885. ! ----------------------------------------------------------------------
  1886. ! OUTPUT:
  1887. ! ----------------------------------------------------------------------
  1888. real x(n)
  1889. ! ----------------------------------------------------------------------
  1890. ! LOCAL:
  1891. ! ----------------------------------------------------------------------
  1892. integer i
  1893. ! ----------------------------------------------------------------------
  1894. ! END VARIABLES DEFINITIONS
  1895. ! ----------------------------------------------------------------------
  1896. do i=n-1,1,-1
  1897. c(i)=c(i)-a(i,3)*c(i+1)/a(i+1,2)
  1898. a(i,2)=a(i,2)-a(i,3)*a(i+1,1)/a(i+1,2)
  1899. enddo
  1900. do i=2,n
  1901. c(i)=c(i)-a(i,1)*c(i-1)/a(i-1,2)
  1902. enddo
  1903. do i=1,n
  1904. x(i)=c(i)/a(i,2)
  1905. enddo
  1906. return
  1907. end subroutine invert
  1908. ! ===6=8===============================================================72
  1909. ! ===6=8===============================================================72
  1910. subroutine flux_wall(ua,va,pt,da,ptw,uva,vva,uvb,vvb, &
  1911. tva,tvb,evb,drst,dt)
  1912. ! ----------------------------------------------------------------------
  1913. ! This routine computes the surface sources or sinks of momentum, tke,
  1914. ! and heat from vertical surfaces (walls).
  1915. ! ----------------------------------------------------------------------
  1916. implicit none
  1917. ! INPUT:
  1918. ! -----
  1919. real drst ! street directions for the current urban class
  1920. real da ! air density
  1921. real pt ! potential temperature
  1922. real ptw ! Walls potential temperatures
  1923. real ua ! wind speed
  1924. real va ! wind speed
  1925. real dt !time step
  1926. ! OUTPUT:
  1927. ! ------
  1928. ! Explicit and implicit component of the momentum, temperature and TKE sources or sinks on
  1929. ! vertical surfaces (walls).
  1930. ! The fluxes can be computed as follow: Fluxes of X = A*X + B
  1931. ! Example: Momentum fluxes on vertical surfaces = uva_u * ua_u + uvb_u
  1932. real uva ! U (wind component) Vertical surfaces, A (implicit) term
  1933. real uvb ! U (wind component) Vertical surfaces, B (explicit) term
  1934. real vva ! V (wind component) Vertical surfaces, A (implicit) term
  1935. real vvb ! V (wind component) Vertical surfaces, B (explicit) term
  1936. real tva ! Temperature Vertical surfaces, A (implicit) term
  1937. real tvb ! Temperature Vertical surfaces, B (explicit) term
  1938. real evb ! Energy (TKE) Vertical surfaces, B (explicit) term
  1939. ! LOCAL:
  1940. ! -----
  1941. real hc
  1942. real u_ort
  1943. real vett
  1944. ! -------------------------
  1945. ! END VARIABLES DEFINITIONS
  1946. ! -------------------------
  1947. vett=(ua**2+va**2)**.5
  1948. u_ort=abs((cos(drst)*ua-sin(drst)*va))
  1949. uva=-cdrag*u_ort/2.*cos(drst)*cos(drst)
  1950. vva=-cdrag*u_ort/2.*sin(drst)*sin(drst)
  1951. uvb=cdrag*u_ort/2.*sin(drst)*cos(drst)*va
  1952. vvb=cdrag*u_ort/2.*sin(drst)*cos(drst)*ua
  1953. hc=5.678*(1.09+0.23*(vett/0.3048))
  1954. if(hc.gt.da*cp_u/dt)then
  1955. hc=da*cp_u/dt
  1956. endif
  1957. ! tvb=hc*ptw/da/cp_u
  1958. ! tva=-hc/da/cp_u
  1959. !!!!!!!!!!!!!!!!!!!!
  1960. ! explicit
  1961. tvb=hc*ptw/da/cp_u-hc/da/cp_u*pt !c
  1962. tva = 0. !c
  1963. evb=cdrag*(abs(u_ort)**3.)/2.
  1964. return
  1965. end subroutine flux_wall
  1966. ! ===6=8===============================================================72
  1967. ! ===6=8===============================================================72
  1968. subroutine flux_flat(dz,z0,ua,va,pt,pt0,ptg, &
  1969. uhb,vhb,thb,ehb)
  1970. ! ----------------------------------------------------------------------
  1971. ! Calculation of the flux at the ground
  1972. ! Formulation of Louis (Louis, 1979)
  1973. ! ----------------------------------------------------------------------
  1974. implicit none
  1975. ! ----------------------------------------------------------------------
  1976. ! INPUT:
  1977. ! ----------------------------------------------------------------------
  1978. real dz ! first vertical level
  1979. real pt ! potential temperature
  1980. real pt0 ! reference potential temperature
  1981. real ptg ! ground potential temperature
  1982. real ua ! wind speed
  1983. real va ! wind speed
  1984. real z0 ! Roughness length
  1985. ! ----------------------------------------------------------------------
  1986. ! OUTPUT:
  1987. ! ----------------------------------------------------------------------
  1988. ! Explicit component of the momentum, temperature and TKE sources or sinks on horizontal
  1989. ! surfaces (roofs and street)
  1990. ! The fluxes can be computed as follow: Fluxes of X = B
  1991. ! Example: Momentum fluxes on horizontal surfaces = uhb_u
  1992. real uhb ! U (wind component) Horizontal surfaces, B (explicit) term
  1993. real vhb ! V (wind component) Horizontal surfaces, B (explicit) term
  1994. real thb ! Temperature Horizontal surfaces, B (explicit) term
  1995. real tva ! Temperature Vertical surfaces, A (implicit) term
  1996. real tvb ! Temperature Vertical surfaces, B (explicit) term
  1997. real ehb ! Energy (TKE) Horizontal surfaces, B (explicit) term
  1998. ! ----------------------------------------------------------------------
  1999. ! LOCAL:
  2000. ! ----------------------------------------------------------------------
  2001. real aa
  2002. real al
  2003. real buu
  2004. real c
  2005. real fbuw
  2006. real fbpt
  2007. real fh
  2008. real fm
  2009. real ric
  2010. real tstar
  2011. real ustar
  2012. real utot
  2013. real wstar
  2014. real zz
  2015. real b,cm,ch,rr,tol
  2016. parameter(b=9.4,cm=7.4,ch=5.3,rr=0.74,tol=.001)
  2017. ! ----------------------------------------------------------------------
  2018. ! END VARIABLES DEFINITIONS
  2019. ! ----------------------------------------------------------------------
  2020. ! computation of the ground temperature
  2021. utot=(ua**2+va**2)**.5
  2022. !!!! Louis formulation
  2023. !
  2024. ! compute the bulk Richardson Number
  2025. zz=dz/2.
  2026. ! if(tstar.lt.0.)then
  2027. ! wstar=(-ustar*tstar*g*hii/pt)**(1./3.)
  2028. ! else
  2029. ! wstar=0.
  2030. ! endif
  2031. !
  2032. ! if (utot.le.0.7*wstar) utot=max(0.7*wstar,0.00001)
  2033. utot=max(utot,0.01)
  2034. ric=2.*g_u*zz*(pt-ptg)/((pt+ptg)*(utot**2))
  2035. aa=vk/log(zz/z0)
  2036. ! determine the parameters fm and fh for stable, neutral and unstable conditions
  2037. if(ric.gt.0)then
  2038. fm=1/(1+0.5*b*ric)**2
  2039. fh=fm
  2040. else
  2041. c=b*cm*aa*aa*(zz/z0)**.5
  2042. fm=1-b*ric/(1+c*(-ric)**.5)
  2043. c=c*ch/cm
  2044. fh=1-b*ric/(1+c*(-ric)**.5)
  2045. endif
  2046. fbuw=-aa*aa*utot*utot*fm
  2047. fbpt=-aa*aa*utot*(pt-ptg)*fh/rr
  2048. ustar=(-fbuw)**.5
  2049. tstar=-fbpt/ustar
  2050. al=(vk*g_u*tstar)/(pt*ustar*ustar)
  2051. buu=-g_u/pt0*ustar*tstar
  2052. uhb=-ustar*ustar*ua/utot
  2053. vhb=-ustar*ustar*va/utot
  2054. thb=-ustar*tstar
  2055. ! thb= 0.
  2056. ehb=buu
  2057. !!!!!!!!!!!!!!!
  2058. return
  2059. end subroutine flux_flat
  2060. ! ===6=8===============================================================72
  2061. ! ===6=8===============================================================72
  2062. subroutine icBEP (alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u, &
  2063. albg_u,albw_u,albr_u,emg_u,emw_u,emr_u, &
  2064. fww,fwg,fgw,fsw,fws,fsg, &
  2065. z0g_u,z0r_u, &
  2066. nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b,ss_u,pb_u, &
  2067. nz_u,z_u, &
  2068. twini_u,trini_u)
  2069. implicit none
  2070. ! Building parameters
  2071. real alag_u(nurbm) ! Ground thermal diffusivity [m^2 s^-1]
  2072. real alaw_u(nurbm) ! Wall thermal diffusivity [m^2 s^-1]
  2073. real alar_u(nurbm) ! Roof thermal diffusivity [m^2 s^-1]
  2074. real csg_u(nurbm) ! Specific heat of the ground material [J m^3 K^-1]
  2075. real csw_u(nurbm) ! Specific heat of the wall material [J m^3 K^-1]
  2076. real csr_u(nurbm) ! Specific heat of the roof material [J m^3 K^-1]
  2077. real twini_u(nurbm) ! Temperature inside the buildings behind the wall [K]
  2078. real trini_u(nurbm) ! Temperature inside the buildings behind the roof [K]
  2079. ! Radiation parameters
  2080. real albg_u(nurbm) ! Albedo of the ground
  2081. real albw_u(nurbm) ! Albedo of the wall
  2082. real albr_u(nurbm) ! Albedo of the roof
  2083. real emg_u(nurbm) ! Emissivity of ground
  2084. real emw_u(nurbm) ! Emissivity of wall
  2085. real emr_u(nurbm) ! Emissivity of roof
  2086. ! Roughness parameters
  2087. real z0g_u(nurbm) ! The ground's roughness length
  2088. real z0r_u(nurbm) ! The roof's roughness length
  2089. ! Street parameters
  2090. integer nd_u(nurbm) ! Number of street direction for each urban class
  2091. real strd_u(ndm,nurbm) ! Street length (fix to greater value to the horizontal length of the cells)
  2092. real drst_u(ndm,nurbm) ! Street direction [degree]
  2093. real ws_u(ndm,nurbm) ! Street width [m]
  2094. real bs_u(ndm,nurbm) ! Building width [m]
  2095. real h_b(nz_um,nurbm) ! Bulding's heights [m]
  2096. real d_b(nz_um,nurbm) ! The probability that a building has an height h_b
  2097. ! -----------------------------------------------------------------------
  2098. ! Output
  2099. !------------------------------------------------------------------------
  2100. ! fww,fwg,fgw,fsw,fsg are the view factors used to compute the long wave
  2101. ! and the short wave radation. They are the part of radiation from a surface
  2102. ! or from the sky to another surface.
  2103. real fww(nz_um,nz_um,ndm,nurbm) ! from wall to wall
  2104. real fwg(nz_um,ndm,nurbm) ! from wall to ground
  2105. real fgw(nz_um,ndm,nurbm) ! from ground to wall
  2106. real fsw(nz_um,ndm,nurbm) ! from sky to wall
  2107. real fws(nz_um,ndm,nurbm) ! from wall to sky
  2108. real fsg(ndm,nurbm) ! from sky to ground
  2109. real ss_u(nz_um,nurbm) ! The probability that a building has an height equal to z
  2110. real pb_u(nz_um,nurbm) ! The probability that a building has an height greater or equal to z
  2111. ! Grid parameters
  2112. integer nz_u(nurbm) ! Number of layer in the urban grid
  2113. real z_u(nz_um) ! Height of the urban grid levels
  2114. ! -----------------------------------------------------------------------
  2115. ! Local
  2116. !------------------------------------------------------------------------
  2117. integer iz_u,id,ilu,iurb
  2118. real dtot
  2119. real hbmax
  2120. !------------------------------------------------------------------------
  2121. ! -----------------------------------------------------------------------
  2122. ! This routine initialise the urban paramters for the BEP module
  2123. !------------------------------------------------------------------------
  2124. !
  2125. !Initialize variables
  2126. !
  2127. nz_u=0
  2128. z_u=0.
  2129. ss_u=0.
  2130. pb_u=0.
  2131. fww=0.
  2132. fwg=0.
  2133. fgw=0.
  2134. fsw=0.
  2135. fws=0.
  2136. fsg=0.
  2137. ! Computation of the urban levels height
  2138. z_u(1)=0.
  2139. do iz_u=1,nz_um-1
  2140. z_u(iz_u+1)=z_u(iz_u)+dz_u
  2141. enddo
  2142. ! Normalisation of the building density
  2143. do iurb=1,nurbm
  2144. dtot=0.
  2145. do ilu=1,nz_um
  2146. dtot=dtot+d_b(ilu,iurb)
  2147. enddo
  2148. do ilu=1,nz_um
  2149. d_b(ilu,iurb)=d_b(ilu,iurb)/dtot
  2150. enddo
  2151. enddo
  2152. ! Compute the view factors, pb and ss
  2153. do iurb=1,nurbm
  2154. hbmax=0.
  2155. nz_u(iurb)=0
  2156. do ilu=1,nz_um
  2157. if(h_b(ilu,iurb).gt.hbmax)hbmax=h_b(ilu,iurb)
  2158. enddo
  2159. do iz_u=1,nz_um-1
  2160. if(z_u(iz_u+1).gt.hbmax)go to 10
  2161. enddo
  2162. 10 continue
  2163. nz_u(iurb)=iz_u+1
  2164. do id=1,nd_u(iurb)
  2165. call view_factors(iurb,nz_u(iurb),id,strd_u(id,iurb), &
  2166. z_u,ws_u(id,iurb), &
  2167. fww,fwg,fgw,fsg,fsw,fws)
  2168. do iz_u=1,nz_u(iurb)
  2169. ss_u(iz_u,iurb)=0.
  2170. do ilu=1,nz_um
  2171. if(z_u(iz_u).le.h_b(ilu,iurb) &
  2172. .and.z_u(iz_u+1).gt.h_b(ilu,iurb))then
  2173. ss_u(iz_u,iurb)=ss_u(iz_u,iurb)+d_b(ilu,iurb)
  2174. endif
  2175. enddo
  2176. enddo
  2177. pb_u(1,iurb)=1.
  2178. do iz_u=1,nz_u(iurb)
  2179. pb_u(iz_u+1,iurb)=max(0.,pb_u(iz_u,iurb)-ss_u(iz_u,iurb))
  2180. enddo
  2181. enddo
  2182. end do
  2183. return
  2184. end subroutine icBEP
  2185. ! ===6=8===============================================================72
  2186. ! ===6=8===============================================================72
  2187. subroutine view_factors(iurb,nz_u,id,dxy,z,ws,fww,fwg,fgw,fsg,fsw,fws)
  2188. implicit none
  2189. ! -----------------------------------------------------------------------
  2190. ! Input
  2191. !------------------------------------------------------------------------
  2192. integer iurb ! Number of the urban class
  2193. integer nz_u ! Number of levels in the urban grid
  2194. integer id ! Street direction number
  2195. real ws ! Street width
  2196. real z(nz_um) ! Height of the urban grid levels
  2197. real dxy ! Street lenght
  2198. ! -----------------------------------------------------------------------
  2199. ! Output
  2200. !------------------------------------------------------------------------
  2201. ! fww,fwg,fgw,fsw,fsg are the view factors used to compute the long wave
  2202. ! and the short wave radation. They are the part of radiation from a surface
  2203. ! or from the sky to another surface.
  2204. real fww(nz_um,nz_um,ndm,nurbm) ! from wall to wall
  2205. real fwg(nz_um,ndm,nurbm) ! from wall to ground
  2206. real fgw(nz_um,ndm,nurbm) ! from ground to wall
  2207. real fsw(nz_um,ndm,nurbm) ! from sky to wall
  2208. real fws(nz_um,ndm,nurbm) ! from wall to sky
  2209. real fsg(ndm,nurbm) ! from sky to ground
  2210. ! -----------------------------------------------------------------------
  2211. ! Local
  2212. !------------------------------------------------------------------------
  2213. integer jz,iz
  2214. real hut
  2215. real f1,f2,f12,f23,f123,ftot
  2216. real fprl,fnrm
  2217. real a1,a2,a3,a4,a12,a23,a123
  2218. ! -----------------------------------------------------------------------
  2219. ! This routine calculates the view factors
  2220. !------------------------------------------------------------------------
  2221. hut=z(nz_u+1)
  2222. do jz=1,nz_u
  2223. ! radiation from wall to wall
  2224. do iz=1,nz_u
  2225. call fprls (fprl,dxy,abs(z(jz+1)-z(iz )),ws)
  2226. f123=fprl
  2227. call fprls (fprl,dxy,abs(z(jz+1)-z(iz+1)),ws)
  2228. f23=fprl
  2229. call fprls (fprl,dxy,abs(z(jz )-z(iz )),ws)
  2230. f12=fprl
  2231. call fprls (fprl,dxy,abs(z(jz )-z(iz+1)),ws)
  2232. f2 = fprl
  2233. a123=dxy*(abs(z(jz+1)-z(iz )))
  2234. a12 =dxy*(abs(z(jz )-z(iz )))
  2235. a23 =dxy*(abs(z(jz+1)-z(iz+1)))
  2236. a1 =dxy*(abs(z(iz+1)-z(iz )))
  2237. a2 =dxy*(abs(z(jz )-z(iz+1)))
  2238. a3 =dxy*(abs(z(jz+1)-z(jz )))
  2239. ftot=0.5*(a123*f123-a23*f23-a12*f12+a2*f2)/a1
  2240. fww(iz,jz,id,iurb)=ftot*a1/a3
  2241. enddo
  2242. ! radiation from ground to wall
  2243. call fnrms (fnrm,z(jz+1),dxy,ws)
  2244. f12=fnrm
  2245. call fnrms (fnrm,z(jz) ,dxy,ws)
  2246. f1=fnrm
  2247. a1 = ws*dxy
  2248. a12= ws*dxy
  2249. a4=(z(jz+1)-z(jz))*dxy
  2250. ftot=(a12*f12-a12*f1)/a1
  2251. fgw(jz,id,iurb)=ftot*a1/a4
  2252. ! radiation from sky to wall
  2253. call fnrms(fnrm,hut-z(jz) ,dxy,ws)
  2254. f12 = fnrm
  2255. call fnrms (fnrm,hut-z(jz+1),dxy,ws)
  2256. f1 =fnrm
  2257. a1 = ws*dxy
  2258. a12= ws*dxy
  2259. a4 = (z(jz+1)-z(jz))*dxy
  2260. ftot=(a12*f12-a12*f1)/a1
  2261. fsw(jz,id,iurb)=ftot*a1/a4
  2262. enddo
  2263. ! radiation from wall to sky
  2264. do iz=1,nz_u
  2265. call fnrms(fnrm,ws,dxy,hut-z(iz))
  2266. f12=fnrm
  2267. call fnrms(fnrm,ws,dxy,hut-z(iz+1))
  2268. f1=fnrm
  2269. a1 = (z(iz+1)-z(iz))*dxy
  2270. a2 = (hut-z(iz+1))*dxy
  2271. a12= (hut-z(iz))*dxy
  2272. a4 = ws*dxy
  2273. ftot=(a12*f12-a2*f1)/a1
  2274. fws(iz,id,iurb)=ftot*a1/a4
  2275. enddo
  2276. !!!!!!!!!!!!!
  2277. do iz=1,nz_u
  2278. ! radiation from wall to ground
  2279. call fnrms (fnrm,ws,dxy,z(iz+1))
  2280. f12=fnrm
  2281. call fnrms (fnrm,ws,dxy,z(iz ))
  2282. f1 =fnrm
  2283. a1= (z(iz+1)-z(iz) )*dxy
  2284. a2 = z(iz)*dxy
  2285. a12= z(iz+1)*dxy
  2286. a4 = ws*dxy
  2287. ftot=(a12*f12-a2*f1)/a1
  2288. fwg(iz,id,iurb)=ftot*a1/a4
  2289. enddo
  2290. ! radiation from sky to ground
  2291. call fprls (fprl,dxy,ws,hut)
  2292. fsg(id,iurb)=fprl
  2293. return
  2294. end subroutine view_factors
  2295. ! ===6=8===============================================================72
  2296. ! ===6=8===============================================================72
  2297. SUBROUTINE fprls (fprl,a,b,c)
  2298. implicit none
  2299. real a,b,c
  2300. real x,y
  2301. real fprl
  2302. x=a/c
  2303. y=b/c
  2304. if(a.eq.0.or.b.eq.0.)then
  2305. fprl=0.
  2306. else
  2307. fprl=log( ( (1.+x**2)*(1.+y**2)/(1.+x**2+y**2) )**.5)+ &
  2308. y*((1.+x**2)**.5)*atan(y/((1.+x**2)**.5))+ &
  2309. x*((1.+y**2)**.5)*atan(x/((1.+y**2)**.5))- &
  2310. y*atan(y)-x*atan(x)
  2311. fprl=fprl*2./(pi*x*y)
  2312. endif
  2313. return
  2314. end subroutine fprls
  2315. ! ===6=8===============================================================72
  2316. ! ===6=8===============================================================72
  2317. SUBROUTINE fnrms (fnrm,a,b,c)
  2318. implicit none
  2319. real a,b,c
  2320. real x,y,z,a1,a2,a3,a4,a5,a6
  2321. real fnrm
  2322. x=a/b
  2323. y=c/b
  2324. z=x**2+y**2
  2325. if(y.eq.0.or.x.eq.0)then
  2326. fnrm=0.
  2327. else
  2328. a1=log( (1.+x*x)*(1.+y*y)/(1.+z) )
  2329. a2=y*y*log(y*y*(1.+z)/z/(1.+y*y) )
  2330. a3=x*x*log(x*x*(1.+z)/z/(1.+x*x) )
  2331. a4=y*atan(1./y)
  2332. a5=x*atan(1./x)
  2333. a6=sqrt(z)*atan(1./sqrt(z))
  2334. fnrm=0.25*(a1+a2+a3)+a4+a5-a6
  2335. fnrm=fnrm/(pi*y)
  2336. endif
  2337. return
  2338. end subroutine fnrms
  2339. ! ===6=8===============================================================72
  2340. SUBROUTINE init_para(alag_u,alaw_u,alar_u,csg_u,csw_u,csr_u,&
  2341. twini_u,trini_u,tgini_u,albg_u,albw_u,albr_u,emg_u,emw_u,&
  2342. emr_u,z0g_u,z0r_u,nd_u,strd_u,drst_u,ws_u,bs_u,h_b,d_b)
  2343. ! initialization routine, where the variables from the table are read
  2344. implicit none
  2345. integer iurb ! urban class number
  2346. ! Building parameters
  2347. real alag_u(nurbm) ! Ground thermal diffusivity [m^2 s^-1]
  2348. real alaw_u(nurbm) ! Wall thermal diffusivity [m^2 s^-1]
  2349. real alar_u(nurbm) ! Roof thermal diffusivity [m^2 s^-1]
  2350. real csg_u(nurbm) ! Specific heat of the ground material [J m^3 K^-1]
  2351. real csw_u(nurbm) ! Specific heat of the wall material [J m^3 K^-1]
  2352. real csr_u(nurbm) ! Specific heat of the roof material [J m^3 K^-1]
  2353. real twini_u(nurbm) ! Temperature inside the buildings behind the wall [K]
  2354. real trini_u(nurbm) ! Temperature inside the buildings behind the roof [K]
  2355. real tgini_u(nurbm) ! Initial road temperature
  2356. ! Radiation parameters
  2357. real albg_u(nurbm) ! Albedo of the ground
  2358. real albw_u(nurbm) ! Albedo of the wall
  2359. real albr_u(nurbm) ! Albedo of the roof
  2360. real emg_u(nurbm) ! Emissivity of ground
  2361. real emw_u(nurbm) ! Emissivity of wall
  2362. real emr_u(nurbm) ! Emissivity of roof
  2363. ! Roughness parameters
  2364. real z0g_u(nurbm) ! The ground's roughness length
  2365. real z0r_u(nurbm) ! The roof's roughness length
  2366. ! Street parameters
  2367. integer nd_u(nurbm) ! Number of street direction for each urban class
  2368. real strd_u(ndm,nurbm) ! Street length (fix to greater value to the horizontal length of the cells)
  2369. real drst_u(ndm,nurbm) ! Street direction [degree]
  2370. real ws_u(ndm,nurbm) ! Street width [m]
  2371. real bs_u(ndm,nurbm) ! Building width [m]
  2372. real h_b(nz_um,nurbm) ! Bulding's heights [m]
  2373. real d_b(nz_um,nurbm) ! The probability that a building has an height h_b
  2374. integer i,iu
  2375. integer nurb ! number of urban classes used
  2376. !
  2377. !Initialize some variables
  2378. !
  2379. h_b=0.
  2380. d_b=0.
  2381. nurb=ICATE
  2382. do iu=1,nurb
  2383. nd_u(iu)=0
  2384. enddo
  2385. csw_u=CAPB_TBL / (( 1.0 / 4.1868 ) * 1.E-6)
  2386. csr_u=CAPR_TBL / (( 1.0 / 4.1868 ) * 1.E-6)
  2387. csg_u=CAPG_TBL / (( 1.0 / 4.1868 ) * 1.E-6)
  2388. do i=1,icate
  2389. alaw_u(i)=AKSB_TBL(i) / csw_u(i) / (( 1.0 / 4.1868 ) * 1.E-2)
  2390. alar_u(i)=AKSR_TBL(i) / csr_u(i) / (( 1.0 / 4.1868 ) * 1.E-2)
  2391. alag_u(i)=AKSG_TBL(i) / csg_u(i) / (( 1.0 / 4.1868 ) * 1.E-2)
  2392. enddo
  2393. twini_u=TBLEND_TBL
  2394. trini_u=TRLEND_TBL
  2395. tgini_u=TGLEND_TBL
  2396. albw_u=ALBB_TBL
  2397. albr_u=ALBR_TBL
  2398. albg_u=ALBG_TBL
  2399. emw_u=EPSB_TBL
  2400. emr_u=EPSR_TBL
  2401. emg_u=EPSG_TBL
  2402. z0r_u=Z0R_TBL
  2403. z0g_u=Z0G_TBL
  2404. nd_u=NUMDIR_TBL
  2405. do iu=1,icate
  2406. if(ndm.lt.nd_u(iu))then
  2407. write(*,*)'ndm too small in module_sf_bep, please increase to at least ', nd_u(iu)
  2408. write(*,*)'remember also that num_urban_layers should be equal or greater than nz_um*ndm*nwr-u!'
  2409. stop
  2410. endif
  2411. do i=1,nd_u(iu)
  2412. drst_u(i,iu)=STREET_DIRECTION_TBL(i,iu) * pi/180.
  2413. ws_u(i,iu)=STREET_WIDTH_TBL(i,iu)
  2414. bs_u(i,iu)=BUILDING_WIDTH_TBL(i,iu)
  2415. enddo
  2416. enddo
  2417. do iu=1,ICATE
  2418. if(nz_um.lt.numhgt_tbl(iu)+3)then
  2419. write(*,*)'nz_um too small in module_sf_bep, please increase to at least ',numhgt_tbl(iu)+3
  2420. write(*,*)'remember also that num_urban_layers should be equal or greater than nz_um*ndm*nwr-u!'
  2421. stop
  2422. endif
  2423. do i=1,NUMHGT_TBL(iu)
  2424. h_b(i,iu)=HEIGHT_BIN_TBL(i,iu)
  2425. d_b(i,iu)=HPERCENT_BIN_TBL(i,iu)
  2426. enddo
  2427. enddo
  2428. do i=1,ndm
  2429. do iu=1,nurbm
  2430. strd_u(i,iu)=100000.
  2431. enddo
  2432. enddo
  2433. return
  2434. END SUBROUTINE init_para
  2435. !==============================================================
  2436. !==============================================================
  2437. subroutine angle(along,alat,day,realt,zr,deltar,ah)
  2438. ! ----------------
  2439. !
  2440. ! Computation of the solar angles
  2441. ! schayes (1982,atm. env. , p1407)
  2442. ! Inputs
  2443. !========================
  2444. ! along=longitud
  2445. ! alat=latitude
  2446. ! day=julian day (from the beginning of the year)
  2447. ! realt= time GMT in hours
  2448. ! Outputs
  2449. !============================
  2450. ! zr=solar zenith angle
  2451. ! deltar=declination angle
  2452. ! ah=hour angle
  2453. !===============================
  2454. implicit none
  2455. real along,alat, realt, zr, deltar, ah, arg
  2456. real rad,om,radh,initt, pii, drad, alongt, cphi, sphi
  2457. real c1, c2, c3, s1, s2, s3, delta, rmsr2, cd, sid
  2458. real et, ahor, chor, coznt
  2459. integer day
  2460. data rad,om,radh,initt/0.0174533,0.0172142,0.26179939,0/
  2461. zr=0.
  2462. deltar=0.
  2463. ah=0.
  2464. pii = 3.14159265358979312
  2465. drad = pii/180.
  2466. alongt=along/15.
  2467. cphi=cos(alat*drad)
  2468. sphi=sin(alat*drad)
  2469. !
  2470. ! declination
  2471. !
  2472. arg=om*day
  2473. c1=cos(arg)
  2474. c2=cos(2.*arg)
  2475. c3=cos(3.*arg)
  2476. s1=sin(arg)
  2477. s2=sin(2.*arg)
  2478. s3=sin(3.*arg)
  2479. delta=0.33281-22.984*c1-0.3499*c2-0.1398*c3+3.7872*s1+0.03205*s2+0.07187*s3
  2480. rmsr2=(1./(1.-0.01673*c1))**2
  2481. deltar=delta*rad
  2482. cd=cos(deltar)
  2483. sid=sin(deltar)
  2484. !
  2485. ! time equation in hours
  2486. !
  2487. et=0.0072*c1-0.0528*c2-0.0012*c3-0.1229*s1-0.1565*s2-0.0041*s3
  2488. !
  2489. !
  2490. ! hour angle
  2491. !
  2492. ! ifh=0
  2493. ! ahor=realt-12.+ifh+et+alongt
  2494. ahor=realt-12.+et+alongt
  2495. ah=ahor*radh
  2496. chor=cos(ah)
  2497. !
  2498. ! zenith angle
  2499. !
  2500. coznt=sphi*sid+cphi*cd*chor
  2501. zr=acos(coznt)
  2502. return
  2503. END SUBROUTINE angle
  2504. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  2505. subroutine upward_rad(nd_u,iurb,nz_u,ws,bs,sigma,fsw,fsg,pb,ss, &
  2506. tg,emg_u,albg_u,rlg,rsg,sfg, &
  2507. tw,emw_u,albw_u,rlw,rsw,sfw, &
  2508. tr,emr_u,albr_u,rld,rs, sfr, &
  2509. rs_abs,rl_up,emiss,grdflx_urb)
  2510. !
  2511. ! IN this surboutine we compute the upward longwave flux, and the albedo
  2512. ! needed for the radiation scheme
  2513. !
  2514. implicit none
  2515. !
  2516. !INPUT VARIABLES
  2517. !
  2518. real rsw(2*ndm,nz_um) ! Short wave radiation at the wall for a given canyon direction [W/m2]
  2519. real rlw(2*ndm,nz_um) ! Long wave radiation at the walls for a given canyon direction [W/m2]
  2520. real rsg(ndm) ! Short wave radiation at the canyon for a given canyon direction [W/m2]
  2521. real rlg(ndm) ! Long wave radiation at the ground for a given canyon direction [W/m2]
  2522. real rs ! Short wave radiation at the horizontal surface from the sun [W/m²]
  2523. real sfw(2*ndm,nz_um) ! Sensible heat flux from walls [W/m²]
  2524. real sfg(ndm) ! Sensible heat flux from ground (road) [W/m²]
  2525. real sfr(ndm,nz_um) ! Sensible heat flux from roofs [W/m²]
  2526. real rld ! Long wave radiation from the sky [W/m²]
  2527. real albg_u ! albedo of the ground/street
  2528. real albw_u ! albedo of the walls
  2529. real albr_u ! albedo of the roof
  2530. real ws(ndm) ! width of the street
  2531. real bs(ndm)
  2532. ! building size
  2533. real pb(nz_um) ! Probability to have a building with an height equal or higher
  2534. integer nz_u
  2535. real ss(nz_um) ! Probability to have a building of a given height
  2536. real sigma
  2537. real emg_u ! emissivity of the street
  2538. real emw_u ! emissivity of the wall
  2539. real emr_u ! emissivity of the roof
  2540. real fsw(nz_um,ndm,nurbm) ! View factors from sky to wall
  2541. real fsg(ndm,nurbm) ! groud to sky view factor
  2542. real tw(2*ndm,nz_um,nwr_u) ! Temperature in each layer of the wall [K]
  2543. real tr(ndm,nz_um,nwr_u) ! Temperature in each layer of the roof [K]
  2544. real tg(ndm,ng_u) ! Temperature in each layer of the ground [K]
  2545. integer iurb ! urban class
  2546. integer id ! street direction
  2547. integer nd_u ! number of street directions
  2548. !OUTPUT/INPUT
  2549. real rs_abs ! absrobed solar radiationfor this street direction
  2550. real rl_up ! upward longwave radiation for this street direction
  2551. real emiss ! mean emissivity
  2552. real grdflx_urb ! ground heat flux
  2553. !LOCAL
  2554. integer iz,iw
  2555. real rl_inc,rl_emit
  2556. real gfl
  2557. integer ix,iy,iwrong
  2558. iwrong=1
  2559. do iz=1,nz_u+1
  2560. do id=1,nd_u
  2561. do iw=1,nwr_u
  2562. if(tr(id,iz,iw).lt.100.)then
  2563. write(*,*)'in upward_rad ',iz,id,iw,tr(id,iz,iw)
  2564. iwrong=0
  2565. endif
  2566. enddo
  2567. enddo
  2568. enddo
  2569. if(iwrong.eq.0)stop
  2570. rl_up=0.
  2571. rs_abs=0.
  2572. rl_inc=0.
  2573. emiss=0.
  2574. rl_emit=0.
  2575. grdflx_urb=0.
  2576. do id=1,nd_u
  2577. 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
  2578. rl_inc=rl_inc+rlg(id)*ws(id)/(ws(id)+bs(id))/nd_u
  2579. rs_abs=rs_abs+(1.-albg_u)*rsg(id)*ws(id)/(ws(id)+bs(id))/nd_u
  2580. gfl=(1.-albg_u)*rsg(id)+emg_u*rlg(id)-emg_u*sigma*(tg(id,ng_u)**4.)+sfg(id)
  2581. grdflx_urb=grdflx_urb-gfl*ws(id)/(ws(id)+bs(id))/nd_u
  2582. do iz=2,nz_u
  2583. 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
  2584. rl_inc=rl_inc+rld*ss(iz)*bs(id)/(ws(id)+bs(id))/nd_u
  2585. rs_abs=rs_abs+(1.-albr_u)*rs*ss(iz)*bs(id)/(ws(id)+bs(id))/nd_u
  2586. gfl=(1.-albr_u)*rs+emr_u*rld-emr_u*sigma*(tr(id,iz,nwr_u)**4.)+sfr(id,iz)
  2587. grdflx_urb=grdflx_urb-gfl*ss(iz)*bs(id)/(ws(id)+bs(id))/nd_u
  2588. enddo
  2589. do iz=1,nz_u
  2590. rl_emit=rl_emit-(emw_u*sigma*( tw(2*id-1,iz,nwr_u)**4.+tw(2*id,iz,nwr_u)**4. )+ &
  2591. (1-emw_u)*( rlw(2*id-1,iz)+rlw(2*id,iz) ) )*dz_u*pb(iz+1)/(ws(id)+bs(id))/nd_u
  2592. rl_inc=rl_inc+(( rlw(2*id-1,iz)+rlw(2*id,iz) ) )*dz_u*pb(iz+1)/(ws(id)+bs(id))/nd_u
  2593. rs_abs=rs_abs+((1.-albw_u)*( rsw(2*id-1,iz)+rsw(2*id,iz) ) )*dz_u*pb(iz+1)/(ws(id)+bs(id))/nd_u
  2594. gfl=(1.-albw_u)*(rsw(2*id-1,iz)+rsw(2*id,iz)) +emw_u*( rlw(2*id-1,iz)+rlw(2*id,iz) ) &
  2595. -emw_u*sigma*( tw(2*id-1,iz,nwr_u)**4.+tw(2*id,iz,nwr_u)**4. )+(sfw(2*id-1,iz)+sfw(2*id,iz))
  2596. grdflx_urb=grdflx_urb-gfl*dz_u*pb(iz+1)/(ws(id)+bs(id))/nd_u
  2597. enddo
  2598. enddo
  2599. emiss=(emg_u+emw_u+emr_u)/3.
  2600. rl_up=(rl_inc+rl_emit)-rld
  2601. return
  2602. END SUBROUTINE upward_rad
  2603. !====6=8===============================================================72
  2604. !====6=8===============================================================72
  2605. END MODULE module_sf_bep