SURFEX v7.3
General documentation of Surfex
 All Classes Files Functions Variables Typedefs
/home/dasprezs/EXPORT_v7_3/src/SURFEX/teb.F90
Go to the documentation of this file.
00001 !   ##########################################################################
00002     SUBROUTINE TEB  (HZ0H, HIMPLICIT_WIND, HWALL_OPT, HBEM,                    &
00003                      PT_CANYON, PQ_CANYON, PU_CANYON,                          &
00004                      PT_LOWCAN, PQ_LOWCAN, PU_LOWCAN, PZ_LOWCAN, PTI_BLD,      &
00005                      PT_ROOF, PT_ROAD, PT_WALL_A, PT_WALL_B,PWS_ROOF, PWS_ROAD,&
00006                      HSNOW_ROOF, PWSNOW_ROOF, PTSNOW_ROOF, PRSNOW_ROOF,        &
00007                      PASNOW_ROOF, PTSSNOW_ROOF, PESNOW_ROOF,                   &
00008                      HSNOW_ROAD, PWSNOW_ROAD, PTSNOW_ROAD, PRSNOW_ROAD,        &
00009                      PASNOW_ROAD, PTSSNOW_ROAD, PESNOW_ROAD,                   &
00010                      PPEW_A_COEF, PPEW_B_COEF,                                 &
00011                      PPEW_A_COEF_LOWCAN, PPEW_B_COEF_LOWCAN,                   &
00012                      PPS, PPA, PEXNS, PEXNA, PTA, PQA, PRHOA, PLW_RAD,         &
00013                      PRR, PSR, PZREF, PUREF,                                   &
00014                      PVMOD, PH_TRAFFIC, PLE_TRAFFIC, PH_INDUSTRY, PLE_INDUSTRY,&
00015                      PTSTEP, PZ0_TOWN, PBLD, PGARDEN, PROAD, PFRAC_GR,         &
00016                      PBLD_HEIGHT, PWALL_O_HOR, PCAN_HW_RATIO, PWALL_O_GRND,    &
00017                      PDF_ROOF, PDN_ROOF, PDF_ROAD,                             &
00018                      PDN_ROAD, PQSAT_ROOF, PQSAT_ROAD, PDELT_ROOF, PDELT_ROAD, &
00019                      PEMIS_ROOF, PHC_ROOF, PTC_ROOF, PD_ROOF,                  &
00020                      PEMIS_ROAD, PHC_ROAD, PTC_ROAD,                           &
00021                      PD_ROAD, PEMIS_WALL, PTS_GARDEN,                          &
00022                      PHC_WALL, PTC_WALL, PD_WALL, PRN_ROOF, PH_ROOF, PLE_ROOF, &
00023                      PLEW_ROOF, PGFLUX_ROOF, PRUNOFF_ROOF,                     &
00024                      PRN_GREENROOF, PH_GREENROOF, PLE_GREENROOF,               &
00025                      PGFLUX_GREENROOF, PUW_GREENROOF,                          &
00026                      PRN_STRLROOF, PH_STRLROOF, PLE_STRLROOF, PGFLUX_STRLROOF, &
00027                      PRN_ROAD, PH_ROAD,                                        &
00028                      PLE_ROAD, PLEW_ROAD, PGFLUX_ROAD, PRUNOFF_ROAD,           &
00029                      PRN_WALL_A, PH_WALL_A, PLE_WALL_A, PGFLUX_WALL_A,         &
00030                      PRN_WALL_B, PH_WALL_B, PLE_WALL_B, PGFLUX_WALL_B,         &
00031                      PRN_BLT, PH_BLT, PLE_BLT, PGFLUX_BLT,                     &
00032                      PRNSNOW_ROOF, PHSNOW_ROOF, PLESNOW_ROOF, PGSNOW_ROOF,     &
00033                      PMELT_ROOF,                                               &
00034                      PRNSNOW_ROAD, PHSNOW_ROAD, PLESNOW_ROAD, PGSNOW_ROAD,     &
00035                      PMELT_ROAD,                                               &
00036                      PG_GREENROOF_ROOF,                                        &
00037                      PRUNOFF_TOWN,                                             &
00038                      PUW_ROAD, PUW_ROOF, PDUWDU_ROAD, PDUWDU_ROOF,             &
00039                      PUSTAR_TOWN, PCD, PCDN, PCH_TOWN, PRI_TOWN,               &
00040                      PRESA_TOWN, PDQS_TOWN, PQF_TOWN, PQF_BLD, PFLX_BLD,       &
00041                      PAC_ROOF, PAC_ROAD, PAC_WALL, PAC_TOP, PAC_GARDEN,        &
00042                      PAC_ROOF_WAT, PAC_ROAD_WAT, PABS_SW_ROOF, PABS_LW_ROOF,   &
00043                      PABS_SW_SNOW_ROOF, PABS_LW_SNOW_ROOF, PABS_SW_ROAD,       &
00044                      PABS_LW_ROAD, PABS_SW_SNOW_ROAD, PABS_LW_SNOW_ROAD,       &
00045                      PABS_SW_WALL_A,PABS_LW_WALL_A,                            &
00046                      PABS_SW_WALL_B,PABS_LW_WALL_B,                            &
00047                      PLW_WA_TO_WB,                                             &
00048                      PLW_WA_TO_R, PLW_WB_TO_R,                                 &
00049                      PLW_WA_TO_NR, PLW_WB_TO_NR,                               &
00050                      PLW_R_TO_WA, PLW_R_TO_WB,                                 &
00051                      PLW_G_TO_WA, PLW_G_TO_WB,                                 &
00052                      PLW_S_TO_WA, PLW_S_TO_WB, PLW_S_TO_R,                     &
00053                      PLW_S_TO_NR, PLW_NR_TO_WA, PLW_NR_TO_WB,                  &
00054                      PLW_NR_TO_WIN, PLW_WA_TO_WIN, PLW_WB_TO_WIN, PLW_G_TO_WIN,&
00055                      PLW_R_TO_WIN, PLW_S_TO_WIN, PLW_WIN_TO_WA, PLW_WIN_TO_WB, &
00056                      PLW_WIN_TO_R, PLW_WIN_TO_NR,                              &
00057                      HNATVENT,                                                 &
00058                      HCOOL_COIL, PF_WATER_COND, HHEAT_COIL, OAUTOSIZE,         &
00059                      KDAY, PAUX_MAX, PT_FLOOR, PT_MASS, PH_BLD_COOL,           &
00060                      PT_BLD_COOL, PH_BLD_HEAT, PLE_BLD_COOL, PLE_BLD_HEAT,     &
00061                      PH_WASTE, PLE_WASTE, PF_WASTE_CAN, PHVAC_COOL, PHVAC_HEAT,&
00062                      PQIN, PQIN_FRAD, PQIN_FLAT, PGR, PEFF_HEAT,               &
00063                      PINF, PTCOOL_TARGET, PTHEAT_TARGET, PHR_TARGET, PT_WIN2,  &
00064                      PQI_BLD, PV_VENT, PCAP_SYS_HEAT, PCAP_SYS_RAT, PT_ADP,    &
00065                      PM_SYS_RAT, PCOP_RAT, PCAP_SYS, PM_SYS, PCOP,  PQ_SYS,    &
00066                      PT_SYS, PTR_SW_WIN, PFAN_POWER, PHC_FLOOR, PTC_FLOOR,     &
00067                      PD_FLOOR,                                                 &
00068                      PT_WIN1, PABS_SW_WIN, PABS_LW_WIN, PUGG_WIN, PEMIT_LW_FAC,&
00069                      PEMIT_LW_ROAD, PT_RAD_IND, PHU_BLD, PTIME, PE_SHADING,    &
00070                      ONATVENT_NIGHT, PN_FLOOR, PWALL_O_BLD, PGLAZ_O_BLD, PMASS_O_BLD, &
00071                      PFLOOR_HW_RATIO, PF_FLOOR_MASS, PF_FLOOR_WALL,            &
00072                      PF_FLOOR_WIN, PF_FLOOR_ROOF, PF_WALL_FLOOR, PF_WALL_MASS, &
00073                      PF_WALL_WIN, PF_WIN_FLOOR, PF_WIN_MASS, PF_WIN_WALL,      &
00074                      PF_MASS_FLOOR, PF_MASS_WALL, PF_MASS_WIN, OCANOPY,        &
00075                      HCH_BEM, PROUGH_ROOF, PROUGH_WALL, PF_WIN_WIN )
00076 !   ##########################################################################
00077 !
00078 !!****  *TEB*  
00079 !!
00080 !!    PURPOSE
00081 !!    -------
00082 !
00083 !     Computes the evoultion of prognostic variables and the fluxes
00084 !     over artificial surfaces as towns, taking into account the canyon like
00085 !     geometry of urbanized areas.
00086 !         
00087 !     
00088 !!**  METHOD
00089 !     ------
00090 !
00091 !     The prognostic variables are:
00092 !       - the surface temperature for roofs, roads, and walls
00093 !       - the water reservoir, whose maximum value is 10mm
00094 !
00095 !
00096 !    1 : Warning about snow
00097 !        ******************
00098 !
00099 !     Except for snow mantel evolution, all other computation with snow
00100 !   variables must be performed with these variables at previous time-step,
00101 !   and NOT new time-step. This insure coherence between snow fractions
00102 !   (computed at the begining) and other snow characteristics (albedo, Ts).
00103 !
00104 !
00105 !    2 : computation of input solar radiation on each surface
00106 !        ****************************************************
00107 !
00108 !      Those are now done in subroutine urban_solar_abs.F90
00109 !
00110 !    3 : drag coefficient for momentum 
00111 !        *****************************
00112 !
00113 !
00114 !    4 : aerodynamical resistance for heat transfers
00115 !        *******************************************
00116 !
00117 !
00118 !    5 : equation for evolution of Ts_roof
00119 !        *********************************
00120 !
00121 !
00122 !       Rn = (dir_Rg + sca_Rg) (1-a) + emis * ( Rat - sigma Ts**4 (t+dt) )
00123 !
00124 !       H  = rho Cp CH V ( Ts (t+dt) - Tas )
00125 !
00126 !       LE = rho Lv CH V ( qs (t+dt) - qas )
00127 !
00128 !      where the as subscript denotes atmospheric values at ground level
00129 !      (and not at first half level)
00130 !
00131 !
00132 !    6 : equations for evolution of Ts_road and Ts_wall simultaneously
00133 !        *************************************************************
00134 !
00135 !
00136 !
00137 !   Rn_w = abs_Rg_w 
00138 !  - sigma * emis_w                                                   * Ts_w**4 (t+dt)
00139 !  +         emis_w                       *      SVF_w                * Rat
00140 !  + sigma * emis_w * emis_r              *      SVF_w                * Ts_r**4 (t+dt)
00141 !  + sigma * emis_w * emis_w              * (1-2*SVF_w)               * Ts_w**4 (t+dt)
00142 !  + sigma * emis_w * emis_w * (1-emis_r) *      SVF_w  * (1-  SVF_r) * Ts_w**4 (t+dt)
00143 !  + sigma * emis_w * emis_w * (1-emis_w) * (1-2*SVF_w) * (1-2*SVF_w) * Ts_w**4 (t+dt)
00144 !  + sigma * emis_w * emis_r * (1-emis_w) *      SVF_w  * (1-2*SVF_w) * Ts_r**4 (t+dt)
00145 !
00146 !   Rn_r = abs_Rg_r
00147 !  - sigma * emis_r                                                   * Ts_r**4 (t+dt)
00148 !  +         emis_r                       *    SVF_r                  * Rat
00149 !  + sigma * emis_r * emis_w              * (1-SVF_r)                 * Ts_w**4 (t+dt)
00150 !  + sigma * emis_r * emis_w * (1-emis_w) * (1-SVF_r)   * (1-2*SVF_w) * Ts_w**4 (t+dt)
00151 !  + sigma * emis_r * emis_r * (1-emis_w) * (1-SVF_r)   *      SVF_w  * Ts_r**4 (t+dt)
00152 !
00153 !  H_w  = rho Cp CH V ( Ts_w (t+dt) - Ta_canyon )
00154 !
00155 !  LE_w = rho Lv CH V ( qs_w (t+dt) - qa_canyon )
00156 !
00157 !  H_r  = rho Cp CH V ( Ts_r (t+dt) - Ta_canyon )
00158 !
00159 !  LE_r = rho Lv CH V ( qs_r (t+dt) - qa_canyon )
00160 !
00161 ! with again
00162 !                AC_can * Swall/Sroad * Twall + AC_can * Troad + AC_top * Ta + H_traffic/Cp/rho/Sroad
00163 !   Ta_canyon = -------------------------------------------------------------------------------------
00164 !                AC_can * Swall/Sroad         + AC_can         + AC_top
00165 !
00166 !
00167 !                 AC_can * delt_road * Hu_road * qsat(Troad) + AC_top * qa + LE_traffic/Lv/rho/Sroad
00168 !   qa_canyon = ------------------------------------------------------------------------------------
00169 !                 AC_can * delt_road                        + AC_top
00170 !
00171 !
00172 !
00173 !
00174 !    7 : computation of fluxes for each surface type
00175 !        *******************************************
00176 !
00177 !
00178 !    8 : averaging of the fluxes
00179 !        ***********************
00180 !
00181 !   This is done on the total exchange surface (roof + wall + road),
00182 !  which is bigger than the horizontal surface (roof+road), leading
00183 !  to bigger fluxes.
00184 !
00185 !   The fluxes due to industrial activity are directly added into the 
00186 !  atmosphere
00187 !
00188 !
00189 !    9 : road reservoir evolution
00190 !        ************************
00191 !
00192 !   The roof reservoir runoff goes directly into the road reservoir.
00193 !
00194 !   Runoff occurs for road reservoir (too much water), as well as drainage
00195 !   (evacuation system, typical time scale: 1 day)
00196 !
00197 !
00198 !------------------------
00199 !!    EXTERNAL
00200 !!    --------
00201 !!
00202 !!
00203 !!    IMPLICIT ARGUMENTS
00204 !!    ------------------
00205 !!
00206 !!    MODD_CST
00207 !!
00208 !!      
00209 !!    REFERENCE
00210 !!    ---------
00211 !!
00212 !!      
00213 !!    AUTHOR
00214 !!    ------
00215 !!
00216 !!      V. Masson           * Meteo-France *
00217 !!
00218 !!    MODIFICATIONS
00219 !!    -------------
00220 !!      Original    23/01/98 
00221 !!     21 / 10 / 2003   P. Tulet    output aerodynamical resistance
00222 !!     01 / 07 / 2005   P.Le Moigne Exner functions as arguments to urban_fluxes
00223 !!     17 / 10 / 2005   (G. Pigeon) computation of anthropogenic heat from domestic heating
00224 !!          01 / 2012   V. Masson   Separates the 2 walls 
00225 !!     25 / 09 / 2012   B. Decharme new wind implicitation
00226 !-------------------------------------------------------------------------------
00227 !
00228 !*       0.     DECLARATIONS
00229 !               ------------
00230 !
00231 USE MODD_CSTS,         ONLY : XTT, XSTEFAN, XCPD, XLVTT
00232 USE MODD_SURF_PAR,     ONLY : XUNDEF
00233 USE MODD_SNOW_PAR,     ONLY : XEMISSN, XANSMAX_ROOF, &
00234                           XANSMAX_ROAD,XWCRN_ROOF,XWCRN_ROAD
00235 !
00236 USE MODE_THERMOS
00237 USE MODE_SURF_SNOW_FRAC
00238 !
00239 USE MODI_SNOW_COVER_1LAYER
00240 USE MODI_URBAN_DRAG
00241 USE MODI_URBAN_SNOW_EVOL
00242 USE MODI_ROOF_LAYER_E_BUDGET
00243 USE MODI_ROAD_LAYER_E_BUDGET
00244 USE MODI_FACADE_E_BUDGET
00245 USE MODI_URBAN_FLUXES
00246 USE MODI_URBAN_HYDRO
00247 USE MODI_BLD_E_BUDGET
00248 USE MODI_WIND_THRESHOLD
00249 USE MODI_BEM
00250 !
00251 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
00252 USE PARKIND1  ,ONLY : JPRB
00253 !
00254 IMPLICIT NONE
00255 !
00256 !*      0.1    Declarations of arguments
00257 !
00258 !
00259  CHARACTER(LEN=6), INTENT(IN)      :: HZ0H          ! TEB option for z0h roof & road
00260 !                                                  ! 'MASC95' : Mascart et al 1995
00261 !                                                  ! 'BRUT82' : Brustaert     1982
00262 !                                                  ! 'KAND07' : Kanda         2007
00263  CHARACTER(LEN=*),     INTENT(IN)  :: HIMPLICIT_WIND   ! wind implicitation option
00264 !                                                     ! 'OLD' = direct
00265 !                                                     ! 'NEW' = Taylor serie, order 1
00266  CHARACTER(LEN=4), INTENT(IN)      :: HWALL_OPT     ! TEB option for walls
00267                                                    ! 'UNIF' : uniform walls
00268                                                    ! 'TWO ' : two different opposite walls
00269  CHARACTER(LEN=3), INTENT(IN)      :: HBEM          ! Building Energy model 'DEF' or 'BEM'
00270 REAL, DIMENSION(:), INTENT(INOUT) :: PT_CANYON     ! canyon air temperature
00271 REAL, DIMENSION(:), INTENT(INOUT) :: PQ_CANYON     ! canyon air specific humidity
00272 REAL, DIMENSION(:), INTENT(IN)    :: PU_CANYON     ! canyon hor. wind
00273 REAL, DIMENSION(:), INTENT(IN)    :: PU_LOWCAN     ! wind near the road
00274 REAL, DIMENSION(:), INTENT(IN)    :: PT_LOWCAN     ! temp. near the road
00275 REAL, DIMENSION(:), INTENT(IN)    :: PQ_LOWCAN     ! hum. near the road
00276 REAL, DIMENSION(:), INTENT(IN)    :: PZ_LOWCAN     ! height of atm. var. near the road
00277 REAL, DIMENSION(:), INTENT(INOUT) :: PTI_BLD       ! inside building temperature
00278 REAL, DIMENSION(:,:), INTENT(INOUT) :: PT_ROOF     ! roof layers temperatures
00279 REAL, DIMENSION(:,:), INTENT(INOUT) :: PT_ROAD     ! road layers temperatures
00280 REAL, DIMENSION(:,:), INTENT(INOUT) :: PT_WALL_A   ! wall A layers temperatures
00281 REAL, DIMENSION(:,:), INTENT(INOUT) :: PT_WALL_B   ! wall B layers temperatures
00282 REAL, DIMENSION(:), INTENT(INOUT) :: PWS_ROOF      ! roof water reservoir
00283 REAL, DIMENSION(:), INTENT(INOUT) :: PWS_ROAD      ! road water reservoir
00284  CHARACTER(LEN=*),   INTENT(IN)    :: HSNOW_ROOF    ! snow roof scheme
00285 !                                                  ! 'NONE'
00286 !                                                  ! 'D95 '
00287 !                                                  ! '1-L '
00288  CHARACTER(LEN=*),   INTENT(IN)    :: HSNOW_ROAD    ! snow road scheme
00289 !                                                  ! 'NONE'
00290 !                                                  ! 'D95 '
00291 !                                                  ! '1-L '
00292 REAL, DIMENSION(:,:), INTENT(INOUT) :: PWSNOW_ROOF ! snow layers reservoir
00293 REAL, DIMENSION(:,:), INTENT(INOUT) :: PTSNOW_ROOF ! snow layers temperature
00294 REAL, DIMENSION(:,:), INTENT(INOUT) :: PRSNOW_ROOF ! snow layers density
00295 REAL, DIMENSION(:),   INTENT(INOUT) :: PASNOW_ROOF ! snow albedo
00296 REAL, DIMENSION(:),   INTENT(INOUT) :: PESNOW_ROOF ! snow emissivity
00297 REAL, DIMENSION(:),   INTENT(INOUT) :: PTSSNOW_ROOF! snow surface temperature
00298 REAL, DIMENSION(:,:), INTENT(INOUT) :: PWSNOW_ROAD ! snow layers reservoir
00299 REAL, DIMENSION(:,:), INTENT(INOUT) :: PTSNOW_ROAD ! snow layers temperature
00300 REAL, DIMENSION(:,:), INTENT(INOUT) :: PRSNOW_ROAD ! snow layers density
00301 REAL, DIMENSION(:),   INTENT(INOUT) :: PASNOW_ROAD ! snow albedo
00302 REAL, DIMENSION(:),   INTENT(INOUT) :: PESNOW_ROAD ! snow emissivity
00303 REAL, DIMENSION(:),   INTENT(INOUT) :: PTSSNOW_ROAD! snow surface temperature
00304 REAL, DIMENSION(:), INTENT(IN)    :: PPEW_A_COEF   ! implicit coefficients
00305 REAL, DIMENSION(:), INTENT(IN)    :: PPEW_B_COEF   ! for wind coupling
00306 REAL, DIMENSION(:), INTENT(IN)    :: PPEW_A_COEF_LOWCAN ! implicit coefficients for wind coupling
00307 REAL, DIMENSION(:), INTENT(IN)    :: PPEW_B_COEF_LOWCAN ! between low canyon wind and road
00308 REAL, DIMENSION(:), INTENT(IN)    :: PPS           ! pressure at the surface
00309 REAL, DIMENSION(:), INTENT(IN)    :: PPA           ! pressure at the first atmospheric level
00310 REAL, DIMENSION(:), INTENT(IN)    :: PEXNS         ! surface exner function
00311 REAL, DIMENSION(:), INTENT(IN)    :: PTA           ! temperature at the lowest level
00312 REAL, DIMENSION(:), INTENT(IN)    :: PQA           ! specific humidity
00313                                                    ! at the lowest level
00314 REAL, DIMENSION(:), INTENT(IN)    :: PVMOD         ! module of the horizontal wind
00315 REAL, DIMENSION(:), INTENT(IN)    :: PEXNA         ! exner function
00316                                                    ! at the lowest level
00317 REAL, DIMENSION(:), INTENT(IN)    :: PRHOA         ! air density
00318                                                    ! at the lowest level
00319 REAL, DIMENSION(:), INTENT(IN)    :: PLW_RAD       ! atmospheric infrared radiation
00320 REAL, DIMENSION(:), INTENT(IN)    :: PRR           ! rain rate
00321 REAL, DIMENSION(:), INTENT(IN)    :: PSR           ! snow rate
00322 REAL, DIMENSION(:), INTENT(IN)    :: PH_TRAFFIC    ! anthropogenic sensible
00323 !                                                  ! heat fluxes due to traffic
00324 REAL, DIMENSION(:), INTENT(IN)    :: PLE_TRAFFIC   ! anthropogenic latent
00325 !                                                  ! heat fluxes due to traffic
00326 REAL, DIMENSION(:), INTENT(IN)    :: PH_INDUSTRY   ! anthropogenic sensible
00327 !                                                  ! heat fluxes due to factories
00328 REAL, DIMENSION(:), INTENT(IN)    :: PLE_INDUSTRY  ! anthropogenic latent
00329 !                                                  ! heat fluxes due to factories
00330 REAL, DIMENSION(:), INTENT(IN)    :: PZREF         ! reference height of the first
00331                                                    ! atmospheric level (temperature)
00332 REAL, DIMENSION(:), INTENT(IN)    :: PUREF         ! reference height of the first
00333                                                    ! atmospheric level (wind)
00334 REAL,               INTENT(IN)    :: PTSTEP        ! time step
00335 REAL, DIMENSION(:), INTENT(IN)    :: PZ0_TOWN      ! town roughness length
00336                                                    ! for momentum
00337 REAL, DIMENSION(:), INTENT(IN)    :: PBLD          ! fraction of buildings
00338 REAL, DIMENSION(:), INTENT(IN)    :: PGARDEN       ! fraction of GARDEN areas
00339 REAL, DIMENSION(:), INTENT(IN)    :: PROAD         ! fraction of roads
00340 REAL, DIMENSION(:), INTENT(IN)    :: PFRAC_GR      ! fraction of green roofs
00341 REAL, DIMENSION(:), INTENT(IN)    :: PBLD_HEIGHT   ! buildings h
00342 REAL, DIMENSION(:), INTENT(IN)    :: PWALL_O_HOR   ! wall surf. / hor. surf.
00343 REAL, DIMENSION(:), INTENT(IN)    :: PCAN_HW_RATIO ! canyon    h/W
00344 REAL, DIMENSION(:), INTENT(IN)    :: PWALL_O_GRND  ! wall surf. / (road + gard.  surf.)
00345 !
00346 REAL, DIMENSION(:), INTENT(INOUT) :: PDF_ROOF      ! snow-free    fraction on roofs
00347 REAL, DIMENSION(:), INTENT(INOUT) :: PDN_ROOF      ! snow-covered fraction on roofs
00348 REAL, DIMENSION(:), INTENT(INOUT) :: PDF_ROAD      ! snow-free    fraction on roads
00349 REAL, DIMENSION(:), INTENT(INOUT) :: PDN_ROAD      ! snow-covered fraction on roads
00350 REAL, DIMENSION(:), INTENT(OUT)   :: PQSAT_ROOF    ! hum at saturation over roof
00351 REAL, DIMENSION(:), INTENT(OUT)   :: PQSAT_ROAD    ! hum at saturation over road
00352 REAL, DIMENSION(:), INTENT(OUT)   :: PDELT_ROOF    ! water fraction on roof
00353 REAL, DIMENSION(:), INTENT(OUT)   :: PDELT_ROAD    ! water fraction on road
00354 !
00355 REAL, DIMENSION(:), INTENT(IN)    :: PEMIS_ROOF    ! roof emissivity
00356 REAL, DIMENSION(:,:), INTENT(IN)  :: PHC_ROOF      ! heat capacity for roof layers
00357 REAL, DIMENSION(:,:), INTENT(IN)  :: PTC_ROOF      ! thermal conductivity for roof layers
00358 REAL, DIMENSION(:,:), INTENT(IN)  :: PD_ROOF       ! depth of roof layers
00359 REAL, DIMENSION(:), INTENT(IN)    :: PEMIS_ROAD    ! road emissivity
00360 REAL, DIMENSION(:,:), INTENT(IN)  :: PHC_ROAD      ! heat capacity for road layers
00361 REAL, DIMENSION(:,:), INTENT(IN)  :: PTC_ROAD      ! thermal conductivity for road layers
00362 REAL, DIMENSION(:,:), INTENT(IN)  :: PD_ROAD       ! depth of road layers
00363 REAL, DIMENSION(:), INTENT(IN)    :: PEMIS_WALL    ! wall emissivity
00364 REAL, DIMENSION(:,:), INTENT(IN)  :: PHC_WALL      ! heat capacity for wall layers
00365 REAL, DIMENSION(:,:), INTENT(IN)  :: PTC_WALL      ! thermal conductivity for wall layers
00366 REAL, DIMENSION(:,:), INTENT(IN)  :: PD_WALL       ! depth of wall layers
00367 REAL, DIMENSION(:), INTENT(IN)    :: PTS_GARDEN    ! GARDEN area surf temp.
00368 ! greenroof
00369 REAL, DIMENSION(:), INTENT(IN)    :: PG_GREENROOF_ROOF ! snow melt
00370 !
00371 REAL, DIMENSION(:), INTENT(OUT)   :: PRN_ROOF     ! net radiation over roof
00372 REAL, DIMENSION(:), INTENT(OUT)   :: PH_ROOF      ! sensible heat flux over roof
00373 REAL, DIMENSION(:), INTENT(OUT)   :: PLE_ROOF     ! latent heat flux over roof
00374 REAL, DIMENSION(:), INTENT(OUT)   :: PLEW_ROOF    ! latent heat flux over roof (snow)
00375 REAL, DIMENSION(:), INTENT(OUT)   :: PGFLUX_ROOF  ! flux through the roof
00376 REAL, DIMENSION(:), INTENT(OUT)   :: PRUNOFF_ROOF ! runoff over the ground
00377 REAL, DIMENSION(:), INTENT(OUT)   :: PRN_ROAD     ! net radiation over road
00378 REAL, DIMENSION(:), INTENT(OUT)   :: PH_ROAD      ! sensible heat flux over road
00379 REAL, DIMENSION(:), INTENT(OUT)   :: PLE_ROAD     ! latent heat flux over road
00380 REAL, DIMENSION(:), INTENT(OUT)   :: PLEW_ROAD    ! latent heat flux over road (snow)
00381 REAL, DIMENSION(:), INTENT(OUT)   :: PGFLUX_ROAD  ! flux through the road
00382 REAL, DIMENSION(:), INTENT(OUT)   :: PRUNOFF_ROAD ! runoff over the ground
00383 REAL, DIMENSION(:), INTENT(OUT)   :: PRN_WALL_A   ! net radiation over wall
00384 REAL, DIMENSION(:), INTENT(OUT)   :: PH_WALL_A    ! sensible heat flux over wall
00385 REAL, DIMENSION(:), INTENT(OUT)   :: PLE_WALL_A   ! latent heat flux over wall
00386 REAL, DIMENSION(:), INTENT(OUT)   :: PGFLUX_WALL_A! flux through the wall
00387 REAL, DIMENSION(:), INTENT(OUT)   :: PRN_WALL_B   ! net radiation over wall
00388 REAL, DIMENSION(:), INTENT(OUT)   :: PH_WALL_B    ! sensible heat flux over wall
00389 REAL, DIMENSION(:), INTENT(OUT)   :: PLE_WALL_B   ! latent heat flux over wall
00390 REAL, DIMENSION(:), INTENT(OUT)   :: PGFLUX_WALL_B! flux through the wall
00391 REAL, DIMENSION(:), INTENT(OUT)   :: PRN_BLT       ! net radiation over built surf 
00392 REAL, DIMENSION(:), INTENT(OUT)   :: PH_BLT        ! sensible heat flux over built surf 
00393 REAL, DIMENSION(:), INTENT(OUT)   :: PLE_BLT       ! latent heat flux over built surf 
00394 REAL, DIMENSION(:), INTENT(OUT)   :: PGFLUX_BLT    ! flux through the built surf 
00395 !
00396 REAL, DIMENSION(:), INTENT(IN)    :: PRN_GREENROOF     ! net radiation over greenroof
00397 REAL, DIMENSION(:), INTENT(IN)    :: PH_GREENROOF      ! sensible heat flux over greenroof
00398 REAL, DIMENSION(:), INTENT(IN)    :: PLE_GREENROOF     ! latent heat flux over greenroof
00399 REAL, DIMENSION(:), INTENT(IN)    :: PGFLUX_GREENROOF  ! flux through the greenroof
00400 REAL, DIMENSION(:), INTENT(IN)    :: PUW_GREENROOF     ! Momentum flux for greenroofs
00401 !
00402 REAL, DIMENSION(:), INTENT(OUT)   :: PRN_STRLROOF      ! net radiation over structural roof
00403 REAL, DIMENSION(:), INTENT(OUT)   :: PH_STRLROOF       ! sensible heat flux over structural roof
00404 REAL, DIMENSION(:), INTENT(OUT)   :: PLE_STRLROOF      ! latent heat flux over structural roof
00405 REAL, DIMENSION(:), INTENT(OUT)   :: PGFLUX_STRLROOF   ! flux through the structural roof
00406 !
00407 REAL, DIMENSION(:), INTENT(OUT)   :: PRNSNOW_ROOF ! net radiation over snow
00408 REAL, DIMENSION(:), INTENT(OUT)   :: PHSNOW_ROOF  ! sensible heat flux over snow
00409 REAL, DIMENSION(:), INTENT(OUT)   :: PLESNOW_ROOF ! latent heat flux over snow
00410 REAL, DIMENSION(:), INTENT(OUT)   :: PGSNOW_ROOF  ! flux under the snow
00411 REAL, DIMENSION(:), INTENT(OUT)   :: PMELT_ROOF   ! snow melt
00412 REAL, DIMENSION(:), INTENT(OUT)   :: PRNSNOW_ROAD ! net radiation over snow
00413 REAL, DIMENSION(:), INTENT(OUT)   :: PHSNOW_ROAD  ! sensible heat flux over snow
00414 REAL, DIMENSION(:), INTENT(OUT)   :: PLESNOW_ROAD ! latent heat flux over snow
00415 REAL, DIMENSION(:), INTENT(OUT)   :: PGSNOW_ROAD  ! flux under the snow
00416 REAL, DIMENSION(:), INTENT(OUT)   :: PMELT_ROAD   ! snow melt
00417 !
00418 REAL, DIMENSION(:), INTENT(OUT)   :: PRUNOFF_TOWN ! runoff over the ground
00419 REAL, DIMENSION(:), INTENT(OUT)   :: PUW_ROAD     ! Momentum flux for roads
00420 REAL, DIMENSION(:), INTENT(OUT)   :: PUW_ROOF     ! Momentum flux for roofs
00421 REAL, DIMENSION(:), INTENT(OUT)   :: PDUWDU_ROAD  !
00422 REAL, DIMENSION(:), INTENT(OUT)   :: PDUWDU_ROOF  !
00423 REAL, DIMENSION(:), INTENT(OUT)   :: PUSTAR_TOWN  ! friciton velocity over town
00424 REAL, DIMENSION(:), INTENT(OUT)   :: PCD          ! town averaged drag coefficient
00425 REAL, DIMENSION(:), INTENT(OUT)   :: PCDN         ! town averaged neutral drag coefficient
00426 REAL, DIMENSION(:), INTENT(OUT)   :: PCH_TOWN     ! town averaged heat transfer
00427 !                                                 ! coefficient
00428 REAL, DIMENSION(:), INTENT(OUT)   :: PRI_TOWN      ! town averaged Richardson number
00429 REAL, DIMENSION(:), INTENT(OUT)   :: PRESA_TOWN    ! town aerodynamical resistance
00430 REAL, DIMENSION(:), INTENT(OUT)   :: PDQS_TOWN     ! heat storage inside town
00431 REAL, DIMENSION(:), INTENT(OUT)   :: PQF_TOWN      ! total anthropogenic heat
00432 REAL, DIMENSION(:), INTENT(OUT)   :: PQF_BLD       ! anthropogenic heat flux of
00433                                                    ! domestic heating  
00434 REAL, DIMENSION(:), INTENT(OUT)   :: PFLX_BLD      ! heat flx from inside bld through its structure
00435 REAL, DIMENSION(:), INTENT(OUT)   :: PAC_ROOF      ! roof conductance
00436 REAL, DIMENSION(:), INTENT(INOUT) :: PAC_ROAD      ! road conductance
00437 REAL, DIMENSION(:), INTENT(OUT)   :: PAC_WALL      ! wall conductance
00438 REAL, DIMENSION(:), INTENT(OUT)   :: PAC_TOP       ! top conductance
00439 REAL, DIMENSION(:), INTENT(IN)    :: PAC_GARDEN    ! garden conductance
00440 REAL, DIMENSION(:), INTENT(OUT)   :: PAC_ROOF_WAT  ! roof water conductance
00441 REAL, DIMENSION(:), INTENT(OUT)   :: PAC_ROAD_WAT  ! roof water conductance
00442 !
00443 REAL, DIMENSION(:), INTENT(IN)    :: PABS_SW_ROOF      ! absorbed solar rad by roof
00444 REAL, DIMENSION(:), INTENT(IN)    :: PABS_SW_SNOW_ROOF ! absorbed solar rad by snow on roof
00445 REAL, DIMENSION(:), INTENT(IN)    :: PABS_SW_ROAD      ! absorbed solar rad by road
00446 REAL, DIMENSION(:), INTENT(IN)    :: PABS_SW_SNOW_ROAD ! absorbed solar rad by snow on road
00447 REAL, DIMENSION(:), INTENT(IN)    :: PABS_SW_WALL_A    ! absorbed solar rad by wall
00448 REAL, DIMENSION(:), INTENT(IN)    :: PABS_SW_WALL_B    ! absorbed solar rad by wall
00449 REAL, DIMENSION(:), INTENT(OUT)   :: PABS_LW_ROOF      ! absorbed IR rad by roof
00450 REAL, DIMENSION(:), INTENT(OUT)   :: PABS_LW_SNOW_ROOF ! absorbed IR rad by snow on roof
00451 REAL, DIMENSION(:), INTENT(OUT)   :: PABS_LW_ROAD      ! absorbed IR rad by road
00452 REAL, DIMENSION(:), INTENT(OUT)   :: PABS_LW_SNOW_ROAD ! absorbed IR rad by snow on road
00453 REAL, DIMENSION(:), INTENT(OUT)   :: PABS_LW_WALL_A    ! absorbed IR rad by wall
00454 REAL, DIMENSION(:), INTENT(OUT)   :: PABS_LW_WALL_B    ! absorbed IR rad by wall
00455 !
00456 REAL, DIMENSION(:), INTENT(IN)    :: PLW_WA_TO_WB      ! LW contrib. wall A (orB) -> wall B (or A)
00457 REAL, DIMENSION(:), INTENT(IN)    :: PLW_WA_TO_R         ! LW contrib. wall       -> road
00458 REAL, DIMENSION(:), INTENT(IN)    :: PLW_WB_TO_R         ! LW contrib. wall       -> road
00459 REAL, DIMENSION(:), INTENT(IN)    :: PLW_WA_TO_NR        ! LW contrib. wall       -> road(snow)
00460 REAL, DIMENSION(:), INTENT(IN)    :: PLW_WB_TO_NR        ! LW contrib. wall       -> road(snow)
00461 REAL, DIMENSION(:), INTENT(IN)    :: PLW_R_TO_WA         ! LW contrib. road       -> wall
00462 REAL, DIMENSION(:), INTENT(IN)    :: PLW_R_TO_WB         ! LW contrib. road       -> wall
00463 REAL, DIMENSION(:), INTENT(IN)    :: PLW_G_TO_WA         ! LW contrib. GARDEN     -> wall
00464 REAL, DIMENSION(:), INTENT(IN)    :: PLW_G_TO_WB         ! LW contrib. GARDEN     -> wall
00465 REAL, DIMENSION(:), INTENT(IN)    :: PLW_NR_TO_WA        ! LW contrib. road(snow) -> wall
00466 REAL, DIMENSION(:), INTENT(IN)    :: PLW_NR_TO_WB        ! LW contrib. road(snow) -> wall
00467 REAL, DIMENSION(:), INTENT(IN)    :: PLW_S_TO_WA         ! LW contrib. sky        -> wall
00468 REAL, DIMENSION(:), INTENT(IN)    :: PLW_S_TO_WB         ! LW contrib. sky        -> wall
00469 REAL, DIMENSION(:), INTENT(IN)    :: PLW_S_TO_R          ! LW contrib. sky        -> road
00470 REAL, DIMENSION(:), INTENT(IN)    :: PLW_S_TO_NR         ! LW contrib. sky        -> road(snow)
00471 !
00472 ! new arguments after BEM
00473 !
00474  CHARACTER(LEN=4), DIMENSION(:), INTENT(IN) :: HNATVENT
00475  CHARACTER(LEN=6), INTENT(IN)       :: HCOOL_COIL
00476 REAL, DIMENSION(:), INTENT(IN)     :: PF_WATER_COND!fraction of evaporation for the condensers
00477  CHARACTER(LEN=6), INTENT(IN)       :: HHEAT_COIL
00478 LOGICAL,            INTENT(IN)     :: OAUTOSIZE    ! Flag to activate autosize calculations
00479 INTEGER,            INTENT(IN)     :: KDAY         ! Simulation day
00480 REAL, DIMENSION(:), INTENT(INOUT)  :: PAUX_MAX     ! Auxiliar variable for autosize calcs
00481 REAL, DIMENSION(:,:), INTENT(INOUT):: PT_FLOOR     ! Floor layers temperatures [K]
00482 REAL, DIMENSION(:,:), INTENT(INOUT):: PT_MASS      ! Internal mass layers temperatures [K]
00483 REAL, DIMENSION(:), INTENT(OUT)    :: PH_BLD_COOL  ! Sensible cooling energy demand  
00484                                                    ! of the building [W m-2(bld)]
00485 REAL, DIMENSION(:), INTENT(OUT)   :: PT_BLD_COOL   ! Total cooling energy demand  
00486                                                    ! of the building [W m-2(bld)]
00487 REAL, DIMENSION(:), INTENT(OUT)   :: PH_BLD_HEAT   ! Heating energy demand       
00488                                                    ! of the building [W m-2(bld)]
00489 REAL, DIMENSION(:), INTENT(OUT)   :: PLE_BLD_COOL  ! Latent cooling energy demand 
00490                                                    ! of the building [W m-2(bld)]
00491 REAL, DIMENSION(:), INTENT(OUT)   :: PLE_BLD_HEAT  ! Latent heating energy demand 
00492                                                    ! of the building [W m-2(bld)]
00493 REAL, DIMENSION(:), INTENT(OUT)   :: PH_WASTE      ! Sensible waste heat from HVAC system
00494                                                    ! [W m-2(tot)]
00495 REAL, DIMENSION(:), INTENT(OUT)   :: PLE_WASTE     ! Latent waste heat from HVAC system
00496                                                    ! [W m-2(tot)]
00497 REAL, DIMENSION(:), INTENT(IN)    :: PF_WASTE_CAN  ! fraction of waste heat released into the canyon
00498 REAL, DIMENSION(:), INTENT(OUT)   :: PHVAC_COOL    ! Energy consumption of the cooling system
00499                                                    ! [W m-2(bld)]
00500 REAL, DIMENSION(:), INTENT(OUT)  :: PHVAC_HEAT     ! Energy consumption of the heating system
00501                                                    ! [W m-2(bld)]
00502 REAL, DIMENSION(:), INTENT(IN)   :: PQIN          ! Internal heat gains [W m-2(floor)]
00503 REAL, DIMENSION(:), INTENT(IN)   :: PQIN_FRAD     ! Radiant fraction of internal heat gains
00504 REAL, DIMENSION(:), INTENT(IN)   :: PQIN_FLAT     ! Latent franction of internal heat gains
00505 REAL, DIMENSION(:), INTENT(IN)   :: PGR           ! Glazing ratio
00506 REAL, DIMENSION(:), INTENT(IN)   :: PEFF_HEAT     ! Efficiency of the heating system
00507 REAL, DIMENSION(:), INTENT(IN)   :: PINF          ! Infiltration flow rate [AC/H]
00508 REAL, DIMENSION(:), INTENT(IN)   :: PTCOOL_TARGET ! Cooling setpoint of HVAC system [K]
00509 REAL, DIMENSION(:), INTENT(IN)   :: PTHEAT_TARGET ! Heating setpoint of HVAC system [K]
00510 REAL, DIMENSION(:), INTENT(IN)   :: PHR_TARGET    ! Relative humidity setpoint
00511 REAL, DIMENSION(:), INTENT(OUT)  :: PT_WIN2       ! Indoor window temperature [K]
00512 REAL, DIMENSION(:), INTENT(INOUT):: PQI_BLD       ! Indoor air specific humidity [kg kg-1]
00513 REAL, DIMENSION(:), INTENT(IN)   :: PV_VENT       ! Ventilation flow rate [AC/H]
00514 REAL, DIMENSION(:), INTENT(IN)   :: PCAP_SYS_HEAT ! Capacity of the heating system 
00515                                                   ! [W m-2(bld)]
00516 REAL, DIMENSION(:), INTENT(INOUT):: PCAP_SYS_RAT  ! Rated capacity of the cooling system
00517                                                   ! [W m-2(bld)]
00518 REAL, DIMENSION(:), INTENT(IN)   :: PT_ADP        ! Apparatus dewpoint temperature of the
00519                                                   ! cooling coil [K]
00520 REAL, DIMENSION(:), INTENT(INOUT):: PM_SYS_RAT    ! Rated HVAC mass flow rate 
00521                                                   ! [kg s-1 m-2(bld)]
00522 REAL, DIMENSION(:), INTENT(IN)   :: PCOP_RAT      ! Rated COP of the cooling system
00523 REAL, DIMENSION(:), INTENT(OUT)  :: PCAP_SYS      ! Actual capacity of the cooling system
00524                                                   ! [W m-2(bld)] 
00525 REAL, DIMENSION(:), INTENT(OUT)  :: PM_SYS        ! Actual HVAC mass flow rate 
00526                                                   ! [kg s-1 m-2(bld)]
00527 REAL, DIMENSION(:), INTENT(OUT)  :: PCOP          ! COP of the cooling system
00528 REAL, DIMENSION(:), INTENT(OUT)  :: PQ_SYS        ! Supply air specific humidity [kg kg-1]
00529 REAL, DIMENSION(:), INTENT(OUT)  :: PT_SYS        ! Supply air temperature [K]
00530 REAL, DIMENSION(:), INTENT(IN)   :: PTR_SW_WIN    ! Solar radiation transmitted throught
00531                                                   ! windows [W m-2(bld)]
00532 REAL, DIMENSION(:), INTENT(OUT)  :: PFAN_POWER    ! HVAC fan power
00533 REAL, DIMENSION(:,:),INTENT(IN)  :: PHC_FLOOR     ! heat capacity for road layers
00534 REAL, DIMENSION(:,:),INTENT(IN)  :: PTC_FLOOR     ! thermal conductivity for 
00535                                                   ! road layers
00536 REAL, DIMENSION(:,:),INTENT(IN)  :: PD_FLOOR      ! depth of road layers
00537 REAL, DIMENSION(:), INTENT(IN)   :: PLW_WA_TO_WIN ! Radiative heat trasfer coeff wall-window 
00538                                                   ! [W K-1 m-2] 
00539 REAL, DIMENSION(:), INTENT(IN)   :: PLW_WB_TO_WIN ! Radiative heat trasfer coeff wall-window 
00540                                                   ! [W K-1 m-2] 
00541 REAL, DIMENSION(:), INTENT(IN)   :: PLW_G_TO_WIN  ! Radiative heat trasfer coeff garden-window 
00542                                                   ! [W K-1 m-2]
00543 REAL, DIMENSION(:), INTENT(IN)   :: PLW_R_TO_WIN  ! Radiative heat trasfer coeff road-window 
00544                                                   ! [W K-1 m-2] 
00545 REAL, DIMENSION(:), INTENT(IN)   :: PLW_S_TO_WIN ! Radiative heat trasfer coeff window-sky 
00546                                                  ! [W K-1 m-2]
00547 REAL, DIMENSION(:), INTENT(IN)   :: PLW_WIN_TO_WA! Radiative heat trasfer coeff window-wall
00548                                                  ! [W K-1 m-2] 
00549 REAL, DIMENSION(:), INTENT(IN)   :: PLW_WIN_TO_WB! Radiative heat trasfer coeff window-wall
00550                                                  ! [W K-1 m-2] 
00551 REAL, DIMENSION(:), INTENT(IN)   :: PLW_WIN_TO_R ! Radiative heat trasfer coeff window-road 
00552                                                  ! [W K-1 m-2]
00553 REAL, DIMENSION(:), INTENT(IN)   :: PLW_NR_TO_WIN! Radiative heat trasfer coeff road(snow)-win 
00554                                                  ! [W K-1 m-2]
00555 REAL, DIMENSION(:), INTENT(IN)   :: PLW_WIN_TO_NR! Radiative heat trasfer coeff win-road(snow) 
00556                                                  ! [W K-1 m-2]
00557 REAL, DIMENSION(:), INTENT(INOUT):: PT_WIN1       ! outdoor window temperature [K]
00558 REAL, DIMENSION(:), INTENT(IN)   :: PABS_SW_WIN   ! window absorbed shortwave radiation [W m-2] 
00559 REAL, DIMENSION(:), INTENT(OUT)  :: PABS_LW_WIN   ! absorbed infrared rad. [W m-2]
00560 REAL, DIMENSION(:), INTENT(IN)   :: PUGG_WIN      ! window glass-to-glass U-factro [W m-2 K-1]
00561  !new argument for PET calculation
00562 REAL, DIMENSION(:), INTENT(OUT) :: PEMIT_LW_ROAD ! LW fluxes emitted by road (W/m² surf road)
00563 REAL, DIMENSION(:), INTENT(OUT) :: PEMIT_LW_FAC  ! LW fluxes emitted by wall (W/m² surf wall)
00564 REAL, DIMENSION(:), INTENT(OUT) :: PT_RAD_IND    ! Indoor mean radiant temperature [K]
00565 REAL, DIMENSION(:), INTENT(OUT) :: PHU_BLD       ! Indoor relative humidity 0 < (-) < 1
00566 REAL,                INTENT(IN)  :: PTIME        ! current time since midnight (UTC, s)
00567 REAL, DIMENSION(:), INTENT(IN)  :: PE_SHADING    !energy not ref., nor absorbed, nor
00568                                                  !trans. by glazing [Wm-2(win)]
00569 LOGICAL, DIMENSION(:),INTENT(INOUT) :: ONATVENT_NIGHT ! has natural ventilation
00570                                                  !been necessary/possible during the night
00571 !
00572 REAL, DIMENSION(:)  , INTENT(IN)  :: PN_FLOOR        ! Number of floors     
00573 REAL, DIMENSION(:)  , INTENT(IN)  :: PWALL_O_BLD     ! Wall area [m2_wall/m2_bld]
00574 REAL, DIMENSION(:)  , INTENT(IN)  :: PGLAZ_O_BLD     ! Window area [m2_win/m2_bld]
00575 REAL, DIMENSION(:)  , INTENT(IN)  :: PMASS_O_BLD     ! Mass area [m2_mass/m2_bld]
00576 REAL, DIMENSION(:)  , INTENT(IN)  :: PFLOOR_HW_RATIO ! H/W ratio of 1 floor level
00577 REAL, DIMENSION(:)  , INTENT(IN)  :: PF_FLOOR_MASS   ! View factor floor-mass
00578 REAL, DIMENSION(:)  , INTENT(IN)  :: PF_FLOOR_WALL   ! View factor floor-wall
00579 REAL, DIMENSION(:)  , INTENT(IN)  :: PF_FLOOR_WIN    ! View factor floor-window
00580 REAL, DIMENSION(:)  , INTENT(IN)  :: PF_FLOOR_ROOF   ! View factor floor-roof
00581 REAL, DIMENSION(:)  , INTENT(IN)  :: PF_WALL_FLOOR   ! View factor wall-floor
00582 REAL, DIMENSION(:)  , INTENT(IN)  :: PF_WALL_MASS    ! View factor wall-mass
00583 REAL, DIMENSION(:)  , INTENT(IN)  :: PF_WALL_WIN     ! View factor wall-win
00584 REAL, DIMENSION(:)  , INTENT(IN)  :: PF_WIN_FLOOR    ! View factor win-floor
00585 REAL, DIMENSION(:)  , INTENT(IN)  :: PF_WIN_MASS     ! View factor win-mass
00586 REAL, DIMENSION(:)  , INTENT(IN)  :: PF_WIN_WALL     ! View factor win-wall
00587 REAL, DIMENSION(:)  , INTENT(IN)  :: PF_MASS_FLOOR   ! View factor mass-floor
00588 REAL, DIMENSION(:)  , INTENT(IN)  :: PF_MASS_WALL    ! View factor mass-wall
00589 REAL, DIMENSION(:)  , INTENT(IN)  :: PF_MASS_WIN     ! View factor mass-window
00590 LOGICAL,              INTENT(IN)  :: OCANOPY         ! is canopy active ?
00591  CHARACTER(LEN=5), INTENT(IN)      :: HCH_BEM         ! TEB option for outside building coef
00592                                                      ! "DOE-2"
00593 REAL, DIMENSION(:)  , INTENT(IN)  :: PROUGH_ROOF     ! roof roughness coef
00594 REAL, DIMENSION(:)  , INTENT(IN)  :: PROUGH_WALL     ! wall roughness coef
00595 REAL, DIMENSION(:)  , INTENT(IN)  :: PF_WIN_WIN      ! indoor win to win view factor
00596 !
00597 !*      0.2    Declarations of local variables
00598 !
00599 REAL, DIMENSION(SIZE(PTA)) :: ZVMOD          ! wind
00600 REAL, DIMENSION(SIZE(PTA)) :: ZWS_ROOF_MAX   ! maximum deepness of roof
00601 REAL, DIMENSION(SIZE(PTA)) :: ZWS_ROAD_MAX   ! and road water reservoirs
00602 !
00603 REAL, DIMENSION(SIZE(PTA)) :: ZAC_BLD        ! surface conductance inside the building itself in DEF building model
00604 REAL, DIMENSION(SIZE(PTA)) :: ZTA            ! air temperature extrapolated at roof level
00605 REAL, DIMENSION(SIZE(PTA)) :: ZQA            ! air humidity extrapolated at roof level
00606 !
00607 REAL, DIMENSION(SIZE(PTA)) :: ZDQS_ROAD      ! heat storage inside road
00608 REAL, DIMENSION(SIZE(PTA)) :: ZDQS_ROOF      ! heat storage inside roof
00609 REAL, DIMENSION(SIZE(PTA)) :: ZDQS_WALL_A    ! heat storage inside wall
00610 REAL, DIMENSION(SIZE(PTA)) :: ZDQS_WALL_B    ! heat storage inside wall
00611 REAL, DIMENSION(SIZE(PTA)) :: ZFLX_BLD_ROOF  !heat flux from inside through roof
00612 REAL, DIMENSION(SIZE(PTA)) :: ZFLX_BLD_WALL_A!heat flux from inside through wall
00613 REAL, DIMENSION(SIZE(PTA)) :: ZFLX_BLD_WALL_B!heat flux from inside through wall
00614 REAL, DIMENSION(SIZE(PTA)) :: ZFLX_BLD_FLOOR !heat flux from inside through floor
00615 REAL, DIMENSION(SIZE(PTA)) :: ZFLX_BLD_MASS  !heat flux from inside through mass
00616 !
00617 REAL, DIMENSION(SIZE(PTA)) :: ZDQS_SNOW_ROOF ! heat storage inside roof snowpack
00618 REAL, DIMENSION(SIZE(PTA)) :: ZDQS_SNOW_ROAD ! heat storage inside road snowpack
00619 REAL, DIMENSION(SIZE(PTA)) :: ZMELT_BLT      ! Snow melt for built & impervious part
00620 !
00621 ! coefficients for LW computations over snow (from previous time-step)
00622 !
00623 REAL, DIMENSION(SIZE(PTA)) :: ZTSSNOW_ROAD ! road snow temperature
00624 !                                          ! at previous time-step
00625 ! new local variables after BEM
00626 !
00627 REAL, DIMENSION(SIZE(PTA)) :: ZIMB_ROOF      ! residual energy imbalance
00628                                              ! of the roof for
00629                                              ! verification
00630 REAL, DIMENSION(SIZE(PTA)) :: ZIMB_ROAD      ! road residual energy imbalance 
00631                                              ! for verification [W m-2]
00632 REAL, DIMENSION(SIZE(PTA)) :: ZIMB_WALL      ! wall residual energy imbalance 
00633                                              ! for verification [W m-2]
00634 REAL, DIMENSION(SIZE(PTA)) :: ZTS_ROAD       ! road surface temperature 
00635 !                                            ! at previous time-step
00636 REAL, DIMENSION(SIZE(PTA)) :: ZTS_WALL_A     ! wall A surface temperature 
00637 !                                            ! at previous time-step
00638 REAL, DIMENSION(SIZE(PTA)) :: ZTS_WALL_B     ! wall B surface temperature 
00639 !                                            ! at previous time-step
00640 REAL, DIMENSION(SIZE(PTA)) :: ZTS_WALL       ! averaged wall surface temperature 
00641 !                                            ! at previous time-step
00642 REAL, DIMENSION(SIZE(PTA)) :: ZTS_ROOF       ! roof surface temperature 
00643 !                                            ! at previous time-step
00644 REAL, DIMENSION(SIZE(PTA),SIZE(PT_WALL_A,2)) :: ZT_WALL ! averaged wall surface temperature 
00645 !
00646 INTEGER :: IWALL, IROOF                      ! number of wall, roof layer
00647 REAL, DIMENSION(SIZE(PTA)) :: ZRADHT_IN     ! Indoor radiant heat transfer coefficient
00648                                                     ! [W K-1 m-2]
00649 REAL, DIMENSION(SIZE(PTA)) :: ZTS_FLOOR       ! floor surface temperature [K]
00650 REAL, DIMENSION(SIZE(PTA)) :: ZRAD_ROOF_WALL  ! rad. flux from roof to averaged wall [W m-2(roof)]
00651 REAL, DIMENSION(SIZE(PTA)) :: ZRAD_ROOF_WIN   ! rad. flux from roof to window [W m-2(roof)]
00652 REAL, DIMENSION(SIZE(PTA)) :: ZRAD_ROOF_FLOOR ! rad. flux from roof to floor [W m-2(roof)]
00653 REAL, DIMENSION(SIZE(PTA)) :: ZRAD_ROOF_MASS  ! rad. flux from roof to mass [W m-2(roof)]
00654 REAL, DIMENSION(SIZE(PTA)) :: ZCONV_ROOF_BLD  ! rad. flux from roof to bld [W m-2(roof)]
00655 REAL, DIMENSION(SIZE(PTA)) :: ZRAD_WALL_FLOOR ! rad. flux from averaged wall to floor [W m-2(wall)]
00656 REAL, DIMENSION(SIZE(PTA)) :: ZRAD_WALL_MASS  ! rad. flux from averaged wall to mass [W m-2(wall)]
00657 REAL, DIMENSION(SIZE(PTA)) :: ZRAD_WIN_FLOOR  ! rad. flux from averaged wall to floor [W m-2(win)]
00658 REAL, DIMENSION(SIZE(PTA)) :: ZRAD_WIN_MASS   ! rad. flux from averaged wall to mass [W m-2(win)]
00659 REAL, DIMENSION(SIZE(PTA)) :: ZCONV_WALL_BLD  ! rad. flux from roof to bld [W m-2(wall)]
00660 REAL, DIMENSION(SIZE(PTA)) :: ZCONV_WIN_BLD   ! rad. flux from roof to bld [W m-2(win)]
00661 REAL, DIMENSION(SIZE(PTA)) :: ZAC_WIN         ! window aerodynamic conductance
00662 
00663 REAL, DIMENSION(SIZE(PTA)) :: ZLOAD_IN_ROOF   ! indoor load on roof W/m²[roof]
00664 REAL, DIMENSION(SIZE(PTA)) :: ZLOAD_IN_FLOOR   ! indoor load on floor W/m²[floor]
00665 REAL, DIMENSION(SIZE(PTA)) :: ZLOAD_IN_WALL   ! indoor load on wall W/m²[wall]
00666 REAL, DIMENSION(SIZE(PTA)) :: ZLOAD_IN_WIN   ! indoor load on win W/m²[win]
00667 REAL, DIMENSION(SIZE(PTA)) :: ZLOAD_IN_MASS   ! indoor load on mass W/m²[mass]
00668 !
00669 REAL(KIND=JPRB) :: ZHOOK_HANDLE                                             
00670 !-------------------------------------------------------------------------------
00671 !
00672 !*      1.     Initializations
00673 !              ---------------
00674 !
00675 !*      1.1    Water reservoirs
00676 !              ----------------
00677 !
00678 IF (LHOOK) CALL DR_HOOK('TEB',0,ZHOOK_HANDLE)
00679 ZWS_ROOF_MAX =  1. ! (1mm) maximum deepness of roof water reservoir
00680 ZWS_ROAD_MAX =  1. ! (1mm) maximum deepness of road water reservoir
00681 !
00682 !*      1.2    radiative snow variables at previous time-step
00683 !              ----------------------------------------------
00684 !
00685 ZTSSNOW_ROAD(:)=PTSSNOW_ROAD(:)
00686 !
00687 !
00688 !*      1.3    indoor aerodynamique conductance for DEF case
00689 !              ----------------------------------------------
00690 !
00691 ZAC_BLD(:) = XUNDEF
00692 IF (HBEM=='DEF') ZAC_BLD=1. / 0.123 / (XCPD * PRHOA(:)) !* (normalized by rho Cp for convenience)
00693 !-------------------------------------------------------------------------------
00694 !
00695 !*      1.3    number of roof/wall layer
00696 !              -------------------------
00697 !
00698 IWALL = SIZE(PT_WALL_A,2)
00699 IROOF = SIZE(PT_ROOF,2)
00700 !
00701 ZTS_WALL_A  (:)=PT_WALL_A   (:,1)
00702 ZTS_WALL_B  (:)=PT_WALL_B   (:,1)
00703 ZTS_WALL    (:)=0.5 * (ZTS_WALL_A(:)+ZTS_WALL_B(:))
00704 ZTS_ROAD    (:)=PT_ROAD     (:,1)
00705 ZTS_ROOF    (:)=PT_ROOF     (:,1)
00706 !
00707 !
00708 !*      1.4    load on indoor walls
00709 !              -------------------------
00710 !
00711 IF (HBEM=='BEM') THEN
00712   !
00713   ZLOAD_IN_ROOF = PF_FLOOR_WIN * PTR_SW_WIN + PQIN * PN_FLOOR * (1-PQIN_FLAT) * PQIN_FRAD  &
00714            / (2 + PWALL_O_BLD + PGLAZ_O_BLD + PMASS_O_BLD ) ! W/m² [ROOF]
00715   ZLOAD_IN_FLOOR = PF_FLOOR_WIN * PTR_SW_WIN + PQIN * PN_FLOOR * (1-PQIN_FLAT) * PQIN_FRAD  &
00716            / (2 + PWALL_O_BLD + PGLAZ_O_BLD + PMASS_O_BLD )
00717   ZLOAD_IN_MASS = PF_MASS_WIN * PTR_SW_WIN + PQIN * PN_FLOOR * (1-PQIN_FLAT) * PQIN_FRAD  &
00718            / (2 + PWALL_O_BLD + PGLAZ_O_BLD + PMASS_O_BLD )
00719   ZLOAD_IN_WALL = PF_WALL_WIN * PTR_SW_WIN + PQIN * PN_FLOOR * (1-PQIN_FLAT) * PQIN_FRAD  &
00720            / (2 + PWALL_O_BLD + PGLAZ_O_BLD + PMASS_O_BLD )
00721   ZLOAD_IN_WIN = PF_WIN_WIN * PTR_SW_WIN + PQIN * PN_FLOOR * (1-PQIN_FLAT) * PQIN_FRAD  &
00722            / (2 + PWALL_O_BLD + PGLAZ_O_BLD + PMASS_O_BLD )
00723 ELSE
00724   ZLOAD_IN_ROOF = 0.
00725   ZLOAD_IN_FLOOR = 0.
00726   ZLOAD_IN_MASS = 0.
00727   ZLOAD_IN_WALL = 0.
00728   ZLOAD_IN_WIN = 0.
00729 ENDIF
00730 !-------------------------------------------------------------------------------
00731 !
00732 !*      2.     Snow-covered surfaces relative effects
00733 !              --------------------------------------
00734 !
00735 !*      2.1    Effects on water reservoirs
00736 !              ---------------------------
00737 !
00738 ZWS_ROOF_MAX(:) = ZWS_ROOF_MAX(:) * PDF_ROOF(:)
00739 ZWS_ROAD_MAX(:) = ZWS_ROAD_MAX(:) * PDF_ROAD(:)
00740 !
00741 !-------------------------------------------------------------------------------
00742 !
00743 !*      3.     Surface drag
00744 !              ------------
00745 !
00746  CALL URBAN_DRAG(HZ0H, HIMPLICIT_WIND, PTSTEP, PT_CANYON, PQ_CANYON,  &
00747                 PU_CANYON, PT_LOWCAN, PQ_LOWCAN, PU_LOWCAN,          &
00748                 PZ_LOWCAN, ZTS_ROOF, ZTS_ROAD, ZTS_WALL,             &
00749                 PTS_GARDEN, PDN_ROOF, PDN_ROAD,                      &
00750                 PEXNS, PEXNA, PTA, PQA, PPS, PRHOA,                  &
00751                 PZREF, PUREF, PVMOD,                                 &
00752                 PZ0_TOWN,                                            &
00753                 PBLD, PGARDEN, PROAD,                                &
00754                 PBLD_HEIGHT, PCAN_HW_RATIO,                          &
00755                 PWALL_O_GRND,                                        &
00756                 PWS_ROOF, PWS_ROAD,                                  &
00757                 ZWS_ROOF_MAX, ZWS_ROAD_MAX,                          &
00758                 PPEW_A_COEF, PPEW_B_COEF,                            &
00759                 PPEW_A_COEF_LOWCAN, PPEW_B_COEF_LOWCAN,              &
00760                 PQSAT_ROOF, PQSAT_ROAD, PDELT_ROOF, PDELT_ROAD,      &
00761                 PCD, PCDN, PAC_ROOF, PAC_ROOF_WAT,                   &
00762                 PAC_WALL, PAC_ROAD, PAC_ROAD_WAT, PAC_TOP,           &
00763                 PAC_GARDEN, PRI_TOWN,                                &
00764                 PUW_ROAD, PUW_ROOF, PDUWDU_ROAD, PDUWDU_ROOF,        &
00765                 PUSTAR_TOWN, OCANOPY, PT_WIN1,  ZAC_WIN, HCH_BEM,    &
00766                 PROUGH_ROOF, PROUGH_WALL                             )
00767 !
00768 !* area-averaged heat transfer coefficient
00769 !
00770 ZVMOD(:) = WIND_THRESHOLD(PVMOD(:),PUREF(:))
00771 !
00772 PCH_TOWN(:) = (PBLD(:) * PAC_ROOF(:) + (1.-PBLD(:)) * PAC_TOP (:)) / ZVMOD(:)
00773 !
00774 !* aggregation of momentum fluxes for roofs (=> derivate of flux also recalculated)
00775 !
00776 PUW_ROOF (:) = (1-PFRAC_GR(:)) * PUW_ROOF(:) + PFRAC_GR(:) * PUW_GREENROOF(:)
00777 WHERE (PVMOD(:)/=0.) PDUWDU_ROOF(:) = 2. * PUW_ROOF(:) / PVMOD(:)
00778 !
00779 !-------------------------------------------------------------------------------
00780 !
00781 !*      4.     Extrapolation of atmospheric T and q at roof level (for fluxes computation)
00782 !              --------------------------------------------------
00783 !
00784 ZTA(:) = PTA(:) * PEXNS(:) / PEXNA(:)
00785 ZQA(:) = PQA(:) * QSAT(PTA(:),PPS(:)) / QSAT(ZTA(:),PPA(:))
00786 !
00787 !-------------------------------------------------------------------------------
00788 !
00789 !*      5.     Snow mantel model
00790 !              -----------------
00791 !
00792  CALL URBAN_SNOW_EVOL(PT_LOWCAN, PQ_LOWCAN, PU_LOWCAN,                         &
00793                      ZTS_ROOF,ZTS_ROAD,ZTS_WALL_A, ZTS_WALL_B,                &
00794                      HSNOW_ROOF,                                              &
00795                      PWSNOW_ROOF, PTSNOW_ROOF, PRSNOW_ROOF, PASNOW_ROOF,      &
00796                      PTSSNOW_ROOF, PESNOW_ROOF,                               &
00797                      HSNOW_ROAD,                                              &
00798                      PWSNOW_ROAD, PTSNOW_ROAD, PRSNOW_ROAD, PASNOW_ROAD,      &
00799                      PTSSNOW_ROAD, PESNOW_ROAD,                               &
00800                      PPS, ZTA, ZQA, PRHOA,                                    &
00801                      PLW_RAD,                                                 &
00802                      PSR, PZREF, PUREF, PVMOD,                                &
00803                      PTSTEP,                                                  &
00804                      PZ_LOWCAN,                                               &
00805                      PDN_ROOF, PABS_SW_SNOW_ROOF, PABS_LW_SNOW_ROOF,          &
00806                      PDN_ROAD, PABS_SW_SNOW_ROAD, PABS_LW_SNOW_ROAD,          &
00807                      PRNSNOW_ROOF, PHSNOW_ROOF, PLESNOW_ROOF, PGSNOW_ROOF,    &
00808                      PMELT_ROOF,                                              &
00809                      PRNSNOW_ROAD, PHSNOW_ROAD, PLESNOW_ROAD, PGSNOW_ROAD,    &
00810                      PMELT_ROAD,                                              &
00811                      PLW_WA_TO_NR, PLW_WB_TO_NR, PLW_S_TO_NR, PLW_WIN_TO_NR,  &
00812                      ZDQS_SNOW_ROOF, ZDQS_SNOW_ROAD, PT_WIN1                  )
00813 !
00814 !-------------------------------------------------------------------------------
00815 !
00816 !*      6.    LW properties
00817 !              -------------
00818 !
00819 PDF_ROAD (:) = 1. - PDN_ROAD (:)
00820 !
00821 !-------------------------------------------------------------------------------
00822 !
00823 !*      7.    Indoor radiative temperature
00824 !              ---------------------------
00825 !
00826 ! uses the averaged temperature of both walls for the building energy balance
00827 ZT_WALL   (:,:)=0.5 * (PT_WALL_A(:,:)+PT_WALL_B(:,:))
00828 !
00829 SELECT CASE(HBEM)
00830    CASE("DEF")
00831       ZTS_FLOOR(:) = 19. + XTT
00832       PT_RAD_IND(:) = (PWALL_O_HOR(:) / PBLD(:) * ZT_WALL(:,IWALL) + &
00833                     PT_ROOF(:,IROOF) + ZTS_FLOOR(:)) &
00834                    / (PWALL_O_HOR(:) / PBLD(:) + 1. + 1.) 
00835       ZRADHT_IN(:) = XUNDEF
00836    CASE("BEM")
00837       ZTS_FLOOR(:) = PT_FLOOR(:,1)
00838       PT_RAD_IND(:)  = (PT_MASS(:,1)*PMASS_O_BLD(:) + ZT_WALL(:,IWALL)*PWALL_O_BLD(:)     &
00839                  + ZTS_FLOOR(:) + PT_ROOF(:,IROOF) + PT_WIN2(:) * PGLAZ_O_BLD(:)) &
00840                  /(PMASS_O_BLD(:) + PWALL_O_BLD(:) + 1. + 1. + PGLAZ_O_BLD(:))
00841       !             Assuming indoor surface emissivities of 0.9
00842       ZRADHT_IN(:)   = 0.9 * 0.9 * 4 * XSTEFAN * PT_RAD_IND(:)**3          
00843 END SELECT
00844 !
00845 !
00846 !*      7.    Roof Ts computation
00847 !              -------------------
00848 !
00849 !* ts_roof and qsat_roof are updated
00850 !
00851 
00852  CALL ROOF_LAYER_E_BUDGET(PT_ROOF, PQSAT_ROOF, PTI_BLD, ZAC_BLD, PTSTEP, &
00853                          HBEM, PHC_ROOF, PTC_ROOF, PD_ROOF, PDN_ROOF,   &
00854                          PRHOA, PAC_ROOF, PAC_ROOF_WAT, PLW_RAD, PPS,   &
00855                          PDELT_ROOF, ZTA, ZQA, PEXNA, PEXNS,            &
00856                          PABS_SW_ROOF, PGSNOW_ROOF, PEMIS_ROOF,         &
00857                          ZFLX_BLD_ROOF, ZDQS_ROOF, PABS_LW_ROOF,        &
00858                          PH_ROOF, PLEW_ROOF, ZIMB_ROOF,                 &
00859                          PFRAC_GR, PG_GREENROOF_ROOF,                   &
00860                          PF_FLOOR_MASS, PF_FLOOR_WALL, PF_FLOOR_WIN,    &
00861                          PF_FLOOR_ROOF, ZRADHT_IN,         &
00862                          PT_MASS(:,1), PT_WIN2, ZTS_FLOOR(:),           &
00863                          ZT_WALL(:,IWALL), ZRAD_ROOF_WALL,              &
00864                          ZRAD_ROOF_WIN, ZRAD_ROOF_FLOOR, ZRAD_ROOF_MASS,&
00865                          ZCONV_ROOF_BLD,                                &
00866                          PRR, & !modif to add heating/cooling of rain
00867                          ZLOAD_IN_ROOF )
00868 !
00869 !-------------------------------------------------------------------------------
00870 !
00871 !*      8.    Road and wall Ts computations
00872 !              -----------------------------
00873 !
00874 !* ts_road, ts_wall, qsat_road, t_canyon and q_canyon are updated
00875 !
00876  CALL ROAD_LAYER_E_BUDGET(PT_ROAD, PTSTEP, PHC_ROAD, PTC_ROAD, PD_ROAD,       &
00877                          PDN_ROAD, PRHOA, PAC_ROAD, PAC_ROAD_WAT,            &
00878                          PLW_RAD, PPS, PQSAT_ROAD, PDELT_ROAD, PEXNS,        &
00879                          PABS_SW_ROAD, PGSNOW_ROAD, PQ_LOWCAN, PT_LOWCAN,    &
00880                          ZTS_WALL_A, ZTS_WALL_B, ZTSSNOW_ROAD,               &
00881                          PTS_GARDEN, PT_WIN1,                                &
00882                          PLW_WA_TO_R, PLW_WB_TO_R, PLW_S_TO_R, PLW_WIN_TO_R, &
00883                          PEMIS_ROAD, PEMIT_LW_ROAD, ZDQS_ROAD, PABS_LW_ROAD, &
00884                          PH_ROAD, PLEW_ROAD, ZIMB_ROAD, PRR                  )
00885 !
00886  CALL FACADE_E_BUDGET(HWALL_OPT, HBEM,                                    &
00887                      PT_WALL_A, PT_WALL_B, PTSTEP,                       &
00888                      PHC_WALL, PTC_WALL, PD_WALL,                        &
00889                      PDN_ROAD, PRHOA, PAC_WALL,                          &
00890                      ZAC_BLD, PTI_BLD, PLW_RAD, PPS, PEXNS,              &
00891                      PABS_SW_WALL_A, PABS_SW_WALL_B, PT_CANYON,          &
00892                      ZTS_ROAD, ZTSSNOW_ROAD, PTS_GARDEN, PUGG_WIN, PGR,  &
00893                      PABS_SW_WIN, PF_WIN_MASS, PF_WIN_WALL,              &
00894                      PF_WIN_FLOOR, PT_MASS(:,1), ZTS_FLOOR(:),           &
00895                      PEMIS_WALL,                                         &
00896                      PLW_WA_TO_WB,                                       &
00897                      PLW_R_TO_WA, PLW_R_TO_WB, PLW_G_TO_WA, PLW_G_TO_WB, &
00898                      PLW_S_TO_WA, PLW_S_TO_WB, PLW_NR_TO_WA,PLW_NR_TO_WB,&
00899                      PLW_WIN_TO_WA, PLW_WIN_TO_WB,                       &
00900                      PLW_S_TO_WIN, PLW_WA_TO_WIN, PLW_WB_TO_WIN,         &
00901                      PLW_R_TO_WIN, PLW_G_TO_WIN, PLW_NR_TO_WIN, PT_WIN1, &
00902                      ZFLX_BLD_WALL_A, ZDQS_WALL_A,                       &
00903                      ZFLX_BLD_WALL_B, ZDQS_WALL_B,                       &
00904                      PT_WIN2, PEMIT_LW_FAC,                              &
00905                      PABS_LW_WALL_A, PABS_LW_WALL_B, PABS_LW_WIN,        &
00906                      PH_WALL_A, PH_WALL_B,                               &
00907                      ZIMB_WALL, PF_WALL_MASS, PF_WALL_FLOOR,             &
00908                      PF_WALL_WIN, ZRADHT_IN, ZRAD_ROOF_WALL,             &
00909                      ZRAD_ROOF_WIN, ZRAD_WALL_FLOOR, ZRAD_WALL_MASS,     &
00910                      ZRAD_WIN_FLOOR, ZRAD_WIN_MASS, ZCONV_WALL_BLD,      &
00911                      ZCONV_WIN_BLD, ZAC_WIN,                             &
00912                      ZLOAD_IN_WALL, ZLOAD_IN_WIN                         )
00913 !
00914 !-------------------------------------------------------------------------------
00915 !
00916 !*      9.     Evolution of interior building air temperature
00917 !              ----------------------------------------------
00918 !
00919 ! uses the averaged temperature of both walls for the building energy balance
00920 ZT_WALL   (:,:)=0.5 * (PT_WALL_A(:,:)+PT_WALL_B(:,:))
00921 !
00922 SELECT CASE(HBEM)
00923 CASE("DEF")
00924 !
00925    CALL BLD_E_BUDGET(.TRUE., PTSTEP, PBLD, PWALL_O_HOR,        &
00926                      PRHOA, PT_ROOF, ZT_WALL, PTI_BLD, ZTS_FLOOR(:) )
00927 
00928    !variables that needs to be computed apart
00929    PQI_BLD = 0.5 * QSAT(PTI_BLD, PPS)
00930    !variables that need to be set 0 for calculation
00931    PH_WASTE      (:) = 0.
00932    PLE_WASTE     (:) = 0.
00933    ZFLX_BLD_FLOOR(:) = 0.
00934    ZFLX_BLD_MASS (:) = 0.
00935    !other variables
00936    PH_BLD_COOL(:) = XUNDEF
00937    PLE_BLD_COOL(:)= XUNDEF
00938    PT_BLD_COOL(:) = XUNDEF
00939    PH_BLD_HEAT(:) = XUNDEF
00940    PLE_BLD_HEAT(:)= XUNDEF
00941    PHVAC_COOL(:)  = XUNDEF
00942    PHVAC_HEAT(:)  = XUNDEF
00943    PCAP_SYS(:)    = XUNDEF
00944    PM_SYS(:)      = XUNDEF
00945    PCOP(:)        = XUNDEF
00946    PQ_SYS(:)      = XUNDEF
00947    PFAN_POWER(:)  = XUNDEF
00948    PHU_BLD(:)     = XUNDEF
00949 
00950 CASE("BEM")
00951   CALL BEM(PTSTEP, PTIME, HCOOL_COIL, HHEAT_COIL,                 &
00952     OAUTOSIZE, KDAY, HNATVENT,                                    &
00953     PPS, PRHOA, PT_CANYON, PQ_CANYON, PU_CANYON,                  &
00954     PT_ROOF, PT_WALL_A, PT_WALL_B, PBLD, PBLD_HEIGHT, PWALL_O_HOR,&
00955     PHC_FLOOR, PTC_FLOOR, PD_FLOOR,                               &
00956     PT_WIN2, PGR, PQIN, PQIN_FRAD, PQIN_FLAT,                     &
00957     PEFF_HEAT, PINF, PTCOOL_TARGET, PTHEAT_TARGET, PHR_TARGET,    &
00958     PF_WATER_COND, PV_VENT, PCAP_SYS_HEAT, PT_ADP, PCOP_RAT,      &
00959     PAUX_MAX, PT_FLOOR, PT_MASS, PTI_BLD, PQI_BLD,                &
00960     PCAP_SYS_RAT, PM_SYS_RAT, ONATVENT_NIGHT,                     &
00961     PH_BLD_COOL, PH_BLD_HEAT, PLE_BLD_COOL, PLE_BLD_HEAT,         &
00962     PT_BLD_COOL, PHVAC_COOL, PT_SYS, PQ_SYS, PH_WASTE, PLE_WASTE, & 
00963     PFAN_POWER, PHVAC_HEAT, PM_SYS, PCOP, PCAP_SYS, PHU_BLD,      &
00964     PTR_SW_WIN, PT_RAD_IND, ZFLX_BLD_FLOOR, ZFLX_BLD_MASS,        &
00965     PF_FLOOR_MASS, PF_FLOOR_WALL, PF_FLOOR_WIN,                   &
00966     ZRADHT_IN, PN_FLOOR, PWALL_O_BLD, PGLAZ_O_BLD, PMASS_O_BLD,   &
00967     PFLOOR_HW_RATIO, PF_FLOOR_ROOF, PF_MASS_FLOOR, PF_MASS_WALL,  &
00968     PF_MASS_WIN, ZRAD_ROOF_MASS, ZRAD_ROOF_FLOOR, ZRAD_WALL_MASS, &
00969     ZRAD_WALL_FLOOR, ZRAD_WIN_MASS, ZRAD_WIN_FLOOR,               &
00970     ZCONV_ROOF_BLD, ZCONV_WALL_BLD, ZCONV_WIN_BLD,                &
00971     ZLOAD_IN_FLOOR, ZLOAD_IN_MASS                                 )
00972 
00973    PH_WASTE  = PH_WASTE  * PBLD
00974    PLE_WASTE = PLE_WASTE * PBLD
00975 END SELECT
00976 !
00977 !-------------------------------------------------------------------------------
00978 !
00979 !*      10.    Fluxes over built surfaces
00980 !              --------------------------
00981 !
00982  CALL URBAN_FLUXES   (HIMPLICIT_WIND, OCANOPY, PT_CANYON,                      &
00983                      PPEW_A_COEF, PPEW_B_COEF,                                &
00984                      PEXNS, PRHOA, PVMOD,                                     &
00985                      PH_TRAFFIC, PLE_TRAFFIC, PH_INDUSTRY, PLE_INDUSTRY,      &
00986                      PBLD, PROAD, PWALL_O_HOR, PFRAC_GR,                      &
00987                      PABS_SW_ROOF, PABS_LW_ROOF,                              &
00988                      PABS_SW_WALL_A, PABS_LW_WALL_A,                          &
00989                      PABS_SW_WALL_B, PABS_LW_WALL_B,                          &
00990                      PABS_SW_ROAD, PABS_LW_ROAD,                              &
00991                      PAC_WALL, PCD,                                           &
00992                      PDF_ROOF, PDN_ROOF, PDF_ROAD, PDN_ROAD,                  &
00993                      PRNSNOW_ROOF, PHSNOW_ROOF, PLESNOW_ROOF, PGSNOW_ROOF,    &
00994                      PRNSNOW_ROAD, PHSNOW_ROAD, PLESNOW_ROAD, PGSNOW_ROAD,    &
00995                      PMELT_ROOF, ZDQS_ROOF,                                   &
00996                      PMELT_ROAD, ZDQS_ROAD,                                   &
00997                      ZDQS_WALL_A, ZDQS_WALL_B,                                &
00998                      ZFLX_BLD_ROOF, ZFLX_BLD_WALL_A, ZFLX_BLD_WALL_B,         &
00999                      ZFLX_BLD_FLOOR,                                          &
01000                      ZFLX_BLD_MASS, PE_SHADING, HBEM, PGR, PT_WIN1, PH_WASTE, &
01001                      PLE_WASTE, PF_WASTE_CAN, PABS_SW_WIN, PABS_LW_WIN, PQIN, &
01002                      PN_FLOOR, PLEW_ROOF, PLEW_ROAD,                          &
01003                      PRN_GREENROOF, PH_GREENROOF, PLE_GREENROOF,              &
01004                      PGFLUX_GREENROOF,                                        &
01005                      PH_ROOF, PH_ROAD, PH_WALL_A, PH_WALL_B,                  &
01006                      PRN_ROOF,PLE_ROOF,                                       &
01007                      PGFLUX_ROOF, PRN_ROAD, PLE_ROAD, PGFLUX_ROAD,            &
01008                      PRN_WALL_A, PLE_WALL_A, PGFLUX_WALL_A,                   &
01009                      PRN_WALL_B, PLE_WALL_B, PGFLUX_WALL_B,                   &
01010                      PRN_STRLROOF, PH_STRLROOF, PLE_STRLROOF,                 & 
01011                      PGFLUX_STRLROOF,                                         &
01012                      PRN_BLT, PH_BLT, PLE_BLT,                                &
01013                      PGFLUX_BLT, ZMELT_BLT, PQF_BLD, PFLX_BLD, PDQS_TOWN,     &
01014                      PQF_TOWN, PUSTAR_TOWN, PHVAC_COOL, PHVAC_HEAT            )
01015 !
01016 !
01017 ! Water transfer from snow reservoir to water reservoir in case of snow melt
01018 !
01019 WHERE (PMELT_ROOF(:) .GT. 0.)
01020  PWS_ROOF(:) = MIN(ZWS_ROOF_MAX,PWS_ROOF(:) + PMELT_ROOF(:)*PTSTEP)
01021 ENDWHERE
01022 !
01023 WHERE (PMELT_ROAD(:) .GT. 0.)
01024  PWS_ROAD(:) = MIN(ZWS_ROAD_MAX,PWS_ROAD(:) + PMELT_ROAD(:)*PTSTEP)
01025 ENDWHERE
01026 !
01027 !-------------------------------------------------------------------------------
01028 !
01029 !*      11.    Roof ans road reservoirs evolution
01030 !              ----------------------------------
01031 !
01032  CALL URBAN_HYDRO(ZWS_ROOF_MAX,ZWS_ROAD_MAX, PWS_ROOF, PWS_ROAD,        &
01033                  PRR, PTSTEP, PBLD, PLE_ROOF, PLE_ROAD,                &
01034                  PRUNOFF_ROOF,                                         &
01035                  PRUNOFF_ROAD,                                         &
01036                  PRUNOFF_TOWN                                          )
01037 !
01038 !-------------------------------------------------------------------------------
01039 !
01040 !*      19.    Compute aerodynamical resistance 
01041 !              --------------------------------
01042 !
01043 PRESA_TOWN(:) = 1. / ( PBLD(:) * PAC_ROOF(:)  + ( 1. - PBLD(:)) * PAC_TOP (:))
01044 !
01045 IF (LHOOK) CALL DR_HOOK('TEB',1,ZHOOK_HANDLE)
01046 !-------------------------------------------------------------------------------
01047 !
01048 END SUBROUTINE TEB