Ignore:
Timestamp:
Feb 1, 2019 3:37:28 PM (5 years ago)
Author:
kanani
Message:

Formatting and clean-up (urban_surface_mod)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/urban_surface_mod.f90

    r3710 r3712  
    1515! PALM. If not, see <http://www.gnu.org/licenses/>.
    1616!
    17 ! Copyright 2015-2018 Czech Technical University in Prague
    18 ! Copyright 2015-2018 Institute of Computer Science of the
     17! Copyright 2015-2019 Czech Technical University in Prague
     18! Copyright 2015-2019 Institute of Computer Science of the
    1919!                     Czech Academy of Sciences, Prague
    2020! Copyright 1997-2019 Leibniz Universitaet Hannover
     
    2828! -----------------
    2929! $Id$
     30! Formatting and clean-up (rvtils)
     31!
     32! 3710 2019-01-30 18:11:19Z suehring
    3033! Check if building type is set within a valid range.
    3134!
     
    477480
    478481    REAL(wp), PARAMETER ::                     &
    479               b_ch               = 6.04_wp,    & ! Clapp & Hornberger exponent
    480               lambda_h_green_dry = 0.19_wp,    & ! heat conductivity for dry soil   
    481               lambda_h_green_sm  = 3.44_wp,    & ! heat conductivity of the soil matrix
    482               lambda_h_water     = 0.57_wp,    & ! heat conductivity of water
    483               psi_sat            = -0.388_wp,  & ! soil matrix potential at saturation
    484               rho_c_soil         = 2.19E6_wp,  & ! volumetric heat capacity of soil
    485               rho_c_water        = 4.20E6_wp !,  & ! volumetric heat capacity of water
     482              b_ch               = 6.04_wp,    &  !< Clapp & Hornberger exponent
     483              lambda_h_green_dry = 0.19_wp,    &  !< heat conductivity for dry soil   
     484              lambda_h_green_sm  = 3.44_wp,    &  !< heat conductivity of the soil matrix
     485              lambda_h_water     = 0.57_wp,    &  !< heat conductivity of water
     486              psi_sat            = -0.388_wp,  &  !< soil matrix potential at saturation
     487              rho_c_soil         = 2.19E6_wp,  &  !< volumetric heat capacity of soil
     488              rho_c_water        = 4.20E6_wp      !< volumetric heat capacity of water
    486489!               m_max_depth        = 0.0002_wp     ! Maximum capacity of the water reservoir (m)
    487490
     
    489492!-- Soil parameters I           alpha_vg,      l_vg_green,    n_vg, gamma_w_green_sat
    490493    REAL(wp), DIMENSION(0:3,1:7), PARAMETER :: soil_pars = RESHAPE( (/     &
    491                                  3.83_wp,  1.250_wp, 1.38_wp,  6.94E-6_wp, & ! 1
    492                                  3.14_wp, -2.342_wp, 1.28_wp,  1.16E-6_wp, & ! 2
    493                                  0.83_wp, -0.588_wp, 1.25_wp,  0.26E-6_wp, & ! 3
    494                                  3.67_wp, -1.977_wp, 1.10_wp,  2.87E-6_wp, & ! 4
    495                                  2.65_wp,  2.500_wp, 1.10_wp,  1.74E-6_wp, & ! 5
    496                                  1.30_wp,  0.400_wp, 1.20_wp,  0.93E-6_wp, & ! 6
    497                                  0.00_wp,  0.00_wp,  0.00_wp,  0.57E-6_wp  & ! 7
     494                                 3.83_wp,  1.250_wp, 1.38_wp,  6.94E-6_wp, &  !< soil 1
     495                                 3.14_wp, -2.342_wp, 1.28_wp,  1.16E-6_wp, &  !< soil 2
     496                                 0.83_wp, -0.588_wp, 1.25_wp,  0.26E-6_wp, &  !< soil 3
     497                                 3.67_wp, -1.977_wp, 1.10_wp,  2.87E-6_wp, &  !< soil 4
     498                                 2.65_wp,  2.500_wp, 1.10_wp,  1.74E-6_wp, &  !< soil 5
     499                                 1.30_wp,  0.400_wp, 1.20_wp,  0.93E-6_wp, &  !< soil 6
     500                                 0.00_wp,  0.00_wp,  0.00_wp,  0.57E-6_wp  &  !< soil 7
    498501                                 /), (/ 4, 7 /) )
    499502
     
    501504!-- Soil parameters II              swc_sat,     fc,   wilt,    swc_res 
    502505    REAL(wp), DIMENSION(0:3,1:7), PARAMETER :: m_soil_pars = RESHAPE( (/ &
    503                                  0.403_wp, 0.244_wp, 0.059_wp, 0.025_wp, & ! 1
    504                                  0.439_wp, 0.347_wp, 0.151_wp, 0.010_wp, & ! 2
    505                                  0.430_wp, 0.383_wp, 0.133_wp, 0.010_wp, & ! 3
    506                                  0.520_wp, 0.448_wp, 0.279_wp, 0.010_wp, & ! 4
    507                                  0.614_wp, 0.541_wp, 0.335_wp, 0.010_wp, & ! 5
    508                                  0.766_wp, 0.663_wp, 0.267_wp, 0.010_wp, & ! 6
    509                                  0.472_wp, 0.323_wp, 0.171_wp, 0.000_wp  & ! 7
     506                                 0.403_wp, 0.244_wp, 0.059_wp, 0.025_wp, &  !< soil 1
     507                                 0.439_wp, 0.347_wp, 0.151_wp, 0.010_wp, &  !< soil 2
     508                                 0.430_wp, 0.383_wp, 0.133_wp, 0.010_wp, &  !< soil 3
     509                                 0.520_wp, 0.448_wp, 0.279_wp, 0.010_wp, &  !< soil 4
     510                                 0.614_wp, 0.541_wp, 0.335_wp, 0.010_wp, &  !< soil 5
     511                                 0.766_wp, 0.663_wp, 0.267_wp, 0.010_wp, &  !< soil 6
     512                                 0.472_wp, 0.323_wp, 0.171_wp, 0.000_wp  &  !< soil 7
    510513                                 /), (/ 4, 7 /) )
    511                                
    512     !  value 9999999.9_wp -> generic available or user-defined value must be set
    513 !  otherwise -> no generic variable and user setting is optional
    514     REAL(wp) :: alpha_vangenuchten = 9999999.9_wp,      & !< NAMELIST alpha_vg
    515                 field_capacity = 9999999.9_wp,          & !< NAMELIST fc
    516                 hydraulic_conductivity = 9999999.9_wp,  & !< NAMELIST gamma_w_green_sat
    517                 lambda_h_green_sat = 0.0_wp,            & !< heat conductivity for saturated soil
    518                 l_vangenuchten = 9999999.9_wp,          & !< NAMELIST l_vg
    519                 n_vangenuchten = 9999999.9_wp,          & !< NAMELIST n_vg
    520                 residual_moisture = 9999999.9_wp,       & !< NAMELIST m_res
    521                 saturation_moisture = 9999999.9_wp,     & !< NAMELIST m_sat
    522                 wilting_point = 9999999.9_wp!,           & !< NAMELIST m_wilt
     514!
     515!-- value 9999999.9_wp -> generic available or user-defined value must be set
     516!-- otherwise -> no generic variable and user setting is optional
     517    REAL(wp) :: alpha_vangenuchten = 9999999.9_wp,      &  !< NAMELIST alpha_vg
     518                field_capacity = 9999999.9_wp,          &  !< NAMELIST fc
     519                hydraulic_conductivity = 9999999.9_wp,  &  !< NAMELIST gamma_w_green_sat
     520                lambda_h_green_sat = 0.0_wp,            &  !< heat conductivity for saturated soil
     521                l_vangenuchten = 9999999.9_wp,          &  !< NAMELIST l_vg
     522                n_vangenuchten = 9999999.9_wp,          &  !< NAMELIST n_vg
     523                residual_moisture = 9999999.9_wp,       &  !< NAMELIST m_res
     524                saturation_moisture = 9999999.9_wp,     &  !< NAMELIST m_sat
     525                wilting_point = 9999999.9_wp              !< NAMELIST m_wilt
    523526   
    524 
     527!
    525528!-- configuration parameters (they can be setup in PALM config)
    526529    LOGICAL ::  usm_material_model = .TRUE.        !< flag parameter indicating wheather the  model of heat in materials is used
    527     LOGICAL ::  usm_anthropogenic_heat = .FALSE.   !< flag parameter indicating wheather the anthropogenic heat sources (e.g.transportation) are used
     530    LOGICAL ::  usm_anthropogenic_heat = .FALSE.   !< flag parameter indicating wheather the anthropogenic heat sources
     531                                                   !< (e.g.transportation) are used
    528532    LOGICAL ::  force_radiation_call_l = .FALSE.   !< flag parameter for unscheduled radiation model calls
    529533    LOGICAL ::  indoor_model = .FALSE.             !< whether to use the indoor model
     
    540544!
    541545!-- Indices of input attributes for (above) ground floor level
    542     INTEGER(iwp) ::  ind_alb_wall_agfl     = 65  !< index in input list for albedo_type of wall above ground floor level
    543     INTEGER(iwp) ::  ind_alb_wall_gfl      = 32  !< index in input list for albedo_type of wall ground floor level
    544     INTEGER(iwp) ::  ind_alb_wall_r        = 96  !< index in input list for albedo_type of wall roof
    545     INTEGER(iwp) ::  ind_alb_green_agfl    = 83  !< index in input list for albedo_type of green above ground floor level
    546     INTEGER(iwp) ::  ind_alb_green_gfl     = 50  !< index in input list for albedo_type of green ground floor level
    547     INTEGER(iwp) ::  ind_alb_green_r       = 115 !< index in input list for albedo_type of green roof
    548     INTEGER(iwp) ::  ind_alb_win_agfl      = 79  !< index in input list for albedo_type of window fraction above ground floor level
    549     INTEGER(iwp) ::  ind_alb_win_gfl       = 46  !< index in input list for albedo_type of window fraction ground floor level
    550     INTEGER(iwp) ::  ind_alb_win_r         = 110 !< index in input list for albedo_type of window fraction roof
    551     INTEGER(iwp) ::  ind_emis_wall_agfl    = 64  !< index in input list for wall emissivity, above ground floor level
    552     INTEGER(iwp) ::  ind_emis_wall_gfl     = 31  !< index in input list for wall emissivity, ground floor level
    553     INTEGER(iwp) ::  ind_emis_wall_r       = 95  !< index in input list for wall emissivity, roof
    554     INTEGER(iwp) ::  ind_emis_green_agfl   = 82  !< index in input list for green emissivity, above ground floor level
    555     INTEGER(iwp) ::  ind_emis_green_gfl    = 49  !< index in input list for green emissivity, ground floor level
    556     INTEGER(iwp) ::  ind_emis_green_r      = 114 !< index in input list for green emissivity, roof
    557     INTEGER(iwp) ::  ind_emis_win_agfl     = 77  !< index in input list for window emissivity, above ground floor level
    558     INTEGER(iwp) ::  ind_emis_win_gfl      = 44  !< index in input list for window emissivity, ground floor level
    559     INTEGER(iwp) ::  ind_emis_win_r        = 108 !< index in input list for window emissivity, roof
    560     INTEGER(iwp) ::  ind_green_frac_w_agfl = 80  !< index in input list for green fraction on wall, above ground floor level
    561     INTEGER(iwp) ::  ind_green_frac_w_gfl  = 47  !< index in input list for green fraction on wall, ground floor level
    562     INTEGER(iwp) ::  ind_green_frac_r_agfl = 112 !< index in input list for green fraction on roof, above ground floor level
    563     INTEGER(iwp) ::  ind_green_frac_r_gfl  = 111 !< index in input list for green fraction on roof, ground floor level
    564     INTEGER(iwp) ::  ind_hc1_agfl          = 58  !< index in input list for heat capacity at first wall layer, above ground floor level
    565     INTEGER(iwp) ::  ind_hc1_gfl           = 25  !< index in input list for heat capacity at first wall layer, ground floor level
    566     INTEGER(iwp) ::  ind_hc1_wall_r        = 89  !< index in input list for heat capacity at first wall layer, roof
    567     INTEGER(iwp) ::  ind_hc1_win_agfl      = 71  !< index in input list for heat capacity at first window layer, above ground floor level
    568     INTEGER(iwp) ::  ind_hc1_win_gfl       = 38  !< index in input list for heat capacity at first window layer, ground floor level
    569     INTEGER(iwp) ::  ind_hc1_win_r         = 102 !< index in input list for heat capacity at first window layer, roof
    570     INTEGER(iwp) ::  ind_hc2_agfl          = 59  !< index in input list for heat capacity at second wall layer, above ground floor level
    571     INTEGER(iwp) ::  ind_hc2_gfl           = 26  !< index in input list for heat capacity at second wall layer, ground floor level
    572     INTEGER(iwp) ::  ind_hc2_wall_r        = 90  !< index in input list for heat capacity at second wall layer, roof
    573     INTEGER(iwp) ::  ind_hc2_win_agfl      = 72  !< index in input list for heat capacity at second window layer, above ground floor level
    574     INTEGER(iwp) ::  ind_hc2_win_gfl       = 39  !< index in input list for heat capacity at second window layer, ground floor level
    575     INTEGER(iwp) ::  ind_hc2_win_r         = 103 !< index in input list for heat capacity at second window layer, roof
    576     INTEGER(iwp) ::  ind_hc3_agfl          = 60  !< index in input list for heat capacity at third wall layer, above ground floor level
    577     INTEGER(iwp) ::  ind_hc3_gfl           = 27  !< index in input list for heat capacity at third wall layer, ground floor level
    578     INTEGER(iwp) ::  ind_hc3_wall_r        = 91  !< index in input list for heat capacity at third wall layer, roof
    579     INTEGER(iwp) ::  ind_hc3_win_agfl      = 73  !< index in input list for heat capacity at third window layer, above ground floor level
    580     INTEGER(iwp) ::  ind_hc3_win_gfl       = 40  !< index in input list for heat capacity at third window layer, ground floor level
    581     INTEGER(iwp) ::  ind_hc3_win_r         = 104 !< index in input list for heat capacity at third window layer, roof
    582     INTEGER(iwp) ::  ind_gflh              = 17  !< index in input list for ground floor level height
    583     INTEGER(iwp) ::  ind_lai_r_agfl        = 113 !< index in input list for LAI on roof, above ground floor level
     546    INTEGER(iwp) ::  ind_alb_wall_agfl     = 65   !< index in input list for albedo_type of wall above ground floor level
     547    INTEGER(iwp) ::  ind_alb_wall_gfl      = 32   !< index in input list for albedo_type of wall ground floor level
     548    INTEGER(iwp) ::  ind_alb_wall_r        = 96   !< index in input list for albedo_type of wall roof
     549    INTEGER(iwp) ::  ind_alb_green_agfl    = 83   !< index in input list for albedo_type of green above ground floor level
     550    INTEGER(iwp) ::  ind_alb_green_gfl     = 50   !< index in input list for albedo_type of green ground floor level
     551    INTEGER(iwp) ::  ind_alb_green_r       = 115  !< index in input list for albedo_type of green roof
     552    INTEGER(iwp) ::  ind_alb_win_agfl      = 79   !< index in input list for albedo_type of window fraction
     553                                                  !< above ground floor level
     554    INTEGER(iwp) ::  ind_alb_win_gfl       = 46   !< index in input list for albedo_type of window fraction ground floor level
     555    INTEGER(iwp) ::  ind_alb_win_r         = 110  !< index in input list for albedo_type of window fraction roof
     556    INTEGER(iwp) ::  ind_emis_wall_agfl    = 64   !< index in input list for wall emissivity, above ground floor level
     557    INTEGER(iwp) ::  ind_emis_wall_gfl     = 31   !< index in input list for wall emissivity, ground floor level
     558    INTEGER(iwp) ::  ind_emis_wall_r       = 95   !< index in input list for wall emissivity, roof
     559    INTEGER(iwp) ::  ind_emis_green_agfl   = 82   !< index in input list for green emissivity, above ground floor level
     560    INTEGER(iwp) ::  ind_emis_green_gfl    = 49   !< index in input list for green emissivity, ground floor level
     561    INTEGER(iwp) ::  ind_emis_green_r      = 114  !< index in input list for green emissivity, roof
     562    INTEGER(iwp) ::  ind_emis_win_agfl     = 77   !< index in input list for window emissivity, above ground floor level
     563    INTEGER(iwp) ::  ind_emis_win_gfl      = 44   !< index in input list for window emissivity, ground floor level
     564    INTEGER(iwp) ::  ind_emis_win_r        = 108  !< index in input list for window emissivity, roof
     565    INTEGER(iwp) ::  ind_green_frac_w_agfl = 80   !< index in input list for green fraction on wall, above ground floor level
     566    INTEGER(iwp) ::  ind_green_frac_w_gfl  = 47   !< index in input list for green fraction on wall, ground floor level
     567    INTEGER(iwp) ::  ind_green_frac_r_agfl = 112  !< index in input list for green fraction on roof, above ground floor level
     568    INTEGER(iwp) ::  ind_green_frac_r_gfl  = 111  !< index in input list for green fraction on roof, ground floor level
     569    INTEGER(iwp) ::  ind_hc1_agfl          = 58   !< index in input list for heat capacity at first wall layer,
     570                                                  !< above ground floor level
     571    INTEGER(iwp) ::  ind_hc1_gfl           = 25   !< index in input list for heat capacity at first wall layer, ground floor level
     572    INTEGER(iwp) ::  ind_hc1_wall_r        = 89   !< index in input list for heat capacity at first wall layer, roof
     573    INTEGER(iwp) ::  ind_hc1_win_agfl      = 71   !< index in input list for heat capacity at first window layer,
     574                                                  !< above ground floor level
     575    INTEGER(iwp) ::  ind_hc1_win_gfl       = 38   !< index in input list for heat capacity at first window layer,
     576                                                  !< ground floor level
     577    INTEGER(iwp) ::  ind_hc1_win_r         = 102  !< index in input list for heat capacity at first window layer, roof
     578    INTEGER(iwp) ::  ind_hc2_agfl          = 59   !< index in input list for heat capacity at second wall layer,
     579                                                  !< above ground floor level
     580    INTEGER(iwp) ::  ind_hc2_gfl           = 26   !< index in input list for heat capacity at second wall layer, ground floor level
     581    INTEGER(iwp) ::  ind_hc2_wall_r        = 90   !< index in input list for heat capacity at second wall layer, roof
     582    INTEGER(iwp) ::  ind_hc2_win_agfl      = 72   !< index in input list for heat capacity at second window layer,
     583                                                  !< above ground floor level
     584    INTEGER(iwp) ::  ind_hc2_win_gfl       = 39   !< index in input list for heat capacity at second window layer,
     585                                                  !< ground floor level
     586    INTEGER(iwp) ::  ind_hc2_win_r         = 103  !< index in input list for heat capacity at second window layer, roof
     587    INTEGER(iwp) ::  ind_hc3_agfl          = 60   !< index in input list for heat capacity at third wall layer,
     588                                                  !< above ground floor level
     589    INTEGER(iwp) ::  ind_hc3_gfl           = 27   !< index in input list for heat capacity at third wall layer, ground floor level
     590    INTEGER(iwp) ::  ind_hc3_wall_r        = 91   !< index in input list for heat capacity at third wall layer, roof
     591    INTEGER(iwp) ::  ind_hc3_win_agfl      = 73   !< index in input list for heat capacity at third window layer,
     592                                                  !< above ground floor level
     593    INTEGER(iwp) ::  ind_hc3_win_gfl       = 40   !< index in input list for heat capacity at third window layer,
     594                                                  !< ground floor level
     595    INTEGER(iwp) ::  ind_hc3_win_r         = 104  !< index in input list for heat capacity at third window layer, roof
     596    INTEGER(iwp) ::  ind_gflh              = 17   !< index in input list for ground floor level height
     597    INTEGER(iwp) ::  ind_lai_r_agfl        = 113  !< index in input list for LAI on roof, above ground floor level
    584598    INTEGER(iwp) ::  ind_lai_r_gfl         = 113  !< index in input list for LAI on roof, ground floor level
    585     INTEGER(iwp) ::  ind_lai_w_agfl        = 81  !< index in input list for LAI on wall, above ground floor level
    586     INTEGER(iwp) ::  ind_lai_w_gfl         = 48  !< index in input list for LAI on wall, ground floor level
    587     INTEGER(iwp) ::  ind_tc1_agfl          = 61  !< index in input list for thermal conductivity at first wall layer, above ground floor level
    588     INTEGER(iwp) ::  ind_tc1_gfl           = 28  !< index in input list for thermal conductivity at first wall layer, ground floor level
    589     INTEGER(iwp) ::  ind_tc1_wall_r        = 92  !< index in input list for thermal conductivity at first wall layer, roof
    590     INTEGER(iwp) ::  ind_tc1_win_agfl      = 74  !< index in input list for thermal conductivity at first window layer, above ground floor level
    591     INTEGER(iwp) ::  ind_tc1_win_gfl       = 41  !< index in input list for thermal conductivity at first window layer, ground floor level
    592     INTEGER(iwp) ::  ind_tc1_win_r         = 105 !< index in input list for thermal conductivity at first window layer, roof
    593     INTEGER(iwp) ::  ind_tc2_agfl          = 62  !< index in input list for thermal conductivity at second wall layer, above ground floor level
    594     INTEGER(iwp) ::  ind_tc2_gfl           = 29  !< index in input list for thermal conductivity at second wall layer, ground floor level
    595     INTEGER(iwp) ::  ind_tc2_wall_r        = 93  !< index in input list for thermal conductivity at second wall layer, roof
    596     INTEGER(iwp) ::  ind_tc2_win_agfl      = 75  !< index in input list for thermal conductivity at second window layer, above ground floor level
    597     INTEGER(iwp) ::  ind_tc2_win_gfl       = 42  !< index in input list for thermal conductivity at second window layer, ground floor level
    598     INTEGER(iwp) ::  ind_tc2_win_r         = 106 !< index in input list for thermal conductivity at second window layer, ground floor level
    599     INTEGER(iwp) ::  ind_tc3_agfl          = 63  !< index in input list for thermal conductivity at third wall layer, above ground floor level
    600     INTEGER(iwp) ::  ind_tc3_gfl           = 30  !< index in input list for thermal conductivity at third wall layer, ground floor level
    601     INTEGER(iwp) ::  ind_tc3_wall_r        = 94  !< index in input list for thermal conductivity at third wall layer, roof
    602     INTEGER(iwp) ::  ind_tc3_win_agfl      = 76  !< index in input list for thermal conductivity at third window layer, above ground floor level
    603     INTEGER(iwp) ::  ind_tc3_win_gfl       = 43  !< index in input list for thermal conductivity at third window layer, ground floor level
    604     INTEGER(iwp) ::  ind_tc3_win_r         = 107 !< index in input list for thermal conductivity at third window layer, roof
    605     INTEGER(iwp) ::  ind_thick_1_agfl      = 54  !< index for wall layer thickness - 1st layer above ground floor level
    606     INTEGER(iwp) ::  ind_thick_1_gfl       = 21  !< index for wall layer thickness - 1st layer ground floor level
    607     INTEGER(iwp) ::  ind_thick_1_wall_r    = 85  !< index for wall layer thickness - 1st layer roof
    608     INTEGER(iwp) ::  ind_thick_1_win_agfl  = 67  !< index for window layer thickness - 1st layer above ground floor level
    609     INTEGER(iwp) ::  ind_thick_1_win_gfl   = 34  !< index for window layer thickness - 1st layer ground floor level
    610     INTEGER(iwp) ::  ind_thick_1_win_r     = 98  !< index for window layer thickness - 1st layer roof
    611     INTEGER(iwp) ::  ind_thick_2_agfl      = 55  !< index for wall layer thickness - 2nd layer above ground floor level
    612     INTEGER(iwp) ::  ind_thick_2_gfl       = 22  !< index for wall layer thickness - 2nd layer ground floor level
    613     INTEGER(iwp) ::  ind_thick_2_wall_r    = 86  !< index for wall layer thickness - 2nd layer roof
    614     INTEGER(iwp) ::  ind_thick_2_win_agfl  = 68  !< index for window layer thickness - 2nd layer above ground floor level
    615     INTEGER(iwp) ::  ind_thick_2_win_gfl   = 35  !< index for window layer thickness - 2nd layer ground floor level
    616     INTEGER(iwp) ::  ind_thick_2_win_r     = 99  !< index for window layer thickness - 2nd layer roof
    617     INTEGER(iwp) ::  ind_thick_3_agfl      = 56  !< index for wall layer thickness - 3rd layer above ground floor level
    618     INTEGER(iwp) ::  ind_thick_3_gfl       = 23  !< index for wall layer thickness - 3rd layer ground floor level
    619     INTEGER(iwp) ::  ind_thick_3_wall_r    = 87  !< index for wall layer thickness - 3rd layer roof
    620     INTEGER(iwp) ::  ind_thick_3_win_agfl  = 69  !< index for window layer thickness - 3rd layer above ground floor level
    621     INTEGER(iwp) ::  ind_thick_3_win_gfl   = 36  !< index for window layer thickness - 3rd layer ground floor level 
    622     INTEGER(iwp) ::  ind_thick_3_win_r     = 100 !< index for window layer thickness - 3rd layer roof
    623     INTEGER(iwp) ::  ind_thick_4_agfl      = 57  !< index for wall layer thickness - 4th layer above ground floor level
    624     INTEGER(iwp) ::  ind_thick_4_gfl       = 24  !< index for wall layer thickness - 4th layer ground floor level
    625     INTEGER(iwp) ::  ind_thick_4_wall_r    = 88  !< index for wall layer thickness - 4st layer roof
    626     INTEGER(iwp) ::  ind_thick_4_win_agfl  = 70  !< index for window layer thickness - 4th layer above ground floor level
    627     INTEGER(iwp) ::  ind_thick_4_win_gfl   = 37  !< index for window layer thickness - 4th layer ground floor level
    628     INTEGER(iwp) ::  ind_thick_4_win_r     = 101 !< index for window layer thickness - 4th layer roof
    629     INTEGER(iwp) ::  ind_trans_agfl        = 78  !< index in input list for window transmissivity, above ground floor level
    630     INTEGER(iwp) ::  ind_trans_gfl         = 45  !< index in input list for window transmissivity, ground floor level
    631     INTEGER(iwp) ::  ind_trans_r           = 109 !< index in input list for window transmissivity, roof
    632     INTEGER(iwp) ::  ind_wall_frac_agfl    = 53  !< index in input list for wall fraction, above ground floor level
    633     INTEGER(iwp) ::  ind_wall_frac_gfl     = 20  !< index in input list for wall fraction, ground floor level
    634     INTEGER(iwp) ::  ind_wall_frac_r       = 84  !< index in input list for wall fraction, roof
    635     INTEGER(iwp) ::  ind_win_frac_agfl     = 66  !< index in input list for window fraction, above ground floor level
    636     INTEGER(iwp) ::  ind_win_frac_gfl      = 33  !< index in input list for window fraction, ground floor level
    637     INTEGER(iwp) ::  ind_win_frac_r        = 97  !< index in input list for window fraction, roof
    638     INTEGER(iwp) ::  ind_z0_agfl           = 51  !< index in input list for z0, above ground floor level
    639     INTEGER(iwp) ::  ind_z0_gfl            = 18  !< index in input list for z0, ground floor level
    640     INTEGER(iwp) ::  ind_z0qh_agfl         = 52  !< index in input list for z0h / z0q, above ground floor level
    641     INTEGER(iwp) ::  ind_z0qh_gfl          = 19  !< index in input list for z0h / z0q, ground floor level
    642     INTEGER(iwp) ::  ind_green_type_roof   = 116 !< index in input list for type of green roof
    643 
    644 
    645     REAL(wp)  ::  roof_height_limit = 4.0_wp          !< height for distinguish between land surfaces and roofs
     599    INTEGER(iwp) ::  ind_lai_w_agfl        = 81   !< index in input list for LAI on wall, above ground floor level
     600    INTEGER(iwp) ::  ind_lai_w_gfl         = 48   !< index in input list for LAI on wall, ground floor level
     601    INTEGER(iwp) ::  ind_tc1_agfl          = 61   !< index in input list for thermal conductivity at first wall layer,
     602                                                  !< above ground floor level
     603    INTEGER(iwp) ::  ind_tc1_gfl           = 28   !< index in input list for thermal conductivity at first wall layer,
     604                                                  !< ground floor level
     605    INTEGER(iwp) ::  ind_tc1_wall_r        = 92   !< index in input list for thermal conductivity at first wall layer, roof
     606    INTEGER(iwp) ::  ind_tc1_win_agfl      = 74   !< index in input list for thermal conductivity at first window layer,
     607                                                  !< above ground floor level
     608    INTEGER(iwp) ::  ind_tc1_win_gfl       = 41   !< index in input list for thermal conductivity at first window layer,
     609                                                  !< ground floor level
     610    INTEGER(iwp) ::  ind_tc1_win_r         = 105  !< index in input list for thermal conductivity at first window layer, roof
     611    INTEGER(iwp) ::  ind_tc2_agfl          = 62   !< index in input list for thermal conductivity at second wall layer,
     612                                                  !< above ground floor level
     613    INTEGER(iwp) ::  ind_tc2_gfl           = 29   !< index in input list for thermal conductivity at second wall layer,
     614                                                  !< ground floor level
     615    INTEGER(iwp) ::  ind_tc2_wall_r        = 93   !< index in input list for thermal conductivity at second wall layer, roof
     616    INTEGER(iwp) ::  ind_tc2_win_agfl      = 75   !< index in input list for thermal conductivity at second window layer,
     617                                                  !< above ground floor level
     618    INTEGER(iwp) ::  ind_tc2_win_gfl       = 42   !< index in input list for thermal conductivity at second window layer,
     619                                                  !< ground floor level
     620    INTEGER(iwp) ::  ind_tc2_win_r         = 106  !< index in input list for thermal conductivity at second window layer,
     621                                                  !< ground floor level
     622    INTEGER(iwp) ::  ind_tc3_agfl          = 63   !< index in input list for thermal conductivity at third wall layer,
     623                                                  !< above ground floor level
     624    INTEGER(iwp) ::  ind_tc3_gfl           = 30   !< index in input list for thermal conductivity at third wall layer,
     625                                                  !< ground floor level
     626    INTEGER(iwp) ::  ind_tc3_wall_r        = 94   !< index in input list for thermal conductivity at third wall layer, roof
     627    INTEGER(iwp) ::  ind_tc3_win_agfl      = 76   !< index in input list for thermal conductivity at third window layer,
     628                                                  !< above ground floor level
     629    INTEGER(iwp) ::  ind_tc3_win_gfl       = 43   !< index in input list for thermal conductivity at third window layer,
     630                                                  !< ground floor level
     631    INTEGER(iwp) ::  ind_tc3_win_r         = 107  !< index in input list for thermal conductivity at third window layer, roof
     632    INTEGER(iwp) ::  ind_thick_1_agfl      = 54   !< index for wall layer thickness - 1st layer above ground floor level
     633    INTEGER(iwp) ::  ind_thick_1_gfl       = 21   !< index for wall layer thickness - 1st layer ground floor level
     634    INTEGER(iwp) ::  ind_thick_1_wall_r    = 85   !< index for wall layer thickness - 1st layer roof
     635    INTEGER(iwp) ::  ind_thick_1_win_agfl  = 67   !< index for window layer thickness - 1st layer above ground floor level
     636    INTEGER(iwp) ::  ind_thick_1_win_gfl   = 34   !< index for window layer thickness - 1st layer ground floor level
     637    INTEGER(iwp) ::  ind_thick_1_win_r     = 98   !< index for window layer thickness - 1st layer roof
     638    INTEGER(iwp) ::  ind_thick_2_agfl      = 55   !< index for wall layer thickness - 2nd layer above ground floor level
     639    INTEGER(iwp) ::  ind_thick_2_gfl       = 22   !< index for wall layer thickness - 2nd layer ground floor level
     640    INTEGER(iwp) ::  ind_thick_2_wall_r    = 86   !< index for wall layer thickness - 2nd layer roof
     641    INTEGER(iwp) ::  ind_thick_2_win_agfl  = 68   !< index for window layer thickness - 2nd layer above ground floor level
     642    INTEGER(iwp) ::  ind_thick_2_win_gfl   = 35   !< index for window layer thickness - 2nd layer ground floor level
     643    INTEGER(iwp) ::  ind_thick_2_win_r     = 99   !< index for window layer thickness - 2nd layer roof
     644    INTEGER(iwp) ::  ind_thick_3_agfl      = 56   !< index for wall layer thickness - 3rd layer above ground floor level
     645    INTEGER(iwp) ::  ind_thick_3_gfl       = 23   !< index for wall layer thickness - 3rd layer ground floor level
     646    INTEGER(iwp) ::  ind_thick_3_wall_r    = 87   !< index for wall layer thickness - 3rd layer roof
     647    INTEGER(iwp) ::  ind_thick_3_win_agfl  = 69   !< index for window layer thickness - 3rd layer above ground floor level
     648    INTEGER(iwp) ::  ind_thick_3_win_gfl   = 36   !< index for window layer thickness - 3rd layer ground floor level 
     649    INTEGER(iwp) ::  ind_thick_3_win_r     = 100  !< index for window layer thickness - 3rd layer roof
     650    INTEGER(iwp) ::  ind_thick_4_agfl      = 57   !< index for wall layer thickness - 4th layer above ground floor level
     651    INTEGER(iwp) ::  ind_thick_4_gfl       = 24   !< index for wall layer thickness - 4th layer ground floor level
     652    INTEGER(iwp) ::  ind_thick_4_wall_r    = 88   !< index for wall layer thickness - 4st layer roof
     653    INTEGER(iwp) ::  ind_thick_4_win_agfl  = 70   !< index for window layer thickness - 4th layer above ground floor level
     654    INTEGER(iwp) ::  ind_thick_4_win_gfl   = 37   !< index for window layer thickness - 4th layer ground floor level
     655    INTEGER(iwp) ::  ind_thick_4_win_r     = 101  !< index for window layer thickness - 4th layer roof
     656    INTEGER(iwp) ::  ind_trans_agfl        = 78   !< index in input list for window transmissivity, above ground floor level
     657    INTEGER(iwp) ::  ind_trans_gfl         = 45   !< index in input list for window transmissivity, ground floor level
     658    INTEGER(iwp) ::  ind_trans_r           = 109  !< index in input list for window transmissivity, roof
     659    INTEGER(iwp) ::  ind_wall_frac_agfl    = 53   !< index in input list for wall fraction, above ground floor level
     660    INTEGER(iwp) ::  ind_wall_frac_gfl     = 20   !< index in input list for wall fraction, ground floor level
     661    INTEGER(iwp) ::  ind_wall_frac_r       = 84   !< index in input list for wall fraction, roof
     662    INTEGER(iwp) ::  ind_win_frac_agfl     = 66   !< index in input list for window fraction, above ground floor level
     663    INTEGER(iwp) ::  ind_win_frac_gfl      = 33   !< index in input list for window fraction, ground floor level
     664    INTEGER(iwp) ::  ind_win_frac_r        = 97   !< index in input list for window fraction, roof
     665    INTEGER(iwp) ::  ind_z0_agfl           = 51   !< index in input list for z0, above ground floor level
     666    INTEGER(iwp) ::  ind_z0_gfl            = 18   !< index in input list for z0, ground floor level
     667    INTEGER(iwp) ::  ind_z0qh_agfl         = 52   !< index in input list for z0h / z0q, above ground floor level
     668    INTEGER(iwp) ::  ind_z0qh_gfl          = 19   !< index in input list for z0h / z0q, ground floor level
     669    INTEGER(iwp) ::  ind_green_type_roof   = 116  !< index in input list for type of green roof
     670
     671
     672    REAL(wp)  ::  roof_height_limit = 4.0_wp         !< height for distinguish between land surfaces and roofs
    646673    REAL(wp)  ::  ground_floor_level = 4.0_wp        !< default ground floor level
    647674
    648675
    649676    CHARACTER(37), DIMENSION(0:7), PARAMETER :: building_type_name = (/     &
    650                                    'user-defined                         ', & ! 0
    651                                    'residential - 1950                   ', & !  1
    652                                    'residential 1951 - 2000              ', & !  2
    653                                    'residential 2001 -                   ', & !  3
    654                                    'office - 1950                        ', & !  4
    655                                    'office 1951 - 2000                   ', & !  5
    656                                    'office 2001 -                        ', & !  6
    657                                    'bridges                              '  & !  7
     677                                   'user-defined                         ', &  !< type 0
     678                                   'residential - 1950                   ', &  !< type  1
     679                                   'residential 1951 - 2000              ', &  !< type  2
     680                                   'residential 2001 -                   ', &  !< type  3
     681                                   'office - 1950                        ', &  !< type  4
     682                                   'office 1951 - 2000                   ', &  !< type  5
     683                                   'office 2001 -                        ', &  !< type  6
     684                                   'bridges                              '  &  !< type  7
    658685                                                                     /)
    659686!
     
    744771        0.57_wp, 0.57_wp, 0.57_wp, 0.91_wp,                                    & !parameter 41-44
    745772        0.75_wp, 27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp,                             & !parameter 45-49
    746         5.0_wp, 0.001_wp, 0.0001_wp, 0.7_wp, 0.005_wp,                        & !parameter 50-54
     773        5.0_wp, 0.001_wp, 0.0001_wp, 0.7_wp, 0.005_wp,                         & !parameter 50-54
    747774        0.01_wp, 0.39_wp, 0.63_wp, 2200000.0_wp,                               & !parameter 55-58
    748775        1400000.0_wp, 1300000.0_wp, 0.35_wp, 0.8_wp,                           & !parameter 59-62
     
    757784        1736000.0_wp, 1736000.0_wp, 0.57_wp, 0.57_wp, 0.57_wp,                 & !parameter 103-107
    758785        0.91_wp, 0.75_wp, 27.0_wp, 0.0_wp, 0.0_wp, 1.5_wp,                     & !parameter 108-113
    759         0.86_wp, 5.0_wp, 0.0_wp,                                              & !parameter 114-116
     786        0.86_wp, 5.0_wp, 0.0_wp,                                               & !parameter 114-116
    760787        299.15_wp, 293.15_wp, 0.8_wp, 0.76_wp, 5.0_wp,                         & !parameter 117-121
    761788        0.1_wp, 0.5_wp, 0.0_wp, 3.5_wp, 370000.0_wp, 4.5_wp,                   & !parameter 122-127
     
    772799        0.11_wp, 0.11_wp, 0.11_wp, 0.11_wp,                                    & !parameter 41-44
    773800        0.7_wp, 27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp,                              & !parameter 45-49
    774         5.0_wp, 0.001_wp, 0.0001_wp, 0.73_wp, 0.005_wp,                       & !parameter 50-54
     801        5.0_wp, 0.001_wp, 0.0001_wp, 0.73_wp, 0.005_wp,                        & !parameter 50-54
    775802        0.01_wp, 0.31_wp, 0.43_wp, 2000000.0_wp,                               & !parameter 55-58
    776803        103000.0_wp, 900000.0_wp, 0.35_wp, 0.38_wp,                            & !parameter 59-62
     
    785812        1736000.0_wp, 1736000.0_wp, 0.11_wp, 0.11_wp, 0.11_wp,                 & !parameter 103-107
    786813        0.87_wp, 0.7_wp, 27.0_wp, 0.0_wp, 0.0_wp, 1.5_wp,                      & !parameter 108-113
    787         0.86_wp, 5.0_wp, 0.0_wp,                                              & !parameter 114-116
     814        0.86_wp, 5.0_wp, 0.0_wp,                                               & !parameter 114-116
    788815        299.15_wp, 293.15_wp, 0.8_wp, 0.6_wp, 3.0_wp,                          & !parameter 117-121
    789816        0.1_wp, 0.5_wp, 0.0_wp, 2.5_wp, 165000.0_wp, 4.5_wp,                   & !parameter 122-127
     
    798825        27.0_wp, 0.25_wp, 0.003_wp, 0.006_wp, 0.012_wp, 0.018_wp,              & !parameter 32-37
    799826        1736000.0_wp, 1736000.0_wp, 1736000.0_wp,                              & !parameter 38-40
    800         0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp,                                     & !parameter 41-44
     827        0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp,                                  & !parameter 41-44
    801828        0.6_wp, 27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp,                              & !parameter 45-49
    802         5.0_wp, 0.001_wp, 0.0001_wp, 0.7_wp, 0.005_wp,                        & !parameter 50-54
     829        5.0_wp, 0.001_wp, 0.0001_wp, 0.7_wp, 0.005_wp,                         & !parameter 50-54
    803830        0.01_wp, 0.41_wp, 0.7_wp, 2000000.0_wp,                                & !parameter 55-58
    804831        103000.0_wp, 900000.0_wp, 0.35_wp, 0.14_wp,                            & !parameter 59-62
     
    806833        0.003_wp, 0.006_wp, 0.012_wp, 0.018_wp,                                & !parameter 67-70
    807834        1736000.0_wp, 1736000.0_wp, 1736000.0_wp,                              & !parameter 71-73
    808         0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp, 0.6_wp,                             & !parameter 74-78
     835        0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp, 0.6_wp,                          & !parameter 74-78
    809836        27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp, 5.0_wp, 1.0_wp,                      & !parameter 79-84
    810837        0.005_wp, 0.01_wp, 0.41_wp, 0.7_wp, 2000000.0_wp, 103000.0_wp,         & !parameter 85-90
    811838        900000.0_wp, 0.35_wp, 0.14_wp, 0.035_wp, 0.93_wp, 27.0_wp, 0.0_wp,     & !parameter 91-97
    812839        0.003_wp, 0.006_wp, 0.012_wp, 0.018_wp, 1736000.0_wp,                  & !parameter 98-102
    813         1736000.0_wp, 1736000.0_wp, 0.037_wp, 0.037_wp, 0.037_wp,                 & !parameter 103-107
     840        1736000.0_wp, 1736000.0_wp, 0.037_wp, 0.037_wp, 0.037_wp,              & !parameter 103-107
    814841        0.8_wp, 0.6_wp, 27.0_wp, 0.0_wp, 0.0_wp, 1.5_wp,                       & !parameter 108-113
    815         0.86_wp, 5.0_wp, 0.0_wp,                                              & !parameter 114-116
     842        0.86_wp, 5.0_wp, 0.0_wp,                                               & !parameter 114-116
    816843        299.15_wp, 293.15_wp, 0.8_wp, 0.5_wp, 0.6_wp,                          & !parameter 117-121
    817844        0.1_wp, 0.5_wp, 0.8_wp, 2.5_wp, 80000.0_wp, 4.5_wp,                    & !parameter 122-127
     
    828855        0.57_wp, 0.57_wp, 0.57_wp, 0.91_wp,                                    & !parameter 41-44
    829856        0.75_wp, 27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp,                             & !parameter 45-49
    830         5.0_wp, 0.001_wp, 0.0001_wp, 0.5_wp, 0.005_wp,                        & !parameter 50-54
     857        5.0_wp, 0.001_wp, 0.0001_wp, 0.5_wp, 0.005_wp,                         & !parameter 50-54
    831858        0.01_wp, 0.39_wp, 0.63_wp, 2200000.0_wp,                               & !parameter 55-58
    832859        1400000.0_wp, 1300000.0_wp, 0.35_wp, 0.8_wp,                           & !parameter 59-62
     
    841868        1736000.0_wp, 1736000.0_wp, 0.57_wp, 0.57_wp, 0.57_wp,                 & !parameter 103-107
    842869        0.91_wp, 0.75_wp, 27.0_wp, 0.0_wp, 0.0_wp, 1.5_wp,                     & !parameter 108-113
    843         0.86_wp, 5.0_wp, 0.0_wp,                                              & !parameter 114-116
     870        0.86_wp, 5.0_wp, 0.0_wp,                                               & !parameter 114-116
    844871        299.15_wp, 293.15_wp, 0.8_wp, 0.76_wp, 5.0_wp,                         & !parameter 117-121
    845872        0.1_wp, 1.5_wp, 0.0_wp, 3.5_wp, 370000.0_wp, 4.5_wp,                   & !parameter 122-127
     
    856883        0.11_wp, 0.11_wp, 0.11_wp, 0.87_wp,                                    & !parameter 41-44
    857884        0.7_wp, 27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp,                              & !parameter 45-49
    858         5.0_wp, 0.001_wp, 0.0001_wp, 0.5_wp, 0.005_wp,                        & !parameter 50-54
     885        5.0_wp, 0.001_wp, 0.0001_wp, 0.5_wp, 0.005_wp,                         & !parameter 50-54
    859886        0.01_wp, 0.31_wp, 0.43_wp, 2000000.0_wp,                               & !parameter 55-58
    860887        103000.0_wp, 900000.0_wp, 0.35_wp, 0.38_wp,                            & !parameter 59-62
     
    869896        1736000.0_wp, 1736000.0_wp, 0.11_wp, 0.11_wp, 0.11_wp,                 & !parameter 103-107
    870897        0.87_wp, 0.7_wp, 27.0_wp, 0.0_wp, 0.0_wp, 1.5_wp,                      & !parameter 108-113
    871         0.86_wp, 5.0_wp, 0.0_wp,                                              & !parameter 114-116
     898        0.86_wp, 5.0_wp, 0.0_wp,                                               & !parameter 114-116
    872899        299.15_wp, 293.15_wp, 0.8_wp, 0.6_wp, 3.0_wp,                          & !parameter 117-121
    873900        0.1_wp, 1.5_wp, 0.65_wp, 2.5_wp, 165000.0_wp, 4.5_wp,                  & !parameter 122-127
     
    882909        27.0_wp, 0.525_wp, 0.003_wp, 0.006_wp, 0.012_wp, 0.018_wp,             & !parameter 32-37
    883910        1736000.0_wp, 1736000.0_wp, 1736000.0_wp,                              & !parameter 38-40
    884         0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp,                                     & !parameter 41-44
     911        0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp,                                  & !parameter 41-44
    885912        0.6_wp, 27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp,                              & !parameter 45-49
    886         5.0_wp, 0.001_wp, 0.0001_wp, 0.425_wp, 0.005_wp,                      & !parameter 50-54
     913        5.0_wp, 0.001_wp, 0.0001_wp, 0.425_wp, 0.005_wp,                       & !parameter 50-54
    887914        0.01_wp, 0.41_wp, 0.7_wp, 2000000.0_wp,                                & !parameter 55-58
    888915        103000.0_wp, 900000.0_wp, 0.35_wp, 0.14_wp,                            & !parameter 59-62
     
    890917        0.003_wp, 0.006_wp, 0.012_wp, 0.018_wp,                                & !parameter 67-70
    891918        1736000.0_wp, 1736000.0_wp, 1736000.0_wp,                              & !parameter 71-73
    892         0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp, 0.6_wp,                             & !parameter 74-78
     919        0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp, 0.6_wp,                          & !parameter 74-78
    893920        27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp, 5.0_wp, 1.0_wp,                      & !parameter 79-84
    894921        0.005_wp, 0.01_wp, 0.41_wp, 0.7_wp, 2000000.0_wp, 103000.0_wp,         & !parameter 85-90
    895922        900000.0_wp, 0.35_wp, 0.14_wp, 0.035_wp, 0.91_wp, 27.0_wp, 0.0_wp,     & !parameter 91-97
    896923        0.003_wp, 0.006_wp, 0.012_wp, 0.018_wp, 1736000.0_wp,                  & !parameter 98-102
    897         1736000.0_wp, 1736000.0_wp, 0.037_wp, 0.037_wp, 0.037_wp,                 & !parameter 103-107
     924        1736000.0_wp, 1736000.0_wp, 0.037_wp, 0.037_wp, 0.037_wp,              & !parameter 103-107
    898925        0.8_wp, 0.6_wp, 27.0_wp, 0.0_wp, 0.0_wp, 1.5_wp,                       & !parameter 108-113
    899         0.86_wp, 5.0_wp, 0.0_wp,                                              & !parameter 114-116
     926        0.86_wp, 5.0_wp, 0.0_wp,                                               & !parameter 114-116
    900927        299.15_wp, 293.15_wp, 0.8_wp, 0.5_wp, 0.6_wp,                          & !parameter 117-121
    901928        0.1_wp, 1.5_wp, 0.9_wp, 2.5_wp, 80000.0_wp, 4.5_wp,                    & !parameter 122-127
     
    912939        0.57_wp, 0.57_wp, 0.57_wp, 0.8_wp,                                     & !parameter 41-44
    913940        0.6_wp, 27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp,                              & !parameter 45-49
    914         5.0_wp, 0.001_wp, 0.0001_wp, 1.0_wp, 0.29_wp,                         & !parameter 50-54
     941        5.0_wp, 0.001_wp, 0.0001_wp, 1.0_wp, 0.29_wp,                          & !parameter 50-54
    915942        0.295_wp, 0.695_wp, 0.985_wp, 1950400.0_wp,                            & !parameter 55-58
    916943        1848000.0_wp, 1848000.0_wp, 0.7_wp, 1.0_wp,                            & !parameter 59-62
     
    925952        1736000.0_wp, 1736000.0_wp, 0.57_wp, 0.57_wp, 0.57_wp,                 & !parameter 103-107
    926953        0.8_wp, 0.6_wp, 27.0_wp, 0.0_wp, 0.0_wp, 1.5_wp,                       & !parameter 108-113
    927         0.86_wp, 5.0_wp, 0.0_wp,                                              & !parameter 114-116
     954        0.86_wp, 5.0_wp, 0.0_wp,                                               & !parameter 114-116
    928955        299.15_wp, 293.15_wp, 0.8_wp, 100.0_wp, 100.0_wp,                      & !parameter 117-121
    929956        20.0_wp, 20.0_wp, 0.0_wp, 1.0_wp, 1.0_wp, 4.5_wp,                      & !parameter 122-127
     
    944971
    945972    TYPE surf_type_usm
    946        REAL(wp), DIMENSION(:),   ALLOCATABLE ::  var_usm_1d !< 1D prognostic variable
    947        REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  var_usm_2d !< 2D prognostic variable
     973       REAL(wp), DIMENSION(:),   ALLOCATABLE ::  var_usm_1d  !< 1D prognostic variable
     974       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  var_usm_2d  !< 2D prognostic variable
    948975    END TYPE surf_type_usm
    949976   
    950     TYPE(surf_type_usm), POINTER  ::  m_liq_usm_h,        & !< liquid water reservoir (m), horizontal surface elements
    951                                       m_liq_usm_h_p         !< progn. liquid water reservoir (m), horizontal surface elements
    952 
    953     TYPE(surf_type_usm), TARGET   ::  m_liq_usm_h_1,      & !<
    954                                       m_liq_usm_h_2         !<
    955 
    956     TYPE(surf_type_usm), DIMENSION(:), POINTER  ::    &
    957                                       m_liq_usm_v,        & !< liquid water reservoir (m), vertical surface elements
    958                                       m_liq_usm_v_p         !< progn. liquid water reservoir (m), vertical surface elements
    959 
    960     TYPE(surf_type_usm), DIMENSION(0:3), TARGET   ::  &
    961                                       m_liq_usm_v_1,      & !<
    962                                       m_liq_usm_v_2         !<
     977    TYPE(surf_type_usm), POINTER  ::  m_liq_usm_h,        &  !< liquid water reservoir (m), horizontal surface elements
     978                                      m_liq_usm_h_p          !< progn. liquid water reservoir (m), horizontal surface elements
     979
     980    TYPE(surf_type_usm), TARGET   ::  m_liq_usm_h_1,      &  !<
     981                                      m_liq_usm_h_2          !<
     982
     983    TYPE(surf_type_usm), DIMENSION(:), POINTER  ::        &
     984                                      m_liq_usm_v,        &  !< liquid water reservoir (m), vertical surface elements
     985                                      m_liq_usm_v_p          !< progn. liquid water reservoir (m), vertical surface elements
     986
     987    TYPE(surf_type_usm), DIMENSION(0:3), TARGET   ::      &
     988                                      m_liq_usm_v_1,      &  !<
     989                                      m_liq_usm_v_2          !<
    963990
    964991    TYPE(surf_type_usm), TARGET ::  tm_liq_usm_h_m      !< liquid water reservoir tendency (m), horizontal surface elements
    965     TYPE(surf_type_usm), DIMENSION(0:3), TARGET ::  tm_liq_usm_v_m      !< liquid water reservoir tendency (m), vertical surface elements
    966 
    967 
    968 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     992    TYPE(surf_type_usm), DIMENSION(0:3), TARGET ::  tm_liq_usm_v_m      !< liquid water reservoir tendency (m),
     993                                                                        !< vertical surface elements
     994
     995!
    969996!-- anthropogenic heat sources
    970 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    971997    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE        ::  aheat             !< daily average of anthropogenic heat (W/m2)
    972     REAL(wp), DIMENSION(:,:), ALLOCATABLE          ::  aheatprof         !< diurnal profiles of anthropogenic heat for particular layers
     998    REAL(wp), DIMENSION(:,:), ALLOCATABLE          ::  aheatprof         !< diurnal profiles of anthropogenic heat
     999                                                                         !< for particular layers
    9731000    INTEGER(iwp)                                   ::  naheatlayers = 1  !< number of layers of anthropogenic heat
    9741001
    975 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1002!
    9761003!-- wall surface model
    977 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    9781004!-- wall surface model constants
    9791005    INTEGER(iwp), PARAMETER                        :: nzb_wall = 0       !< inner side of the wall model (to be switched)
     
    9811007    INTEGER(iwp), PARAMETER                        :: nzw = 4            !< number of wall layers (fixed for now)
    9821008
    983     REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default = (/0.0242_wp, 0.0969_wp, 0.346_wp, 1.0_wp /)
    984                                                                          !< normalized soil, wall and roof layer depths (m/m)
    985 !    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default = (/0.33_wp, 0.66_wp, 1.0_wp /)
    986     REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_window = (/0.25_wp, 0.5_wp, 0.75_wp, 1.0_wp /)
    987 !    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_window = (/0.33_wp, 0.66_wp, 1.0_wp /)
    988 !    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_window = (/0.0242_wp, 0.0969_wp, 0.346_wp, 1.0_wp /)
    989                                                                          !< normalized window layer depths (m/m)
    990 !    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_green = (/0.0242_wp, 0.0969_wp, 0.346_wp, 1.0_wp /)
    991                                                                          !< normalized green layer depths (m/m)
    992     REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_green = (/0.25_wp, 0.5_wp, 0.75_wp, 1.0_wp /)
    993 !    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_green = (/0.33_wp, 0.66_wp, 1.0_wp /)
    994 
    995 
    996     REAL(wp)                                       :: wall_inner_temperature = 295.0_wp    !< temperature of the inner wall surface (~22 degrees C) (K)
    997     REAL(wp)                                       :: roof_inner_temperature = 295.0_wp    !< temperature of the inner roof surface (~22 degrees C) (K)
    998     REAL(wp)                                       :: soil_inner_temperature = 288.0_wp    !< temperature of the deep soil (~15 degrees C) (K)
    999     REAL(wp)                                       :: window_inner_temperature = 295.0_wp  !< temperature of the inner window surface (~22 degrees C) (K)
    1000 
    1001     REAL(wp)                                       ::   m_total = 0.0_wp !< weighted total water content of the soil (m3/m3)
    1002     INTEGER(iwp)                                   ::   soil_type
    1003    
    1004 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1009    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default        = (/0.0242_wp, 0.0969_wp, 0.346_wp, 1.0_wp /)
     1010    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_window = (/0.25_wp,   0.5_wp,    0.75_wp,  1.0_wp /)
     1011    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_green  = (/0.25_wp,   0.5_wp,    0.75_wp,  1.0_wp /)
     1012                                                                         !< normalized soil, wall and roof, window and
     1013                                                                         !<green layer depths (m/m)
     1014
     1015    REAL(wp)                                       :: wall_inner_temperature   = 295.0_wp    !< temperature of the inner wall
     1016                                                                                             !< surface (~22 degrees C) (K)
     1017    REAL(wp)                                       :: roof_inner_temperature   = 295.0_wp    !< temperature of the inner roof
     1018                                                                                             !< surface (~22 degrees C) (K)
     1019    REAL(wp)                                       :: soil_inner_temperature   = 288.0_wp    !< temperature of the deep soil
     1020                                                                                             !< (~15 degrees C) (K)
     1021    REAL(wp)                                       :: window_inner_temperature = 295.0_wp    !< temperature of the inner window
     1022                                                                                             !< surface (~22 degrees C) (K)
     1023
     1024    REAL(wp)                                       :: m_total = 0.0_wp  !< weighted total water content of the soil (m3/m3)
     1025    INTEGER(iwp)                                   :: soil_type
     1026
     1027!
    10051028!-- surface and material model variables for walls, ground, roofs
    1006 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    10071029    REAL(wp), DIMENSION(:), ALLOCATABLE            :: zwn                !< normalized wall layer depths (m)
    10081030    REAL(wp), DIMENSION(:), ALLOCATABLE            :: zwn_window         !< normalized window layer depths (m)
     
    10231045    REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET    :: t_surf_green_h_2
    10241046
    1025     TYPE(t_surf_vertical), DIMENSION(:), POINTER ::  t_surf_wall_v
    1026     TYPE(t_surf_vertical), DIMENSION(:), POINTER ::  t_surf_wall_v_p
    1027     TYPE(t_surf_vertical), DIMENSION(:), POINTER ::  t_surf_window_v
    1028     TYPE(t_surf_vertical), DIMENSION(:), POINTER ::  t_surf_window_v_p
    1029     TYPE(t_surf_vertical), DIMENSION(:), POINTER ::  t_surf_green_v
    1030     TYPE(t_surf_vertical), DIMENSION(:), POINTER ::  t_surf_green_v_p
     1047    TYPE(t_surf_vertical), DIMENSION(:), POINTER   ::  t_surf_wall_v
     1048    TYPE(t_surf_vertical), DIMENSION(:), POINTER   ::  t_surf_wall_v_p
     1049    TYPE(t_surf_vertical), DIMENSION(:), POINTER   ::  t_surf_window_v
     1050    TYPE(t_surf_vertical), DIMENSION(:), POINTER   ::  t_surf_window_v_p
     1051    TYPE(t_surf_vertical), DIMENSION(:), POINTER   ::  t_surf_green_v
     1052    TYPE(t_surf_vertical), DIMENSION(:), POINTER   ::  t_surf_green_v_p
    10311053
    10321054    TYPE(t_surf_vertical), DIMENSION(0:3), TARGET  :: t_surf_wall_v_1
     
    10371059    TYPE(t_surf_vertical), DIMENSION(0:3), TARGET  :: t_surf_green_v_2
    10381060
    1039 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1061!
    10401062!-- Energy balance variables
    1041 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    10421063!-- parameters of the land, roof and wall surfaces
    10431064
     
    10621083    TYPE(t_wall_vertical), DIMENSION(0:3), TARGET  :: swc_v_1, swc_v_2
    10631084
     1085!
    10641086!-- Surface and material parameters classes (surface_type)
    10651087!-- albedo, emissivity, lambda_surf, roughness, thickness, volumetric heat capacity, thermal conductivity
    1066     INTEGER(iwp)                                   :: n_surface_types      !< number of the wall type categories
    1067     INTEGER(iwp), PARAMETER                        :: n_surface_params = 9 !< number of parameters for each type of the wall
    1068     INTEGER(iwp), PARAMETER                        :: ialbedo  = 1         !< albedo of the surface
    1069     INTEGER(iwp), PARAMETER                        :: iemiss   = 2         !< emissivity of the surface
    1070     INTEGER(iwp), PARAMETER                        :: ilambdas = 3         !< heat conductivity lambda S between surface and material ( W m-2 K-1 )
    1071     INTEGER(iwp), PARAMETER                        :: irough   = 4         !< roughness length z0 for movements
    1072     INTEGER(iwp), PARAMETER                        :: iroughh  = 5         !< roughness length z0h for scalars (heat, humidity,...)
    1073     INTEGER(iwp), PARAMETER                        :: icsurf   = 6         !< Surface skin layer heat capacity (J m-2 K-1 )
    1074     INTEGER(iwp), PARAMETER                        :: ithick   = 7         !< thickness of the surface (wall, roof, land)  ( m )
    1075     INTEGER(iwp), PARAMETER                        :: irhoC    = 8         !< volumetric heat capacity rho*C of the material ( J m-3 K-1 )
    1076     INTEGER(iwp), PARAMETER                        :: ilambdah = 9         !< thermal conductivity lambda H of the wall (W m-1 K-1 )
    1077     CHARACTER(12), DIMENSION(:), ALLOCATABLE       :: surface_type_names   !< names of wall types (used only for reports)
    1078     INTEGER(iwp), DIMENSION(:), ALLOCATABLE        :: surface_type_codes   !< codes of wall types
    1079     REAL(wp), DIMENSION(:,:), ALLOCATABLE          :: surface_params       !< parameters of wall types
    1080 
    1081    
     1088    INTEGER(iwp)                                   :: n_surface_types       !< number of the wall type categories
     1089    INTEGER(iwp), PARAMETER                        :: n_surface_params = 9  !< number of parameters for each type of the wall
     1090    INTEGER(iwp), PARAMETER                        :: ialbedo  = 1          !< albedo of the surface
     1091    INTEGER(iwp), PARAMETER                        :: iemiss   = 2          !< emissivity of the surface
     1092    INTEGER(iwp), PARAMETER                        :: ilambdas = 3          !< heat conductivity lambda S between surface
     1093                                                                            !< and material ( W m-2 K-1 )
     1094    INTEGER(iwp), PARAMETER                        :: irough   = 4          !< roughness length z0 for movements
     1095    INTEGER(iwp), PARAMETER                        :: iroughh  = 5          !< roughness length z0h for scalars
     1096                                                                            !< (heat, humidity,...)
     1097    INTEGER(iwp), PARAMETER                        :: icsurf   = 6          !< Surface skin layer heat capacity (J m-2 K-1 )
     1098    INTEGER(iwp), PARAMETER                        :: ithick   = 7          !< thickness of the surface (wall, roof, land)  ( m )
     1099    INTEGER(iwp), PARAMETER                        :: irhoC    = 8          !< volumetric heat capacity rho*C of
     1100                                                                            !< the material ( J m-3 K-1 )
     1101    INTEGER(iwp), PARAMETER                        :: ilambdah = 9          !< thermal conductivity lambda H
     1102                                                                            !< of the wall (W m-1 K-1 )
     1103    CHARACTER(12), DIMENSION(:), ALLOCATABLE       :: surface_type_names    !< names of wall types (used only for reports)
     1104    INTEGER(iwp), DIMENSION(:), ALLOCATABLE        :: surface_type_codes    !< codes of wall types
     1105    REAL(wp), DIMENSION(:,:), ALLOCATABLE          :: surface_params        !< parameters of wall types
     1106
     1107!
    10821108!-- interfaces of subroutines accessed from outside of this module
     1109    INTERFACE usm_3d_data_averaging
     1110       MODULE PROCEDURE usm_3d_data_averaging
     1111    END INTERFACE usm_3d_data_averaging
     1112
    10831113    INTERFACE usm_boundary_condition
    10841114       MODULE PROCEDURE usm_boundary_condition
     
    11051135    END INTERFACE usm_init
    11061136
     1137    INTERFACE usm_init_arrays
     1138       MODULE PROCEDURE usm_init_arrays
     1139    END INTERFACE usm_init_arrays
     1140
    11071141    INTERFACE usm_material_heat_model
    11081142       MODULE PROCEDURE usm_material_heat_model
     
    11331167    END INTERFACE usm_wrd_local
    11341168
    1135     INTERFACE usm_init_arrays
    1136        MODULE PROCEDURE usm_init_arrays
    1137     END INTERFACE usm_init_arrays
    1138 
    1139     INTERFACE usm_3d_data_averaging
    1140        MODULE PROCEDURE usm_3d_data_averaging
    1141     END INTERFACE usm_3d_data_averaging
    1142 
    11431169   
    11441170    SAVE
    11451171
    11461172    PRIVATE
    1147    
     1173
     1174!
    11481175!-- Public functions
    1149     PUBLIC usm_boundary_condition, usm_check_parameters, usm_init,&
    1150            usm_rrd_local,                                                      &
    1151            usm_surface_energy_balance, usm_material_heat_model,                &
    1152            usm_swap_timelevel, usm_check_data_output, usm_3d_data_averaging,   &
    1153            usm_data_output_3d, usm_define_netcdf_grid, usm_parin,              &
     1176    PUBLIC usm_boundary_condition, usm_check_parameters, usm_init,               &
     1177           usm_rrd_local,                                                        &
     1178           usm_surface_energy_balance, usm_material_heat_model,                  &
     1179           usm_swap_timelevel, usm_check_data_output, usm_3d_data_averaging,     &
     1180           usm_data_output_3d, usm_define_netcdf_grid, usm_parin,                &
    11541181           usm_wrd_local, usm_init_arrays
    11551182
     1183!
    11561184!-- Public parameters, constants and initial values
    1157     PUBLIC usm_anthropogenic_heat, usm_material_model, usm_wall_mod,           &
    1158            usm_green_heat_model, building_pars,                                &
    1159            nzb_wall, nzt_wall, t_wall_h, t_wall_v,                             &
     1185    PUBLIC usm_anthropogenic_heat, usm_material_model, usm_wall_mod, &
     1186           usm_green_heat_model, building_pars,                      &
     1187           nzb_wall, nzt_wall, t_wall_h, t_wall_v,                   &
    11601188           t_window_h, t_window_v, building_type
    11611189
     
    11811209!--     Allocate radiation arrays which are part of the new data type.
    11821210!--     For horizontal surfaces.
    1183         ALLOCATE( surf_usm_h%surfhf(1:surf_usm_h%ns)    )
    1184         ALLOCATE( surf_usm_h%rad_net_l(1:surf_usm_h%ns) )
     1211        ALLOCATE ( surf_usm_h%surfhf(1:surf_usm_h%ns)    )
     1212        ALLOCATE ( surf_usm_h%rad_net_l(1:surf_usm_h%ns) )
    11851213!
    11861214!--     For vertical surfaces
    11871215        DO  l = 0, 3
    1188            ALLOCATE( surf_usm_v(l)%surfhf(1:surf_usm_v(l)%ns)    )
    1189            ALLOCATE( surf_usm_v(l)%rad_net_l(1:surf_usm_v(l)%ns) )
     1216           ALLOCATE ( surf_usm_v(l)%surfhf(1:surf_usm_v(l)%ns)    )
     1217           ALLOCATE ( surf_usm_v(l)%rad_net_l(1:surf_usm_v(l)%ns) )
    11901218        ENDDO
    11911219
     1220!
    11921221!--     Wall surface model
    11931222!--     allocate arrays for wall surface model and define pointers
    1194        
    11951223!--     allocate array of wall types and wall parameters
    11961224        ALLOCATE ( surf_usm_h%surface_types(1:surf_usm_h%ns)      )
     
    12001228        surf_usm_h%building_type_name = 'none'
    12011229        DO  l = 0, 3
    1202            ALLOCATE( surf_usm_v(l)%surface_types(1:surf_usm_v(l)%ns) )
     1230           ALLOCATE ( surf_usm_v(l)%surface_types(1:surf_usm_v(l)%ns)      )
    12031231           ALLOCATE ( surf_usm_v(l)%building_type(1:surf_usm_v(l)%ns)      )
    12041232           ALLOCATE ( surf_usm_v(l)%building_type_name(1:surf_usm_v(l)%ns) )
     
    12091237!--     Allocate albedo_type and albedo. Each surface element
    12101238!--     has 3 values, 0: wall fraction, 1: green fraction, 2: window fraction.
    1211         ALLOCATE( surf_usm_h%albedo_type(0:2,1:surf_usm_h%ns) )
    1212         ALLOCATE( surf_usm_h%albedo(0:2,1:surf_usm_h%ns)      )
     1239        ALLOCATE ( surf_usm_h%albedo_type(0:2,1:surf_usm_h%ns) )
     1240        ALLOCATE ( surf_usm_h%albedo(0:2,1:surf_usm_h%ns)      )
    12131241        surf_usm_h%albedo_type = albedo_type
    12141242        DO  l = 0, 3
    1215            ALLOCATE( surf_usm_v(l)%albedo_type(0:2,1:surf_usm_v(l)%ns) )
    1216            ALLOCATE( surf_usm_v(l)%albedo(0:2,1:surf_usm_v(l)%ns)      )
     1243           ALLOCATE ( surf_usm_v(l)%albedo_type(0:2,1:surf_usm_v(l)%ns) )
     1244           ALLOCATE ( surf_usm_v(l)%albedo(0:2,1:surf_usm_v(l)%ns)      )
    12171245           surf_usm_v(l)%albedo_type = albedo_type
    12181246        ENDDO       
    12191247
    1220 
    12211248!
    12221249!--     Allocate indoor target temperature for summer and winter
    1223         ALLOCATE( surf_usm_h%target_temp_summer(1:surf_usm_h%ns) )
    1224         ALLOCATE( surf_usm_h%target_temp_winter(1:surf_usm_h%ns) )
     1250        ALLOCATE ( surf_usm_h%target_temp_summer(1:surf_usm_h%ns) )
     1251        ALLOCATE ( surf_usm_h%target_temp_winter(1:surf_usm_h%ns) )
    12251252        DO  l = 0, 3
    1226            ALLOCATE( surf_usm_v(l)%target_temp_summer(1:surf_usm_v(l)%ns) )
    1227            ALLOCATE( surf_usm_v(l)%target_temp_winter(1:surf_usm_v(l)%ns) )
     1253           ALLOCATE ( surf_usm_v(l)%target_temp_summer(1:surf_usm_v(l)%ns) )
     1254           ALLOCATE ( surf_usm_v(l)%target_temp_winter(1:surf_usm_v(l)%ns) )
    12281255        ENDDO   
    12291256!
     
    12311258        ALLOCATE ( surf_usm_h%ground_level(1:surf_usm_h%ns) )
    12321259        DO  l = 0, 3
    1233            ALLOCATE( surf_usm_v(l)%ground_level(1:surf_usm_v(l)%ns) )
     1260           ALLOCATE ( surf_usm_v(l)%ground_level(1:surf_usm_v(l)%ns) )
    12341261        ENDDO   
    12351262!
    12361263!--      Allocate arrays for relative surface fraction.
    12371264!--      0 - wall fraction, 1 - green fraction, 2 - window fraction
    1238          ALLOCATE( surf_usm_h%frac(0:2,1:surf_usm_h%ns) )
     1265         ALLOCATE ( surf_usm_h%frac(0:2,1:surf_usm_h%ns) )
    12391266         surf_usm_h%frac = 0.0_wp
    12401267         DO  l = 0, 3
    1241             ALLOCATE( surf_usm_v(l)%frac(0:2,1:surf_usm_v(l)%ns) )
     1268            ALLOCATE ( surf_usm_v(l)%frac(0:2,1:surf_usm_v(l)%ns) )
    12421269            surf_usm_v(l)%frac = 0.0_wp
    12431270         ENDDO
    1244        
     1271
     1272!
    12451273!--     wall and roof surface parameters. First for horizontal surfaces
    12461274        ALLOCATE ( surf_usm_h%isroof_surf(1:surf_usm_h%ns)        )
     
    12631291!--     For vertical surfaces.
    12641292        DO  l = 0, 3
    1265            ALLOCATE ( surf_usm_v(l)%lambda_surf(1:surf_usm_v(l)%ns)     )
    1266            ALLOCATE ( surf_usm_v(l)%c_surface(1:surf_usm_v(l)%ns)       )
     1293           ALLOCATE ( surf_usm_v(l)%lambda_surf(1:surf_usm_v(l)%ns)        )
     1294           ALLOCATE ( surf_usm_v(l)%c_surface(1:surf_usm_v(l)%ns)          )
    12671295           ALLOCATE ( surf_usm_v(l)%lambda_surf_window(1:surf_usm_v(l)%ns) )
    12681296           ALLOCATE ( surf_usm_v(l)%c_surface_window(1:surf_usm_v(l)%ns)   )
    12691297           ALLOCATE ( surf_usm_v(l)%lambda_surf_green(1:surf_usm_v(l)%ns)  )
    12701298           ALLOCATE ( surf_usm_v(l)%c_surface_green(1:surf_usm_v(l)%ns)    )
    1271            ALLOCATE ( surf_usm_v(l)%transmissivity(1:surf_usm_v(l)%ns)  )
    1272            ALLOCATE ( surf_usm_v(l)%lai(1:surf_usm_v(l)%ns)             )
    1273            ALLOCATE ( surf_usm_v(l)%emissivity(0:2,1:surf_usm_v(l)%ns)  )
    1274            ALLOCATE ( surf_usm_v(l)%r_a(1:surf_usm_v(l)%ns)             )
    1275            ALLOCATE ( surf_usm_v(l)%r_a_green(1:surf_usm_v(l)%ns)       )
    1276            ALLOCATE ( surf_usm_v(l)%r_a_window(1:surf_usm_v(l)%ns)      )           
     1299           ALLOCATE ( surf_usm_v(l)%transmissivity(1:surf_usm_v(l)%ns)     )
     1300           ALLOCATE ( surf_usm_v(l)%lai(1:surf_usm_v(l)%ns)                )
     1301           ALLOCATE ( surf_usm_v(l)%emissivity(0:2,1:surf_usm_v(l)%ns)     )
     1302           ALLOCATE ( surf_usm_v(l)%r_a(1:surf_usm_v(l)%ns)                )
     1303           ALLOCATE ( surf_usm_v(l)%r_a_green(1:surf_usm_v(l)%ns)          )
     1304           ALLOCATE ( surf_usm_v(l)%r_a_window(1:surf_usm_v(l)%ns)         )           
    12771305           ALLOCATE ( surf_usm_v(l)%r_s(1:surf_usm_v(l)%ns)                )
    12781306        ENDDO
     
    12801308!       
    12811309!--     allocate wall and roof material parameters. First for horizontal surfaces
    1282         ALLOCATE ( surf_usm_h%thickness_wall(1:surf_usm_h%ns)               )
     1310        ALLOCATE ( surf_usm_h%thickness_wall(1:surf_usm_h%ns)                    )
    12831311        ALLOCATE ( surf_usm_h%thickness_window(1:surf_usm_h%ns)                  )
    12841312        ALLOCATE ( surf_usm_h%thickness_green(1:surf_usm_h%ns)                   )
    1285         ALLOCATE ( surf_usm_h%lambda_h(nzb_wall:nzt_wall,1:surf_usm_h%ns)   )
    1286         ALLOCATE ( surf_usm_h%rho_c_wall(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
     1313        ALLOCATE ( surf_usm_h%lambda_h(nzb_wall:nzt_wall,1:surf_usm_h%ns)        )
     1314        ALLOCATE ( surf_usm_h%rho_c_wall(nzb_wall:nzt_wall,1:surf_usm_h%ns)      )
    12871315        ALLOCATE ( surf_usm_h%lambda_h_window(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
    12881316        ALLOCATE ( surf_usm_h%rho_c_window(nzb_wall:nzt_wall,1:surf_usm_h%ns)    )
     
    12901318        ALLOCATE ( surf_usm_h%rho_c_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)     )
    12911319
    1292         ALLOCATE ( surf_usm_h%rho_c_total_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)     )
    1293         ALLOCATE ( surf_usm_h%n_vg_green(1:surf_usm_h%ns)     )
    1294         ALLOCATE ( surf_usm_h%alpha_vg_green(1:surf_usm_h%ns)     )
    1295         ALLOCATE ( surf_usm_h%l_vg_green(1:surf_usm_h%ns)     )
    1296         ALLOCATE ( surf_usm_h%gamma_w_green_sat(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)     )
    1297         ALLOCATE ( surf_usm_h%lambda_w_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)     )
    1298         ALLOCATE ( surf_usm_h%gamma_w_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)     )
    1299         ALLOCATE ( surf_usm_h%tswc_h_m(nzb_wall:nzt_wall,1:surf_usm_h%ns)     )
     1320        ALLOCATE ( surf_usm_h%rho_c_total_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)    )
     1321        ALLOCATE ( surf_usm_h%n_vg_green(1:surf_usm_h%ns)                             )
     1322        ALLOCATE ( surf_usm_h%alpha_vg_green(1:surf_usm_h%ns)                         )
     1323        ALLOCATE ( surf_usm_h%l_vg_green(1:surf_usm_h%ns)                             )
     1324        ALLOCATE ( surf_usm_h%gamma_w_green_sat(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)  )
     1325        ALLOCATE ( surf_usm_h%lambda_w_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)       )
     1326        ALLOCATE ( surf_usm_h%gamma_w_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)        )
     1327        ALLOCATE ( surf_usm_h%tswc_h_m(nzb_wall:nzt_wall,1:surf_usm_h%ns)             )
    13001328
    13011329!
    13021330!--     For vertical surfaces.
    13031331        DO  l = 0, 3
    1304            ALLOCATE ( surf_usm_v(l)%thickness_wall(1:surf_usm_v(l)%ns)               )
     1332           ALLOCATE ( surf_usm_v(l)%thickness_wall(1:surf_usm_v(l)%ns)                    )
    13051333           ALLOCATE ( surf_usm_v(l)%thickness_window(1:surf_usm_v(l)%ns)                  )
    13061334           ALLOCATE ( surf_usm_v(l)%thickness_green(1:surf_usm_v(l)%ns)                   )
    1307            ALLOCATE ( surf_usm_v(l)%lambda_h(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)   )
    1308            ALLOCATE ( surf_usm_v(l)%rho_c_wall(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
     1335           ALLOCATE ( surf_usm_v(l)%lambda_h(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)        )
     1336           ALLOCATE ( surf_usm_v(l)%rho_c_wall(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)      )
    13091337           ALLOCATE ( surf_usm_v(l)%lambda_h_window(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
    13101338           ALLOCATE ( surf_usm_v(l)%rho_c_window(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)    )
     
    13351363          ALLOCATE ( surf_usm_v(l)%r_canopy(1:surf_usm_v(l)%ns)         )
    13361364          ALLOCATE ( surf_usm_v(l)%r_canopy_min(1:surf_usm_v(l)%ns)     )
    1337           ALLOCATE ( surf_usm_v(l)%pt_10cm(1:surf_usm_v(l)%ns)     )
     1365          ALLOCATE ( surf_usm_v(l)%pt_10cm(1:surf_usm_v(l)%ns)          )
    13381366        ENDDO
    1339        
     1367
     1368!
    13401369!--     allocate wall and roof layers sizes. For horizontal surfaces.
    1341         ALLOCATE ( zwn(nzb_wall:nzt_wall) )
    1342         ALLOCATE ( surf_usm_h%dz_wall(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)     )
    1343         ALLOCATE ( zwn_window(nzb_wall:nzt_wall) )
     1370        ALLOCATE ( zwn(nzb_wall:nzt_wall)                                        )
     1371        ALLOCATE ( surf_usm_h%dz_wall(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)       )
     1372        ALLOCATE ( zwn_window(nzb_wall:nzt_wall)                                 )
    13441373        ALLOCATE ( surf_usm_h%dz_window(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)     )
    1345         ALLOCATE ( zwn_green(nzb_wall:nzt_wall) )
     1374        ALLOCATE ( zwn_green(nzb_wall:nzt_wall)                                  )
    13461375        ALLOCATE ( surf_usm_h%dz_green(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)      )
    1347         ALLOCATE ( surf_usm_h%ddz_wall(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)    )
    1348         ALLOCATE ( surf_usm_h%dz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_h%ns)  )
    1349         ALLOCATE ( surf_usm_h%ddz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
    1350         ALLOCATE ( surf_usm_h%zw(nzb_wall:nzt_wall,1:surf_usm_h%ns)            )
     1376        ALLOCATE ( surf_usm_h%ddz_wall(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)      )
     1377        ALLOCATE ( surf_usm_h%dz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_h%ns)    )
     1378        ALLOCATE ( surf_usm_h%ddz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_h%ns)   )
     1379        ALLOCATE ( surf_usm_h%zw(nzb_wall:nzt_wall,1:surf_usm_h%ns)              )
    13511380        ALLOCATE ( surf_usm_h%ddz_window(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)    )
    13521381        ALLOCATE ( surf_usm_h%dz_window_stag(nzb_wall:nzt_wall,1:surf_usm_h%ns)  )
     
    13571386        ALLOCATE ( surf_usm_h%ddz_green_stag(nzb_wall:nzt_wall,1:surf_usm_h%ns)  )
    13581387        ALLOCATE ( surf_usm_h%zw_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)        )
     1388
    13591389!
    13601390!--     For vertical surfaces.
    13611391        DO  l = 0, 3
    1362            ALLOCATE ( surf_usm_v(l)%dz_wall(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)     )
     1392           ALLOCATE ( surf_usm_v(l)%dz_wall(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)       )
    13631393           ALLOCATE ( surf_usm_v(l)%dz_window(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)     )
    13641394           ALLOCATE ( surf_usm_v(l)%dz_green(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)      )
    1365            ALLOCATE ( surf_usm_v(l)%ddz_wall(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)    )
    1366            ALLOCATE ( surf_usm_v(l)%dz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)  )
    1367            ALLOCATE ( surf_usm_v(l)%ddz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
    1368            ALLOCATE ( surf_usm_v(l)%zw(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)            )
     1395           ALLOCATE ( surf_usm_v(l)%ddz_wall(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)      )
     1396           ALLOCATE ( surf_usm_v(l)%dz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)    )
     1397           ALLOCATE ( surf_usm_v(l)%ddz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)   )
     1398           ALLOCATE ( surf_usm_v(l)%zw(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)              )
    13691399           ALLOCATE ( surf_usm_v(l)%ddz_window(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)    )
    13701400           ALLOCATE ( surf_usm_v(l)%dz_window_stag(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)  )
     
    13771407        ENDDO
    13781408
     1409!
    13791410!--     allocate wall and roof temperature arrays, for horizontal walls
    13801411!
    13811412!--     Allocate if required. Note, in case of restarts, some of these arrays
    13821413!--     might be already allocated.
    1383         IF ( .NOT. ALLOCATED( t_surf_wall_h_1 ) )                                   &
     1414        IF ( .NOT. ALLOCATED( t_surf_wall_h_1 ) )                              &
    13841415           ALLOCATE ( t_surf_wall_h_1(1:surf_usm_h%ns) )
    1385         IF ( .NOT. ALLOCATED( t_surf_wall_h_2 ) )                                   &
     1416        IF ( .NOT. ALLOCATED( t_surf_wall_h_2 ) )                              &
    13861417           ALLOCATE ( t_surf_wall_h_2(1:surf_usm_h%ns) )
    13871418        IF ( .NOT. ALLOCATED( t_wall_h_1 ) )                                   &           
     
    14051436        IF ( .NOT. ALLOCATED( t_green_h_2 ) )                                  &           
    14061437           ALLOCATE ( t_green_h_2(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )         
    1407         IF ( .NOT. ALLOCATED( swc_h_1 ) )                                  &           
     1438        IF ( .NOT. ALLOCATED( swc_h_1 ) )                                      &           
    14081439           ALLOCATE ( swc_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
    14091440        IF ( .NOT. ALLOCATED( swc_sat_h_1 ) )                                  &           
     
    14111442        IF ( .NOT. ALLOCATED( swc_res_h_1 ) )                                  &           
    14121443           ALLOCATE ( swc_res_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
    1413         IF ( .NOT. ALLOCATED( swc_h_2 ) )                                  &           
     1444        IF ( .NOT. ALLOCATED( swc_h_2 ) )                                      &           
    14141445           ALLOCATE ( swc_h_2(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
    1415         IF ( .NOT. ALLOCATED( rootfr_h_1 ) )                                  &           
     1446        IF ( .NOT. ALLOCATED( rootfr_h_1 ) )                                   &           
    14161447           ALLOCATE ( rootfr_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
    1417         IF ( .NOT. ALLOCATED( wilt_h_1 ) )                                  &           
     1448        IF ( .NOT. ALLOCATED( wilt_h_1 ) )                                     &           
    14181449           ALLOCATE ( wilt_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
    1419         IF ( .NOT. ALLOCATED( fc_h_1 ) )                                  &           
     1450        IF ( .NOT. ALLOCATED( fc_h_1 ) )                                       &           
    14201451           ALLOCATE ( fc_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
    14211452
    1422         IF ( .NOT. ALLOCATED( m_liq_usm_h_1%var_usm_1d ) )                         &
     1453        IF ( .NOT. ALLOCATED( m_liq_usm_h_1%var_usm_1d ) )                     &
    14231454           ALLOCATE ( m_liq_usm_h_1%var_usm_1d(1:surf_usm_h%ns) )
    1424         IF ( .NOT. ALLOCATED( m_liq_usm_h_2%var_usm_1d ) )                         &
     1455        IF ( .NOT. ALLOCATED( m_liq_usm_h_2%var_usm_1d ) )                     &
    14251456           ALLOCATE ( m_liq_usm_h_2%var_usm_1d(1:surf_usm_h%ns) )
    14261457           
    14271458!           
    14281459!--     initial assignment of the pointers
    1429         t_wall_h    => t_wall_h_1;    t_wall_h_p    => t_wall_h_2
    1430         t_window_h    => t_window_h_1;    t_window_h_p    => t_window_h_2
    1431         t_green_h    => t_green_h_1;    t_green_h_p    => t_green_h_2
    1432         t_surf_wall_h => t_surf_wall_h_1; t_surf_wall_h_p => t_surf_wall_h_2           
     1460        t_wall_h    => t_wall_h_1;   t_wall_h_p   => t_wall_h_2
     1461        t_window_h  => t_window_h_1; t_window_h_p => t_window_h_2
     1462        t_green_h   => t_green_h_1;  t_green_h_p  => t_green_h_2
     1463        t_surf_wall_h   => t_surf_wall_h_1;   t_surf_wall_h_p  => t_surf_wall_h_2           
    14331464        t_surf_window_h => t_surf_window_h_1; t_surf_window_h_p => t_surf_window_h_2 
    1434         t_surf_green_h => t_surf_green_h_1; t_surf_green_h_p => t_surf_green_h_2           
     1465        t_surf_green_h  => t_surf_green_h_1;  t_surf_green_h_p => t_surf_green_h_2           
    14351466        m_liq_usm_h     => m_liq_usm_h_1;     m_liq_usm_h_p     => m_liq_usm_h_2
    1436         swc_h       => swc_h_1; swc_h_p     => swc_h_2
    1437         swc_sat_h    => swc_sat_h_1
    1438         swc_res_h    => swc_res_h_1
    1439         rootfr_h       => rootfr_h_1
    1440         wilt_h       => wilt_h_1
    1441         fc_h       => fc_h_1
    1442 
     1467        swc_h     => swc_h_1; swc_h_p => swc_h_2
     1468        swc_sat_h => swc_sat_h_1
     1469        swc_res_h => swc_res_h_1
     1470        rootfr_h  => rootfr_h_1
     1471        wilt_h    => wilt_h_1
     1472        fc_h      => fc_h_1
     1473
     1474!
    14431475!--     allocate wall and roof temperature arrays, for vertical walls if required
    14441476!
     
    14461478!--     might be already allocated.
    14471479        DO  l = 0, 3
    1448            IF ( .NOT. ALLOCATED( t_surf_wall_v_1(l)%t ) )                           &
     1480           IF ( .NOT. ALLOCATED( t_surf_wall_v_1(l)%t ) )                      &
    14491481              ALLOCATE ( t_surf_wall_v_1(l)%t(1:surf_usm_v(l)%ns) )
    1450            IF ( .NOT. ALLOCATED( t_surf_wall_v_2(l)%t ) )                           &
     1482           IF ( .NOT. ALLOCATED( t_surf_wall_v_2(l)%t ) )                      &
    14511483              ALLOCATE ( t_surf_wall_v_2(l)%t(1:surf_usm_v(l)%ns) )
    14521484           IF ( .NOT. ALLOCATED( t_wall_v_1(l)%t ) )                           &           
     
    14701502           IF ( .NOT. ALLOCATED( t_green_v_2(l)%t ) )                          &           
    14711503              ALLOCATE ( t_green_v_2(l)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) ) 
    1472            IF ( .NOT. ALLOCATED( m_liq_usm_v_1(l)%var_usm_1d ) )              &
     1504           IF ( .NOT. ALLOCATED( m_liq_usm_v_1(l)%var_usm_1d ) )               &
    14731505              ALLOCATE ( m_liq_usm_v_1(l)%var_usm_1d(1:surf_usm_v(l)%ns) )
    1474            IF ( .NOT. ALLOCATED( m_liq_usm_v_2(l)%var_usm_1d ) )              &
     1506           IF ( .NOT. ALLOCATED( m_liq_usm_v_2(l)%var_usm_1d ) )               &
    14751507              ALLOCATE ( m_liq_usm_v_2(l)%var_usm_1d(1:surf_usm_v(l)%ns) )
    1476            IF ( .NOT. ALLOCATED( swc_v_1(l)%t ) )                           &           
     1508           IF ( .NOT. ALLOCATED( swc_v_1(l)%t ) )                              &           
    14771509              ALLOCATE ( swc_v_1(l)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) )
    1478            IF ( .NOT. ALLOCATED( swc_v_2(l)%t ) )                           &           
     1510           IF ( .NOT. ALLOCATED( swc_v_2(l)%t ) )                              &           
    14791511              ALLOCATE ( swc_v_2(l)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) ) 
    14801512        ENDDO
    14811513!
    14821514!--     initial assignment of the pointers
    1483         t_wall_v    => t_wall_v_1;    t_wall_v_p    => t_wall_v_2
    1484         t_surf_wall_v => t_surf_wall_v_1; t_surf_wall_v_p => t_surf_wall_v_2
    1485         t_window_v    => t_window_v_1;    t_window_v_p    => t_window_v_2
    1486         t_green_v    => t_green_v_1;    t_green_v_p    => t_green_v_2
     1515        t_wall_v        => t_wall_v_1;        t_wall_v_p        => t_wall_v_2
     1516        t_surf_wall_v   => t_surf_wall_v_1;   t_surf_wall_v_p  => t_surf_wall_v_2
     1517        t_window_v      => t_window_v_1;      t_window_v_p      => t_window_v_2
     1518        t_green_v       => t_green_v_1;       t_green_v_p       => t_green_v_2
    14871519        t_surf_window_v => t_surf_window_v_1; t_surf_window_v_p => t_surf_window_v_2
    1488         t_surf_green_v => t_surf_green_v_1; t_surf_green_v_p => t_surf_green_v_2
     1520        t_surf_green_v  => t_surf_green_v_1;  t_surf_green_v_p => t_surf_green_v_2
    14891521        m_liq_usm_v     => m_liq_usm_v_1;     m_liq_usm_v_p     => m_liq_usm_v_2
    1490         swc_v    => swc_v_1;    swc_v_p    => swc_v_2
     1522        swc_v           => swc_v_1;           swc_v_p           => swc_v_2
    14911523
    14921524!
    14931525!--     Allocate intermediate timestep arrays. For horizontal surfaces.
    1494         ALLOCATE ( surf_usm_h%tt_surface_wall_m(1:surf_usm_h%ns)                  )
    1495         ALLOCATE ( surf_usm_h%tt_wall_m(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
     1526        ALLOCATE ( surf_usm_h%tt_surface_wall_m(1:surf_usm_h%ns)               )
     1527        ALLOCATE ( surf_usm_h%tt_wall_m(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)   )
    14961528        ALLOCATE ( surf_usm_h%tt_surface_window_m(1:surf_usm_h%ns)             )
    14971529        ALLOCATE ( surf_usm_h%tt_window_m(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
     
    15111543!
    15121544!--     Set inital values for prognostic quantities
    1513         IF ( ALLOCATED( surf_usm_h%tt_surface_wall_m ) )  surf_usm_h%tt_surface_wall_m = 0.0_wp
    1514         IF ( ALLOCATED( surf_usm_h%tt_wall_m    ) )  surf_usm_h%tt_wall_m    = 0.0_wp
     1545        IF ( ALLOCATED( surf_usm_h%tt_surface_wall_m )   )  surf_usm_h%tt_surface_wall_m  = 0.0_wp
     1546        IF ( ALLOCATED( surf_usm_h%tt_wall_m )           )  surf_usm_h%tt_wall_m           = 0.0_wp
    15151547        IF ( ALLOCATED( surf_usm_h%tt_surface_window_m ) )  surf_usm_h%tt_surface_window_m = 0.0_wp
    15161548        IF ( ALLOCATED( surf_usm_h%tt_window_m    )      )  surf_usm_h%tt_window_m         = 0.0_wp
     
    15201552!--     Now, for vertical surfaces
    15211553        DO  l = 0, 3
    1522            ALLOCATE ( surf_usm_v(l)%tt_surface_wall_m(1:surf_usm_v(l)%ns)                  )
    1523            ALLOCATE ( surf_usm_v(l)%tt_wall_m(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) )
     1554           ALLOCATE ( surf_usm_v(l)%tt_surface_wall_m(1:surf_usm_v(l)%ns)               )
     1555           ALLOCATE ( surf_usm_v(l)%tt_wall_m(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)   )
    15241556           IF ( ALLOCATED( surf_usm_v(l)%tt_surface_wall_m ) )  surf_usm_v(l)%tt_surface_wall_m = 0.0_wp
    15251557           IF ( ALLOCATED( surf_usm_v(l)%tt_wall_m    ) )  surf_usm_v(l)%tt_wall_m    = 0.0_wp
     
    15331565           IF ( ALLOCATED( surf_usm_v(l)%tt_green_m   ) )  surf_usm_v(l)%tt_green_m    = 0.0_wp
    15341566        ENDDO
    1535 
     1567!
    15361568!--     allocate wall heat flux output array and set initial values. For horizontal surfaces
    1537 !         ALLOCATE ( surf_usm_h%wshf(1:surf_usm_h%ns)    )  !can be removed
     1569!        ALLOCATE ( surf_usm_h%wshf(1:surf_usm_h%ns)    )  !can be removed
    15381570        ALLOCATE ( surf_usm_h%wshf_eb(1:surf_usm_h%ns) )
    15391571        ALLOCATE ( surf_usm_h%wghf_eb(1:surf_usm_h%ns) )
     
    15521584!--     Now, for vertical surfaces
    15531585        DO  l = 0, 3
    1554 !            ALLOCATE ( surf_usm_v(l)%wshf(1:surf_usm_v(l)%ns)    )    ! can be removed
     1586!           ALLOCATE ( surf_usm_v(l)%wshf(1:surf_usm_v(l)%ns)    )    ! can be removed
    15551587           ALLOCATE ( surf_usm_v(l)%wshf_eb(1:surf_usm_v(l)%ns) )
    15561588           ALLOCATE ( surf_usm_v(l)%wghf_eb(1:surf_usm_v(l)%ns) )
     
    15691601
    15701602        CALL location_message( 'finished', .TRUE. )
    1571 
     1603       
    15721604    END SUBROUTINE usm_init_arrays
    15731605
     
    15861618        CHARACTER(LEN=*), INTENT(IN) :: variable
    15871619 
    1588         INTEGER(iwp)                                       :: i, j, k, l, m, ids, idsint, iwl, istat
    1589         CHARACTER(LEN=varnamelength)                       :: var
    1590         INTEGER(iwp), PARAMETER                            :: nd = 5
     1620        INTEGER(iwp)                                       :: i, j, k, l, m, ids, idsint, iwl, istat  !< runnin indices
     1621        CHARACTER(LEN=varnamelength)                       :: var                                     !< trimmed variable
     1622        INTEGER(iwp), PARAMETER                            :: nd = 5                                  !< number of directions
    15911623        CHARACTER(LEN=6), DIMENSION(0:nd-1), PARAMETER     :: dirname = (/ '_roof ', '_south', '_north', '_west ', '_east ' /)
    15921624        INTEGER(iwp), DIMENSION(0:nd-1), PARAMETER         :: dirint = (/ iup_u, isouth_u, inorth_u, iwest_u, ieast_u /)
     
    15941626        IF ( variable(1:4) == 'usm_' )  THEN  ! is such a check really rquired?
    15951627
     1628!
    15961629!--     find the real name of the variable
    15971630        ids = -1
     
    16161649        ENDIF
    16171650        IF ( var(1:11) == 'usm_t_wall_'  .AND.  len(TRIM(var)) >= 12 )  THEN
     1651!
    16181652!--          wall layers
    16191653            READ(var(12:12), '(I1)', iostat=istat ) iwl
     
    16211655                var = var(1:10)
    16221656            ELSE
     1657!
    16231658!--             wrong wall layer index
    16241659                RETURN
     
    16261661        ENDIF
    16271662        IF ( var(1:13) == 'usm_t_window_'  .AND.  len(TRIM(var)) >= 14 )  THEN
     1663!
    16281664!--          wall layers
    16291665            READ(var(14:14), '(I1)', iostat=istat ) iwl
     
    16311667                var = var(1:12)
    16321668            ELSE
     1669!
    16331670!--             wrong window layer index
    16341671                RETURN
     
    16361673        ENDIF
    16371674        IF ( var(1:12) == 'usm_t_green_'  .AND.  len(TRIM(var)) >= 13 )  THEN
     1675!
    16381676!--          wall layers
    16391677            READ(var(13:13), '(I1)', iostat=istat ) iwl
     
    16411679                var = var(1:11)
    16421680            ELSE
     1681!
    16431682!--             wrong green layer index
    16441683                RETURN
     
    16461685        ENDIF
    16471686        IF ( var(1:8) == 'usm_swc_'  .AND.  len(TRIM(var)) >= 9 )  THEN
     1687!
    16481688!--          swc layers
    16491689            READ(var(9:9), '(I1)', iostat=istat ) iwl
     
    16511691                var = var(1:7)
    16521692            ELSE
     1693!
    16531694!--             wrong swc layer index
    16541695                RETURN
     
    16611702
    16621703                CASE ( 'usm_wshf' )
     1704!
    16631705!--                 array of sensible heat flux from surfaces
    16641706!--                 land surfaces
    16651707                    IF ( l == -1 ) THEN
    16661708                       IF ( .NOT.  ALLOCATED(surf_usm_h%wshf_eb_av) )  THEN
    1667                           ALLOCATE( surf_usm_h%wshf_eb_av(1:surf_usm_h%ns) )
     1709                          ALLOCATE ( surf_usm_h%wshf_eb_av(1:surf_usm_h%ns) )
    16681710                          surf_usm_h%wshf_eb_av = 0.0_wp
    16691711                       ENDIF
    16701712                    ELSE
    16711713                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%wshf_eb_av) )  THEN
    1672                            ALLOCATE( surf_usm_v(l)%wshf_eb_av(1:surf_usm_v(l)%ns) )
     1714                           ALLOCATE ( surf_usm_v(l)%wshf_eb_av(1:surf_usm_v(l)%ns) )
    16731715                           surf_usm_v(l)%wshf_eb_av = 0.0_wp
    16741716                       ENDIF
     
    16761718                   
    16771719                CASE ( 'usm_qsws' )
     1720!
    16781721!--                 array of latent heat flux from surfaces
    16791722!--                 land surfaces
    16801723                    IF ( l == -1 .AND. .NOT.  ALLOCATED(surf_usm_h%qsws_eb_av) )  THEN
    1681                         ALLOCATE( surf_usm_h%qsws_eb_av(1:surf_usm_h%ns) )
     1724                        ALLOCATE ( surf_usm_h%qsws_eb_av(1:surf_usm_h%ns) )
    16821725                        surf_usm_h%qsws_eb_av = 0.0_wp
    16831726                    ELSE
    16841727                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%qsws_eb_av) )  THEN
    1685                            ALLOCATE( surf_usm_v(l)%qsws_eb_av(1:surf_usm_v(l)%ns) )
     1728                           ALLOCATE ( surf_usm_v(l)%qsws_eb_av(1:surf_usm_v(l)%ns) )
    16861729                           surf_usm_v(l)%qsws_eb_av = 0.0_wp
    16871730                       ENDIF
     
    16891732                   
    16901733                CASE ( 'usm_qsws_veg' )
     1734!
    16911735!--                 array of latent heat flux from vegetation surfaces
    16921736!--                 land surfaces
    16931737                    IF ( l == -1 .AND. .NOT.  ALLOCATED(surf_usm_h%qsws_veg_av) )  THEN
    1694                         ALLOCATE( surf_usm_h%qsws_veg_av(1:surf_usm_h%ns) )
     1738                        ALLOCATE ( surf_usm_h%qsws_veg_av(1:surf_usm_h%ns) )
    16951739                        surf_usm_h%qsws_veg_av = 0.0_wp
    16961740                    ELSE
    16971741                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%qsws_veg_av) )  THEN
    1698                            ALLOCATE( surf_usm_v(l)%qsws_veg_av(1:surf_usm_v(l)%ns) )
     1742                           ALLOCATE ( surf_usm_v(l)%qsws_veg_av(1:surf_usm_v(l)%ns) )
    16991743                           surf_usm_v(l)%qsws_veg_av = 0.0_wp
    17001744                       ENDIF
     
    17021746                   
    17031747                CASE ( 'usm_qsws_liq' )
     1748!
    17041749!--                 array of latent heat flux from surfaces with liquid
    17051750!--                 land surfaces
    17061751                    IF ( l == -1 .AND. .NOT.  ALLOCATED(surf_usm_h%qsws_liq_av) )  THEN
    1707                         ALLOCATE( surf_usm_h%qsws_liq_av(1:surf_usm_h%ns) )
     1752                        ALLOCATE ( surf_usm_h%qsws_liq_av(1:surf_usm_h%ns) )
    17081753                        surf_usm_h%qsws_liq_av = 0.0_wp
    17091754                    ELSE
    17101755                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%qsws_liq_av) )  THEN
    1711                            ALLOCATE( surf_usm_v(l)%qsws_liq_av(1:surf_usm_v(l)%ns) )
     1756                           ALLOCATE ( surf_usm_v(l)%qsws_liq_av(1:surf_usm_v(l)%ns) )
    17121757                           surf_usm_v(l)%qsws_liq_av = 0.0_wp
    17131758                       ENDIF
     
    17191764!--             accordingly in average_3d_data, sum_up_3d_data, etc..
    17201765                CASE ( 'usm_wghf' )
     1766!
    17211767!--                 array of heat flux from ground (wall, roof, land)
    17221768                    IF ( l == -1 ) THEN
    17231769                       IF ( .NOT.  ALLOCATED(surf_usm_h%wghf_eb_av) )  THEN
    1724                            ALLOCATE( surf_usm_h%wghf_eb_av(1:surf_usm_h%ns) )
     1770                           ALLOCATE ( surf_usm_h%wghf_eb_av(1:surf_usm_h%ns) )
    17251771                           surf_usm_h%wghf_eb_av = 0.0_wp
    17261772                       ENDIF
    17271773                    ELSE
    17281774                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%wghf_eb_av) )  THEN
    1729                            ALLOCATE( surf_usm_v(l)%wghf_eb_av(1:surf_usm_v(l)%ns) )
     1775                           ALLOCATE ( surf_usm_v(l)%wghf_eb_av(1:surf_usm_v(l)%ns) )
    17301776                           surf_usm_v(l)%wghf_eb_av = 0.0_wp
    17311777                       ENDIF
     
    17331779
    17341780                CASE ( 'usm_wghf_window' )
     1781!
    17351782!--                 array of heat flux from window ground (wall, roof, land)
    17361783                    IF ( l == -1 ) THEN
    17371784                       IF ( .NOT.  ALLOCATED(surf_usm_h%wghf_eb_window_av) )  THEN
    1738                            ALLOCATE( surf_usm_h%wghf_eb_window_av(1:surf_usm_h%ns) )
     1785                           ALLOCATE ( surf_usm_h%wghf_eb_window_av(1:surf_usm_h%ns) )
    17391786                           surf_usm_h%wghf_eb_window_av = 0.0_wp
    17401787                       ENDIF
    17411788                    ELSE
    17421789                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%wghf_eb_window_av) )  THEN
    1743                            ALLOCATE( surf_usm_v(l)%wghf_eb_window_av(1:surf_usm_v(l)%ns) )
     1790                           ALLOCATE ( surf_usm_v(l)%wghf_eb_window_av(1:surf_usm_v(l)%ns) )
    17441791                           surf_usm_v(l)%wghf_eb_window_av = 0.0_wp
    17451792                       ENDIF
     
    17471794
    17481795                CASE ( 'usm_wghf_green' )
     1796!
    17491797!--                 array of heat flux from green ground (wall, roof, land)
    17501798                    IF ( l == -1 ) THEN
    17511799                       IF ( .NOT.  ALLOCATED(surf_usm_h%wghf_eb_green_av) )  THEN
    1752                            ALLOCATE( surf_usm_h%wghf_eb_green_av(1:surf_usm_h%ns) )
     1800                           ALLOCATE ( surf_usm_h%wghf_eb_green_av(1:surf_usm_h%ns) )
    17531801                           surf_usm_h%wghf_eb_green_av = 0.0_wp
    17541802                       ENDIF
    17551803                    ELSE
    17561804                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%wghf_eb_green_av) )  THEN
    1757                            ALLOCATE( surf_usm_v(l)%wghf_eb_green_av(1:surf_usm_v(l)%ns) )
     1805                           ALLOCATE ( surf_usm_v(l)%wghf_eb_green_av(1:surf_usm_v(l)%ns) )
    17581806                           surf_usm_v(l)%wghf_eb_green_av = 0.0_wp
    17591807                       ENDIF
     
    17611809
    17621810                CASE ( 'usm_iwghf' )
     1811!
    17631812!--                 array of heat flux from indoor ground (wall, roof, land)
    17641813                    IF ( l == -1 ) THEN
    17651814                       IF ( .NOT.  ALLOCATED(surf_usm_h%iwghf_eb_av) )  THEN
    1766                            ALLOCATE( surf_usm_h%iwghf_eb_av(1:surf_usm_h%ns) )
     1815                           ALLOCATE ( surf_usm_h%iwghf_eb_av(1:surf_usm_h%ns) )
    17671816                           surf_usm_h%iwghf_eb_av = 0.0_wp
    17681817                       ENDIF
    17691818                    ELSE
    17701819                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%iwghf_eb_av) )  THEN
    1771                            ALLOCATE( surf_usm_v(l)%iwghf_eb_av(1:surf_usm_v(l)%ns) )
     1820                           ALLOCATE ( surf_usm_v(l)%iwghf_eb_av(1:surf_usm_v(l)%ns) )
    17721821                           surf_usm_v(l)%iwghf_eb_av = 0.0_wp
    17731822                       ENDIF
     
    17751824
    17761825                CASE ( 'usm_iwghf_window' )
     1826!
    17771827!--                 array of heat flux from indoor window ground (wall, roof, land)
    17781828                    IF ( l == -1 ) THEN
    17791829                       IF ( .NOT.  ALLOCATED(surf_usm_h%iwghf_eb_window_av) )  THEN
    1780                            ALLOCATE( surf_usm_h%iwghf_eb_window_av(1:surf_usm_h%ns) )
     1830                           ALLOCATE ( surf_usm_h%iwghf_eb_window_av(1:surf_usm_h%ns) )
    17811831                           surf_usm_h%iwghf_eb_window_av = 0.0_wp
    17821832                       ENDIF
    17831833                    ELSE
    17841834                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%iwghf_eb_window_av) )  THEN
    1785                            ALLOCATE( surf_usm_v(l)%iwghf_eb_window_av(1:surf_usm_v(l)%ns) )
     1835                           ALLOCATE ( surf_usm_v(l)%iwghf_eb_window_av(1:surf_usm_v(l)%ns) )
    17861836                           surf_usm_v(l)%iwghf_eb_window_av = 0.0_wp
    17871837                       ENDIF
     
    17891839
    17901840                CASE ( 'usm_t_surf_wall' )
     1841!
    17911842!--                 surface temperature for surfaces
    17921843                    IF ( l == -1 ) THEN
    17931844                       IF ( .NOT.  ALLOCATED(surf_usm_h%t_surf_wall_av) )  THEN
    1794                            ALLOCATE( surf_usm_h%t_surf_wall_av(1:surf_usm_h%ns) )
     1845                           ALLOCATE ( surf_usm_h%t_surf_wall_av(1:surf_usm_h%ns) )
    17951846                           surf_usm_h%t_surf_wall_av = 0.0_wp
    17961847                       ENDIF
    17971848                    ELSE
    17981849                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%t_surf_wall_av) )  THEN
    1799                            ALLOCATE( surf_usm_v(l)%t_surf_wall_av(1:surf_usm_v(l)%ns) )
     1850                           ALLOCATE ( surf_usm_v(l)%t_surf_wall_av(1:surf_usm_v(l)%ns) )
    18001851                           surf_usm_v(l)%t_surf_wall_av = 0.0_wp
    18011852                       ENDIF
     
    18031854
    18041855                CASE ( 'usm_t_surf_window' )
     1856!
    18051857!--                 surface temperature for window surfaces
    18061858                    IF ( l == -1 ) THEN
    18071859                       IF ( .NOT.  ALLOCATED(surf_usm_h%t_surf_window_av) )  THEN
    1808                            ALLOCATE( surf_usm_h%t_surf_window_av(1:surf_usm_h%ns) )
     1860                           ALLOCATE ( surf_usm_h%t_surf_window_av(1:surf_usm_h%ns) )
    18091861                           surf_usm_h%t_surf_window_av = 0.0_wp
    18101862                       ENDIF
    18111863                    ELSE
    18121864                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%t_surf_window_av) )  THEN
    1813                            ALLOCATE( surf_usm_v(l)%t_surf_window_av(1:surf_usm_v(l)%ns) )
     1865                           ALLOCATE ( surf_usm_v(l)%t_surf_window_av(1:surf_usm_v(l)%ns) )
    18141866                           surf_usm_v(l)%t_surf_window_av = 0.0_wp
    18151867                       ENDIF
     
    18171869                   
    18181870                CASE ( 'usm_t_surf_green' )
     1871!
    18191872!--                 surface temperature for green surfaces
    18201873                    IF ( l == -1 ) THEN
    18211874                       IF ( .NOT.  ALLOCATED(surf_usm_h%t_surf_green_av) )  THEN
    1822                            ALLOCATE( surf_usm_h%t_surf_green_av(1:surf_usm_h%ns) )
     1875                           ALLOCATE ( surf_usm_h%t_surf_green_av(1:surf_usm_h%ns) )
    18231876                           surf_usm_h%t_surf_green_av = 0.0_wp
    18241877                       ENDIF
    18251878                    ELSE
    18261879                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%t_surf_green_av) )  THEN
    1827                            ALLOCATE( surf_usm_v(l)%t_surf_green_av(1:surf_usm_v(l)%ns) )
     1880                           ALLOCATE ( surf_usm_v(l)%t_surf_green_av(1:surf_usm_v(l)%ns) )
    18281881                           surf_usm_v(l)%t_surf_green_av = 0.0_wp
    18291882                       ENDIF
     
    18311884               
    18321885                CASE ( 'usm_theta_10cm' )
     1886!
    18331887!--                 near surface (10cm) temperature for whole surfaces
    18341888                    IF ( l == -1 ) THEN
    18351889                       IF ( .NOT.  ALLOCATED(surf_usm_h%pt_10cm_av) )  THEN
    1836                            ALLOCATE( surf_usm_h%pt_10cm_av(1:surf_usm_h%ns) )
     1890                           ALLOCATE ( surf_usm_h%pt_10cm_av(1:surf_usm_h%ns) )
    18371891                           surf_usm_h%pt_10cm_av = 0.0_wp
    18381892                       ENDIF
    18391893                    ELSE
    18401894                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%pt_10cm_av) )  THEN
    1841                            ALLOCATE( surf_usm_v(l)%pt_10cm_av(1:surf_usm_v(l)%ns) )
     1895                           ALLOCATE ( surf_usm_v(l)%pt_10cm_av(1:surf_usm_v(l)%ns) )
    18421896                           surf_usm_v(l)%pt_10cm_av = 0.0_wp
    18431897                       ENDIF
     
    18451899                 
    18461900                CASE ( 'usm_t_wall' )
     1901!
    18471902!--                 wall temperature for iwl layer of walls and land
    18481903                    IF ( l == -1 ) THEN
    18491904                       IF ( .NOT.  ALLOCATED(surf_usm_h%t_wall_av) )  THEN
    1850                            ALLOCATE( surf_usm_h%t_wall_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
     1905                           ALLOCATE ( surf_usm_h%t_wall_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
    18511906                           surf_usm_h%t_wall_av = 0.0_wp
    18521907                       ENDIF
    18531908                    ELSE
    18541909                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%t_wall_av) )  THEN
    1855                            ALLOCATE( surf_usm_v(l)%t_wall_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
     1910                           ALLOCATE ( surf_usm_v(l)%t_wall_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
    18561911                           surf_usm_v(l)%t_wall_av = 0.0_wp
    18571912                       ENDIF
     
    18591914
    18601915                CASE ( 'usm_t_window' )
     1916!
    18611917!--                 window temperature for iwl layer of walls and land
    18621918                    IF ( l == -1 ) THEN
    18631919                       IF ( .NOT.  ALLOCATED(surf_usm_h%t_window_av) )  THEN
    1864                            ALLOCATE( surf_usm_h%t_window_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
     1920                           ALLOCATE ( surf_usm_h%t_window_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
    18651921                           surf_usm_h%t_window_av = 0.0_wp
    18661922                       ENDIF
    18671923                    ELSE
    18681924                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%t_window_av) )  THEN
    1869                            ALLOCATE( surf_usm_v(l)%t_window_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
     1925                           ALLOCATE ( surf_usm_v(l)%t_window_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
    18701926                           surf_usm_v(l)%t_window_av = 0.0_wp
    18711927                       ENDIF
     
    18731929
    18741930                CASE ( 'usm_t_green' )
     1931!
    18751932!--                 green temperature for iwl layer of walls and land
    18761933                    IF ( l == -1 ) THEN
    18771934                       IF ( .NOT.  ALLOCATED(surf_usm_h%t_green_av) )  THEN
    1878                            ALLOCATE( surf_usm_h%t_green_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
     1935                           ALLOCATE ( surf_usm_h%t_green_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
    18791936                           surf_usm_h%t_green_av = 0.0_wp
    18801937                       ENDIF
    18811938                    ELSE
    18821939                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%t_green_av) )  THEN
    1883                            ALLOCATE( surf_usm_v(l)%t_green_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
     1940                           ALLOCATE ( surf_usm_v(l)%t_green_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
    18841941                           surf_usm_v(l)%t_green_av = 0.0_wp
    18851942                       ENDIF
    18861943                    ENDIF
    18871944                CASE ( 'usm_swc' )
     1945!
    18881946!--                 soil water content for iwl layer of walls and land
    18891947                    IF ( l == -1 .AND. .NOT.  ALLOCATED(surf_usm_h%swc_av) )  THEN
    1890                         ALLOCATE( surf_usm_h%swc_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
     1948                        ALLOCATE ( surf_usm_h%swc_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
    18911949                        surf_usm_h%swc_av = 0.0_wp
    18921950                    ELSE
    18931951                       IF ( .NOT.  ALLOCATED(surf_usm_v(l)%swc_av) )  THEN
    1894                            ALLOCATE( surf_usm_v(l)%swc_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
     1952                           ALLOCATE ( surf_usm_v(l)%swc_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
    18951953                           surf_usm_v(l)%swc_av = 0.0_wp
    18961954                       ENDIF
     
    19071965
    19081966                CASE ( 'usm_wshf' )
     1967!
    19091968!--                 array of sensible heat flux from surfaces (land, roof, wall)
    19101969                    IF ( l == -1 ) THEN
     
    19231982                   
    19241983                CASE ( 'usm_qsws' )
     1984!
    19251985!--                 array of latent heat flux from surfaces (land, roof, wall)
    19261986                    IF ( l == -1 ) THEN
     
    19391999                   
    19402000                CASE ( 'usm_qsws_veg' )
     2001!
    19412002!--                 array of latent heat flux from vegetation surfaces (land, roof, wall)
    19422003                    IF ( l == -1 ) THEN
     
    19552016                   
    19562017                CASE ( 'usm_qsws_liq' )
     2018!
    19572019!--                 array of latent heat flux from surfaces with liquid (land, roof, wall)
    19582020                    IF ( l == -1 ) THEN
     
    19712033                   
    19722034                CASE ( 'usm_wghf' )
     2035!
    19732036!--                 array of heat flux from ground (wall, roof, land)
    19742037                    IF ( l == -1 ) THEN
     
    19872050                   
    19882051                CASE ( 'usm_wghf_window' )
     2052!
    19892053!--                 array of heat flux from window ground (wall, roof, land)
    19902054                    IF ( l == -1 ) THEN
     
    20032067
    20042068                CASE ( 'usm_wghf_green' )
     2069!
    20052070!--                 array of heat flux from green ground (wall, roof, land)
    20062071                    IF ( l == -1 ) THEN
     
    20192084                   
    20202085                CASE ( 'usm_iwghf' )
     2086!
    20212087!--                 array of heat flux from indoor ground (wall, roof, land)
    20222088                    IF ( l == -1 ) THEN
     
    20352101                   
    20362102                CASE ( 'usm_iwghf_window' )
     2103!
    20372104!--                 array of heat flux from indoor window ground (wall, roof, land)
    20382105                    IF ( l == -1 ) THEN
     
    20512118                   
    20522119                CASE ( 'usm_t_surf_wall' )
     2120!
    20532121!--                 surface temperature for surfaces
    20542122                    IF ( l == -1 ) THEN
     
    20672135                   
    20682136                CASE ( 'usm_t_surf_window' )
     2137!
    20692138!--                 surface temperature for window surfaces
    20702139                    IF ( l == -1 ) THEN
     
    20832152                   
    20842153                CASE ( 'usm_t_surf_green' )
     2154!
    20852155!--                 surface temperature for green surfaces
    20862156                    IF ( l == -1 ) THEN
     
    20992169               
    21002170                CASE ( 'usm_theta_10cm' )
     2171!
    21012172!--                 near surface temperature for whole surfaces
    21022173                    IF ( l == -1 ) THEN
     
    21152186                   
    21162187                CASE ( 'usm_t_wall' )
     2188!
    21172189!--                 wall temperature for  iwl layer of walls and land
    21182190                    IF ( l == -1 ) THEN
     
    21312203                   
    21322204                CASE ( 'usm_t_window' )
     2205!
    21332206!--                 window temperature for  iwl layer of walls and land
    21342207                    IF ( l == -1 ) THEN
     
    21472220
    21482221                CASE ( 'usm_t_green' )
     2222!
    21492223!--                 green temperature for  iwl layer of walls and land
    21502224                    IF ( l == -1 ) THEN
     
    21632237
    21642238                CASE ( 'usm_swc' )
     2239!
    21652240!--                 soil water content for  iwl layer of walls and land
    21662241                    IF ( l == -1 ) THEN
     
    21882263
    21892264                CASE ( 'usm_wshf' )
     2265!
    21902266!--                 array of sensible heat flux from surfaces (land, roof, wall)
    21912267                    IF ( l == -1 ) THEN
     
    22042280                   
    22052281                CASE ( 'usm_qsws' )
     2282!
    22062283!--                 array of latent heat flux from surfaces (land, roof, wall)
    22072284                    IF ( l == -1 ) THEN
     
    22202297
    22212298                CASE ( 'usm_qsws_veg' )
     2299!
    22222300!--                 array of latent heat flux from vegetation surfaces (land, roof, wall)
    22232301                    IF ( l == -1 ) THEN
     
    22362314                   
    22372315                CASE ( 'usm_qsws_liq' )
     2316!
    22382317!--                 array of latent heat flux from surfaces with liquid (land, roof, wall)
    22392318                    IF ( l == -1 ) THEN
     
    22522331                   
    22532332                CASE ( 'usm_wghf' )
     2333!
    22542334!--                 array of heat flux from ground (wall, roof, land)
    22552335                    IF ( l == -1 ) THEN
     
    22682348                   
    22692349                CASE ( 'usm_wghf_window' )
     2350!
    22702351!--                 array of heat flux from window ground (wall, roof, land)
    22712352                    IF ( l == -1 ) THEN
     
    22842365
    22852366                CASE ( 'usm_wghf_green' )
     2367!
    22862368!--                 array of heat flux from green ground (wall, roof, land)
    22872369                    IF ( l == -1 ) THEN
     
    23002382
    23012383                CASE ( 'usm_iwghf' )
     2384!
    23022385!--                 array of heat flux from indoor ground (wall, roof, land)
    23032386                    IF ( l == -1 ) THEN
     
    23162399                   
    23172400                CASE ( 'usm_iwghf_window' )
     2401!
    23182402!--                 array of heat flux from indoor window ground (wall, roof, land)
    23192403                    IF ( l == -1 ) THEN
     
    23322416                   
    23332417                CASE ( 'usm_t_surf_wall' )
     2418!
    23342419!--                 surface temperature for surfaces
    23352420                    IF ( l == -1 ) THEN
     
    23482433                   
    23492434                CASE ( 'usm_t_surf_window' )
     2435!
    23502436!--                 surface temperature for window surfaces
    23512437                    IF ( l == -1 ) THEN
     
    23642450                   
    23652451                CASE ( 'usm_t_surf_green' )
     2452!
    23662453!--                 surface temperature for green surfaces
    23672454                    IF ( l == -1 ) THEN
     
    23802467                   
    23812468                CASE ( 'usm_theta_10cm' )
     2469!
    23822470!--                 near surface temperature for whole surfaces
    23832471                    IF ( l == -1 ) THEN
     
    23972485                   
    23982486                CASE ( 'usm_t_wall' )
     2487!
    23992488!--                 wall temperature for  iwl layer of walls and land
    24002489                    IF ( l == -1 ) THEN
     
    24132502
    24142503                CASE ( 'usm_t_window' )
     2504!
    24152505!--                 window temperature for  iwl layer of walls and land
    24162506                    IF ( l == -1 ) THEN
     
    24292519
    24302520                CASE ( 'usm_t_green' )
     2521!
    24312522!--                 green temperature for  iwl layer of walls and land
    24322523                    IF ( l == -1 ) THEN
     
    24452536                   
    24462537                CASE ( 'usm_swc' )
     2538!
    24472539!--                 soil water content for  iwl layer of walls and land
    24482540                    IF ( l == -1 ) THEN
     
    25262618        CHARACTER(LEN=*),INTENT(OUT)   ::  unit       !<
    25272619
    2528         INTEGER(iwp)                                  :: i,j,l        !< index
     2620        INTEGER(iwp)                                  :: i,j,l         !< index
    25292621        CHARACTER(LEN=2)                              :: ls
    2530         CHARACTER(LEN=varnamelength)                  :: var          !< TRIM(variable)
    2531         INTEGER(iwp), PARAMETER                       :: nl1 = 16     !< number of directional usm variables
    2532         CHARACTER(LEN=varnamelength), DIMENSION(nl1)  :: varlist1 = & !< list of directional usm variables
     2622        CHARACTER(LEN=varnamelength)                  :: var           !< TRIM(variable)
     2623        INTEGER(iwp), PARAMETER                       :: nl1 = 16      !< number of directional usm variables
     2624        CHARACTER(LEN=varnamelength), DIMENSION(nl1)  :: varlist1 = &  !< list of directional usm variables
    25332625                  (/'usm_wshf                      ', &
    25342626                    'usm_wghf                      ', &
     
    25482640                    'usm_theta_10cm                '/)
    25492641
    2550         INTEGER(iwp), PARAMETER                       :: nl2 = 3      !< number of directional layer usm variables
    2551         CHARACTER(LEN=varnamelength), DIMENSION(nl2)  :: varlist2 = & !< list of directional layer usm variables
     2642        INTEGER(iwp), PARAMETER                       :: nl2 = 3       !< number of directional layer usm variables
     2643        CHARACTER(LEN=varnamelength), DIMENSION(nl2)  :: varlist2 = &  !< list of directional layer usm variables
    25522644                  (/'usm_t_wall                    ', &
    25532645                    'usm_t_window                  ', &
     
    25642656        var = TRIM(variable)
    25652657
     2658!
    25662659!--     check if variable exists
    2567 !       directional variables
     2660!--     directional variables
    25682661        DO i = 1, nl1
    25692662           DO j = 1, nd
     
    25762669        ENDDO
    25772670        IF ( lfound ) GOTO 10
    2578 !       directional layer variables
     2671!
     2672!--     directional layer variables
    25792673        DO i = 1, nl2
    25802674           DO j = 1, nd
     
    26242718!------------------------------------------------------------------------------!
    26252719    SUBROUTINE usm_check_parameters
    2626    
     2720
    26272721       USE control_parameters,                                                 &
    26282722           ONLY:  bc_pt_b, bc_q_b, constant_flux_layer, large_scale_forcing,   &
    26292723                  lsf_surf, topography
    2630                  
     2724
    26312725       USE netcdf_data_input_mod,                                             &
    26322726            ONLY:  building_type_f
    26332727
    2634        IMPLICIT NONE           
    2635                  
     2728       IMPLICIT NONE
     2729
    26362730       INTEGER(iwp) ::  i        !< running index, x-dimension
    26372731       INTEGER(iwp) ::  j        !< running index, y-dimension
     2732
    26382733!
    26392734!--    Dirichlet boundary conditions are required as the surface fluxes are
     
    26802775       ENDIF
    26812776!
    2682 !--    Check if building types are set within a valid range.   
    2683        IF ( building_type < LBOUND( building_pars, 2 )  .AND.                 &
     2777!--    Check if building types are set within a valid range.
     2778       IF ( building_type < LBOUND( building_pars, 2 )  .AND.                  &
    26842779            building_type > UBOUND( building_pars, 2 ) )  THEN
    26852780          WRITE( message_string, * ) 'building_type = ', building_type,        &
     
    26962791                   WRITE( message_string, * ) 'building_type = is out of ' //  &
    26972792                                        'the valid range at (j,i) = ', j, i
    2698                    CALL message( 'usm_check_parameters', 'PA0529', 2, 2, 0, 6, 0 ) 
     2793                   CALL message( 'usm_check_parameters', 'PA0529', 2, 2, 0, 6, 0 )
    26992794                ENDIF
    27002795             ENDDO
    27012796          ENDDO
    27022797       ENDIF
    2703 
    27042798    END SUBROUTINE usm_check_parameters
    27052799
     
    27192813        IMPLICIT NONE
    27202814
    2721         INTEGER(iwp), INTENT(IN)       ::  av        !<
    2722         CHARACTER (len=*), INTENT(IN)  ::  variable  !<
     2815        INTEGER(iwp), INTENT(IN)       ::  av        !< flag if averaged
     2816        CHARACTER (len=*), INTENT(IN)  ::  variable  !< variable name
    27232817        INTEGER(iwp), INTENT(IN)       ::  nzb_do    !< lower limit of the data output (usually 0)
    27242818        INTEGER(iwp), INTENT(IN)       ::  nzt_do    !< vertical upper limit of the data output (usually nz_do3d)
     
    27272821        REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr)     ::  temp_pf    !< temp array for urban surface output procedure
    27282822       
    2729         CHARACTER (len=varnamelength)                          :: var
    2730         INTEGER(iwp), PARAMETER                                :: nd = 5
     2823        CHARACTER (len=varnamelength)                          :: var     !< trimmed variable name
     2824        INTEGER(iwp), PARAMETER                                :: nd = 5  !< number of directions
    27312825        CHARACTER(len=6), DIMENSION(0:nd-1), PARAMETER         :: dirname = (/ '_roof ', '_south', '_north', '_west ', '_east ' /)
    27322826        INTEGER(iwp), DIMENSION(0:nd-1), PARAMETER             :: dirint =  (/    iup_u, isouth_u, inorth_u,  iwest_u,  ieast_u /)
     
    27342828                                                                     !< index for surf_*_v: 0:3 = (North, South, East, West)
    27352829        INTEGER(iwp)                                           :: ids,idsint,idsidx,isvf
    2736         INTEGER(iwp)                                           :: i,j,k,iwl,istat, l, m
     2830        INTEGER(iwp)                                           :: i,j,k,iwl,istat, l, m  !< running indices
    27372831
    27382832        found = .TRUE.
     
    27562850        ENDIF
    27572851        IF ( var(1:11) == 'usm_t_wall_'  .AND.  len(TRIM(var)) >= 12 )  THEN
     2852!
    27582853!--         wall layers
    27592854            READ(var(12:12), '(I1)', iostat=istat ) iwl
     
    27632858        ENDIF
    27642859        IF ( var(1:13) == 'usm_t_window_'  .AND.  len(TRIM(var)) >= 14 )  THEN
     2860!
    27652861!--         window layers
    27662862            READ(var(14:14), '(I1)', iostat=istat ) iwl
     
    27702866        ENDIF
    27712867        IF ( var(1:12) == 'usm_t_green_'  .AND.  len(TRIM(var)) >= 13 )  THEN
     2868!
    27722869!--         green layers
    27732870            READ(var(13:13), '(I1)', iostat=istat ) iwl
     
    27772874        ENDIF
    27782875        IF ( var(1:8) == 'usm_swc_'  .AND.  len(TRIM(var)) >= 9 )  THEN
     2876!
    27792877!--         green layers soil water content
    27802878            READ(var(9:9), '(I1)', iostat=istat ) iwl
     
    27872885
    27882886          CASE ( 'usm_surfz' )
     2887!
    27892888!--           array of surface height (z)
    27902889              IF ( idsint == iup_u )  THEN
     
    28062905
    28072906          CASE ( 'usm_surfcat' )
     2907!
    28082908!--           surface category
    28092909              IF ( idsint == iup_u )  THEN
     
    28252925             
    28262926          CASE ( 'usm_surfalb' )
     2927!
    28272928!--           surface albedo, weighted average
    28282929              IF ( idsint == iup_u )  THEN
     
    28542955             
    28552956          CASE ( 'usm_surfemis' )
     2957!
    28562958!--           surface emissivity, weighted average
    28572959              IF ( idsint == iup_u )  THEN
     
    28832985
    28842986          CASE ( 'usm_surfwintrans' )
     2987!
    28852988!--           transmissivity window tiles
    28862989              IF ( idsint == iup_u )  THEN
     
    29023005
    29033006          CASE ( 'usm_wshf' )
     3007!
    29043008!--           array of sensible heat flux from surfaces
    29053009              IF ( av == 0 )  THEN
     
    29413045             
    29423046          CASE ( 'usm_qsws' )
     3047!
    29433048!--           array of latent heat flux from surfaces
    29443049              IF ( av == 0 )  THEN
     
    29793084             
    29803085          CASE ( 'usm_qsws_veg' )
     3086!
    29813087!--           array of latent heat flux from vegetation surfaces
    29823088              IF ( av == 0 )  THEN
     
    30173123             
    30183124          CASE ( 'usm_qsws_liq' )
     3125!
    30193126!--           array of latent heat flux from surfaces with liquid
    30203127              IF ( av == 0 )  THEN
     
    30553162
    30563163          CASE ( 'usm_wghf' )
     3164!
    30573165!--           array of heat flux from ground (land, wall, roof)
    30583166              IF ( av == 0 )  THEN
     
    30933201
    30943202          CASE ( 'usm_wghf_window' )
     3203!
    30953204!--           array of heat flux from window ground (land, wall, roof)
    3096 
    30973205              IF ( av == 0 )  THEN
    30983206                 IF ( idsint == iup_u )  THEN
     
    31323240
    31333241          CASE ( 'usm_wghf_green' )
     3242!
    31343243!--           array of heat flux from green ground (land, wall, roof)
    3135 
    31363244              IF ( av == 0 )  THEN
    31373245                 IF ( idsint == iup_u )  THEN
     
    31713279
    31723280          CASE ( 'usm_iwghf' )
     3281!
    31733282!--           array of heat flux from indoor ground (land, wall, roof)
    31743283              IF ( av == 0 )  THEN
     
    32093318
    32103319          CASE ( 'usm_iwghf_window' )
     3320!
    32113321!--           array of heat flux from indoor window ground (land, wall, roof)
    3212 
    32133322              IF ( av == 0 )  THEN
    32143323                 IF ( idsint == iup_u )  THEN
     
    32483357             
    32493358          CASE ( 'usm_t_surf_wall' )
     3359!
    32503360!--           surface temperature for surfaces
    32513361              IF ( av == 0 )  THEN
     
    32863396             
    32873397          CASE ( 'usm_t_surf_window' )
     3398!
    32883399!--           surface temperature for window surfaces
    3289 
    32903400              IF ( av == 0 )  THEN
    32913401                 IF ( idsint == iup_u )  THEN
     
    33283438
    33293439          CASE ( 'usm_t_surf_green' )
     3440!
    33303441!--           surface temperature for green surfaces
    3331 
    33323442              IF ( av == 0 )  THEN
    33333443                 IF ( idsint == iup_u )  THEN
     
    33703480
    33713481          CASE ( 'usm_theta_10cm' )
     3482!
    33723483!--           near surface temperature for whole surfaces
    3373 
    33743484              IF ( av == 0 )  THEN
    33753485                 IF ( idsint == iup_u )  THEN
     
    34123522             
    34133523          CASE ( 'usm_t_wall' )
     3524!
    34143525!--           wall temperature for  iwl layer of walls and land
    34153526              IF ( av == 0 )  THEN
     
    34503561             
    34513562          CASE ( 'usm_t_window' )
     3563!
    34523564!--           window temperature for iwl layer of walls and land
    34533565              IF ( av == 0 )  THEN
     
    34883600
    34893601          CASE ( 'usm_t_green' )
     3602!
    34903603!--           green temperature for  iwl layer of walls and land
    34913604              IF ( av == 0 )  THEN
     
    35263639             
    35273640              CASE ( 'usm_swc' )
     3641!
    35283642!--           soil water content for  iwl layer of walls and land
    35293643              IF ( av == 0 )  THEN
     
    36123726             var(1:16) == 'usm_t_surf_green'  .OR. var(1:11) == 'usm_t_green' .OR.          &
    36133727             var(1:15) == 'usm_theta_10cm' .OR.                                             &
    3614              var(1:9) == 'usm_surfz'  .OR.  var(1:11) == 'usm_surfcat'  .OR.                  &
     3728             var(1:9) == 'usm_surfz'  .OR.  var(1:11) == 'usm_surfcat'  .OR.                &
    36153729             var(1:11) == 'usm_surfalb'  .OR.  var(1:12) == 'usm_surfemis'  .OR.            &
    36163730             var(1:16) == 'usm_surfwintrans'  .OR. var(1:7) == 'usm_swc' ) THEN
     
    36423756       
    36433757        CALL location_message( '    initialization of wall surface model', .TRUE. )
    3644        
     3758
     3759!
    36453760!--     Calculate wall grid spacings.
    36463761!--     Temperature is defined at the center of the wall layers,
     
    36593774                                         surf_usm_h%zw_window(k-1,m)
    36603775           ENDDO
    3661 !            surf_usm_h%dz_green(nzb_wall,m) = surf_usm_h%zw_green(nzb_wall,m)
    3662 !            DO k = nzb_wall+1, nzt_wall
    3663 !                surf_usm_h%dz_green(k,m) = surf_usm_h%zw_green(k,m) -           &
    3664 !                                          surf_usm_h%zw_green(k-1,m)
    3665 !            ENDDO
    36663776           
    36673777           surf_usm_h%dz_wall(nzt_wall+1,m) = surf_usm_h%dz_wall(nzt_wall,m)
     
    36813791           surf_usm_h%dz_window_stag(nzt_wall,m) = surf_usm_h%dz_window(nzt_wall,m)
    36823792
    3683 !            surf_usm_h%dz_green(nzt_wall+1,m) = surf_usm_h%dz_green(nzt_wall,m)
    3684 !
    3685 !            DO k = nzb_wall, nzt_wall-1
    3686 !                surf_usm_h%dz_green_stag(k,m) = 0.5 * (                         &
    3687 !                            surf_usm_h%dz_green(k+1,m) + surf_usm_h%dz_green(k,m) )
    3688 !            ENDDO
    3689 !            surf_usm_h%dz_green_stag(nzt_wall,m) = surf_usm_h%dz_green(nzt_wall,m)
    3690 !-------------           
    3691            IF (surf_usm_h%green_type_roof(m) == 2.0_wp ) then
    3692              soil_type = 3 !extensiv green roof
    3693              surf_usm_h%lai(m) = 2.0_wp
     3793           IF (surf_usm_h%green_type_roof(m) == 2.0_wp ) THEN
     3794!
     3795!-- extensive green roof
     3796!-- set ratio of substrate layer thickness, soil-type and LAI
     3797              soil_type = 3
     3798              surf_usm_h%lai(m) = 2.0_wp
    36943799             
    3695            surf_usm_h%zw_green(nzb_wall,m)         = 0.05_wp
    3696            surf_usm_h%zw_green(nzb_wall+1,m)      = 0.10_wp
    3697            surf_usm_h%zw_green(nzb_wall+2,m)      = 0.15_wp
    3698            surf_usm_h%zw_green(nzb_wall+3,m)      = 0.20_wp
     3800              surf_usm_h%zw_green(nzb_wall,m)   = 0.05_wp
     3801              surf_usm_h%zw_green(nzb_wall+1,m) = 0.10_wp
     3802              surf_usm_h%zw_green(nzb_wall+2,m) = 0.15_wp
     3803              surf_usm_h%zw_green(nzb_wall+3,m) = 0.20_wp
    36993804           ELSE
    3700              soil_type = 6 !intensiv green roof
    3701              surf_usm_h%lai(m) = 4.0_wp
     3805!
     3806!-- intensiv green roof
     3807!-- set ratio of substrate layer thickness, soil-type and LAI
     3808              soil_type = 6
     3809              surf_usm_h%lai(m) = 4.0_wp
    37023810             
    3703            surf_usm_h%zw_green(nzb_wall,m)         = 0.05_wp
    3704            surf_usm_h%zw_green(nzb_wall+1,m)      = 0.10_wp
    3705            surf_usm_h%zw_green(nzb_wall+2,m)      = 0.40_wp
    3706            surf_usm_h%zw_green(nzb_wall+3,m)      = 0.80_wp
     3811              surf_usm_h%zw_green(nzb_wall,m)   = 0.05_wp
     3812              surf_usm_h%zw_green(nzb_wall+1,m) = 0.10_wp
     3813              surf_usm_h%zw_green(nzb_wall+2,m) = 0.40_wp
     3814              surf_usm_h%zw_green(nzb_wall+3,m) = 0.80_wp
    37073815           ENDIF
    37083816           
     
    37583866             surf_usm_h%l_vg_green(m)          = l_vangenuchten
    37593867             surf_usm_h%n_vg_green(m)          = n_vangenuchten
    3760              surf_usm_h%gamma_w_green_sat(k,m)   = hydraulic_conductivity
     3868             surf_usm_h%gamma_w_green_sat(k,m) = hydraulic_conductivity
    37613869             swc_sat_h(k,m)                    = saturation_moisture
    37623870             fc_h(k,m)                         = field_capacity
     
    37643872             swc_res_h(k,m)                    = residual_moisture
    37653873          ENDDO
    3766 !-------------------------------           
     3874
    37673875        ENDDO
     3876
    37683877        surf_usm_h%ddz_wall        = 1.0_wp / surf_usm_h%dz_wall
    37693878        surf_usm_h%ddz_wall_stag   = 1.0_wp / surf_usm_h%dz_wall_stag
     
    38023911              surf_usm_v(l)%dz_wall_stag(nzt_wall,m) =                         &
    38033912                                              surf_usm_v(l)%dz_wall(nzt_wall,m)
    3804               surf_usm_v(l)%dz_window(nzt_wall+1,m) =                            &
     3913              surf_usm_v(l)%dz_window(nzt_wall+1,m) =                          &
    38053914                                              surf_usm_v(l)%dz_window(nzt_wall,m)
    38063915
     
    38123921              surf_usm_v(l)%dz_window_stag(nzt_wall,m) =                         &
    38133922                                              surf_usm_v(l)%dz_window(nzt_wall,m)
    3814               surf_usm_v(l)%dz_green(nzt_wall+1,m) =                            &
     3923              surf_usm_v(l)%dz_green(nzt_wall+1,m) =                             &
    38153924                                              surf_usm_v(l)%dz_green(nzt_wall,m)
    38163925
     
    38313940        ENDDO     
    38323941
    3833        
    3834 !     soil_type = 6
    3835 ! !--    Initialize standard soil types. It is possible to overwrite each
    3836 ! !--    parameter by setting the respecticy NAMELIST variable to a
    3837 ! !--    value /= 9999999.9.
    3838 !        IF ( soil_type /= 0 )  THEN 
    3839 
    3840 !           IF ( alpha_vangenuchten == 9999999.9_wp )  THEN
    3841 !              alpha_vangenuchten = soil_pars(0,soil_type)
    3842 !           ENDIF
    3843 !
    3844 !           IF ( l_vangenuchten == 9999999.9_wp )  THEN
    3845 !              l_vangenuchten = soil_pars(1,soil_type)
    3846 !           ENDIF
    3847 !
    3848 !           IF ( n_vangenuchten == 9999999.9_wp )  THEN
    3849 !              n_vangenuchten = soil_pars(2,soil_type)           
    3850 !           ENDIF
    3851 !
    3852 !           IF ( hydraulic_conductivity == 9999999.9_wp )  THEN
    3853 !              hydraulic_conductivity = soil_pars(3,soil_type)           
    3854 !           ENDIF
    3855 !
    3856 !           IF ( saturation_moisture == 9999999.9_wp )  THEN
    3857 !              saturation_moisture = m_soil_pars(0,soil_type)           
    3858 !           ENDIF
    3859 !
    3860 !           IF ( field_capacity == 9999999.9_wp )  THEN
    3861 !              field_capacity = m_soil_pars(1,soil_type)           
    3862 !           ENDIF
    3863 !
    3864 !           IF ( wilting_point == 9999999.9_wp )  THEN
    3865 !              wilting_point = m_soil_pars(2,soil_type)           
    3866 !           ENDIF
    3867 !
    3868 !           IF ( residual_moisture == 9999999.9_wp )  THEN
    3869 !              residual_moisture = m_soil_pars(3,soil_type)       
    3870 !           ENDIF
    3871 !           
    3872 !             DO  m = 1, surf_usm_h%ns
    3873 !                DO k = nzb_wall, nzt_wall+1
    3874 !                    swc_h(k,m) = field_capacity
    3875 !                    rootfr_h(k,m) = 0.5_wp
    3876 !                ENDDO
    3877 !             ENDDO
    3878 ! ! !
    3879 ! ! !--         Vertical surfaces
    3880 ! !             DO  l = 0, 3
    3881 ! !                DO  m = 1, surf_usm_v(l)%ns
    3882 ! !                   DO k = nzb_wall, nzt_wall+1
    3883 ! !                      swc_v(l)%t(k,m) = 0.5_wp
    3884 ! !                   ENDDO
    3885 ! !                ENDDO
    3886 ! !             ENDDO
    3887 !
    3888 !        ENDIF
    3889 !
    3890 ! !
    3891 ! !--    Map values to the respective 2D arrays
    3892 !        surf_usm_h%alpha_vg_green      = alpha_vangenuchten
    3893 !        surf_usm_h%l_vg_green          = l_vangenuchten
    3894 !        surf_usm_h%n_vg_green          = n_vangenuchten
    3895 !        surf_usm_h%gamma_w_green_sat   = hydraulic_conductivity
    3896 !        swc_sat_h         = saturation_moisture
    3897 !        fc_h          = field_capacity
    3898 !        wilt_h        = wilting_point
    3899 !        swc_res_h         = residual_moisture
    3900 ! !        r_soil_min    = min_soil_resistance
    39013942       
    39023943        CALL location_message( '    wall structures filed out', .TRUE. )
     
    39714012
    39724013        CALL cpu_log( log_point_s(78), 'usm_init', 'start' )
     4014!
    39734015!--     surface forcing have to be disabled for LSF
    39744016!--     in case of enabled urban surface module
     
    40374079!
    40384080!--           Set flag for ground level
    4039               IF ( z_agl <= ground_floor_level_l )                                &
     4081              IF ( z_agl <= ground_floor_level_l )                             &
    40404082                 surf_usm_v(l)%ground_level(m) = .TRUE.
    40414083
     
    40574099        ENDDO
    40584100       
    4059 !---------------------------------------------------------------------------------------------
    40604101!
    40614102!--    Map values onto horizontal elemements
    40624103       DO  m = 1, surf_usm_h%ns
    4063              surf_usm_h%r_canopy_min(m)     = 200.0_wp !min_canopy_resistance
    4064              surf_usm_h%g_d(m)              = 0.0_wp !canopy_resistance_coefficient
     4104             surf_usm_h%r_canopy_min(m)     = 200.0_wp !< min_canopy_resistance
     4105             surf_usm_h%g_d(m)              = 0.0_wp   !< canopy_resistance_coefficient
    40654106       ENDDO
    40664107!
     
    40694110       DO  l = 0, 3
    40704111          DO  m = 1, surf_usm_v(l)%ns
    4071                 surf_usm_v(l)%r_canopy_min(m)     = 200.0_wp !min_canopy_resistance
    4072                 surf_usm_v(l)%g_d(m)              = 0.0_wp !canopy_resistance_coefficient
     4112                surf_usm_v(l)%r_canopy_min(m)     = 200.0_wp !< min_canopy_resistance
     4113                surf_usm_v(l)%g_d(m)              = 0.0_wp   !< canopy_resistance_coefficient
    40734114          ENDDO
    40744115       ENDDO
    4075 !---------------------------------------------------------------------------------------------
    4076 !
     4116
    40774117!
    40784118!--     Initialize urban-type surface attribute. According to initialization in
     
    46374677              IF ( building_pars_f%pars_xy(ind_wall_frac_r,j,i) /= building_pars_f%fill )    &
    46384678                 surf_usm_h%frac(ind_veg_wall,m)  = building_pars_f%pars_xy(ind_wall_frac_r,j,i)   
    4639               IF ( building_pars_f%pars_xy(ind_green_frac_r,j,i) /= building_pars_f%fill ) &
     4679              IF ( building_pars_f%pars_xy(ind_green_frac_r,j,i) /= building_pars_f%fill )   &
    46404680                 surf_usm_h%frac(ind_pav_green,m) = building_pars_f%pars_xy(ind_green_frac_r,j,i)
    46414681              IF ( building_pars_f%pars_xy(ind_win_frac_r,j,i) /= building_pars_f%fill )     &
     
    46434683
    46444684 
    4645               IF ( building_pars_f%pars_xy(ind_lai_r,j,i) /= building_pars_f%fill )        &
     4685              IF ( building_pars_f%pars_xy(ind_lai_r,j,i) /= building_pars_f%fill )          &
    46464686                 surf_usm_h%lai(m)             = building_pars_f%pars_xy(ind_lai_r,j,i)
    46474687
     
    47204760              IF ( building_pars_f%pars_xy(ind_alb_wall_r,j,i) /= building_pars_f%fill )    &
    47214761                 surf_usm_h%albedo_type(ind_veg_wall,m)  = building_pars_f%pars_xy(ind_alb_wall_r,j,i)
    4722               IF ( building_pars_f%pars_xy(ind_alb_green_r,j,i) /= building_pars_f%fill )    &
     4762              IF ( building_pars_f%pars_xy(ind_alb_green_r,j,i) /= building_pars_f%fill )   &
    47234763                 surf_usm_h%albedo_type(ind_pav_green,m) = building_pars_f%pars_xy(ind_alb_green_r,j,i)
    4724               IF ( building_pars_f%pars_xy(ind_alb_win_r,j,i) /= building_pars_f%fill )    &
     4764              IF ( building_pars_f%pars_xy(ind_alb_win_r,j,i) /= building_pars_f%fill )     &
    47254765                 surf_usm_h%albedo_type(ind_wat_win,m)   = building_pars_f%pars_xy(ind_alb_win_r,j,i)
    47264766
     
    47414781              IF ( building_pars_f%pars_xy(ind_thick_4_wall_r,j,i) /= building_pars_f%fill )    &
    47424782                 surf_usm_h%zw_green(nzb_wall+3,m) = building_pars_f%pars_xy(ind_thick_4_wall_r,j,i)
    4743               IF ( building_pars_f%pars_xy(ind_thick_1_win_r,j,i) /= building_pars_f%fill )    &
     4783              IF ( building_pars_f%pars_xy(ind_thick_1_win_r,j,i) /= building_pars_f%fill )     &
    47444784                 surf_usm_h%zw_window(nzb_wall,m) = building_pars_f%pars_xy(ind_thick_1_win_r,j,i)
    4745               IF ( building_pars_f%pars_xy(ind_thick_2_win_r,j,i) /= building_pars_f%fill )    &
     4785              IF ( building_pars_f%pars_xy(ind_thick_2_win_r,j,i) /= building_pars_f%fill )     &
    47464786                 surf_usm_h%zw_window(nzb_wall+1,m) = building_pars_f%pars_xy(ind_thick_2_win_r,j,i)
    4747               IF ( building_pars_f%pars_xy(ind_thick_3_win_r,j,i) /= building_pars_f%fill )    &
     4787              IF ( building_pars_f%pars_xy(ind_thick_3_win_r,j,i) /= building_pars_f%fill )     &
    47484788                 surf_usm_h%zw_window(nzb_wall+2,m) = building_pars_f%pars_xy(ind_thick_3_win_r,j,i)
    4749               IF ( building_pars_f%pars_xy(ind_thick_4_win_r,j,i) /= building_pars_f%fill )    &
     4789              IF ( building_pars_f%pars_xy(ind_thick_4_win_r,j,i) /= building_pars_f%fill )     &
    47504790                 surf_usm_h%zw_window(nzb_wall+3,m) = building_pars_f%pars_xy(ind_thick_4_win_r,j,i)
    47514791
     
    47834823                 ind_alb_win      = MERGE( ind_alb_win_gfl,      ind_alb_win_agfl,      &
    47844824                                           surf_usm_v(l)%ground_level(m) )
    4785                  ind_wall_frac    = MERGE( ind_wall_frac_gfl,    ind_wall_frac_agfl,     &
     4825                 ind_wall_frac    = MERGE( ind_wall_frac_gfl,    ind_wall_frac_agfl,    &
    47864826                                           surf_usm_v(l)%ground_level(m) )
    47874827                 ind_win_frac     = MERGE( ind_win_frac_gfl,     ind_win_frac_agfl,     &
     
    49474987                 IF ( building_pars_f%pars_xy(ind_alb_wall,j,i) /= building_pars_f%fill )    &
    49484988                    surf_usm_v(l)%albedo_type(ind_veg_wall,m)  = building_pars_f%pars_xy(ind_alb_wall,j,i)
    4949                  IF ( building_pars_f%pars_xy(ind_alb_green,j,i) /= building_pars_f%fill )    &
     4989                 IF ( building_pars_f%pars_xy(ind_alb_green,j,i) /= building_pars_f%fill )   &
    49504990                    surf_usm_v(l)%albedo_type(ind_pav_green,m) = building_pars_f%pars_xy(ind_alb_green,j,i)
    4951                  IF ( building_pars_f%pars_xy(ind_alb_win,j,i) /= building_pars_f%fill )    &
     4991                 IF ( building_pars_f%pars_xy(ind_alb_win,j,i) /= building_pars_f%fill )     &
    49524992                    surf_usm_v(l)%albedo_type(ind_wat_win,m)   = building_pars_f%pars_xy(ind_alb_win,j,i)
    49534993
     
    50015041        CALL usm_read_urban_surface_types()
    50025042       
    5003 !--     init material heat model
    50045043        CALL usm_init_material_model()
    5005        
     5044!       
    50065045!--     init anthropogenic sources of heat
    50075046        IF ( usm_anthropogenic_heat )  THEN
     5047!
    50085048!--         init anthropogenic sources of heat (from transportation for now)
    50095049            CALL usm_read_anthropogenic_heat()
     
    50465086                surf_usm_v(l)%z0(m) = 0.9_wp * surf_usm_v(l)%z_mo(m)
    50475087             
    5048                 WRITE( message_string, * ) 'z0 exceeds surface-layer height '//&
    5049                             'at vertical urban surface and is ' //             &
    5050                             'decreased appropriately at grid point (i,j) = ',  &
    5051                             surf_usm_v(l)%i(m)+surf_usm_v(l)%ioff,             &
     5088                WRITE( message_string, * ) 'z0 exceeds surface-layer height '// &
     5089                            'at vertical urban surface and is ' //              &
     5090                            'decreased appropriately at grid point (i,j) = ',   &
     5091                            surf_usm_v(l)%i(m)+surf_usm_v(l)%ioff,              &
    50525092                            surf_usm_v(l)%j(m)+surf_usm_v(l)%joff
    5053                 CALL message( 'urban_surface_model_mod', 'PA0503',             &
     5093                CALL message( 'urban_surface_model_mod', 'PA0503',              &
    50545094                            0, 0, 0, 6, 0 )
    50555095             ENDIF
     
    50595099                surf_usm_v(l)%z0q(m) = 0.9_wp * surf_usm_v(l)%z_mo(m)
    50605100             
    5061                 WRITE( message_string, * ) 'z0h exceeds surface-layer height '//&
    5062                             'at vertical urban surface and is ' //             &
    5063                             'decreased appropriately at grid point (i,j) = ',  &
    5064                             surf_usm_v(l)%i(m)+surf_usm_v(l)%ioff,             &
     5101                WRITE( message_string, * ) 'z0h exceeds surface-layer height '// &
     5102                            'at vertical urban surface and is ' //               &
     5103                            'decreased appropriately at grid point (i,j) = ',    &
     5104                            surf_usm_v(l)%i(m)+surf_usm_v(l)%ioff,               &
    50655105                            surf_usm_v(l)%j(m)+surf_usm_v(l)%joff
    5066                 CALL message( 'urban_surface_model_mod', 'PA0507',             &
     5106                CALL message( 'urban_surface_model_mod', 'PA0507',               &
    50675107                            0, 0, 0, 6, 0 )
    50685108             ENDIF
    50695109          ENDDO
    5070        ENDDO   
    5071 
     5110       ENDDO
     5111
     5112!
    50725113!--     Intitialization of the surface and wall/ground/roof temperature
    5073 
     5114!
    50745115!--     Initialization for restart runs
    50755116        IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.        &
     
    51175158               ENDDO
    51185159            ENDIF
    5119      
     5160!
    51205161!--         initial values for t_wall
    51215162!--         outer value is set to surface temperature
     
    51725213        ENDIF
    51735214
     5215!
    51745216!--     If specified, replace constant wall temperatures with fully 3D values from file
    51755217        IF ( read_wall_temp_3d )  CALL usm_read_wall_temperature()
     
    51795221        CALL user_init_urban_surface
    51805222
     5223!
    51815224!--     initialize prognostic values for the first timestep
    51825225        t_surf_wall_h_p = t_surf_wall_h
     
    51945237        t_green_v_p = t_green_v
    51955238
     5239!
    51965240!--     Adjust radiative fluxes for urban surface at model start
    51975241        !CALL radiation_interaction
     
    52015245        m_liq_usm_h_p     = m_liq_usm_h
    52025246        m_liq_usm_v_p     = m_liq_usm_v
    5203 !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    52045247!
    52055248!--    Set initial values for prognostic quantities
     
    52305273          ENDDO
    52315274       ENDIF
    5232 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++       
    5233 
    5234        CALL cpu_log( log_point_s(78), 'usm_init', 'stop' )
    5235 
    5236        CALL location_message( 'finished', .TRUE. )
     5275
     5276        CALL cpu_log( log_point_s(78), 'usm_init', 'stop' )
     5277
     5278        CALL location_message( 'finished', .TRUE. )
    52375279
    52385280    END SUBROUTINE usm_init
     
    52435285! ------------
    52445286!
    5245 !> Wall model as part of the urban surface model. The model predicts wall
    5246 !> temperature.
     5287!> Wall model as part of the urban surface model. The model predicts vertical
     5288!> and horizontal wall / roof temperatures and window layer temperatures.
     5289!> No window layer temperature calculactions during spinup to increase
     5290!> possible timestep.
    52475291!------------------------------------------------------------------------------!
    52485292    SUBROUTINE usm_material_heat_model( spinup )
     
    52545298
    52555299        REAL(wp), DIMENSION(nzb_wall:nzt_wall) :: wtend, wintend  !< tendency
    5256         REAL(wp)     :: win_absorp !absorption coefficient from transmissivity
     5300        REAL(wp)     :: win_absorp  !< absorption coefficient from transmissivity
    52575301        REAL(wp), DIMENSION(nzb_wall:nzt_wall) :: wall_mod
    52585302
    5259         LOGICAL      :: spinup !if true, no calculation of window temperatures
     5303        LOGICAL      :: spinup  !< if true, no calculation of window temperatures
    52605304
    52615305        wall_mod=1.0_wp
    5262         if (usm_wall_mod .AND. spinup) then
    5263           do kw=nzb_wall,nzb_wall+1
    5264             wall_mod(kw)=0.1_wp
    5265           enddo
    5266         endif
     5306        IF (usm_wall_mod .AND. spinup) THEN
     5307           DO kw=nzb_wall,nzb_wall+1
     5308               wall_mod(kw)=0.1_wp
     5309           ENDDO
     5310        ENDIF
    52675311
    52685312!
     
    52915335                                         * ( surf_usm_h%lambda_h_green(nzt_wall,m)* wall_mod(nzt_wall) &
    52925336                                           * surf_usm_h%ddz_green(nzt_wall,m)      &
    5293                                            + surf_usm_h%lambda_h(nzb_wall,m) * wall_mod(nzb_wall)        &
     5337                                           + surf_usm_h%lambda_h(nzb_wall,m) * wall_mod(nzb_wall)      &
    52945338                                           * surf_usm_h%ddz_wall(nzb_wall,m) )     &
    52955339                                         / ( surf_usm_h%ddz_green(nzt_wall,m)      &
     
    52985342                                           - t_green_h(nzt_wall,m) ) ) *           &
    52995343                                       surf_usm_h%ddz_wall_stag(nzb_wall,m)
    5300 
    5301            IF ( indoor_model ) then
     5344!
     5345!-- if indoor model ist used inner wall layer is calculated by using iwghf (indoor wall ground heat flux)
     5346           IF ( indoor_model ) THEN
    53025347              DO  kw = nzb_wall+1, nzt_wall-1
    53035348                  wtend(kw) = (1.0_wp / surf_usm_h%rho_c_wall(kw,m))              &
    5304                                  * (   surf_usm_h%lambda_h(kw,m) * wall_mod(kw)                 &
     5349                                 * (   surf_usm_h%lambda_h(kw,m) * wall_mod(kw)   &
    53055350                                    * ( t_wall_h(kw+1,m) - t_wall_h(kw,m) )       &
    53065351                                    * surf_usm_h%ddz_wall(kw+1,m)                 &
    5307                                  - surf_usm_h%lambda_h(kw-1,m) * wall_mod(kw-1)                     &
     5352                                 - surf_usm_h%lambda_h(kw-1,m) * wall_mod(kw-1)   &
    53085353                                    * ( t_wall_h(kw,m) - t_wall_h(kw-1,m) )       &
    53095354                                    * surf_usm_h%ddz_wall(kw,m)                   &
     
    53115356              ENDDO
    53125357              wtend(nzt_wall) = (1.0_wp / surf_usm_h%rho_c_wall(nzt_wall,m)) *    &
    5313                                          ( -surf_usm_h%lambda_h(nzt_wall-1,m) * wall_mod(nzt_wall-1) *     &
     5358                                         ( -surf_usm_h%lambda_h(nzt_wall-1,m) * wall_mod(nzt_wall-1) * &
    53145359                                           ( t_wall_h(nzt_wall,m)                 &
    53155360                                           - t_wall_h(nzt_wall-1,m) ) *           &
     
    53205365              DO  kw = nzb_wall+1, nzt_wall
    53215366                  wtend(kw) = (1.0_wp / surf_usm_h%rho_c_wall(kw,m))              &
    5322                                  * (   surf_usm_h%lambda_h(kw,m)  * wall_mod(kw)                &
     5367                                 * (   surf_usm_h%lambda_h(kw,m)  * wall_mod(kw)  &
    53235368                                    * ( t_wall_h(kw+1,m) - t_wall_h(kw,m) )       &
    53245369                                    * surf_usm_h%ddz_wall(kw+1,m)                 &
    5325                                  - surf_usm_h%lambda_h(kw-1,m) * wall_mod(kw-1)                   &
     5370                                 - surf_usm_h%lambda_h(kw-1,m) * wall_mod(kw-1)   &
    53265371                                    * ( t_wall_h(kw,m) - t_wall_h(kw-1,m) )       &
    53275372                                    * surf_usm_h%ddz_wall(kw,m)                   &
     
    53355380                                 * surf_usm_h%tt_wall_m(nzb_wall:nzt_wall,m) )   
    53365381
    5337 if (.NOT. spinup) then
    5338            win_absorp = -log(surf_usm_h%transmissivity(m)) / surf_usm_h%zw_window(nzt_wall,m)
    5339 !--        prognostic equation for ground/roof window temperature t_window_h
    5340            wintend(:) = 0.0_wp
    5341            wintend(nzb_wall) = (1.0_wp / surf_usm_h%rho_c_window(nzb_wall,m)) *   &
    5342                                       ( surf_usm_h%lambda_h_window(nzb_wall,m) *  &
    5343                                         ( t_window_h(nzb_wall+1,m)                &
    5344                                         - t_window_h(nzb_wall,m) ) *              &
    5345                                         surf_usm_h%ddz_window(nzb_wall+1,m)       &
    5346                                       + surf_usm_h%wghf_eb_window(m)              &
    5347                                       + surf_usm_h%rad_sw_in(m)                   &
    5348                                         * (1.0_wp - exp(-win_absorp               &
    5349                                         * surf_usm_h%zw_window(nzb_wall,m) ) )    &
    5350                                       ) * surf_usm_h%ddz_window_stag(nzb_wall,m)
    5351 
    5352            IF ( indoor_model ) then
    5353               DO  kw = nzb_wall+1, nzt_wall-1
    5354                   wintend(kw) = (1.0_wp / surf_usm_h%rho_c_window(kw,m))          &
    5355                                  * (   surf_usm_h%lambda_h_window(kw,m)           &
    5356                                     * ( t_window_h(kw+1,m) - t_window_h(kw,m) )   &
    5357                                     * surf_usm_h%ddz_window(kw+1,m)               &
    5358                                  - surf_usm_h%lambda_h_window(kw-1,m)             &
    5359                                     * ( t_window_h(kw,m) - t_window_h(kw-1,m) )   &
    5360                                     * surf_usm_h%ddz_window(kw,m)                 &
    5361                                  + surf_usm_h%rad_sw_in(m)                        &
    5362                                     * (exp(-win_absorp                            &
    5363                                         * surf_usm_h%zw_window(kw-1,m) )          &
    5364                                         - exp(-win_absorp                         &
    5365                                         * surf_usm_h%zw_window(kw,m) ) )          &
    5366                                    ) * surf_usm_h%ddz_window_stag(kw,m)
    5367 
    5368               ENDDO
    5369               wintend(nzt_wall) = (1.0_wp / surf_usm_h%rho_c_window(nzt_wall,m)) *       &
    5370                                          ( -surf_usm_h%lambda_h_window(nzt_wall-1,m) *   &
    5371                                            ( t_window_h(nzt_wall,m)                      &
    5372                                            - t_window_h(nzt_wall-1,m) ) *                &
    5373                                            surf_usm_h%ddz_window(nzt_wall,m)             &
    5374                                          + surf_usm_h%iwghf_eb_window(m)                 &
    5375                                          + surf_usm_h%rad_sw_in(m)                       &
    5376                                            * (exp(-win_absorp                            &
    5377                                            * surf_usm_h%zw_window(nzt_wall-1,m) )        &
    5378                                            - exp(-win_absorp                             &
    5379                                            * surf_usm_h%zw_window(nzt_wall,m) ) )        &
    5380                                          ) * surf_usm_h%ddz_window_stag(nzt_wall,m)
    5381            ELSE
    5382               DO  kw = nzb_wall+1, nzt_wall
    5383                   wintend(kw) = (1.0_wp / surf_usm_h%rho_c_window(kw,m))          &
    5384                                  * (   surf_usm_h%lambda_h_window(kw,m)           &
    5385                                     * ( t_window_h(kw+1,m) - t_window_h(kw,m) )   &
    5386                                     * surf_usm_h%ddz_window(kw+1,m)               &
    5387                                  - surf_usm_h%lambda_h_window(kw-1,m)             &
    5388                                     * ( t_window_h(kw,m) - t_window_h(kw-1,m) )   &
    5389                                     * surf_usm_h%ddz_window(kw,m)                 &
    5390                                  + surf_usm_h%rad_sw_in(m)                        &
    5391                                     * (exp(-win_absorp                            &
    5392                                         * surf_usm_h%zw_window(kw-1,m) )          &
    5393                                         - exp(-win_absorp                         &
    5394                                         * surf_usm_h%zw_window(kw,m) ) )          &
    5395                                    ) * surf_usm_h%ddz_window_stag(kw,m)
    5396 
    5397               ENDDO
    5398            ENDIF
    5399 
    5400            t_window_h_p(nzb_wall:nzt_wall,m) = t_window_h(nzb_wall:nzt_wall,m)    &
     5382!
     5383!-- during spinup the tempeature inside window layers is not calculated to make larger timesteps possible
     5384           IF ( .NOT. spinup) THEN
     5385              win_absorp = -log(surf_usm_h%transmissivity(m)) / surf_usm_h%zw_window(nzt_wall,m)
     5386!
     5387!--           prognostic equation for ground/roof window temperature t_window_h
     5388!--           takes absorption of shortwave radiation into account
     5389              wintend(:) = 0.0_wp
     5390              wintend(nzb_wall) = (1.0_wp / surf_usm_h%rho_c_window(nzb_wall,m)) *   &
     5391                                         ( surf_usm_h%lambda_h_window(nzb_wall,m) *  &
     5392                                           ( t_window_h(nzb_wall+1,m)                &
     5393                                           - t_window_h(nzb_wall,m) ) *              &
     5394                                           surf_usm_h%ddz_window(nzb_wall+1,m)       &
     5395                                         + surf_usm_h%wghf_eb_window(m)              &
     5396                                         + surf_usm_h%rad_sw_in(m)                   &
     5397                                           * (1.0_wp - exp(-win_absorp               &
     5398                                           * surf_usm_h%zw_window(nzb_wall,m) ) )    &
     5399                                         ) * surf_usm_h%ddz_window_stag(nzb_wall,m)
     5400   
     5401              IF ( indoor_model ) THEN
     5402                 DO  kw = nzb_wall+1, nzt_wall-1
     5403                     wintend(kw) = (1.0_wp / surf_usm_h%rho_c_window(kw,m))          &
     5404                                    * (   surf_usm_h%lambda_h_window(kw,m)           &
     5405                                       * ( t_window_h(kw+1,m) - t_window_h(kw,m) )   &
     5406                                       * surf_usm_h%ddz_window(kw+1,m)               &
     5407                                    - surf_usm_h%lambda_h_window(kw-1,m)             &
     5408                                       * ( t_window_h(kw,m) - t_window_h(kw-1,m) )   &
     5409                                       * surf_usm_h%ddz_window(kw,m)                 &
     5410                                    + surf_usm_h%rad_sw_in(m)                        &
     5411                                       * (exp(-win_absorp                            &
     5412                                           * surf_usm_h%zw_window(kw-1,m) )          &
     5413                                           - exp(-win_absorp                         &
     5414                                           * surf_usm_h%zw_window(kw,m) ) )          &
     5415                                      ) * surf_usm_h%ddz_window_stag(kw,m)
     5416   
     5417                 ENDDO
     5418                 wintend(nzt_wall) = (1.0_wp / surf_usm_h%rho_c_window(nzt_wall,m)) *       &
     5419                                            ( -surf_usm_h%lambda_h_window(nzt_wall-1,m) *   &
     5420                                              ( t_window_h(nzt_wall,m)                      &
     5421                                              - t_window_h(nzt_wall-1,m) ) *                &
     5422                                              surf_usm_h%ddz_window(nzt_wall,m)             &
     5423                                            + surf_usm_h%iwghf_eb_window(m)                 &
     5424                                            + surf_usm_h%rad_sw_in(m)                       &
     5425                                              * (exp(-win_absorp                            &
     5426                                              * surf_usm_h%zw_window(nzt_wall-1,m) )        &
     5427                                              - exp(-win_absorp                             &
     5428                                              * surf_usm_h%zw_window(nzt_wall,m) ) )        &
     5429                                            ) * surf_usm_h%ddz_window_stag(nzt_wall,m)
     5430              ELSE
     5431                 DO  kw = nzb_wall+1, nzt_wall
     5432                     wintend(kw) = (1.0_wp / surf_usm_h%rho_c_window(kw,m))          &
     5433                                    * (   surf_usm_h%lambda_h_window(kw,m)           &
     5434                                       * ( t_window_h(kw+1,m) - t_window_h(kw,m) )   &
     5435                                       * surf_usm_h%ddz_window(kw+1,m)               &
     5436                                    - surf_usm_h%lambda_h_window(kw-1,m)             &
     5437                                       * ( t_window_h(kw,m) - t_window_h(kw-1,m) )   &
     5438                                       * surf_usm_h%ddz_window(kw,m)                 &
     5439                                    + surf_usm_h%rad_sw_in(m)                        &
     5440                                       * (exp(-win_absorp                            &
     5441                                           * surf_usm_h%zw_window(kw-1,m) )          &
     5442                                           - exp(-win_absorp                         &
     5443                                           * surf_usm_h%zw_window(kw,m) ) )          &
     5444                                      ) * surf_usm_h%ddz_window_stag(kw,m)
     5445   
     5446                 ENDDO
     5447              ENDIF
     5448
     5449              t_window_h_p(nzb_wall:nzt_wall,m) = t_window_h(nzb_wall:nzt_wall,m) &
    54015450                                 + dt_3d * ( tsc(2)                               &
    54025451                                 * wintend(nzb_wall:nzt_wall) + tsc(3)            &
    54035452                                 * surf_usm_h%tt_window_m(nzb_wall:nzt_wall,m) )   
    54045453
    5405 endif
     5454           ENDIF
    54065455
    54075456!
     
    54215470           ENDIF
    54225471
    5423 if (.NOT. spinup) then
    5424 !--        calculate t_window tendencies for the next Runge-Kutta step
    5425            IF ( timestep_scheme(1:5) == 'runge' )  THEN
    5426                IF ( intermediate_timestep_count == 1 )  THEN
    5427                   DO  kw = nzb_wall, nzt_wall
    5428                      surf_usm_h%tt_window_m(kw,m) = wintend(kw)
    5429                   ENDDO
    5430                ELSEIF ( intermediate_timestep_count <                          &
    5431                         intermediate_timestep_count_max )  THEN
    5432                    DO  kw = nzb_wall, nzt_wall
    5433                       surf_usm_h%tt_window_m(kw,m) = -9.5625_wp * wintend(kw) +    &
    5434                                          5.3125_wp * surf_usm_h%tt_window_m(kw,m)
    5435                    ENDDO
    5436                ENDIF
     5472           IF (.NOT. spinup) THEN
     5473!
     5474!--           calculate t_window tendencies for the next Runge-Kutta step
     5475              IF ( timestep_scheme(1:5) == 'runge' )  THEN
     5476                  IF ( intermediate_timestep_count == 1 )  THEN
     5477                     DO  kw = nzb_wall, nzt_wall
     5478                        surf_usm_h%tt_window_m(kw,m) = wintend(kw)
     5479                     ENDDO
     5480                  ELSEIF ( intermediate_timestep_count <                            &
     5481                           intermediate_timestep_count_max )  THEN
     5482                      DO  kw = nzb_wall, nzt_wall
     5483                         surf_usm_h%tt_window_m(kw,m) = -9.5625_wp * wintend(kw) +  &
     5484                                            5.3125_wp * surf_usm_h%tt_window_m(kw,m)
     5485                      ENDDO
     5486                  ENDIF
     5487              ENDIF
    54375488           ENDIF
    5438 
    5439 endif
    54405489
    54415490        ENDDO
     
    54545503              wtend(:) = 0.0_wp
    54555504
    5456                wtend(nzb_wall) = (1.0_wp / surf_usm_v(l)%rho_c_wall(nzb_wall,m)) *    &
    5457                                        ( surf_usm_v(l)%lambda_h(nzb_wall,m) * wall_mod(nzb_wall)  *      &
    5458                                          ( t_wall_v(l)%t(nzb_wall+1,m)                &
    5459                                          - t_wall_v(l)%t(nzb_wall,m) ) *              &
    5460                                          surf_usm_v(l)%ddz_wall(nzb_wall+1,m)         &
    5461                                        + surf_usm_v(l)%frac(ind_veg_wall,m)           &
    5462                                          / (surf_usm_v(l)%frac(ind_veg_wall,m)        &
    5463                                            + surf_usm_v(l)%frac(ind_pav_green,m) )    &
    5464                                          * surf_usm_v(l)%wghf_eb(m)                   &
    5465                                        - surf_usm_v(l)%frac(ind_pav_green,m)          &
    5466                                          / (surf_usm_v(l)%frac(ind_veg_wall,m)        &
    5467                                            + surf_usm_v(l)%frac(ind_pav_green,m) )    &
    5468                                          * ( surf_usm_v(l)%lambda_h_green(nzt_wall,m)* wall_mod(nzt_wall) &
    5469                                            * surf_usm_v(l)%ddz_green(nzt_wall,m)      &
    5470                                            + surf_usm_v(l)%lambda_h(nzb_wall,m)* wall_mod(nzb_wall)       &
    5471                                            * surf_usm_v(l)%ddz_wall(nzb_wall,m) )     &
    5472                                          / ( surf_usm_v(l)%ddz_green(nzt_wall,m)      &
    5473                                            + surf_usm_v(l)%ddz_wall(nzb_wall,m) )     &
    5474                                          * ( t_wall_v(l)%t(nzb_wall,m)                &
    5475                                            - t_green_v(l)%t(nzt_wall,m) ) ) *         &
    5476                                          surf_usm_v(l)%ddz_wall_stag(nzb_wall,m)
    5477 
    5478               IF ( indoor_model ) then
     5505              wtend(nzb_wall) = (1.0_wp / surf_usm_v(l)%rho_c_wall(nzb_wall,m)) *    &
     5506                                      ( surf_usm_v(l)%lambda_h(nzb_wall,m) * wall_mod(nzb_wall)  *      &
     5507                                        ( t_wall_v(l)%t(nzb_wall+1,m)                &
     5508                                        - t_wall_v(l)%t(nzb_wall,m) ) *              &
     5509                                        surf_usm_v(l)%ddz_wall(nzb_wall+1,m)         &
     5510                                      + surf_usm_v(l)%frac(ind_veg_wall,m)           &
     5511                                        / (surf_usm_v(l)%frac(ind_veg_wall,m)        &
     5512                                          + surf_usm_v(l)%frac(ind_pav_green,m) )    &
     5513                                        * surf_usm_v(l)%wghf_eb(m)                   &
     5514                                      - surf_usm_v(l)%frac(ind_pav_green,m)          &
     5515                                        / (surf_usm_v(l)%frac(ind_veg_wall,m)        &
     5516                                          + surf_usm_v(l)%frac(ind_pav_green,m) )    &
     5517                                        * ( surf_usm_v(l)%lambda_h_green(nzt_wall,m)* wall_mod(nzt_wall) &
     5518                                          * surf_usm_v(l)%ddz_green(nzt_wall,m)      &
     5519                                          + surf_usm_v(l)%lambda_h(nzb_wall,m)* wall_mod(nzb_wall)       &
     5520                                          * surf_usm_v(l)%ddz_wall(nzb_wall,m) )     &
     5521                                        / ( surf_usm_v(l)%ddz_green(nzt_wall,m)      &
     5522                                          + surf_usm_v(l)%ddz_wall(nzb_wall,m) )     &
     5523                                        * ( t_wall_v(l)%t(nzb_wall,m)                &
     5524                                          - t_green_v(l)%t(nzt_wall,m) ) ) *         &
     5525                                        surf_usm_v(l)%ddz_wall_stag(nzb_wall,m)
     5526
     5527              IF ( indoor_model ) THEN
    54795528                 DO  kw = nzb_wall+1, nzt_wall-1
    54805529                     wtend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_wall(kw,m))        &
    5481                               * (   surf_usm_v(l)%lambda_h(kw,m)  * wall_mod(kw)                &
     5530                              * (   surf_usm_v(l)%lambda_h(kw,m)  * wall_mod(kw)  &
    54825531                                 * ( t_wall_v(l)%t(kw+1,m) - t_wall_v(l)%t(kw,m) )&
    54835532                                 * surf_usm_v(l)%ddz_wall(kw+1,m)                 &
    5484                               - surf_usm_v(l)%lambda_h(kw-1,m)  * wall_mod(kw-1)                  &
     5533                              - surf_usm_v(l)%lambda_h(kw-1,m)  * wall_mod(kw-1)  &
    54855534                                 * ( t_wall_v(l)%t(kw,m) - t_wall_v(l)%t(kw-1,m) )&
    54865535                                 * surf_usm_v(l)%ddz_wall(kw,m)                   &
     
    54975546                 DO  kw = nzb_wall+1, nzt_wall
    54985547                     wtend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_wall(kw,m))        &
    5499                               * (   surf_usm_v(l)%lambda_h(kw,m) * wall_mod(kw)                 &
     5548                              * (   surf_usm_v(l)%lambda_h(kw,m) * wall_mod(kw)   &
    55005549                                 * ( t_wall_v(l)%t(kw+1,m) - t_wall_v(l)%t(kw,m) )&
    55015550                                 * surf_usm_v(l)%ddz_wall(kw+1,m)                 &
    5502                               - surf_usm_v(l)%lambda_h(kw-1,m)  * wall_mod(kw-1)                  &
     5551                              - surf_usm_v(l)%lambda_h(kw-1,m)  * wall_mod(kw-1)  &
    55035552                                 * ( t_wall_v(l)%t(kw,m) - t_wall_v(l)%t(kw-1,m) )&
    55045553                                 * surf_usm_v(l)%ddz_wall(kw,m)                   &
     
    55135562                                 * surf_usm_v(l)%tt_wall_m(nzb_wall:nzt_wall,m) )   
    55145563
    5515 if (.NOT. spinup) then
    5516               win_absorp = -log(surf_usm_v(l)%transmissivity(m)) / surf_usm_v(l)%zw_window(nzt_wall,m)
    5517 !--           prognostic equation for window temperature t_window_v
    5518               wintend(:) = 0.0_wp
    5519               wintend(nzb_wall) = (1.0_wp / surf_usm_v(l)%rho_c_window(nzb_wall,m)) * &
    5520                                       ( surf_usm_v(l)%lambda_h_window(nzb_wall,m) *   &
    5521                                         ( t_window_v(l)%t(nzb_wall+1,m)               &
    5522                                         - t_window_v(l)%t(nzb_wall,m) ) *             &
    5523                                         surf_usm_v(l)%ddz_window(nzb_wall+1,m)        &
    5524                                       + surf_usm_v(l)%wghf_eb_window(m)               &
    5525                                       + surf_usm_v(l)%rad_sw_in(m)                    &
    5526                                         * (1.0_wp - exp(-win_absorp                   &
    5527                                         * surf_usm_v(l)%zw_window(nzb_wall,m) ) )     &
    5528                                       ) * surf_usm_v(l)%ddz_window_stag(nzb_wall,m)
    5529 
    5530               IF ( indoor_model ) then
    5531                  DO  kw = nzb_wall+1, nzt_wall -1
    5532                      wintend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_window(kw,m))         &
    5533                               * (   surf_usm_v(l)%lambda_h_window(kw,m)                &
    5534                                  * ( t_window_v(l)%t(kw+1,m) - t_window_v(l)%t(kw,m) ) &
    5535                                  * surf_usm_v(l)%ddz_window(kw+1,m)                    &
    5536                               - surf_usm_v(l)%lambda_h_window(kw-1,m)                  &
    5537                                  * ( t_window_v(l)%t(kw,m) - t_window_v(l)%t(kw-1,m) ) &
    5538                                  * surf_usm_v(l)%ddz_window(kw,m)                      &
    5539                               + surf_usm_v(l)%rad_sw_in(m)                             &
    5540                                  * (exp(-win_absorp                                    &
    5541                                     * surf_usm_v(l)%zw_window(kw-1,m)       )          &
    5542                                         - exp(-win_absorp                              &
    5543                                         * surf_usm_v(l)%zw_window(kw,m) ) )            &
    5544                                  ) * surf_usm_v(l)%ddz_window_stag(kw,m)
    5545                   ENDDO
    5546                   wintend(nzt_wall) = (1.0_wp / surf_usm_v(l)%rho_c_window(nzt_wall,m)) *  &
    5547                                           ( -surf_usm_v(l)%lambda_h_window(nzt_wall-1,m) * &
    5548                                             ( t_window_v(l)%t(nzt_wall,m)                  &
    5549                                             - t_window_v(l)%t(nzt_wall-1,m) ) *            &
    5550                                             surf_usm_v(l)%ddz_window(nzt_wall,m)           &
    5551                                           + surf_usm_v(l)%iwghf_eb_window(m)               &
    5552                                           + surf_usm_v(l)%rad_sw_in(m)                     &
    5553                                             * (exp(-win_absorp                             &
    5554                                           * surf_usm_v(l)%zw_window(nzt_wall-1,m) )        &
    5555                                         - exp(-win_absorp                                  &
    5556                                             * surf_usm_v(l)%zw_window(nzt_wall,m) ) )      &
    5557                                           ) * surf_usm_v(l)%ddz_window_stag(nzt_wall,m)
    5558               ELSE
    5559                  DO  kw = nzb_wall+1, nzt_wall
    5560                      wintend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_window(kw,m))         &
    5561                               * (   surf_usm_v(l)%lambda_h_window(kw,m)                &
    5562                                  * ( t_window_v(l)%t(kw+1,m) - t_window_v(l)%t(kw,m) ) &
    5563                                  * surf_usm_v(l)%ddz_window(kw+1,m)                    &
    5564                               - surf_usm_v(l)%lambda_h_window(kw-1,m)                  &
    5565                                  * ( t_window_v(l)%t(kw,m) - t_window_v(l)%t(kw-1,m) ) &
    5566                                  * surf_usm_v(l)%ddz_window(kw,m)                      &
    5567                               + surf_usm_v(l)%rad_sw_in(m)                             &
    5568                                  * (exp(-win_absorp                                    &
    5569                                     * surf_usm_v(l)%zw_window(kw-1,m)       )          &
    5570                                         - exp(-win_absorp                              &
    5571                                         * surf_usm_v(l)%zw_window(kw,m) ) )            &
    5572                                  ) * surf_usm_v(l)%ddz_window_stag(kw,m)
    5573                  ENDDO
     5564              IF (.NOT. spinup) THEN
     5565                 win_absorp = -log(surf_usm_v(l)%transmissivity(m)) / surf_usm_v(l)%zw_window(nzt_wall,m)
     5566!
     5567!--              prognostic equation for window temperature t_window_v
     5568                 wintend(:) = 0.0_wp
     5569                 wintend(nzb_wall) = (1.0_wp / surf_usm_v(l)%rho_c_window(nzb_wall,m)) * &
     5570                                         ( surf_usm_v(l)%lambda_h_window(nzb_wall,m) *   &
     5571                                           ( t_window_v(l)%t(nzb_wall+1,m)               &
     5572                                           - t_window_v(l)%t(nzb_wall,m) ) *             &
     5573                                           surf_usm_v(l)%ddz_window(nzb_wall+1,m)        &
     5574                                         + surf_usm_v(l)%wghf_eb_window(m)               &
     5575                                         + surf_usm_v(l)%rad_sw_in(m)                    &
     5576                                           * (1.0_wp - exp(-win_absorp                   &
     5577                                           * surf_usm_v(l)%zw_window(nzb_wall,m) ) )     &
     5578                                         ) * surf_usm_v(l)%ddz_window_stag(nzb_wall,m)
     5579   
     5580                 IF ( indoor_model ) THEN
     5581                    DO  kw = nzb_wall+1, nzt_wall -1
     5582                        wintend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_window(kw,m))         &
     5583                                 * (   surf_usm_v(l)%lambda_h_window(kw,m)                &
     5584                                    * ( t_window_v(l)%t(kw+1,m) - t_window_v(l)%t(kw,m) ) &
     5585                                    * surf_usm_v(l)%ddz_window(kw+1,m)                    &
     5586                                 - surf_usm_v(l)%lambda_h_window(kw-1,m)                  &
     5587                                    * ( t_window_v(l)%t(kw,m) - t_window_v(l)%t(kw-1,m) ) &
     5588                                    * surf_usm_v(l)%ddz_window(kw,m)                      &
     5589                                 + surf_usm_v(l)%rad_sw_in(m)                             &
     5590                                    * (exp(-win_absorp                                    &
     5591                                       * surf_usm_v(l)%zw_window(kw-1,m)       )          &
     5592                                           - exp(-win_absorp                              &
     5593                                           * surf_usm_v(l)%zw_window(kw,m) ) )            &
     5594                                    ) * surf_usm_v(l)%ddz_window_stag(kw,m)
     5595                     ENDDO
     5596                     wintend(nzt_wall) = (1.0_wp / surf_usm_v(l)%rho_c_window(nzt_wall,m)) *  &
     5597                                             ( -surf_usm_v(l)%lambda_h_window(nzt_wall-1,m) * &
     5598                                               ( t_window_v(l)%t(nzt_wall,m)                  &
     5599                                               - t_window_v(l)%t(nzt_wall-1,m) ) *            &
     5600                                               surf_usm_v(l)%ddz_window(nzt_wall,m)           &
     5601                                             + surf_usm_v(l)%iwghf_eb_window(m)               &
     5602                                             + surf_usm_v(l)%rad_sw_in(m)                     &
     5603                                               * (exp(-win_absorp                             &
     5604                                             * surf_usm_v(l)%zw_window(nzt_wall-1,m) )        &
     5605                                           - exp(-win_absorp                                  &
     5606                                               * surf_usm_v(l)%zw_window(nzt_wall,m) ) )      &
     5607                                             ) * surf_usm_v(l)%ddz_window_stag(nzt_wall,m)
     5608                 ELSE
     5609                    DO  kw = nzb_wall+1, nzt_wall
     5610                        wintend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_window(kw,m))         &
     5611                                 * (   surf_usm_v(l)%lambda_h_window(kw,m)                &
     5612                                    * ( t_window_v(l)%t(kw+1,m) - t_window_v(l)%t(kw,m) ) &
     5613                                    * surf_usm_v(l)%ddz_window(kw+1,m)                    &
     5614                                 - surf_usm_v(l)%lambda_h_window(kw-1,m)                  &
     5615                                    * ( t_window_v(l)%t(kw,m) - t_window_v(l)%t(kw-1,m) ) &
     5616                                    * surf_usm_v(l)%ddz_window(kw,m)                      &
     5617                                 + surf_usm_v(l)%rad_sw_in(m)                             &
     5618                                    * (exp(-win_absorp                                    &
     5619                                       * surf_usm_v(l)%zw_window(kw-1,m)       )          &
     5620                                           - exp(-win_absorp                              &
     5621                                           * surf_usm_v(l)%zw_window(kw,m) ) )            &
     5622                                    ) * surf_usm_v(l)%ddz_window_stag(kw,m)
     5623                    ENDDO
     5624                 ENDIF
     5625   
     5626                 t_window_v_p(l)%t(nzb_wall:nzt_wall,m) =                           &
     5627                                      t_window_v(l)%t(nzb_wall:nzt_wall,m)          &
     5628                                    + dt_3d * ( tsc(2)                              &
     5629                                    * wintend(nzb_wall:nzt_wall) + tsc(3)           &
     5630                                    * surf_usm_v(l)%tt_window_m(nzb_wall:nzt_wall,m) )   
    55745631              ENDIF
    5575 
    5576               t_window_v_p(l)%t(nzb_wall:nzt_wall,m) =                           &
    5577                                    t_window_v(l)%t(nzb_wall:nzt_wall,m)          &
    5578                                  + dt_3d * ( tsc(2)                              &
    5579                                  * wintend(nzb_wall:nzt_wall) + tsc(3)           &
    5580                                  * surf_usm_v(l)%tt_window_m(nzb_wall:nzt_wall,m) )   
    5581 endif
    55825632
    55835633!
     
    55995649
    56005650
    5601 if (.NOT. spinup) then
    5602 !--           calculate t_window tendencies for the next Runge-Kutta step
    5603               IF ( timestep_scheme(1:5) == 'runge' )  THEN
    5604                   IF ( intermediate_timestep_count == 1 )  THEN
    5605                      DO  kw = nzb_wall, nzt_wall
    5606                         surf_usm_v(l)%tt_window_m(kw,m) = wintend(kw)
    5607                      ENDDO
    5608                   ELSEIF ( intermediate_timestep_count <                       &
    5609                            intermediate_timestep_count_max )  THEN
    5610                       DO  kw = nzb_wall, nzt_wall
    5611                          surf_usm_v(l)%tt_window_m(kw,m) =                     &
    5612                                      - 9.5625_wp * wintend(kw) +               &
    5613                                        5.3125_wp * surf_usm_v(l)%tt_window_m(kw,m)
    5614                       ENDDO
    5615                   ENDIF
     5651              IF (.NOT. spinup) THEN
     5652!
     5653!--              calculate t_window tendencies for the next Runge-Kutta step
     5654                 IF ( timestep_scheme(1:5) == 'runge' )  THEN
     5655                     IF ( intermediate_timestep_count == 1 )  THEN
     5656                        DO  kw = nzb_wall, nzt_wall
     5657                           surf_usm_v(l)%tt_window_m(kw,m) = wintend(kw)
     5658                        ENDDO
     5659                     ELSEIF ( intermediate_timestep_count <                       &
     5660                              intermediate_timestep_count_max )  THEN
     5661                         DO  kw = nzb_wall, nzt_wall
     5662                            surf_usm_v(l)%tt_window_m(kw,m) =                     &
     5663                                        - 9.5625_wp * wintend(kw) +               &
     5664                                          5.3125_wp * surf_usm_v(l)%tt_window_m(kw,m)
     5665                         ENDDO
     5666                     ENDIF
     5667                 ENDIF
    56165668              ENDIF
    5617 endif
    56185669
    56195670           ENDDO
     
    56345685        IMPLICIT NONE
    56355686
    5636         INTEGER(iwp) ::  i,j,k,l,kw, m                      !< running indices
    5637 
    5638         REAL(wp)     :: ke, lambda_h_green_sat
    5639         REAL(wp)     :: h_vg !< Van Genuchten coef. h
    5640         REAL(wp)     :: drho_l_lv
     5687        INTEGER(iwp) ::  i,j,k,l,kw, m              !< running indices
     5688
     5689        REAL(wp)     :: ke, lambda_h_green_sat      !< heat conductivity for saturated soil
     5690        REAL(wp)     :: h_vg                        !< Van Genuchten coef. h
     5691        REAL(wp)     :: drho_l_lv                   !< frequently used parameter
    56415692
    56425693        REAL(wp), DIMENSION(nzb_wall:nzt_wall) :: gtend,tend  !< tendency
     
    56445695        REAL(wp), DIMENSION(nzb_wall:nzt_wall) :: root_extr_green
    56455696
    5646         REAL(wp), DIMENSION(nzb_wall:nzt_wall+1) :: lambda_green_temp !< temp. lambda
    5647         REAL(wp), DIMENSION(nzb_wall:nzt_wall+1) :: gamma_green_temp !< temp. gamma
     5697        REAL(wp), DIMENSION(nzb_wall:nzt_wall+1) :: lambda_green_temp  !< temp. lambda
     5698        REAL(wp), DIMENSION(nzb_wall:nzt_wall+1) :: gamma_green_temp   !< temp. gamma
    56485699
    56495700        LOGICAL :: conserve_water_content = .true.
     
    56565707        DO  m = 1, surf_usm_h%ns
    56575708
    5658 if (surf_usm_h%frac(ind_pav_green,m).gt.0.0_wp) then
    5659 !
    5660 !--        Obtain indices
    5661            i = surf_usm_h%i(m)           
    5662            j = surf_usm_h%j(m)
    5663            k = surf_usm_h%k(m)
    5664 
    5665            DO  kw = nzb_wall, nzt_wall
    5666 !
    5667 !--           Calculate volumetric heat capacity of the soil, taking
    5668 !--           into account water content
    5669               surf_usm_h%rho_c_total_green(kw,m) = (surf_usm_h%rho_c_green(kw,m) * (1.0_wp - swc_sat_h(kw,m)) &
    5670                                    + rho_c_water * swc_h(kw,m))
     5709           IF (surf_usm_h%frac(ind_pav_green,m) > 0.0_wp) THEN
     5710!
     5711!--           Obtain indices
     5712              i = surf_usm_h%i(m)           
     5713              j = surf_usm_h%j(m)
     5714              k = surf_usm_h%k(m)
    56715715   
    5672 !
    5673 !--           Calculate soil heat conductivity at the center of the soil
    5674 !--           layers
    5675               lambda_h_green_sat = lambda_h_green_sm ** (1.0_wp - swc_sat_h(kw,m)) *    &
    5676                              lambda_h_water ** swc_h(kw,m)
     5716              DO  kw = nzb_wall, nzt_wall
     5717!
     5718!--              Calculate volumetric heat capacity of the soil, taking
     5719!--              into account water content
     5720                 surf_usm_h%rho_c_total_green(kw,m) = (surf_usm_h%rho_c_green(kw,m) * (1.0_wp - swc_sat_h(kw,m)) &
     5721                                      + rho_c_water * swc_h(kw,m))
     5722     
     5723!
     5724!--              Calculate soil heat conductivity at the center of the soil
     5725!--              layers
     5726                 lambda_h_green_sat = lambda_h_green_sm ** (1.0_wp - swc_sat_h(kw,m)) *    &
     5727                                lambda_h_water ** swc_h(kw,m)
     5728     
     5729                 ke = 1.0_wp + LOG10(MAX(0.1_wp,swc_h(kw,m)             &
     5730                      / swc_sat_h(kw,m)))
     5731     
     5732                 lambda_green_temp(kw) = ke * (lambda_h_green_sat - lambda_h_green_dry) +    &
     5733                                  lambda_h_green_dry
    56775734   
    5678               ke = 1.0_wp + LOG10(MAX(0.1_wp,swc_h(kw,m)             &
    5679                    / swc_sat_h(kw,m)))
     5735              ENDDO
    56805736   
    5681               lambda_green_temp(kw) = ke * (lambda_h_green_sat - lambda_h_green_dry) +    &
    5682                                lambda_h_green_dry
    5683 
    5684            ENDDO
    5685 
    5686 
    5687 !
    5688 !--        Calculate soil heat conductivity (lambda_h) at the _stag level
    5689 !--        using linear interpolation. For pavement surface, the
    5690 !--        true pavement depth is considered
    5691            DO  kw = nzb_wall, nzt_wall
    5692              surf_usm_h%lambda_h_green(kw,m) = ( lambda_green_temp(kw+1) + lambda_green_temp(kw) )  &
    5693                                    * 0.5_wp
    5694            ENDDO
    5695 !           surf_usm_h%lambda_h_green(nzt_wall+1,m) = lambda_green_temp(nzt_wall+1)           
    5696 !--------------------------------------------------------------------------
    5697            
    5698            t_green_h(nzt_wall+1,m) = t_wall_h(nzb_wall,m)
     5737   
     5738!
     5739!--           Calculate soil heat conductivity (lambda_h) at the _stag level
     5740!--           using linear interpolation. For pavement surface, the
     5741!--           true pavement depth is considered
     5742              DO  kw = nzb_wall, nzt_wall
     5743                surf_usm_h%lambda_h_green(kw,m) = ( lambda_green_temp(kw+1) + lambda_green_temp(kw) )  &
     5744                                      * 0.5_wp
     5745              ENDDO
     5746
     5747              t_green_h(nzt_wall+1,m) = t_wall_h(nzb_wall,m)
    56995748!
    57005749!--        prognostic equation for ground/roof temperature t_green_h
    5701            gtend(:) = 0.0_wp
    5702            gtend(nzb_wall) = (1.0_wp / surf_usm_h%rho_c_total_green(nzb_wall,m)) *    &
    5703                                       ( surf_usm_h%lambda_h_green(nzb_wall,m) * &
    5704                                         ( t_green_h(nzb_wall+1,m)               &
    5705                                         - t_green_h(nzb_wall,m) ) *             &
    5706                                         surf_usm_h%ddz_green(nzb_wall+1,m)      &
    5707                                       + surf_usm_h%wghf_eb_green(m) ) *         &
    5708                                         surf_usm_h%ddz_green_stag(nzb_wall,m)
    5709            
    5710             DO  kw = nzb_wall+1, nzt_wall
    5711                 gtend(kw) = (1.0_wp / surf_usm_h%rho_c_total_green(kw,m))             &
    5712                                * (   surf_usm_h%lambda_h_green(kw,m)            &
    5713                                   * ( t_green_h(kw+1,m) - t_green_h(kw,m) )     &
    5714                                   * surf_usm_h%ddz_green(kw+1,m)                &
    5715                                - surf_usm_h%lambda_h_green(kw-1,m)              &
    5716                                   * ( t_green_h(kw,m) - t_green_h(kw-1,m) )     &
    5717                                   * surf_usm_h%ddz_green(kw,m)                  &
    5718                                  ) * surf_usm_h%ddz_green_stag(kw,m)
    5719             ENDDO
    5720 
    5721            t_green_h_p(nzb_wall:nzt_wall,m) = t_green_h(nzb_wall:nzt_wall,m)    &
    5722                                  + dt_3d * ( tsc(2)                             &
    5723                                  * gtend(nzb_wall:nzt_wall) + tsc(3)            &
    5724                                  * surf_usm_h%tt_green_m(nzb_wall:nzt_wall,m) )   
    5725 
    5726          
     5750              gtend(:) = 0.0_wp
     5751              gtend(nzb_wall) = (1.0_wp / surf_usm_h%rho_c_total_green(nzb_wall,m)) *    &
     5752                                         ( surf_usm_h%lambda_h_green(nzb_wall,m) * &
     5753                                           ( t_green_h(nzb_wall+1,m)               &
     5754                                           - t_green_h(nzb_wall,m) ) *             &
     5755                                           surf_usm_h%ddz_green(nzb_wall+1,m)      &
     5756                                         + surf_usm_h%wghf_eb_green(m) ) *         &
     5757                                           surf_usm_h%ddz_green_stag(nzb_wall,m)
     5758              
     5759               DO  kw = nzb_wall+1, nzt_wall
     5760                   gtend(kw) = (1.0_wp / surf_usm_h%rho_c_total_green(kw,m))       &
     5761                                  * (   surf_usm_h%lambda_h_green(kw,m)            &
     5762                                     * ( t_green_h(kw+1,m) - t_green_h(kw,m) )     &
     5763                                     * surf_usm_h%ddz_green(kw+1,m)                &
     5764                                  - surf_usm_h%lambda_h_green(kw-1,m)              &
     5765                                     * ( t_green_h(kw,m) - t_green_h(kw-1,m) )     &
     5766                                     * surf_usm_h%ddz_green(kw,m)                  &
     5767                                    ) * surf_usm_h%ddz_green_stag(kw,m)
     5768               ENDDO
     5769   
     5770              t_green_h_p(nzb_wall:nzt_wall,m) = t_green_h(nzb_wall:nzt_wall,m)    &
     5771                                    + dt_3d * ( tsc(2)                             &
     5772                                    * gtend(nzb_wall:nzt_wall) + tsc(3)            &
     5773                                    * surf_usm_h%tt_green_m(nzb_wall:nzt_wall,m) )   
     5774   
     5775             
    57275776!
    57285777!--        calculate t_green tendencies for the next Runge-Kutta step
    5729            IF ( timestep_scheme(1:5) == 'runge' )  THEN
    5730                IF ( intermediate_timestep_count == 1 )  THEN
    5731                   DO  kw = nzb_wall, nzt_wall
    5732                      surf_usm_h%tt_green_m(kw,m) = gtend(kw)
    5733                   ENDDO
    5734                ELSEIF ( intermediate_timestep_count <                           &
    5735                         intermediate_timestep_count_max )  THEN
    5736                    DO  kw = nzb_wall, nzt_wall
    5737                       surf_usm_h%tt_green_m(kw,m) = -9.5625_wp * gtend(kw) +    &
    5738                                          5.3125_wp * surf_usm_h%tt_green_m(kw,m)
    5739                    ENDDO
    5740                ENDIF
    5741            ENDIF
    5742 
    5743 !--------------------------------------------------------------
    5744                 DO  kw = nzb_wall, nzt_wall
    5745 
    5746 !
    5747 !--                Calculate soil diffusivity at the center of the soil layers
    5748                    lambda_green_temp(kw) = (- b_ch * surf_usm_h%gamma_w_green_sat(kw,m) * psi_sat       &
    5749                                      / swc_sat_h(kw,m) ) * ( MAX( swc_h(kw,m),    &
    5750                                      wilt_h(kw,m) ) / swc_sat_h(kw,m) )**(           &
    5751                                      b_ch + 2.0_wp )
    5752 
    5753 !
    5754 !--                Parametrization of Van Genuchten
    5755                    IF ( soil_type /= 7 )  THEN
    5756 !
    5757 !--                   Calculate the hydraulic conductivity after Van Genuchten
    5758 !--                   (1980)
    5759                       h_vg = ( ( (swc_res_h(kw,m) - swc_sat_h(kw,m)) / ( swc_res_h(kw,m) -    &
    5760                                  MAX( swc_h(kw,m), wilt_h(kw,m) ) ) )**(      &
    5761                                  surf_usm_h%n_vg_green(m) / (surf_usm_h%n_vg_green(m) - 1.0_wp ) ) - 1.0_wp  &
    5762                              )**( 1.0_wp / surf_usm_h%n_vg_green(m) ) / surf_usm_h%alpha_vg_green(m)
    5763 
    5764 
    5765                       gamma_green_temp(kw) = surf_usm_h%gamma_w_green_sat(kw,m) * ( ( (1.0_wp +         &
    5766                                       ( surf_usm_h%alpha_vg_green(m) * h_vg )**surf_usm_h%n_vg_green(m))**(  &
    5767                                       1.0_wp - 1.0_wp / surf_usm_h%n_vg_green(m) ) - (        &
    5768                                       surf_usm_h%alpha_vg_green(m) * h_vg )**( surf_usm_h%n_vg_green(m)      &
    5769                                       - 1.0_wp) )**2 )                         &
    5770                                       / ( ( 1.0_wp + ( surf_usm_h%alpha_vg_green(m) * h_vg    &
    5771                                       )**surf_usm_h%n_vg_green(m) )**( ( 1.0_wp  - 1.0_wp     &
    5772                                       / surf_usm_h%n_vg_green(m) ) *( surf_usm_h%l_vg_green(m) + 2.0_wp) ) )
    5773 
    5774 !
    5775 !--                Parametrization of Clapp & Hornberger
    5776                    ELSE
    5777                       gamma_green_temp(kw) = surf_usm_h%gamma_w_green_sat(kw,m) * ( swc_h(kw,m)       &
    5778                                       / swc_sat_h(kw,m) )**(2.0_wp * b_ch + 3.0_wp)
    5779                    ENDIF
    5780 
    5781                 ENDDO
    5782 
    5783 !
    5784 !--             Prognostic equation for soil moisture content. Only performed,
    5785 !--             when humidity is enabled in the atmosphere
    5786                 IF ( humidity )  THEN
    5787 !
    5788 !--                Calculate soil diffusivity (lambda_w) at the _stag level
    5789 !--                using linear interpolation. To do: replace this with
    5790 !--                ECMWF-IFS Eq. 8.81
    5791                    DO  kw = nzb_wall, nzt_wall-1
    5792                      
    5793                       surf_usm_h%lambda_w_green(kw,m) = ( lambda_green_temp(kw+1) + lambda_green_temp(kw) )  &
    5794                                         * 0.5_wp
    5795                       surf_usm_h%gamma_w_green(kw,m)  = ( gamma_green_temp(kw+1) + gamma_green_temp(kw) )    &
    5796                                         * 0.5_wp
    5797 
    5798                    ENDDO
    5799 
    5800 !
    5801 !
    5802 !--                In case of a closed bottom (= water content is conserved),
    5803 !--                set hydraulic conductivity to zero to that no water will be
    5804 !--                lost in the bottom layer.
    5805                    IF ( conserve_water_content )  THEN
    5806                       surf_usm_h%gamma_w_green(kw,m) = 0.0_wp
    5807                    ELSE
    5808                       surf_usm_h%gamma_w_green(kw,m) = gamma_green_temp(nzt_wall)
    5809                    ENDIF     
    5810 
    5811 !--                The root extraction (= root_extr * qsws_veg / (rho_l     
    5812 !--                * l_v)) ensures the mass conservation for water. The         
    5813 !--                transpiration of plants equals the cumulative withdrawals by
    5814 !--                the roots in the soil. The scheme takes into account the
    5815 !--                availability of water in the soil layers as well as the root
    5816 !--                fraction in the respective layer. Layer with moisture below
    5817 !--                wilting point will not contribute, which reflects the
    5818 !--                preference of plants to take water from moister layers.
    5819 
    5820 !
    5821 !--                Calculate the root extraction (ECMWF 7.69, the sum of
    5822 !--                root_extr = 1). The energy balance solver guarantees a
    5823 !--                positive transpiration, so that there is no need for an
    5824 !--                additional check.
    5825                    m_total = 0.0_wp
    5826                    DO  kw = nzb_wall, nzt_wall
    5827                        IF ( swc_h(kw,m) > wilt_h(kw,m) )  THEN
    5828                           m_total = m_total + rootfr_h(kw,m) * swc_h(kw,m)
    5829                        ENDIF
    5830                    ENDDO 
    5831 
    5832                    IF ( m_total > 0.0_wp )  THEN
    5833                       DO  kw = nzb_wall, nzt_wall
    5834                          IF ( swc_h(kw,m) > wilt_h(kw,m) )  THEN
    5835                             root_extr_green(kw) = rootfr_h(kw,m) * swc_h(kw,m)      &
    5836                                                             / m_total
    5837                          ELSE
    5838                             root_extr_green(kw) = 0.0_wp
    5839                          ENDIF
    5840                       ENDDO
    5841                    ENDIF
    5842 
    5843 !
    5844 !--                Prognostic equation for soil water content m_soil.
    5845                    tend(:) = 0.0_wp
    5846 
    5847                    tend(nzb_wall) = ( surf_usm_h%lambda_w_green(nzb_wall,m) * (               &
    5848                             swc_h(nzb_wall+1,m) - swc_h(nzb_wall,m) )    &
    5849                             * surf_usm_h%ddz_green(nzb_wall+1,m) - surf_usm_h%gamma_w_green(nzb_wall,m) - ( &
    5850                                root_extr_green(nzb_wall) * surf_usm_h%qsws_veg(m)          &
    5851 !                                + surf_usm_h%qsws_soil_green(m)
    5852                                   ) * drho_l_lv )             &
    5853                                  * surf_usm_h%ddz_green_stag(nzb_wall,m)
    5854 
    5855                    DO  kw = nzb_wall+1, nzt_wall-1
    5856                       tend(kw) = ( surf_usm_h%lambda_w_green(kw,m) * ( swc_h(kw+1,m)          &
    5857                                 - swc_h(kw,m) ) * surf_usm_h%ddz_green(kw+1,m)              &
    5858                                 - surf_usm_h%gamma_w_green(kw,m)                               &
    5859                                 - surf_usm_h%lambda_w_green(kw-1,m) * (swc_h(kw,m) -         &
    5860                                 swc_h(kw-1,m)) * surf_usm_h%ddz_green(kw,m)                 &
    5861                                 + surf_usm_h%gamma_w_green(kw-1,m) - (root_extr_green(kw)             &
    5862                                 * surf_usm_h%qsws_veg(m) * drho_l_lv)                &
    5863                                 ) * surf_usm_h%ddz_green_stag(kw,m)
    5864 
    5865                    ENDDO
    5866                    tend(nzt_wall) = ( - surf_usm_h%gamma_w_green(nzt_wall,m)                  &
    5867                                            - surf_usm_h%lambda_w_green(nzt_wall-1,m)          &
    5868                                            * (swc_h(nzt_wall,m)             &
    5869                                            - swc_h(nzt_wall-1,m))           &
    5870                                            * surf_usm_h%ddz_green(nzt_wall,m)                &
    5871                                            + surf_usm_h%gamma_w_green(nzt_wall-1,m) - (       &
    5872                                              root_extr_green(nzt_wall)               &
    5873                                            * surf_usm_h%qsws_veg(m) * drho_l_lv  )   &
    5874                                      ) * surf_usm_h%ddz_green_stag(nzt_wall,m)             
    5875 
    5876                    swc_h_p(nzb_wall:nzt_wall,m) = swc_h(nzb_wall:nzt_wall,m)&
    5877                                                    + dt_3d * ( tsc(2) * tend(:)   &
    5878                                                    + tsc(3) * surf_usm_h%tswc_h_m(:,m) )   
    5879    
    5880 !
    5881 !--                Account for dry soils (find a better solution here!)
    5882                    DO  kw = nzb_wall, nzt_wall
    5883                       IF ( swc_h_p(kw,m) < 0.0_wp )  swc_h_p(kw,m) = 0.0_wp
    5884                    ENDDO
    5885 
    5886 !
    5887 !--                Calculate m_soil tendencies for the next Runge-Kutta step
    5888                    IF ( timestep_scheme(1:5) == 'runge' )  THEN
    5889                       IF ( intermediate_timestep_count == 1 )  THEN
    5890                          DO  kw = nzb_wall, nzt_wall
    5891                             surf_usm_h%tswc_h_m(kw,m) = tend(kw)
    5892                          ENDDO
    5893                       ELSEIF ( intermediate_timestep_count <                   &
    5894                                intermediate_timestep_count_max )  THEN
    5895                          DO  kw = nzb_wall, nzt_wall
    5896                             surf_usm_h%tswc_h_m(kw,m) = -9.5625_wp * tend(kw) + 5.3125_wp&
    5897                                      * surf_usm_h%tswc_h_m(kw,m)
    5898                          ENDDO
    5899                       ENDIF
    5900                    ENDIF
    5901                 ENDIF
    5902 !--------------------------------------------------------------
    5903 ENDIF
    5904            
    5905         ENDDO
    5906 
    5907 !
    5908 !--     For vertical surfaces     
    5909         DO  l = 0, 3                             
    5910            DO  m = 1, surf_usm_v(l)%ns
    5911 
    5912 if (surf_usm_v(l)%frac(ind_pav_green,m).gt.0.0_wp) then
    5913   if (1.gt.2) then
    5914 !
    5915 !--           Obtain indices
    5916               i = surf_usm_v(l)%i(m)           
    5917               j = surf_usm_v(l)%j(m)
    5918               k = surf_usm_v(l)%k(m)
    5919 
    5920               t_green_v(l)%t(nzt_wall+1,m) = t_wall_v(l)%t(nzb_wall,m)
    5921 !
    5922 !--           prognostic equation for green temperature t_green_v
    5923               gtend(:) = 0.0_wp
    5924               gtend(nzb_wall) = (1.0_wp / surf_usm_v(l)%rho_c_green(nzb_wall,m)) * &
    5925                                       ( surf_usm_v(l)%lambda_h_green(nzb_wall,m) * &
    5926                                         ( t_green_v(l)%t(nzb_wall+1,m)             &
    5927                                         - t_green_v(l)%t(nzb_wall,m) ) *           &
    5928                                         surf_usm_v(l)%ddz_green(nzb_wall+1,m)      &
    5929                                       + surf_usm_v(l)%wghf_eb(m) ) *               &
    5930                                         surf_usm_v(l)%ddz_green_stag(nzb_wall,m)
    5931            
    5932               DO  kw = nzb_wall+1, nzt_wall
    5933                  gtend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_green(kw,m))          &
    5934                            * (   surf_usm_v(l)%lambda_h_green(kw,m)              &
    5935                              * ( t_green_v(l)%t(kw+1,m) - t_green_v(l)%t(kw,m) ) &
    5936                              * surf_usm_v(l)%ddz_green(kw+1,m)                   &
    5937                            - surf_usm_v(l)%lambda_h(kw-1,m)                      &
    5938                              * ( t_green_v(l)%t(kw,m) - t_green_v(l)%t(kw-1,m) ) &
    5939                              * surf_usm_v(l)%ddz_green(kw,m) )                   &
    5940                            * surf_usm_v(l)%ddz_green_stag(kw,m)
    5941               ENDDO
    5942 
    5943               t_green_v_p(l)%t(nzb_wall:nzt_wall,m) =                              &
    5944                                    t_green_v(l)%t(nzb_wall:nzt_wall,m)             &
    5945                                  + dt_3d * ( tsc(2)                                &
    5946                                  * gtend(nzb_wall:nzt_wall) + tsc(3)               &
    5947                                  * surf_usm_v(l)%tt_green_m(nzb_wall:nzt_wall,m) )   
    5948 
    5949 !
    5950 !--           calculate t_green tendencies for the next Runge-Kutta step
    59515778              IF ( timestep_scheme(1:5) == 'runge' )  THEN
    59525779                  IF ( intermediate_timestep_count == 1 )  THEN
    59535780                     DO  kw = nzb_wall, nzt_wall
    5954                         surf_usm_v(l)%tt_green_m(kw,m) = gtend(kw)
     5781                        surf_usm_h%tt_green_m(kw,m) = gtend(kw)
    59555782                     ENDDO
    59565783                  ELSEIF ( intermediate_timestep_count <                           &
    59575784                           intermediate_timestep_count_max )  THEN
    59585785                      DO  kw = nzb_wall, nzt_wall
    5959                          surf_usm_v(l)%tt_green_m(kw,m) =                          &
    5960                                      - 9.5625_wp * gtend(kw) +                     &
    5961                                        5.3125_wp * surf_usm_v(l)%tt_green_m(kw,m)
     5786                         surf_usm_h%tt_green_m(kw,m) = -9.5625_wp * gtend(kw) +    &
     5787                                            5.3125_wp * surf_usm_h%tt_green_m(kw,m)
    59625788                      ENDDO
    59635789                  ENDIF
    59645790              ENDIF
    5965 endif
    5966 
    5967 DO  kw = nzb_wall, nzt_wall+1
    5968 t_green_v(l)%t(kw,m) = t_wall_v(l)%t(nzb_wall,m)
    5969 ENDDO
     5791
     5792              DO  kw = nzb_wall, nzt_wall
     5793
     5794!
     5795!--              Calculate soil diffusivity at the center of the soil layers
     5796                 lambda_green_temp(kw) = (- b_ch * surf_usm_h%gamma_w_green_sat(kw,m) * psi_sat       &
     5797                                   / swc_sat_h(kw,m) ) * ( MAX( swc_h(kw,m),    &
     5798                                   wilt_h(kw,m) ) / swc_sat_h(kw,m) )**(        &
     5799                                   b_ch + 2.0_wp )
     5800
     5801!
     5802!--              Parametrization of Van Genuchten
     5803                 IF ( soil_type /= 7 )  THEN
     5804!
     5805!--                 Calculate the hydraulic conductivity after Van Genuchten
     5806!--                 (1980)
     5807                    h_vg = ( ( (swc_res_h(kw,m) - swc_sat_h(kw,m)) / ( swc_res_h(kw,m) -    &
     5808                               MAX( swc_h(kw,m), wilt_h(kw,m) ) ) )**(      &
     5809                               surf_usm_h%n_vg_green(m) / (surf_usm_h%n_vg_green(m) - 1.0_wp ) ) - 1.0_wp  &
     5810                           )**( 1.0_wp / surf_usm_h%n_vg_green(m) ) / surf_usm_h%alpha_vg_green(m)
     5811
     5812
     5813                    gamma_green_temp(kw) = surf_usm_h%gamma_w_green_sat(kw,m) * ( ( (1.0_wp +         &
     5814                                    ( surf_usm_h%alpha_vg_green(m) * h_vg )**surf_usm_h%n_vg_green(m))**(  &
     5815                                    1.0_wp - 1.0_wp / surf_usm_h%n_vg_green(m) ) - (        &
     5816                                    surf_usm_h%alpha_vg_green(m) * h_vg )**( surf_usm_h%n_vg_green(m)      &
     5817                                    - 1.0_wp) )**2 )                         &
     5818                                    / ( ( 1.0_wp + ( surf_usm_h%alpha_vg_green(m) * h_vg    &
     5819                                    )**surf_usm_h%n_vg_green(m) )**( ( 1.0_wp  - 1.0_wp     &
     5820                                    / surf_usm_h%n_vg_green(m) ) *( surf_usm_h%l_vg_green(m) + 2.0_wp) ) )
     5821
     5822!
     5823!--              Parametrization of Clapp & Hornberger
     5824                 ELSE
     5825                    gamma_green_temp(kw) = surf_usm_h%gamma_w_green_sat(kw,m) * ( swc_h(kw,m)       &
     5826                                    / swc_sat_h(kw,m) )**(2.0_wp * b_ch + 3.0_wp)
     5827                 ENDIF
     5828
     5829              ENDDO
     5830
     5831!
     5832!--           Prognostic equation for soil moisture content. Only performed,
     5833!--           when humidity is enabled in the atmosphere
     5834              IF ( humidity )  THEN
     5835!
     5836!--              Calculate soil diffusivity (lambda_w) at the _stag level
     5837!--              using linear interpolation. To do: replace this with
     5838!--              ECMWF-IFS Eq. 8.81
     5839                 DO  kw = nzb_wall, nzt_wall-1
     5840                   
     5841                    surf_usm_h%lambda_w_green(kw,m) = ( lambda_green_temp(kw+1) + lambda_green_temp(kw) )  &
     5842                                      * 0.5_wp
     5843                    surf_usm_h%gamma_w_green(kw,m)  = ( gamma_green_temp(kw+1) + gamma_green_temp(kw) )    &
     5844                                      * 0.5_wp
     5845
     5846                 ENDDO
     5847
     5848!
     5849!--              In case of a closed bottom (= water content is conserved),
     5850!--              set hydraulic conductivity to zero to that no water will be
     5851!--              lost in the bottom layer.
     5852                 IF ( conserve_water_content )  THEN
     5853                    surf_usm_h%gamma_w_green(kw,m) = 0.0_wp
     5854                 ELSE
     5855                    surf_usm_h%gamma_w_green(kw,m) = gamma_green_temp(nzt_wall)
     5856                 ENDIF     
     5857
     5858!--              The root extraction (= root_extr * qsws_veg / (rho_l     
     5859!--              * l_v)) ensures the mass conservation for water. The         
     5860!--              transpiration of plants equals the cumulative withdrawals by
     5861!--              the roots in the soil. The scheme takes into account the
     5862!--              availability of water in the soil layers as well as the root
     5863!--              fraction in the respective layer. Layer with moisture below
     5864!--              wilting point will not contribute, which reflects the
     5865!--              preference of plants to take water from moister layers.
     5866
     5867!
     5868!--              Calculate the root extraction (ECMWF 7.69, the sum of
     5869!--              root_extr = 1). The energy balance solver guarantees a
     5870!--              positive transpiration, so that there is no need for an
     5871!--              additional check.
     5872                 m_total = 0.0_wp
     5873                 DO  kw = nzb_wall, nzt_wall
     5874                     IF ( swc_h(kw,m) > wilt_h(kw,m) )  THEN
     5875                        m_total = m_total + rootfr_h(kw,m) * swc_h(kw,m)
     5876                     ENDIF
     5877                 ENDDO 
     5878
     5879                 IF ( m_total > 0.0_wp )  THEN
     5880                    DO  kw = nzb_wall, nzt_wall
     5881                       IF ( swc_h(kw,m) > wilt_h(kw,m) )  THEN
     5882                          root_extr_green(kw) = rootfr_h(kw,m) * swc_h(kw,m)      &
     5883                                                          / m_total
     5884                       ELSE
     5885                          root_extr_green(kw) = 0.0_wp
     5886                       ENDIF
     5887                    ENDDO
     5888                 ENDIF
     5889
     5890!
     5891!--              Prognostic equation for soil water content m_soil.
     5892                 tend(:) = 0.0_wp
     5893
     5894                 tend(nzb_wall) = ( surf_usm_h%lambda_w_green(nzb_wall,m) * (            &
     5895                          swc_h(nzb_wall+1,m) - swc_h(nzb_wall,m) )    &
     5896                          * surf_usm_h%ddz_green(nzb_wall+1,m) - surf_usm_h%gamma_w_green(nzb_wall,m) - ( &
     5897                             root_extr_green(nzb_wall) * surf_usm_h%qsws_veg(m)          &
     5898!                                + surf_usm_h%qsws_soil_green(m)
     5899                                ) * drho_l_lv )             &
     5900                               * surf_usm_h%ddz_green_stag(nzb_wall,m)
     5901
     5902                 DO  kw = nzb_wall+1, nzt_wall-1
     5903                    tend(kw) = ( surf_usm_h%lambda_w_green(kw,m) * ( swc_h(kw+1,m)        &
     5904                              - swc_h(kw,m) ) * surf_usm_h%ddz_green(kw+1,m)              &
     5905                              - surf_usm_h%gamma_w_green(kw,m)                            &
     5906                              - surf_usm_h%lambda_w_green(kw-1,m) * (swc_h(kw,m) -        &
     5907                              swc_h(kw-1,m)) * surf_usm_h%ddz_green(kw,m)                 &
     5908                              + surf_usm_h%gamma_w_green(kw-1,m) - (root_extr_green(kw)   &
     5909                              * surf_usm_h%qsws_veg(m) * drho_l_lv)                       &
     5910                              ) * surf_usm_h%ddz_green_stag(kw,m)
     5911
     5912                 ENDDO
     5913                 tend(nzt_wall) = ( - surf_usm_h%gamma_w_green(nzt_wall,m)                  &
     5914                                         - surf_usm_h%lambda_w_green(nzt_wall-1,m)          &
     5915                                         * (swc_h(nzt_wall,m)             &
     5916                                         - swc_h(nzt_wall-1,m))           &
     5917                                         * surf_usm_h%ddz_green(nzt_wall,m)                 &
     5918                                         + surf_usm_h%gamma_w_green(nzt_wall-1,m) - (       &
     5919                                           root_extr_green(nzt_wall)               &
     5920                                         * surf_usm_h%qsws_veg(m) * drho_l_lv  )   &
     5921                                   ) * surf_usm_h%ddz_green_stag(nzt_wall,m)             
     5922
     5923                 swc_h_p(nzb_wall:nzt_wall,m) = swc_h(nzb_wall:nzt_wall,m)&
     5924                                                 + dt_3d * ( tsc(2) * tend(:)   &
     5925                                                 + tsc(3) * surf_usm_h%tswc_h_m(:,m) )   
     5926 
     5927!
     5928!--              Account for dry soils (find a better solution here!)
     5929                 DO  kw = nzb_wall, nzt_wall
     5930                    IF ( swc_h_p(kw,m) < 0.0_wp )  swc_h_p(kw,m) = 0.0_wp
     5931                 ENDDO
     5932
     5933!
     5934!--              Calculate m_soil tendencies for the next Runge-Kutta step
     5935                 IF ( timestep_scheme(1:5) == 'runge' )  THEN
     5936                    IF ( intermediate_timestep_count == 1 )  THEN
     5937                       DO  kw = nzb_wall, nzt_wall
     5938                          surf_usm_h%tswc_h_m(kw,m) = tend(kw)
     5939                       ENDDO
     5940                    ELSEIF ( intermediate_timestep_count <                   &
     5941                             intermediate_timestep_count_max )  THEN
     5942                       DO  kw = nzb_wall, nzt_wall
     5943                          surf_usm_h%tswc_h_m(kw,m) = -9.5625_wp * tend(kw) + 5.3125_wp&
     5944                                   * surf_usm_h%tswc_h_m(kw,m)
     5945                       ENDDO
     5946                    ENDIF
     5947                 ENDIF
     5948              ENDIF
     5949
     5950           ENDIF
     5951           
     5952        ENDDO
     5953
     5954!
     5955!--     For vertical surfaces     
     5956        DO  l = 0, 3                             
     5957           DO  m = 1, surf_usm_v(l)%ns
     5958
     5959              IF (surf_usm_v(l)%frac(ind_pav_green,m) > 0.0_wp) THEN
     5960!
     5961!-- no substrate layer for green walls / only groundbase green walls (ivy i.e.) -> green layers get same
     5962!-- temperature as first wall layer
     5963!-- there fore no temperature calculations for vertical green substrate layers now
     5964
     5965!
     5966! !
     5967! !--              Obtain indices
     5968!                  i = surf_usm_v(l)%i(m)           
     5969!                  j = surf_usm_v(l)%j(m)
     5970!                  k = surf_usm_v(l)%k(m)
     5971!   
     5972!                  t_green_v(l)%t(nzt_wall+1,m) = t_wall_v(l)%t(nzb_wall,m)
     5973! !
     5974! !--              prognostic equation for green temperature t_green_v
     5975!                  gtend(:) = 0.0_wp
     5976!                  gtend(nzb_wall) = (1.0_wp / surf_usm_v(l)%rho_c_green(nzb_wall,m)) * &
     5977!                                          ( surf_usm_v(l)%lambda_h_green(nzb_wall,m) * &
     5978!                                            ( t_green_v(l)%t(nzb_wall+1,m)             &
     5979!                                            - t_green_v(l)%t(nzb_wall,m) ) *           &
     5980!                                            surf_usm_v(l)%ddz_green(nzb_wall+1,m)      &
     5981!                                          + surf_usm_v(l)%wghf_eb(m) ) *               &
     5982!                                            surf_usm_v(l)%ddz_green_stag(nzb_wall,m)
     5983!               
     5984!                  DO  kw = nzb_wall+1, nzt_wall
     5985!                     gtend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_green(kw,m))          &
     5986!                               * (   surf_usm_v(l)%lambda_h_green(kw,m)              &
     5987!                                 * ( t_green_v(l)%t(kw+1,m) - t_green_v(l)%t(kw,m) ) &
     5988!                                 * surf_usm_v(l)%ddz_green(kw+1,m)                   &
     5989!                               - surf_usm_v(l)%lambda_h(kw-1,m)                      &
     5990!                                 * ( t_green_v(l)%t(kw,m) - t_green_v(l)%t(kw-1,m) ) &
     5991!                                 * surf_usm_v(l)%ddz_green(kw,m) )                   &
     5992!                               * surf_usm_v(l)%ddz_green_stag(kw,m)
     5993!                  ENDDO
     5994!   
     5995!                  t_green_v_p(l)%t(nzb_wall:nzt_wall,m) =                              &
     5996!                                       t_green_v(l)%t(nzb_wall:nzt_wall,m)             &
     5997!                                     + dt_3d * ( tsc(2)                                &
     5998!                                     * gtend(nzb_wall:nzt_wall) + tsc(3)               &
     5999!                                     * surf_usm_v(l)%tt_green_m(nzb_wall:nzt_wall,m) )   
     6000!   
     6001! !
     6002! !--              calculate t_green tendencies for the next Runge-Kutta step
     6003!                  IF ( timestep_scheme(1:5) == 'runge' )  THEN
     6004!                      IF ( intermediate_timestep_count == 1 )  THEN
     6005!                         DO  kw = nzb_wall, nzt_wall
     6006!                            surf_usm_v(l)%tt_green_m(kw,m) = gtend(kw)
     6007!                         ENDDO
     6008!                      ELSEIF ( intermediate_timestep_count <                           &
     6009!                               intermediate_timestep_count_max )  THEN
     6010!                          DO  kw = nzb_wall, nzt_wall
     6011!                             surf_usm_v(l)%tt_green_m(kw,m) =                          &
     6012!                                         - 9.5625_wp * gtend(kw) +                     &
     6013!                                           5.3125_wp * surf_usm_v(l)%tt_green_m(kw,m)
     6014!                          ENDDO
     6015!                      ENDIF
     6016!                  ENDIF
     6017
     6018                 DO  kw = nzb_wall, nzt_wall+1
     6019                     t_green_v(l)%t(kw,m) = t_wall_v(l)%t(nzb_wall,m)
     6020                 ENDDO
    59706021             
    5971 ENDIF
     6022              ENDIF
    59726023
    59736024           ENDDO
     
    60256076                           usm_wall_mod
    60266077                           
    6027                            
    60286078 
    60296079!
     
    60946144    SUBROUTINE usm_read_anthropogenic_heat
    60956145   
    6096         INTEGER(iwp)                  :: i,j,k,ii
    6097         REAL(wp)                      :: heat
    6098 
     6146        INTEGER(iwp)                  :: i,j,k,ii  !< running indices
     6147        REAL(wp)                      :: heat      !< anthropogenic heat
     6148
     6149!
    60996150!--     allocation of array of sources of anthropogenic heat and their diural profile
    61006151        ALLOCATE( aheat(naheatlayers,nys:nyn,nxl:nxr) )
    61016152        ALLOCATE( aheatprof(naheatlayers,0:24) )
    61026153
    6103 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     6154!
    61046155!--     read daily amount of heat and its daily cycle
    6105 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    61066156        aheat = 0.0_wp
    61076157        DO  ii = 0, io_blocks-1
     
    61366186        ENDDO
    61376187       
    6138 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     6188!
    61396189!--     read diurnal profiles of heat sources
    6140 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    61416190        aheatprof = 0.0_wp
    61426191        DO  ii = 0, io_blocks-1
    61436192            IF ( ii == io_group )  THEN
    6144 
     6193!
    61456194!--             open anthropogenic heat profile file
    61466195                OPEN( 151, file='ANTHROPOGENIC_HEAT_PROFILE'//TRIM(coupling_char), action='read', &
     
    61886237       IMPLICIT NONE
    61896238
    6190        INTEGER(iwp)       ::  l                !< index variable for surface type
    6191        INTEGER(iwp)       ::  i                !< running index over input files
    6192        INTEGER(iwp)       ::  k                !< running index over previous input files covering current local domain
    6193        INTEGER(iwp)       ::  ns_h_on_file_usm !< number of horizontal surface elements (urban type) on file
    6194        INTEGER(iwp)       ::  nxlc             !< index of left boundary on current subdomain
    6195        INTEGER(iwp)       ::  nxlf             !< index of left boundary on former subdomain
    6196        INTEGER(iwp)       ::  nxl_on_file      !< index of left boundary on former local domain
    6197        INTEGER(iwp)       ::  nxrc             !< index of right boundary on current subdomain
    6198        INTEGER(iwp)       ::  nxrf             !< index of right boundary on former subdomain
    6199        INTEGER(iwp)       ::  nxr_on_file      !< index of right boundary on former local domain
    6200        INTEGER(iwp)       ::  nync             !< index of north boundary on current subdomain
    6201        INTEGER(iwp)       ::  nynf             !< index of north boundary on former subdomain
    6202        INTEGER(iwp)       ::  nyn_on_file      !< index of north boundary on former local domain
    6203        INTEGER(iwp)       ::  nysc             !< index of south boundary on current subdomain
    6204        INTEGER(iwp)       ::  nysf             !< index of south boundary on former subdomain
    6205        INTEGER(iwp)       ::  nys_on_file      !< index of south boundary on former local domain
     6239       INTEGER(iwp)       ::  l                 !< index variable for surface type
     6240       INTEGER(iwp)       ::  i                 !< running index over input files
     6241       INTEGER(iwp)       ::  k                 !< running index over previous input files covering current local domain
     6242       INTEGER(iwp)       ::  ns_h_on_file_usm  !< number of horizontal surface elements (urban type) on file
     6243       INTEGER(iwp)       ::  nxlc              !< index of left boundary on current subdomain
     6244       INTEGER(iwp)       ::  nxlf              !< index of left boundary on former subdomain
     6245       INTEGER(iwp)       ::  nxl_on_file       !< index of left boundary on former local domain
     6246       INTEGER(iwp)       ::  nxrc              !< index of right boundary on current subdomain
     6247       INTEGER(iwp)       ::  nxrf              !< index of right boundary on former subdomain
     6248       INTEGER(iwp)       ::  nxr_on_file       !< index of right boundary on former local domain
     6249       INTEGER(iwp)       ::  nync              !< index of north boundary on current subdomain
     6250       INTEGER(iwp)       ::  nynf              !< index of north boundary on former subdomain
     6251       INTEGER(iwp)       ::  nyn_on_file       !< index of north boundary on former local domain
     6252       INTEGER(iwp)       ::  nysc              !< index of south boundary on current subdomain
     6253       INTEGER(iwp)       ::  nysf              !< index of south boundary on former subdomain
     6254       INTEGER(iwp)       ::  nys_on_file       !< index of south boundary on former local domain
    62066255       
    6207        INTEGER(iwp)       ::  ns_v_on_file_usm(0:3) !< number of vertical surface elements (urban type) on file
     6256       INTEGER(iwp)       ::  ns_v_on_file_usm(0:3)  !< number of vertical surface elements (urban type) on file
    62086257       
    62096258       INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  start_index_on_file
     
    62606309
    62616310                   DO  l = 0, 3
    6262                       IF ( ALLOCATED( tmp_surf_wall_v(l)%t ) )                      &
     6311                      IF ( ALLOCATED( tmp_surf_wall_v(l)%t ) )                 &
    62636312                         DEALLOCATE( tmp_surf_wall_v(l)%t )
    62646313                      IF ( ALLOCATED( tmp_wall_v(l)%t ) )                      &
     
    63226371             CASE ( 't_surf_wall_h' )
    63236372                IF ( k == 1 )  THEN
    6324                    IF ( .NOT.  ALLOCATED( t_surf_wall_h_1 ) )                       &
     6373                   IF ( .NOT.  ALLOCATED( t_surf_wall_h_1 ) )                  &
    63256374                      ALLOCATE( t_surf_wall_h_1(1:surf_usm_h%ns) )
    63266375                   READ ( 13 )  tmp_surf_wall_h
     
    63386387             CASE ( 't_surf_wall_v(0)' )
    63396388                IF ( k == 1 )  THEN
    6340                    IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(0)%t ) )                  &
     6389                   IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(0)%t ) )             &
    63416390                      ALLOCATE( t_surf_wall_v_1(0)%t(1:surf_usm_v(0)%ns) )
    63426391                   READ ( 13 )  tmp_surf_wall_v(0)%t
     
    63546403             CASE ( 't_surf_wall_v(1)' )
    63556404                IF ( k == 1 )  THEN
    6356                    IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(1)%t ) )                  &
     6405                   IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(1)%t ) )             &
    63576406                      ALLOCATE( t_surf_wall_v_1(1)%t(1:surf_usm_v(1)%ns) )
    63586407                   READ ( 13 )  tmp_surf_wall_v(1)%t
     
    63706419             CASE ( 't_surf_wall_v(2)' )
    63716420                IF ( k == 1 )  THEN
    6372                    IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(2)%t ) )                  &
     6421                   IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(2)%t ) )             &
    63736422                      ALLOCATE( t_surf_wall_v_1(2)%t(1:surf_usm_v(2)%ns) )
    63746423                   READ ( 13 )  tmp_surf_wall_v(2)%t
     
    63866435             CASE ( 't_surf_wall_v(3)' )
    63876436                IF ( k == 1 )  THEN
    6388                    IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(3)%t ) )                  &
     6437                   IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(3)%t ) )             &
    63896438                      ALLOCATE( t_surf_wall_v_1(3)%t(1:surf_usm_v(3)%ns) )
    63906439                   READ ( 13 )  tmp_surf_wall_v(3)%t
     
    68356884       
    68366885    END SUBROUTINE usm_rrd_local
    6837    
    68386886
    68396887   
     
    68836931        IF ( .NOT. ascii_file )  RETURN
    68846932
    6885 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     6933!
    68866934!--     read categories of walls and their parameters
    6887 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    68886935        DO  ii = 0, io_blocks-1
    68896936            IF ( ii == io_group )  THEN
    6890 
     6937!
    68916938!--             open urban surface file
    68926939                OPEN( 151, file='SURFACE_PARAMETERS'//coupling_char, action='read', &
    6893                            status='old', form='formatted', err=15 )
     6940                           status='old', form='formatted', err=15 )
     6941!
    68946942!--             first test and get n_surface_types
    68956943                k = 0
     
    69066954                ALLOCATE( surface_type_codes(n_surface_types) )
    69076955                ALLOCATE( surface_params(n_surface_params, n_surface_types) )
     6956!
    69086957!--             real reading
    69096958                rewind( 151 )
     
    69276976        ENDDO
    69286977   
    6929 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     6978!
    69306979!--     read types of surfaces
    6931 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    69326980        usm_par = 0
    69336981        DO  ii = 0, io_blocks-1
    69346982            IF ( ii == io_group )  THEN
    69356983
    6936                 !
     6984!
    69376985!--             open csv urban surface file
    69386986                OPEN( 151, file='URBAN_SURFACE'//TRIM(coupling_char), action='read', &
     
    69426990                DO
    69436991                    l = l+1
     6992!
    69446993!--                 i, j, height, nz, roof, dirwe, dirsn, category, soilcat,
    69456994!--                 weheight1, wecat1, snheight1, sncat1, weheight2, wecat2, snheight2, sncat2,
     
    69557004
    69567005                    IF ( i >= nxlg  .AND.  i <= nxrg  .AND.  j >= nysg  .AND.  j <= nyng )  THEN
     7006!
    69577007!--                     write integer variables into array
    69587008                        usm_par(:,j,i) = (/1, nz, roof, dirwe, dirsn, category,                      &
    69597009                                          weheight1, wecat1, weheight2, wecat2, weheight3, wecat3,   &
    69607010                                          snheight1, sncat1, snheight2, sncat2, snheight3, sncat3 /)
     7011!
    69617012!--                     write real values into array
    69627013                        usm_val(:,j,i) = (/ albedo, thick,                                           &
     
    70037054                     usm_par(16,j,i) > nzt                &  !< incorrect wall or roof level height for south-north wall
    70047055                    ) )  THEN
     7056!
    70057057!--                 incorrect input data
    70067058                    WRITE (message_string, "(A,2I5)") 'missing or incorrect data in file URBAN_SURFACE'// &
     
    70637115           ENDDO
    70647116           IF ( ip == -99999 )  THEN
     7117!
    70657118!--           land/roof category not found
    70667119              WRITE (9,"(A,I5,A,3I5)") 'land/roof category ', it,     &
     
    70797132              ENDDO
    70807133              IF ( ip == -99999 )  THEN
     7134!
    70817135!--              default land/roof category not found
    70827136                 WRITE (9,"(A,I5,A,3I5)") 'Default land/roof category', category, ' not found!'
     
    70907144              surf_usm_h%albedo(:,m) = surface_params(ialbedo,ip)
    70917145           ENDIF
     7146!
    70927147!--        Albedo type is 0 (custom), others are replaced later
    70937148           surf_usm_h%albedo_type(:,m) = 0
     7149!
    70947150!--        Transmissivity
    70957151           IF ( surf_usm_h%transmissivity(m) < 0.0_wp )  THEN
     
    71757231
    71767232              IF ( iw < 0 .OR. jw < 0 ) THEN
     7233!
    71777234!--              wall on west or south border of the domain - assign default category
    71787235                 IF ( kw <= roof_height_limit ) THEN
     
    71817238                     surf_usm_v(l)%surface_types(m) = roof_category   !< default category for wall surface in roof zone
    71827239                 END IF
    7183                  surf_usm_v(l)%albedo(:,m)    = -1.0_wp
    7184                  surf_usm_v(l)%thickness_wall(m) = -1.0_wp
    7185                  surf_usm_v(l)%thickness_window(m)   = -1.0_wp
    7186                  surf_usm_v(l)%thickness_green(m)    = -1.0_wp
    7187                  surf_usm_v(l)%transmissivity(m)  = -1.0_wp
     7240                 surf_usm_v(l)%albedo(:,m)         = -1.0_wp
     7241                 surf_usm_v(l)%thickness_wall(m)   = -1.0_wp
     7242                 surf_usm_v(l)%thickness_window(m) = -1.0_wp
     7243                 surf_usm_v(l)%thickness_green(m)  = -1.0_wp
     7244                 surf_usm_v(l)%transmissivity(m)   = -1.0_wp
    71887245              ELSE IF ( kw <= usm_par(ii,jw,iw) )  THEN
     7246!
    71897247!--                 pedestrian zone
    71907248                 IF ( usm_par(ii+1,jw,iw) == 0 )  THEN
    7191                      surf_usm_v(l)%surface_types(m)  = pedestrian_category   !< default category for wall surface in pedestrian zone
    7192                      surf_usm_v(l)%albedo(:,m)    = -1.0_wp
    7193                      surf_usm_v(l)%thickness_wall(m) = -1.0_wp
    7194                      surf_usm_v(l)%thickness_window(m)   = -1.0_wp
    7195                      surf_usm_v(l)%thickness_green(m)    = -1.0_wp
    7196                      surf_usm_v(l)%transmissivity(m)  = -1.0_wp
     7249                     surf_usm_v(l)%surface_types(m)  = pedestrian_category   !< default category for wall surface in
     7250                                                                             !<pedestrian zone
     7251                     surf_usm_v(l)%albedo(:,m)         = -1.0_wp
     7252                     surf_usm_v(l)%thickness_wall(m)   = -1.0_wp
     7253                     surf_usm_v(l)%thickness_window(m) = -1.0_wp
     7254                     surf_usm_v(l)%thickness_green(m)  = -1.0_wp
     7255                     surf_usm_v(l)%transmissivity(m)   = -1.0_wp
    71977256                 ELSE
    7198                      surf_usm_v(l)%surface_types(m)  = usm_par(ii+1,jw,iw)
    7199                      surf_usm_v(l)%albedo(:,m)    = usm_val(ij,jw,iw)
    7200                      surf_usm_v(l)%thickness_wall(m) = usm_val(ij+1,jw,iw)
    7201                      surf_usm_v(l)%thickness_window(m)   = usm_val(ij+1,jw,iw)
    7202                      surf_usm_v(l)%thickness_green(m)    = usm_val(ij+1,jw,iw)
    7203                      surf_usm_v(l)%transmissivity(m)  = 0.0_wp
     7257                     surf_usm_v(l)%surface_types(m)    = usm_par(ii+1,jw,iw)
     7258                     surf_usm_v(l)%albedo(:,m)         = usm_val(ij,jw,iw)
     7259                     surf_usm_v(l)%thickness_wall(m)   = usm_val(ij+1,jw,iw)
     7260                     surf_usm_v(l)%thickness_window(m) = usm_val(ij+1,jw,iw)
     7261                     surf_usm_v(l)%thickness_green(m)  = usm_val(ij+1,jw,iw)
     7262                     surf_usm_v(l)%transmissivity(m)   = 0.0_wp
    72047263                 ENDIF
    72057264              ELSE IF ( kw <= usm_par(ii+2,jw,iw) )  THEN
     7265!
    72067266!--              wall zone
    72077267                 IF ( usm_par(ii+3,jw,iw) == 0 )  THEN
    7208                      surf_usm_v(l)%surface_types(m)  = wall_category         !< default category for wall surface
    7209                      surf_usm_v(l)%albedo(:,m)    = -1.0_wp
    7210                      surf_usm_v(l)%thickness_wall(m) = -1.0_wp
    7211                      surf_usm_v(l)%thickness_window(m)   = -1.0_wp
    7212                      surf_usm_v(l)%thickness_green(m)    = -1.0_wp
    7213                      surf_usm_v(l)%transmissivity(m)  = -1.0_wp
     7268                     surf_usm_v(l)%surface_types(m)    = wall_category         !< default category for wall surface
     7269                     surf_usm_v(l)%albedo(:,m)         = -1.0_wp
     7270                     surf_usm_v(l)%thickness_wall(m)   = -1.0_wp
     7271                     surf_usm_v(l)%thickness_window(m) = -1.0_wp
     7272                     surf_usm_v(l)%thickness_green(m)  = -1.0_wp
     7273                     surf_usm_v(l)%transmissivity(m)   = -1.0_wp
    72147274                 ELSE
    7215                      surf_usm_v(l)%surface_types(m)  = usm_par(ii+3,jw,iw)
    7216                      surf_usm_v(l)%albedo(:,m)    = usm_val(ij+2,jw,iw)
    7217                      surf_usm_v(l)%thickness_wall(m) = usm_val(ij+3,jw,iw)
    7218                      surf_usm_v(l)%thickness_window(m)   = usm_val(ij+3,jw,iw)
    7219                      surf_usm_v(l)%thickness_green(m)    = usm_val(ij+3,jw,iw)
    7220                      surf_usm_v(l)%transmissivity(m)  = 0.0_wp
     7275                     surf_usm_v(l)%surface_types(m)    = usm_par(ii+3,jw,iw)
     7276                     surf_usm_v(l)%albedo(:,m)         = usm_val(ij+2,jw,iw)
     7277                     surf_usm_v(l)%thickness_wall(m)   = usm_val(ij+3,jw,iw)
     7278                     surf_usm_v(l)%thickness_window(m) = usm_val(ij+3,jw,iw)
     7279                     surf_usm_v(l)%thickness_green(m)  = usm_val(ij+3,jw,iw)
     7280                     surf_usm_v(l)%transmissivity(m)   = 0.0_wp
    72217281                 ENDIF
    72227282              ELSE IF ( kw <= usm_par(ii+4,jw,iw) )  THEN
     7283!
    72237284!--              roof zone
    72247285                 IF ( usm_par(ii+5,jw,iw) == 0 )  THEN
    7225                      surf_usm_v(l)%surface_types(m)  = roof_category         !< default category for roof surface
    7226                      surf_usm_v(l)%albedo(:,m)    = -1.0_wp
    7227                      surf_usm_v(l)%thickness_wall(m) = -1.0_wp
    7228                      surf_usm_v(l)%thickness_window(m)   = -1.0_wp
    7229                      surf_usm_v(l)%thickness_green(m)    = -1.0_wp
    7230                      surf_usm_v(l)%transmissivity(m)  = -1.0_wp
     7286                     surf_usm_v(l)%surface_types(m)    = roof_category         !< default category for roof surface
     7287                     surf_usm_v(l)%albedo(:,m)         = -1.0_wp
     7288                     surf_usm_v(l)%thickness_wall(m)   = -1.0_wp
     7289                     surf_usm_v(l)%thickness_window(m) = -1.0_wp
     7290                     surf_usm_v(l)%thickness_green(m)  = -1.0_wp
     7291                     surf_usm_v(l)%transmissivity(m)   = -1.0_wp
    72317292                 ELSE
    7232                      surf_usm_v(l)%surface_types(m)  = usm_par(ii+5,jw,iw)
    7233                      surf_usm_v(l)%albedo(:,m)    = usm_val(ij+4,jw,iw)
    7234                      surf_usm_v(l)%thickness_wall(m) = usm_val(ij+5,jw,iw)
    7235                      surf_usm_v(l)%thickness_window(m)   = usm_val(ij+5,jw,iw)
    7236                      surf_usm_v(l)%thickness_green(m)    = usm_val(ij+5,jw,iw)
    7237                      surf_usm_v(l)%transmissivity(m)  = 0.0_wp
     7293                     surf_usm_v(l)%surface_types(m)    = usm_par(ii+5,jw,iw)
     7294                     surf_usm_v(l)%albedo(:,m)         = usm_val(ij+4,jw,iw)
     7295                     surf_usm_v(l)%thickness_wall(m)   = usm_val(ij+5,jw,iw)
     7296                     surf_usm_v(l)%thickness_window(m) = usm_val(ij+5,jw,iw)
     7297                     surf_usm_v(l)%thickness_green(m)  = usm_val(ij+5,jw,iw)
     7298                     surf_usm_v(l)%transmissivity(m)   = 0.0_wp
    72387299                 ENDIF
    72397300              ELSE
    7240 !
    72417301                 WRITE(9,*) 'Problem reading USM data:'
    72427302                 WRITE(9,*) l,i,j,kw,get_topography_top_index_ji( j, i, 's' )
     
    72477307                 WRITE(9,*) kw,roof_height_limit,wall_category,roof_category
    72487308                 FLUSH(9)
     7309!
    72497310!--              supply the default category
    72507311                 IF ( kw <= roof_height_limit ) THEN
     
    72537314                     surf_usm_v(l)%surface_types(m) = roof_category   !< default category for wall surface in roof zone
    72547315                 END IF
    7255                  surf_usm_v(l)%albedo(:,m)    = -1.0_wp
    7256                  surf_usm_v(l)%thickness_wall(m) = -1.0_wp
     7316                 surf_usm_v(l)%albedo(:,m)         = -1.0_wp
     7317                 surf_usm_v(l)%thickness_wall(m)   = -1.0_wp
    72577318                 surf_usm_v(l)%thickness_window(m) = -1.0_wp
    7258                  surf_usm_v(l)%thickness_green(m) = -1.0_wp
    7259                  surf_usm_v(l)%transmissivity(m)  = -1.0_wp
     7319                 surf_usm_v(l)%thickness_green(m)  = -1.0_wp
     7320                 surf_usm_v(l)%transmissivity(m)   = -1.0_wp
    72607321              ENDIF
    72617322!
     
    72707331              ENDDO
    72717332              IF ( ip == -99999 )  THEN
     7333!
    72727334!--              wall category not found
    72737335                 WRITE (9, "(A,I7,A,3I5)") 'wall category ', it,  &
     
    72827344                 ENDDO
    72837345                 IF ( ip == -99999 )  THEN
     7346!
    72847347!--                 default wall category not found
    72857348                    WRITE (9, "(A,I5,A,3I5)") 'Default wall category', category, ' not found!'
     
    74057468           ENDDO
    74067469        ENDIF
    7407 
     7470!
    74087471!--     coordinate not found
    74097472        isurfl = -1
     
    74237486    SUBROUTINE usm_read_wall_temperature
    74247487
    7425         INTEGER(iwp)                                          :: i, j, k, d, ii, iline
     7488        INTEGER(iwp)                                          :: i, j, k, d, ii, iline  !> running indices
    74267489        INTEGER(iwp)                                          :: isurfl
    74277490        REAL(wp)                                              :: rtsurf
     
    74297492
    74307493
    7431 
    7432 
    74337494        DO  ii = 0, io_blocks-1
    74347495            IF ( ii == io_group )  THEN
    7435 
     7496!
    74367497!--             open wall temperature file
    74377498                OPEN( 152, file='WALL_TEMPERATURE'//coupling_char, action='read', &
     
    74547515                            CALL message( 'usm_read_wall_temperature', 'PA0521', 1, 2, 0, 6, 0 )
    74557516                        ENDIF
    7456 
     7517!
    74577518!--                     assign temperatures
    74587519                        IF ( d == 0 ) THEN
     
    74987559!> with many simplifications and adjustments.
    74997560!> TODO better description
     7561!> No calculation of window surface temperatures during spinup to increase
     7562!> maximum possible timstep
    75007563!------------------------------------------------------------------------------!
    75017564    SUBROUTINE usm_surface_energy_balance( spinup )
     
    75047567        IMPLICIT NONE
    75057568
    7506         INTEGER(iwp) :: i, j, k, l, m   !< running indices
     7569        INTEGER(iwp)                          :: i, j, k, l, m   !< running indices
    75077570       
    75087571        INTEGER(iwp) ::  i_off     !< offset to determine index of surface element, seen from atmospheric grid point, for x
     
    75127575        LOGICAL                               :: spinup             !true during spinup
    75137576       
    7514         REAL(wp)                              :: stend_wall              !< surface tendency
     7577        REAL(wp)                              :: stend_wall         !< surface tendency
    75157578       
    75167579        REAL(wp)                              :: stend_window       !< surface tendency
     
    75267589        REAL(wp)                              :: f_shf_window       !< factor for shf_eb window
    75277590        REAL(wp)                              :: f_shf_green        !< factor for shf_eb green wall
    7528         REAL(wp)                              :: lambda_surface     !< current value of lambda_surface (heat conductivity between air and wall)
    7529         REAL(wp)                              :: lambda_surface_window !< current value of lambda_surface (heat conductivity between air and window)
    7530         REAL(wp)                              :: lambda_surface_green  !< current value of lambda_surface (heat conductivity between air and greeb wall)
     7591        REAL(wp)                              :: lambda_surface     !< current value of lambda_surface (heat conductivity
     7592                                                                    !<between air and wall)
     7593        REAL(wp)                              :: lambda_surface_window  !< current value of lambda_surface (heat conductivity
     7594                                                                        !< between air and window)
     7595        REAL(wp)                              :: lambda_surface_green   !< current value of lambda_surface (heat conductivity
     7596                                                                        !< between air and greeb wall)
    75317597       
    75327598        REAL(wp)                              :: dtime              !< simulated time of day (in UTC)
    75337599        INTEGER(iwp)                          :: dhour              !< simulated hour of day (in UTC)
    75347600        REAL(wp)                              :: acoef              !< actual coefficient of diurnal profile of anthropogenic heat
    7535         REAL(wp) ::  f1,          & !< resistance correction term 1
    7536                      f2,          & !< resistance correction term 2
    7537                      f3,          & !< resistance correction term 3
    7538                      e,           & !< water vapour pressure
    7539                      e_s,         & !< water vapour saturation pressure
    7540                      e_s_dt,      & !< derivate of e_s with respect to T
    7541                      tend,        & !< tendency
    7542                      dq_s_dt,     & !< derivate of q_s with respect to T
    7543                      f_qsws,      & !< factor for qsws
    7544                      f_qsws_veg,  & !< factor for qsws_veg
    7545                      f_qsws_liq,  & !< factor for qsws_liq
    7546                      m_liq_max,   & !< maxmimum value of the liq. water reservoir
    7547                      qv1,         & !< specific humidity at first grid level
    7548                      m_max_depth = 0.0002_wp, & ! Maximum capacity of the water reservoir (m)
    7549                      rho_lv,      &
    7550                      drho_l_lv,   &
    7551                      q_s
     7601        REAL(wp) ::  f1,          &  !< resistance correction term 1
     7602                     f2,          &  !< resistance correction term 2
     7603                     f3,          &  !< resistance correction term 3
     7604                     e,           &  !< water vapour pressure
     7605                     e_s,         &  !< water vapour saturation pressure
     7606                     e_s_dt,      &  !< derivate of e_s with respect to T
     7607                     tend,        &  !< tendency
     7608                     dq_s_dt,     &  !< derivate of q_s with respect to T
     7609                     f_qsws,      &  !< factor for qsws
     7610                     f_qsws_veg,  &  !< factor for qsws_veg
     7611                     f_qsws_liq,  &  !< factor for qsws_liq
     7612                     m_liq_max,   &  !< maxmimum value of the liq. water reservoir
     7613                     qv1,         &  !< specific humidity at first grid level
     7614                     m_max_depth = 0.0002_wp, &  !< Maximum capacity of the water reservoir (m)
     7615                     rho_lv,      &  !< frequently used parameter for green layers
     7616                     drho_l_lv,   &  !< frequently used parameter for green layers
     7617                     q_s             !< saturation specific humidity
    75527618
    75537619!
     
    76027668!--        pt, us, ts are not available for the prognostic time step,
    76037669!--        data from the last time step is used here.
    7604 
     7670!
    76057671!--        Workaround: use single r_a as stability is only treated for the
    76067672!--        average temperature
     
    76217687               surf_usm_h%r_a(m)        = 1.0_wp
    76227688           IF ( surf_usm_h%r_a_green(m)  < 1.0_wp )                            &
    7623                surf_usm_h%r_a_green(m) = 1.0_wp
     7689               surf_usm_h%r_a_green(m)  = 1.0_wp
    76247690           IF ( surf_usm_h%r_a_window(m) < 1.0_wp )                            &
    76257691               surf_usm_h%r_a_window(m) = 1.0_wp
     
    76317697               surf_usm_h%r_a(m)        = 300.0_wp
    76327698           IF ( surf_usm_h%r_a_green(m)  > 300.0_wp )                          &
    7633                surf_usm_h%r_a_green(m) = 300.0_wp
     7699               surf_usm_h%r_a_green(m)  = 300.0_wp
    76347700           IF ( surf_usm_h%r_a_window(m) > 300.0_wp )                          &
    76357701               surf_usm_h%r_a_window(m) = 300.0_wp               
    76367702               
    7637                
     7703!
    76387704!--        factor for shf_eb
    76397705           f_shf  = rho_cp / surf_usm_h%r_a(m)
     
    76417707           f_shf_green  = rho_cp / surf_usm_h%r_a_green(m)
    76427708       
    7643 !***************************************************************************************
    7644 if (surf_usm_h%frac(ind_pav_green,m).gt.0.0_wp) then
    7645 !--    Adapted from LSM:
    7646 !--    Second step: calculate canopy resistance r_canopy
    7647 !--    f1-f3 here are defined as 1/f1-f3 as in ECMWF documentation
     7709
     7710           IF ( surf_usm_h%frac(ind_pav_green,m) > 0.0_wp ) THEN
     7711!--           Adapted from LSM:
     7712!--           Second step: calculate canopy resistance r_canopy
     7713!--           f1-f3 here are defined as 1/f1-f3 as in ECMWF documentation
    76487714 
    7649 !--    f1: correction for incoming shortwave radiation (stomata close at
    7650 !--    night)
    7651        f1 = MIN( 1.0_wp, ( 0.004_wp * surf_usm_h%rad_sw_in(m) + 0.05_wp ) / &
    7652                         (0.81_wp * (0.004_wp * surf_usm_h%rad_sw_in(m)      &
    7653                          + 1.0_wp)) )
    7654 !
    7655 !--    f2: correction for soil moisture availability to plants (the
    7656 !--    integrated soil moisture must thus be considered here)
    7657 !--    f2 = 0 for very dry soils
    7658           m_total = 0.0_wp
    7659           DO  k = nzb_wall, nzt_wall+1
    7660               m_total = m_total + rootfr_h(nzb_wall,m)                              &
    7661                         * MAX(swc_h(nzb_wall,m),wilt_h(nzb_wall,m))
    7662           ENDDO
    7663 
    7664           IF ( m_total > wilt_h(nzb_wall,m)  .AND.  m_total < fc_h(nzb_wall,m) )  THEN
    7665              f2 = ( m_total - wilt_h(nzb_wall,m) ) / (fc_h(nzb_wall,m) - wilt_h(nzb_wall,m) )
    7666           ELSEIF ( m_total >= fc_h(nzb_wall,m) )  THEN
    7667              f2 = 1.0_wp
    7668           ELSE
    7669              f2 = 1.0E-20_wp
    7670           ENDIF
    7671 
    7672 !
    7673 !--    Calculate water vapour pressure at saturation
    7674        e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp * ( t_surf_green_h(m) &
    7675                      - 273.16_wp ) / ( t_surf_green_h(m) - 35.86_wp ) )
    7676 !
    7677 !--    f3: correction for vapour pressure deficit
    7678        IF ( surf_usm_h%g_d(m) /= 0.0_wp )  THEN
    7679 !
    7680 !--       Calculate vapour pressure
    7681           e  = qv1 * surface_pressure / ( qv1 + 0.622_wp )
    7682           f3 = EXP ( - surf_usm_h%g_d(m) * (e_s - e) )
    7683        ELSE
    7684           f3 = 1.0_wp
    7685        ENDIF
    7686 
    7687 !
    7688 !--    Calculate canopy resistance. In case that c_veg is 0 (bare soils),
    7689 !--    this calculation is obsolete, as r_canopy is not used below.
    7690 !--    To do: check for very dry soil -> r_canopy goes to infinity
    7691        surf_usm_h%r_canopy(m) = surf_usm_h%r_canopy_min(m) /                               &
     7715!--           f1: correction for incoming shortwave radiation (stomata close at
     7716!--           night)
     7717              f1 = MIN( 1.0_wp, ( 0.004_wp * surf_usm_h%rad_sw_in(m) + 0.05_wp ) / &
     7718                               (0.81_wp * (0.004_wp * surf_usm_h%rad_sw_in(m)      &
     7719                                + 1.0_wp)) )
     7720!
     7721!--           f2: correction for soil moisture availability to plants (the
     7722!--           integrated soil moisture must thus be considered here)
     7723!--           f2 = 0 for very dry soils
     7724              m_total = 0.0_wp
     7725              DO  k = nzb_wall, nzt_wall+1
     7726                  m_total = m_total + rootfr_h(nzb_wall,m)                              &
     7727                            * MAX(swc_h(nzb_wall,m),wilt_h(nzb_wall,m))
     7728              ENDDO
     7729   
     7730              IF ( m_total > wilt_h(nzb_wall,m)  .AND.  m_total < fc_h(nzb_wall,m) )  THEN
     7731                 f2 = ( m_total - wilt_h(nzb_wall,m) ) / (fc_h(nzb_wall,m) - wilt_h(nzb_wall,m) )
     7732              ELSEIF ( m_total >= fc_h(nzb_wall,m) )  THEN
     7733                 f2 = 1.0_wp
     7734              ELSE
     7735                 f2 = 1.0E-20_wp
     7736              ENDIF
     7737       
     7738!
     7739!--          Calculate water vapour pressure at saturation
     7740              e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp * ( t_surf_green_h(m) &
     7741                            - 273.16_wp ) / ( t_surf_green_h(m) - 35.86_wp ) )
     7742!
     7743!--           f3: correction for vapour pressure deficit
     7744              IF ( surf_usm_h%g_d(m) /= 0.0_wp )  THEN
     7745!
     7746!--           Calculate vapour pressure
     7747                 e  = qv1 * surface_pressure / ( qv1 + 0.622_wp )
     7748                 f3 = EXP ( - surf_usm_h%g_d(m) * (e_s - e) )
     7749              ELSE
     7750                 f3 = 1.0_wp
     7751              ENDIF
     7752
     7753!
     7754!--           Calculate canopy resistance. In case that c_veg is 0 (bare soils),
     7755!--           this calculation is obsolete, as r_canopy is not used below.
     7756!--           To do: check for very dry soil -> r_canopy goes to infinity
     7757              surf_usm_h%r_canopy(m) = surf_usm_h%r_canopy_min(m) /                   &
    76927758                              ( surf_usm_h%lai(m) * f1 * f2 * f3 + 1.0E-20_wp )
    76937759
    76947760!
    7695 !--    Calculate the maximum possible liquid water amount on plants and
    7696 !--    bare surface. For vegetated surfaces, a maximum depth of 0.2 mm is
    7697 !--    assumed, while paved surfaces might hold up 1 mm of water. The
    7698 !--    liquid water fraction for paved surfaces is calculated after
    7699 !--    Noilhan & Planton (1989), while the ECMWF formulation is used for
    7700 !--    vegetated surfaces and bare soils.
    7701        m_liq_max = m_max_depth * ( surf_usm_h%lai(m) )
    7702        surf_usm_h%c_liq(m) = MIN( 1.0_wp, ( m_liq_usm_h%var_usm_1d(m) / m_liq_max )**0.67 )
    7703 !
    7704 !--    Calculate saturation specific humidity
    7705        q_s = 0.622_wp * e_s / ( surface_pressure - e_s )
    7706 !
    7707 !--    In case of dewfall, set evapotranspiration to zero
    7708 !--    All super-saturated water is then removed from the air
    7709        IF ( humidity  .AND.  q_s <= qv1 )  THEN
    7710           surf_usm_h%r_canopy(m) = 0.0_wp
    7711        ENDIF
    7712 
    7713 !
    7714 !--    Calculate coefficients for the total evapotranspiration
    7715 !--    In case of water surface, set vegetation and soil fluxes to zero.
    7716 !--    For pavements, only evaporation of liquid water is possible.
    7717        f_qsws_veg  = rho_lv *                                &
    7718                          ( 1.0_wp        - surf_usm_h%c_liq(m)    ) /   &
    7719                          ( surf_usm_h%r_a_green(m) + surf_usm_h%r_canopy(m) )
    7720        f_qsws_liq  = rho_lv * surf_usm_h%c_liq(m)   /             &
    7721                            surf_usm_h%r_a_green(m)
    7722 
    7723        f_qsws = f_qsws_veg + f_qsws_liq
    7724 !
    7725 !--    Calculate derivative of q_s for Taylor series expansion
    7726        e_s_dt = e_s * ( 17.269_wp / ( t_surf_green_h(m) - 35.86_wp) -   &
    7727                         17.269_wp*( t_surf_green_h(m) - 273.16_wp)      &
    7728                        / ( t_surf_green_h(m) - 35.86_wp)**2 )
    7729 
    7730        dq_s_dt = 0.622_wp * e_s_dt / ( surface_pressure - e_s_dt )
    7731 endif
    7732 !***********************************************************************************
     7761!--           Calculate the maximum possible liquid water amount on plants and
     7762!--           bare surface. For vegetated surfaces, a maximum depth of 0.2 mm is
     7763!--           assumed, while paved surfaces might hold up 1 mm of water. The
     7764!--           liquid water fraction for paved surfaces is calculated after
     7765!--           Noilhan & Planton (1989), while the ECMWF formulation is used for
     7766!--           vegetated surfaces and bare soils.
     7767              m_liq_max = m_max_depth * ( surf_usm_h%lai(m) )
     7768              surf_usm_h%c_liq(m) = MIN( 1.0_wp, ( m_liq_usm_h%var_usm_1d(m) / m_liq_max )**0.67 )
     7769!
     7770!--           Calculate saturation specific humidity
     7771              q_s = 0.622_wp * e_s / ( surface_pressure - e_s )
     7772!
     7773!--           In case of dewfall, set evapotranspiration to zero
     7774!--           All super-saturated water is then removed from the air
     7775              IF ( humidity  .AND.  q_s <= qv1 )  THEN
     7776                 surf_usm_h%r_canopy(m) = 0.0_wp
     7777              ENDIF
     7778
     7779!
     7780!--           Calculate coefficients for the total evapotranspiration
     7781!--           In case of water surface, set vegetation and soil fluxes to zero.
     7782!--           For pavements, only evaporation of liquid water is possible.
     7783              f_qsws_veg  = rho_lv *                                           &
     7784                                ( 1.0_wp        - surf_usm_h%c_liq(m)    ) /   &
     7785                                ( surf_usm_h%r_a_green(m) + surf_usm_h%r_canopy(m) )
     7786              f_qsws_liq  = rho_lv * surf_usm_h%c_liq(m)   /                   &
     7787                                  surf_usm_h%r_a_green(m)
     7788       
     7789              f_qsws = f_qsws_veg + f_qsws_liq
     7790!
     7791!--           Calculate derivative of q_s for Taylor series expansion
     7792              e_s_dt = e_s * ( 17.269_wp / ( t_surf_green_h(m) - 35.86_wp) -   &
     7793                               17.269_wp*( t_surf_green_h(m) - 273.16_wp)      &
     7794                              / ( t_surf_green_h(m) - 35.86_wp)**2 )
     7795       
     7796              dq_s_dt = 0.622_wp * e_s_dt / ( surface_pressure - e_s_dt )
     7797           ENDIF
     7798!
    77337799!--        add LW up so that it can be removed in prognostic equation
    77347800           surf_usm_h%rad_net_l(m) = surf_usm_h%rad_sw_in(m)  -                &
     
    77367802                                     surf_usm_h%rad_lw_in(m)  -                &
    77377803                                     surf_usm_h%rad_lw_out(m)
    7738 
    7739 !--        numerator of the prognostic equation
     7804!
     7805!--     numerator of the prognostic equation
    77407806!--     Todo: Adjust to tile approach. So far, emissivity for wall (element 0)
    7741 !--           is used
     7807!--     is used
    77427808           coef_1 = surf_usm_h%rad_net_l(m) +                                  &
    77437809                 ( 3.0_wp + 1.0_wp ) * surf_usm_h%emissivity(ind_veg_wall,m) * &
    7744                                        sigma_sb * t_surf_wall_h(m) ** 4 +           
     7810                                       sigma_sb * t_surf_wall_h(m) ** 4 +     
    77457811                                       f_shf * surf_usm_h%pt1(m) +             &
    77467812                                       lambda_surface * t_wall_h(nzb_wall,m)
    7747 if ((.NOT. spinup).AND.(surf_usm_h%frac(ind_wat_win,m).GT.0.0_wp)) then
    7748            coef_window_1 = surf_usm_h%rad_net_l(m) +                           &
    7749                    ( 3.0_wp + 1.0_wp ) * surf_usm_h%emissivity(ind_wat_win,m)  &
    7750                                        * sigma_sb * t_surf_window_h(m) ** 4 +  & 
    7751                                        f_shf_window * surf_usm_h%pt1(m) +      &
    7752                                        lambda_surface_window * t_window_h(nzb_wall,m)
    7753 endif                 
    7754          IF ( (humidity).and.(surf_usm_h%frac(ind_pav_green,m).gt.0.0_wp) )  THEN
    7755                     coef_green_1 = surf_usm_h%rad_net_l(m) +                              &
     7813           IF ( ( .NOT. spinup ) .AND. (surf_usm_h%frac(ind_wat_win,m) > 0.0_wp ) ) THEN
     7814              coef_window_1 = surf_usm_h%rad_net_l(m) +                           &
     7815                      ( 3.0_wp + 1.0_wp ) * surf_usm_h%emissivity(ind_wat_win,m)  &
     7816                                          * sigma_sb * t_surf_window_h(m) ** 4 +  & 
     7817                                          f_shf_window * surf_usm_h%pt1(m) +      &
     7818                                          lambda_surface_window * t_window_h(nzb_wall,m)
     7819           ENDIF                 
     7820           IF ( ( humidity ) .AND. ( surf_usm_h%frac(ind_pav_green,m) > 0.0_wp ) )  THEN
     7821                    coef_green_1 = surf_usm_h%rad_net_l(m) +                                 &
    77567822                   ( 3.0_wp + 1.0_wp ) * surf_usm_h%emissivity(ind_pav_green,m) * sigma_sb * &
    77577823                                       t_surf_green_h(m) ** 4 +                  & 
     
    77667832                                       lambda_surface_green * t_green_h(nzb_wall,m)
    77677833          ENDIF
    7768 
     7834!
    77697835!--        denominator of the prognostic equation
    77707836           coef_2 = 4.0_wp * surf_usm_h%emissivity(ind_veg_wall,m) *           &
    7771                              sigma_sb * t_surf_wall_h(m) ** 3                       &
     7837                             sigma_sb * t_surf_wall_h(m) ** 3                  &
    77727838                           + lambda_surface + f_shf / exner(k)
    7773 if ((.NOT. spinup).AND.(surf_usm_h%frac(ind_wat_win,m).GT.0.0_wp)) then
    7774            coef_window_2 = 4.0_wp * surf_usm_h%emissivity(ind_wat_win,m) *     &
    7775                              sigma_sb * t_surf_window_h(m) ** 3                &
    7776                            + lambda_surface_window + f_shf_window / exner(k)
    7777 endif
    7778            IF ( (humidity).and.(surf_usm_h%frac(ind_pav_green,m).gt.0.0_wp) )  THEN
     7839           IF ( ( .NOT. spinup ) .AND. ( surf_usm_h%frac(ind_wat_win,m) > 0.0_wp ) ) THEN
     7840              coef_window_2 = 4.0_wp * surf_usm_h%emissivity(ind_wat_win,m) *     &
     7841                                sigma_sb * t_surf_window_h(m) ** 3                &
     7842                              + lambda_surface_window + f_shf_window / exner(k)
     7843           ENDIF
     7844           IF ( ( humidity ) .AND. ( surf_usm_h%frac(ind_pav_green,m) > 0.0_wp ) )  THEN
    77797845              coef_green_2 = 4.0_wp * surf_usm_h%emissivity(ind_pav_green,m) * sigma_sb *    &
    7780                                 t_surf_green_h(m) ** 3 + f_qsws * dq_s_dt        &
     7846                                t_surf_green_h(m) ** 3 + f_qsws * dq_s_dt                    &
    77817847                              + lambda_surface_green + f_shf_green / exner(k)
    77827848           ELSE
    77837849           coef_green_2 = 4.0_wp * surf_usm_h%emissivity(ind_pav_green,m) * sigma_sb *    &
    7784                              t_surf_green_h(m) ** 3                           &
     7850                             t_surf_green_h(m) ** 3                                       &
    77857851                           + lambda_surface_green + f_shf_green / exner(k)
    77867852           ENDIF
    7787 
     7853!
    77887854!--        implicit solution when the surface layer has no heat capacity,
    77897855!--        otherwise use RK3 scheme.
     
    77917857                             surf_usm_h%c_surface(m) * t_surf_wall_h(m) ) /        &
    77927858                           ( surf_usm_h%c_surface(m) + coef_2 * dt_3d * tsc(2) )
    7793 if ((.NOT. spinup).AND.(surf_usm_h%frac(ind_wat_win,m).GT.0.0_wp)) then
    7794            t_surf_window_h_p(m) = ( coef_window_1 * dt_3d * tsc(2) +                        &
    7795                              surf_usm_h%c_surface_window(m) * t_surf_window_h(m) ) /        &
    7796                            ( surf_usm_h%c_surface_window(m) + coef_window_2 * dt_3d * tsc(2) )
    7797 endif
     7859           IF ((.NOT. spinup).AND.(surf_usm_h%frac(ind_wat_win,m) > 0.0_wp)) THEN
     7860              t_surf_window_h_p(m) = ( coef_window_1 * dt_3d * tsc(2) +                        &
     7861                                surf_usm_h%c_surface_window(m) * t_surf_window_h(m) ) /        &
     7862                              ( surf_usm_h%c_surface_window(m) + coef_window_2 * dt_3d * tsc(2) )
     7863           ENDIF
    77987864           t_surf_green_h_p(m) = ( coef_green_1 * dt_3d * tsc(2) +                        &
    77997865                             surf_usm_h%c_surface_green(m) * t_surf_green_h(m) ) /        &
    78007866                           ( surf_usm_h%c_surface_green(m) + coef_green_2 * dt_3d * tsc(2) )
    7801 
     7867!
    78027868!--        add RK3 term
    7803            t_surf_wall_h_p(m) = t_surf_wall_h_p(m) + dt_3d * tsc(3) *                   &
     7869           t_surf_wall_h_p(m) = t_surf_wall_h_p(m) + dt_3d * tsc(3) *         &
    78047870                           surf_usm_h%tt_surface_wall_m(m)
    78057871
     
    78147880!--        assumed to be the surface temperature.
    78157881           surf_usm_h%pt_surface(m) = ( surf_usm_h%frac(ind_veg_wall,m) * t_surf_wall_h_p(m)   &
    7816                                + surf_usm_h%frac(ind_wat_win,m) * t_surf_window_h_p(m)   &
    7817                                + surf_usm_h%frac(ind_pav_green,m) * t_surf_green_h_p(m) )  &
     7882                               + surf_usm_h%frac(ind_wat_win,m) * t_surf_window_h_p(m)         &
     7883                               + surf_usm_h%frac(ind_pav_green,m) * t_surf_green_h_p(m) )      &
    78187884                               / exner(k)
    78197885                               
    78207886           IF ( humidity )  surf_usm_h%vpt_surface(m) =                        &
    78217887                                                   surf_usm_h%pt_surface(m)
    7822 
     7888!
    78237889!--        calculate true tendency
    7824            stend_wall = ( t_surf_wall_h_p(m) - t_surf_wall_h(m) - dt_3d * tsc(3) *           &
     7890           stend_wall = ( t_surf_wall_h_p(m) - t_surf_wall_h(m) - dt_3d * tsc(3) *              &
    78257891                     surf_usm_h%tt_surface_wall_m(m)) / ( dt_3d  * tsc(2) )
    78267892           stend_window = ( t_surf_window_h_p(m) - t_surf_window_h(m) - dt_3d * tsc(3) *        &
     
    78287894           stend_green = ( t_surf_green_h_p(m) - t_surf_green_h(m) - dt_3d * tsc(3) *           &
    78297895                     surf_usm_h%tt_surface_green_m(m)) / ( dt_3d  * tsc(2) )
    7830 
     7896!
    78317897!--        calculate t_surf tendencies for the next Runge-Kutta step
    78327898           IF ( timestep_scheme(1:5) == 'runge' )  THEN
     
    78377903              ELSEIF ( intermediate_timestep_count <                          &
    78387904                        intermediate_timestep_count_max )  THEN
    7839                  surf_usm_h%tt_surface_wall_m(m) = -9.5625_wp * stend_wall +            &
     7905                 surf_usm_h%tt_surface_wall_m(m) = -9.5625_wp * stend_wall +       &
    78407906                                     5.3125_wp * surf_usm_h%tt_surface_wall_m(m)
    78417907                 surf_usm_h%tt_surface_window_m(m) = -9.5625_wp * stend_window +   &
     
    78457911              ENDIF
    78467912           ENDIF
    7847 
     7913!
    78487914!--        in case of fast changes in the skin temperature, it is required to
    78497915!--        update the radiative fluxes in order to keep the solution stable
     
    78607926                                     surf_usm_h%frac(ind_veg_wall,m) *                   &
    78617927                                     sigma_sb * surf_usm_h%emissivity(ind_veg_wall,m) *  &
    7862                                      ( t_surf_wall_h_p(m)**4 - t_surf_wall_h(m)**4 )               &
     7928                                     ( t_surf_wall_h_p(m)**4 - t_surf_wall_h(m)**4 )     &
    78637929                                    + surf_usm_h%frac(ind_wat_win,m) *                   &
    78647930                                     sigma_sb * surf_usm_h%emissivity(ind_wat_win,m) *   &
     
    78687934                                     ( t_surf_green_h_p(m)**4 - t_surf_green_h(m)**4 )
    78697935
    7870            surf_usm_h%wghf_eb(m)   = lambda_surface *                         &
     7936           surf_usm_h%wghf_eb(m)   = lambda_surface *                                    &
    78717937                                      ( t_surf_wall_h_p(m) - t_wall_h(nzb_wall,m) )
    78727938           surf_usm_h%wghf_eb_green(m)  = lambda_surface_green *                         &
     
    78777943!
    78787944!--        ground/wall/roof surface heat flux
    7879            surf_usm_h%wshf_eb(m)   = - f_shf  * ( surf_usm_h%pt1(m) - t_surf_wall_h_p(m) / exner(k) ) *               &
     7945           surf_usm_h%wshf_eb(m)   = - f_shf  * ( surf_usm_h%pt1(m) - t_surf_wall_h_p(m) / exner(k) ) *          &
    78807946                                       surf_usm_h%frac(ind_veg_wall,m)         &
    78817947                                     - f_shf_window  * ( surf_usm_h%pt1(m) - t_surf_window_h_p(m) / exner(k) ) * &
     
    78887954           surf_usm_h%shf(m) = surf_usm_h%wshf_eb(m) / c_p
    78897955     
    7890 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    7891 if (surf_usm_h%frac(ind_pav_green,m).gt.0.0_wp) then
    7892 
    7893 ! print*, "tsurfroofgreen",m,t_surf_green_h_p(m),i,j,k,surf_usm_h%wghf_eb_green(m),surf_usm_h%rad_net_l(m),&
    7894 !         surf_usm_h%wshf_eb(m),f_qsws_veg,f_qsws_liq,dq_s_dt
    7895 ! print*, "B",surf_usm_h%rad_sw_in(m),surf_usm_h%rad_sw_out(m),surf_usm_h%rad_lw_in(m),surf_usm_h%rad_lw_out(m)
    7896 ! print*, "lambdasurface",lambda_surface_green,lambda_surface,i,j,k
    7897 ! print*, "fractions",i,j,k,surf_usm_h%frac(0:2,m)
    7898 if ((t_surf_green_h_p(m).gt.370.0_wp).or.(t_surf_green_h_p(m).lt.250.0_wp)) then
    7899   print*, t_surf_green_h_p(m),m,i,j,k
    7900   stop
    7901 endif
    7902 
    7903        IF ( humidity )  THEN
    7904           surf_usm_h%qsws_eb(m)  = - f_qsws * ( qv1 - q_s + dq_s_dt                     &
    7905                           * t_surf_green_h(m) - dq_s_dt *               &
    7906                             t_surf_green_h_p(m) )
    7907 
    7908           surf_usm_h%qsws(m) = surf_usm_h%qsws_eb(m) / rho_lv
    7909 
    7910           surf_usm_h%qsws_veg(m)  = - f_qsws_veg  * ( qv1 - q_s                      &
    7911                               + dq_s_dt * t_surf_green_h(m) - dq_s_dt   &
    7912                               * t_surf_green_h_p(m) )
    7913 
    7914           surf_usm_h%qsws_liq(m)  = - f_qsws_liq  * ( qv1 - q_s                      &
    7915                               + dq_s_dt * t_surf_green_h(m) - dq_s_dt   &
    7916                               * t_surf_green_h_p(m) )
    7917        ENDIF
    7918 
    7919 !
    7920 !--    Calculate the true surface resistance
    7921        IF ( .NOT.  humidity )  THEN
    7922           surf_usm_h%r_s(m) = 1.0E10_wp
    7923        ELSE
    7924           surf_usm_h%r_s(m) = - rho_lv * ( qv1 - q_s + dq_s_dt                       &
    7925                           *  t_surf_green_h(m) - dq_s_dt *               &
    7926                             t_surf_green_h_p(m) ) /                     &
    7927                             (surf_usm_h%qsws(m) + 1.0E-20)  - surf_usm_h%r_a_green(m)
    7928        ENDIF
    7929 
    7930 !
    7931 !--    Calculate change in liquid water reservoir due to dew fall or
    7932 !--    evaporation of liquid water
    7933        IF ( humidity )  THEN
    7934 !
    7935 !--       If precipitation is activated, add rain water to qsws_liq
    7936 !--       and qsws_soil according the the vegetation coverage.
    7937 !--       precipitation_rate is given in mm.
    7938           IF ( precipitation )  THEN
    7939 
    7940 !
    7941 !--          Add precipitation to liquid water reservoir, if possible.
    7942 !--          Otherwise, add the water to soil. In case of
    7943 !--          pavements, the exceeding water amount is implicitely removed
    7944 !--          as runoff as qsws_soil is then not used in the soil model
    7945              IF ( m_liq_usm_h%var_usm_1d(m) /= m_liq_max )  THEN
    7946                 surf_usm_h%qsws_liq(m) = surf_usm_h%qsws_liq(m)                            &
    7947                                  + surf_usm_h%frac(ind_pav_green,m) * prr(k+k_off,j+j_off,i+i_off)&
    7948                                  * hyrho(k+k_off)                              &
    7949                                  * 0.001_wp * rho_l * l_v
    7950              ENDIF
    7951 
    7952           ENDIF
    7953 
    7954 !
    7955 !--       If the air is saturated, check the reservoir water level
    7956           IF ( surf_usm_h%qsws(m) < 0.0_wp )  THEN
    7957 !
    7958 !--          Check if reservoir is full (avoid values > m_liq_max)
    7959 !--          In that case, qsws_liq goes to qsws_soil. In this
    7960 !--          case qsws_veg is zero anyway (because c_liq = 1),       
    7961 !--          so that tend is zero and no further check is needed
    7962              IF ( m_liq_usm_h%var_usm_1d(m) == m_liq_max )  THEN
    7963 !                 surf_usm_h%qsws_soil(m) = surf_usm_h%qsws_soil(m) + surf_usm_h%qsws_liq(m)
    7964 
    7965                 surf_usm_h%qsws_liq(m)  = 0.0_wp
    7966              ENDIF
    7967 
    7968 !
    7969 !--          In case qsws_veg becomes negative (unphysical behavior),
    7970 !--          let the water enter the liquid water reservoir as dew on the
    7971 !--          plant
    7972              IF ( surf_usm_h%qsws_veg(m) < 0.0_wp )  THEN
    7973                 surf_usm_h%qsws_liq(m) = surf_usm_h%qsws_liq(m) + surf_usm_h%qsws_veg(m)
    7974                 surf_usm_h%qsws_veg(m) = 0.0_wp
    7975              ENDIF
    7976           ENDIF                   
     7956
     7957           IF (surf_usm_h%frac(ind_pav_green,m) > 0.0_wp) THEN
     7958
     7959              IF ( humidity )  THEN
     7960                 surf_usm_h%qsws_eb(m)  = - f_qsws * ( qv1 - q_s + dq_s_dt                  &
     7961                                 * t_surf_green_h(m) - dq_s_dt *               &
     7962                                   t_surf_green_h_p(m) )
     7963       
     7964                 surf_usm_h%qsws(m) = surf_usm_h%qsws_eb(m) / rho_lv
     7965       
     7966                 surf_usm_h%qsws_veg(m)  = - f_qsws_veg  * ( qv1 - q_s                      &
     7967                                     + dq_s_dt * t_surf_green_h(m) - dq_s_dt   &
     7968                                     * t_surf_green_h_p(m) )
     7969       
     7970                 surf_usm_h%qsws_liq(m)  = - f_qsws_liq  * ( qv1 - q_s                      &
     7971                                     + dq_s_dt * t_surf_green_h(m) - dq_s_dt   &
     7972                                     * t_surf_green_h_p(m) )
     7973              ENDIF
    79777974 
    7978           surf_usm_h%qsws(m) = surf_usm_h%qsws(m) / l_v
     7975!
     7976!--           Calculate the true surface resistance
     7977              IF ( .NOT.  humidity )  THEN
     7978                 surf_usm_h%r_s(m) = 1.0E10_wp
     7979              ELSE
     7980                 surf_usm_h%r_s(m) = - rho_lv * ( qv1 - q_s + dq_s_dt                       &
     7981                                 *  t_surf_green_h(m) - dq_s_dt *              &
     7982                                   t_surf_green_h_p(m) ) /                     &
     7983                                   (surf_usm_h%qsws(m) + 1.0E-20)  - surf_usm_h%r_a_green(m)
     7984              ENDIF
    79797985 
    7980           tend = - surf_usm_h%qsws_liq(m) * drho_l_lv
    7981           m_liq_usm_h_p%var_usm_1d(m) = m_liq_usm_h%var_usm_1d(m) + dt_3d *    &
    7982                                         ( tsc(2) * tend +                      &
    7983                                           tsc(3) * tm_liq_usm_h_m%var_usm_1d(m) )
    7984 !
    7985 !--       Check if reservoir is overfull -> reduce to maximum
    7986 !--       (conservation of water is violated here)
    7987           m_liq_usm_h_p%var_usm_1d(m) = MIN( m_liq_usm_h_p%var_usm_1d(m),m_liq_max )
    7988 
    7989 !
    7990 !--       Check if reservoir is empty (avoid values < 0.0)
    7991 !--       (conservation of water is violated here)
    7992           m_liq_usm_h_p%var_usm_1d(m) = MAX( m_liq_usm_h_p%var_usm_1d(m), 0.0_wp )
    7993 !
    7994 !--       Calculate m_liq tendencies for the next Runge-Kutta step
    7995           IF ( timestep_scheme(1:5) == 'runge' )  THEN
    7996              IF ( intermediate_timestep_count == 1 )  THEN
    7997                 tm_liq_usm_h_m%var_usm_1d(m) = tend
    7998              ELSEIF ( intermediate_timestep_count <                            &
    7999                       intermediate_timestep_count_max )  THEN
    8000                 tm_liq_usm_h_m%var_usm_1d(m) = -9.5625_wp * tend +             &
    8001                                               5.3125_wp * tm_liq_usm_h_m%var_usm_1d(m)
    8002              ENDIF
    8003           ENDIF
    8004 
    8005        ENDIF
    8006 else
    8007   surf_usm_h%r_s(m) = 1.0E10_wp
    8008 endif
    8009 
     7986!
     7987!--           Calculate change in liquid water reservoir due to dew fall or
     7988!--           evaporation of liquid water
     7989              IF ( humidity )  THEN
     7990!
     7991!--              If precipitation is activated, add rain water to qsws_liq
     7992!--              and qsws_soil according the the vegetation coverage.
     7993!--              precipitation_rate is given in mm.
     7994                 IF ( precipitation )  THEN
     7995
     7996!
     7997!--                 Add precipitation to liquid water reservoir, if possible.
     7998!--                 Otherwise, add the water to soil. In case of
     7999!--                 pavements, the exceeding water amount is implicitely removed
     8000!--                 as runoff as qsws_soil is then not used in the soil model
     8001                    IF ( m_liq_usm_h%var_usm_1d(m) /= m_liq_max )  THEN
     8002                       surf_usm_h%qsws_liq(m) = surf_usm_h%qsws_liq(m)                &
     8003                                        + surf_usm_h%frac(ind_pav_green,m) * prr(k+k_off,j+j_off,i+i_off)&
     8004                                        * hyrho(k+k_off)                              &
     8005                                        * 0.001_wp * rho_l * l_v
     8006                   ENDIF
     8007
     8008                 ENDIF
     8009
     8010!
     8011!--              If the air is saturated, check the reservoir water level
     8012                 IF ( surf_usm_h%qsws(m) < 0.0_wp )  THEN
     8013!
     8014!--                 Check if reservoir is full (avoid values > m_liq_max)
     8015!--                 In that case, qsws_liq goes to qsws_soil. In this
     8016!--                 case qsws_veg is zero anyway (because c_liq = 1),       
     8017!--                 so that tend is zero and no further check is needed
     8018                    IF ( m_liq_usm_h%var_usm_1d(m) == m_liq_max )  THEN
     8019!                      surf_usm_h%qsws_soil(m) = surf_usm_h%qsws_soil(m) + surf_usm_h%qsws_liq(m)
     8020                       surf_usm_h%qsws_liq(m)  = 0.0_wp
     8021                    ENDIF
     8022
     8023!
     8024!--                 In case qsws_veg becomes negative (unphysical behavior),
     8025!--                 let the water enter the liquid water reservoir as dew on the
     8026!--                 plant
     8027                    IF ( surf_usm_h%qsws_veg(m) < 0.0_wp )  THEN
     8028                       surf_usm_h%qsws_liq(m) = surf_usm_h%qsws_liq(m) + surf_usm_h%qsws_veg(m)
     8029                       surf_usm_h%qsws_veg(m) = 0.0_wp
     8030                    ENDIF
     8031                 ENDIF                   
     8032 
     8033                 surf_usm_h%qsws(m) = surf_usm_h%qsws(m) / l_v
     8034       
     8035                 tend = - surf_usm_h%qsws_liq(m) * drho_l_lv
     8036                 m_liq_usm_h_p%var_usm_1d(m) = m_liq_usm_h%var_usm_1d(m) + dt_3d *    &
     8037                                               ( tsc(2) * tend +                      &
     8038                                                 tsc(3) * tm_liq_usm_h_m%var_usm_1d(m) )
     8039!
     8040!--             Check if reservoir is overfull -> reduce to maximum
     8041!--             (conservation of water is violated here)
     8042                 m_liq_usm_h_p%var_usm_1d(m) = MIN( m_liq_usm_h_p%var_usm_1d(m),m_liq_max )
     8043 
     8044!
     8045!--             Check if reservoir is empty (avoid values < 0.0)
     8046!--             (conservation of water is violated here)
     8047                 m_liq_usm_h_p%var_usm_1d(m) = MAX( m_liq_usm_h_p%var_usm_1d(m), 0.0_wp )
     8048!
     8049!--             Calculate m_liq tendencies for the next Runge-Kutta step
     8050                 IF ( timestep_scheme(1:5) == 'runge' )  THEN
     8051                    IF ( intermediate_timestep_count == 1 )  THEN
     8052                       tm_liq_usm_h_m%var_usm_1d(m) = tend
     8053                    ELSEIF ( intermediate_timestep_count <                            &
     8054                             intermediate_timestep_count_max )  THEN
     8055                       tm_liq_usm_h_m%var_usm_1d(m) = -9.5625_wp * tend +             &
     8056                                                     5.3125_wp * tm_liq_usm_h_m%var_usm_1d(m)
     8057                    ENDIF
     8058                 ENDIF
     8059 
     8060              ENDIF
     8061           ELSE
     8062              surf_usm_h%r_s(m) = 1.0E10_wp
     8063           ENDIF
     8064 
    80108065       ENDDO
    80118066!
    8012 !--    Now, treat vertical surface elements
     8067!--   Now, treat vertical surface elements
    80138068       DO  l = 0, 3
    8014           DO  m = 1, surf_usm_v(l)%ns
     8069           DO  m = 1, surf_usm_v(l)%ns
    80158070!
    80168071!--          Get indices of respective grid point
    8017              i = surf_usm_v(l)%i(m)
    8018              j = surf_usm_v(l)%j(m)
    8019              k = surf_usm_v(l)%k(m)
    8020 
     8072              i = surf_usm_v(l)%i(m)
     8073              j = surf_usm_v(l)%j(m)
     8074              k = surf_usm_v(l)%k(m)
     8075 
    80218076!
    80228077!--          TODO - how to calculate lambda_surface for horizontal (??? do you mean verical ???) surfaces
     
    80248079!--          Please note, for vertical surfaces no ol is defined, since
    80258080!--          stratification is not considered in this case.
    8026              lambda_surface = surf_usm_v(l)%lambda_surf(m)
    8027              lambda_surface_window = surf_usm_v(l)%lambda_surf_window(m)
    8028              lambda_surface_green = surf_usm_v(l)%lambda_surf_green(m)
    8029 
     8081              lambda_surface = surf_usm_v(l)%lambda_surf(m)
     8082              lambda_surface_window = surf_usm_v(l)%lambda_surf_window(m)
     8083              lambda_surface_green = surf_usm_v(l)%lambda_surf_green(m)
     8084 
    80308085!            pt1  = pt(k,j,i)
    8031            IF ( humidity )  THEN
    8032               qv1 = q(k,j,i)
    8033            ELSE
    8034               qv1 = 0.0_wp
    8035            ENDIF
     8086              IF ( humidity )  THEN
     8087                 qv1 = q(k,j,i)
     8088              ELSE
     8089                 qv1 = 0.0_wp
     8090              ENDIF
    80368091!
    80378092!--          calculate rho * c_p coefficient at wall layer
    8038              rho_cp  = c_p * hyp(k) / ( r_d * surf_usm_v(l)%pt1(m) * exner(k) )
    8039              
    8040             IF (surf_usm_v(l)%frac(1,m) > 0.0_wp )  THEN
     8093              rho_cp  = c_p * hyp(k) / ( r_d * surf_usm_v(l)%pt1(m) * exner(k) )
     8094              
     8095              IF (surf_usm_v(l)%frac(1,m) > 0.0_wp )  THEN
    80418096!
    80428097!--            Calculate frequently used parameters
    8043                rho_lv    = rho_cp / c_p * l_v
    8044                drho_l_lv = 1.0_wp / (rho_l * l_v)
    8045             ENDIF
    8046 
     8098                 rho_lv    = rho_cp / c_p * l_v
     8099                 drho_l_lv = 1.0_wp / (rho_l * l_v)
     8100              ENDIF
     8101 
    80478102!--          Calculation of r_a for vertical surfaces
    80488103!--
     
    80638118!--                zH: height of the convective layer
    80648119!--                wstar = (g/Tcan*Qs*zH)**(1./3.)
    8065                
    80668120!--          Effective velocity components must always
    80678121!--          be defined at scalar grid point. The wall normal component is
     
    80708124!--          Parameter roughness_concrete (default value = 0.001) is used
    80718125!--          to calculation of roughness relative to concrete
    8072              surf_usm_v(l)%r_a(m) = rho_cp / ( surf_usm_v(l)%z0(m) /           &
    8073                         roughness_concrete * ( 11.8_wp + 4.2_wp *              &
    8074                         SQRT( MAX( ( ( u(k,j,i) + u(k,j,i+1) ) * 0.5_wp )**2 + &
    8075                                    ( ( v(k,j,i) + v(k,j+1,i) ) * 0.5_wp )**2 + &
    8076                                    ( ( w(k,j,i) + w(k-1,j,i) ) * 0.5_wp )**2,  &
    8077                               0.01_wp ) )                                      &
    8078                            )  - 4.0_wp  )
     8126              surf_usm_v(l)%r_a(m) = rho_cp / ( surf_usm_v(l)%z0(m) /           &
     8127                         roughness_concrete * ( 11.8_wp + 4.2_wp *              &
     8128                         SQRT( MAX( ( ( u(k,j,i) + u(k,j,i+1) ) * 0.5_wp )**2 + &
     8129                                    ( ( v(k,j,i) + v(k,j+1,i) ) * 0.5_wp )**2 + &
     8130                                    ( ( w(k,j,i) + w(k-1,j,i) ) * 0.5_wp )**2,  &
     8131                               0.01_wp ) )                                      &
     8132                            )  - 4.0_wp  )
    80798133!
    80808134!--          Limit aerodynamic resistance
    8081              IF ( surf_usm_v(l)%r_a(m) < 1.0_wp )  surf_usm_v(l)%r_a(m) = 1.0_wp   
    8082              
    8083                            
    8084              f_shf         = rho_cp / surf_usm_v(l)%r_a(m)
    8085              f_shf_window  = rho_cp / surf_usm_v(l)%r_a(m)
    8086              f_shf_green   = rho_cp / surf_usm_v(l)%r_a(m)
    8087 
    8088 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    8089 if (surf_usm_v(l)%frac(1,m).gt.0.0_wp) then
    8090 !--    Adapted from LSM:
    8091 !--    Second step: calculate canopy resistance r_canopy
    8092 !--    f1-f3 here are defined as 1/f1-f3 as in ECMWF documentation
     8135              IF ( surf_usm_v(l)%r_a(m) < 1.0_wp )  surf_usm_v(l)%r_a(m) = 1.0_wp   
     8136             
     8137                           
     8138              f_shf         = rho_cp / surf_usm_v(l)%r_a(m)
     8139              f_shf_window  = rho_cp / surf_usm_v(l)%r_a(m)
     8140              f_shf_green   = rho_cp / surf_usm_v(l)%r_a(m)
    80938141 
    8094 !--    f1: correction for incoming shortwave radiation (stomata close at
    8095 !--    night)
    8096        f1 = MIN( 1.0_wp, ( 0.004_wp * surf_usm_v(l)%rad_sw_in(m) + 0.05_wp ) / &
    8097                         (0.81_wp * (0.004_wp * surf_usm_v(l)%rad_sw_in(m)      &
    8098                          + 1.0_wp)) )
    8099 !
    8100 !--    f2: correction for soil moisture availability to plants (the
    8101 !--    integrated soil moisture must thus be considered here)
    8102 !--    f2 = 0 for very dry soils
    8103 
    8104 f2=1.0_wp
    8105 !           m_total = 0.0_wp
    8106 !           DO  k = nzb_wall, nzt_wall+1
    8107 !               m_total = m_total + rootfr_h(nzb_wall,m)                              &
    8108 !                         * MAX(swc_h(nzb_wall,m),wilt_h(nzb_wall,m))
    8109 !           ENDDO
    8110 !
    8111 !           IF ( m_total > wilt_h(nzb_wall,m)  .AND.  m_total < fc_h(nzb_wall,m) )  THEN
    8112 !              f2 = ( m_total - wilt_h(nzb_wall,m) ) / (fc_h(nzb_wall,m) - wilt_h(nzb_wall,m) )
    8113 !           ELSEIF ( m_total >= fc_h(nzb_wall,m) )  THEN
    8114 !              f2 = 1.0_wp
    8115 !           ELSE
    8116 !              f2 = 1.0E-20_wp
    8117 !           ENDIF
    8118 
    8119 !
    8120 !--    Calculate water vapour pressure at saturation
    8121        e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp * (  t_surf_green_v_p(l)%t(m) &
    8122                      - 273.16_wp ) / (  t_surf_green_v_p(l)%t(m) - 35.86_wp ) )
    8123 !
    8124 !--    f3: correction for vapour pressure deficit
    8125        IF ( surf_usm_v(l)%g_d(m) /= 0.0_wp )  THEN
    8126 !
    8127 !--       Calculate vapour pressure
    8128           e  = qv1 * surface_pressure / ( qv1 + 0.622_wp )
    8129           f3 = EXP ( - surf_usm_v(l)%g_d(m) * (e_s - e) )
    8130        ELSE
    8131           f3 = 1.0_wp
    8132        ENDIF
    8133 !
    8134 !--    Calculate canopy resistance. In case that c_veg is 0 (bare soils),
    8135 !--    this calculation is obsolete, as r_canopy is not used below.
    8136 !--    To do: check for very dry soil -> r_canopy goes to infinity
    8137        surf_usm_v(l)%r_canopy(m) = surf_usm_v(l)%r_canopy_min(m) /                               &
    8138                               ( surf_usm_v(l)%lai(m) * f1 * f2 * f3 + 1.0E-20_wp )
    8139                              
    8140 ! !--    Calculate the maximum possible liquid water amount on plants and
    8141 ! !--    bare surface. For vegetated surfaces, a maximum depth of 0.2 mm is
    8142 ! !--    assumed, while paved surfaces might hold up 1 mm of water. The
    8143 ! !--    liquid water fraction for paved surfaces is calculated after
    8144 ! !--    Noilhan & Planton (1989), while the ECMWF formulation is used for
    8145 ! !--    vegetated surfaces and bare soils.
    8146 ! ! surf_usm_h%lai(m)=4.0_wp
    8147 !        m_liq_max = m_max_depth * ( surf_usm_h%lai(m) )
    8148 !        surf_usm_h%c_liq(m) = MIN( 1.0_wp, ( m_liq_usm_h%var_usm_1d(m) / m_liq_max )**0.67 )
    8149 !
    8150 !--    Calculate saturation specific humidity
    8151        q_s = 0.622_wp * e_s / ( surface_pressure - e_s )
    8152 !
    8153 !--    In case of dewfall, set evapotranspiration to zero
    8154 !--    All super-saturated water is then removed from the air
    8155        IF ( humidity  .AND.  q_s <= qv1 )  THEN
    8156           surf_usm_v(l)%r_canopy(m) = 0.0_wp
    8157        ENDIF
    8158 
    8159 !
    8160 !--    Calculate coefficients for the total evapotranspiration
    8161 !--    In case of water surface, set vegetation and soil fluxes to zero.
    8162 !--    For pavements, only evaporation of liquid water is possible.
    8163        f_qsws_veg  = rho_lv *                                &
    8164                          ( 1.0_wp        - 0.0_wp ) / & !surf_usm_h%c_liq(m)    ) /   &
    8165                          ( surf_usm_v(l)%r_a(m) + surf_usm_v(l)%r_canopy(m) )
    8166 !        f_qsws_liq  = rho_lv * surf_usm_h%c_liq(m)   /             &
    8167 !                            surf_usm_h%r_a_green(m)
    8168 
    8169        f_qsws = f_qsws_veg! + f_qsws_liq
    8170 !
    8171 !--    Calculate derivative of q_s for Taylor series expansion
    8172        e_s_dt = e_s * ( 17.269_wp / ( t_surf_green_v_p(l)%t(m) - 35.86_wp) -   &
    8173                         17.269_wp*( t_surf_green_v_p(l)%t(m) - 273.16_wp)      &
    8174                        / ( t_surf_green_v_p(l)%t(m) - 35.86_wp)**2 )
    8175 
    8176        dq_s_dt = 0.622_wp * e_s_dt / ( surface_pressure - e_s_dt )
    8177 endif
    8178 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    8179                
    8180 !--          add LW up so that it can be removed in prognostic equation
    8181              surf_usm_v(l)%rad_net_l(m) = surf_usm_v(l)%rad_sw_in(m)  -        &
    8182                                           surf_usm_v(l)%rad_sw_out(m) +        &
    8183                                           surf_usm_v(l)%rad_lw_in(m)  -        &
    8184                                           surf_usm_v(l)%rad_lw_out(m)
    8185 
     8142
     8143              IF ( surf_usm_v(l)%frac(1,m) > 0.0_wp ) THEN
     8144!
     8145!--             Adapted from LSM:
     8146!--             Second step: calculate canopy resistance r_canopy
     8147!--             f1-f3 here are defined as 1/f1-f3 as in ECMWF documentation
     8148!--             f1: correction for incoming shortwave radiation (stomata close at
     8149!--             night)
     8150                 f1 = MIN( 1.0_wp, ( 0.004_wp * surf_usm_v(l)%rad_sw_in(m) + 0.05_wp ) / &
     8151                                  (0.81_wp * (0.004_wp * surf_usm_v(l)%rad_sw_in(m)      &
     8152                                   + 1.0_wp)) )
     8153!
     8154!--             f2: correction for soil moisture availability to plants (the
     8155!--             integrated soil moisture must thus be considered here)
     8156!--             f2 = 0 for very dry soils
     8157 
     8158                 f2=1.0_wp
     8159 
     8160!
     8161!--              Calculate water vapour pressure at saturation
     8162                 e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp * (  t_surf_green_v_p(l)%t(m) &
     8163                               - 273.16_wp ) / (  t_surf_green_v_p(l)%t(m) - 35.86_wp ) )
     8164!
     8165!--              f3: correction for vapour pressure deficit
     8166                 IF ( surf_usm_v(l)%g_d(m) /= 0.0_wp )  THEN
     8167!
     8168!--                 Calculate vapour pressure
     8169                    e  = qv1 * surface_pressure / ( qv1 + 0.622_wp )
     8170                    f3 = EXP ( - surf_usm_v(l)%g_d(m) * (e_s - e) )
     8171                 ELSE
     8172                    f3 = 1.0_wp
     8173                 ENDIF
     8174!
     8175!--              Calculate canopy resistance. In case that c_veg is 0 (bare soils),
     8176!--              this calculation is obsolete, as r_canopy is not used below.
     8177!--              To do: check for very dry soil -> r_canopy goes to infinity
     8178                 surf_usm_v(l)%r_canopy(m) = surf_usm_v(l)%r_canopy_min(m) /                  &
     8179                                        ( surf_usm_v(l)%lai(m) * f1 * f2 * f3 + 1.0E-20_wp )
     8180                               
     8181!
     8182!--              Calculate saturation specific humidity
     8183                 q_s = 0.622_wp * e_s / ( surface_pressure - e_s )
     8184!
     8185!--              In case of dewfall, set evapotranspiration to zero
     8186!--              All super-saturated water is then removed from the air
     8187                 IF ( humidity  .AND.  q_s <= qv1 )  THEN
     8188                    surf_usm_v(l)%r_canopy(m) = 0.0_wp
     8189                 ENDIF
     8190 
     8191!
     8192!--              Calculate coefficients for the total evapotranspiration
     8193!--              In case of water surface, set vegetation and soil fluxes to zero.
     8194!--              For pavements, only evaporation of liquid water is possible.
     8195                 f_qsws_veg  = rho_lv *                                &
     8196                                   ( 1.0_wp        - 0.0_wp ) / & !surf_usm_h%c_liq(m)    ) /   &
     8197                                   ( surf_usm_v(l)%r_a(m) + surf_usm_v(l)%r_canopy(m) )
     8198!                f_qsws_liq  = rho_lv * surf_usm_h%c_liq(m)   /             &
     8199!                              surf_usm_h%r_a_green(m)
     8200         
     8201                 f_qsws = f_qsws_veg! + f_qsws_liq
     8202!
     8203!--              Calculate derivative of q_s for Taylor series expansion
     8204                 e_s_dt = e_s * ( 17.269_wp / ( t_surf_green_v_p(l)%t(m) - 35.86_wp) -   &
     8205                                  17.269_wp*( t_surf_green_v_p(l)%t(m) - 273.16_wp)      &
     8206                                 / ( t_surf_green_v_p(l)%t(m) - 35.86_wp)**2 )
     8207         
     8208                 dq_s_dt = 0.622_wp * e_s_dt / ( surface_pressure - e_s_dt )
     8209              ENDIF
     8210
     8211!
     8212!--           add LW up so that it can be removed in prognostic equation
     8213              surf_usm_v(l)%rad_net_l(m) = surf_usm_v(l)%rad_sw_in(m)  -        &
     8214                                           surf_usm_v(l)%rad_sw_out(m) +        &
     8215                                           surf_usm_v(l)%rad_lw_in(m)  -        &
     8216                                           surf_usm_v(l)%rad_lw_out(m)
     8217!
    81868218!--           numerator of the prognostic equation
    8187               coef_1 = surf_usm_v(l)%rad_net_l(m) +                            & ! coef +1 corresponds to -lwout included in calculation of radnet_l
    8188              ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_veg_wall,m) *  &
    8189                                      sigma_sb *  t_surf_wall_v(l)%t(m) ** 4 +       & 
    8190                                      f_shf * surf_usm_v(l)%pt1(m) +            &
    8191                                      lambda_surface * t_wall_v(l)%t(nzb_wall,m)
    8192 if ((.NOT. spinup).AND.(surf_usm_v(l)%frac(ind_wat_win,m).GT.0.0_wp)) then
    8193               coef_window_1 = surf_usm_v(l)%rad_net_l(m) +                     & ! coef +1 corresponds to -lwout included in calculation of radnet_l
    8194                ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_wat_win,m) * &
    8195                                      sigma_sb * t_surf_window_v(l)%t(m) ** 4 + & 
    8196                                      f_shf * surf_usm_v(l)%pt1(m) +            &
    8197                                      lambda_surface_window * t_window_v(l)%t(nzb_wall,m)
    8198 endif
    8199            IF ( (humidity).and.(surf_usm_v(l)%frac(ind_pav_green,m).gt.0.0_wp) )  THEN
    8200               coef_green_1 = surf_usm_v(l)%rad_net_l(m) +                      & ! coef +1 corresponds to -lwout included in calculation of radnet_l
    8201                ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *  &
    8202                                      t_surf_green_v(l)%t(m) ** 4 +               & 
    8203                                      f_shf * surf_usm_v(l)%pt1(m) +     f_qsws * ( qv1 - q_s    &
    8204                                           + dq_s_dt * t_surf_green_v(l)%t(m) ) +            &
    8205                                      lambda_surface_green * t_wall_v(l)%t(nzb_wall,m)
    8206            ELSE
    8207               coef_green_1 = surf_usm_v(l)%rad_net_l(m) +                        & ! coef +1 corresponds to -lwout included in calculation of radnet_l
    8208                ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *  &
    8209                                      t_surf_green_v(l)%t(m) ** 4 +               & 
    8210                                      f_shf * surf_usm_v(l)%pt1(m) +            &
    8211                                      lambda_surface_green * t_wall_v(l)%t(nzb_wall,m)
    8212            ENDIF
    8213                                      
    8214 
     8219              coef_1 = surf_usm_v(l)%rad_net_l(m) +                             & ! coef +1 corresponds to -lwout
     8220                                                                                  ! included in calculation of radnet_l
     8221              ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_veg_wall,m) *  &
     8222                                      sigma_sb *  t_surf_wall_v(l)%t(m) ** 4 +  & 
     8223                                      f_shf * surf_usm_v(l)%pt1(m) +            &
     8224                                      lambda_surface * t_wall_v(l)%t(nzb_wall,m)
     8225              IF ( ( .NOT. spinup ) .AND. ( surf_usm_v(l)%frac(ind_wat_win,m) > 0.0_wp ) ) THEN
     8226                 coef_window_1 = surf_usm_v(l)%rad_net_l(m) +                   & ! coef +1 corresponds to -lwout
     8227                                                                                  ! included in calculation of radnet_l
     8228                ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_wat_win,m) * &
     8229                                      sigma_sb * t_surf_window_v(l)%t(m) ** 4 + & 
     8230                                      f_shf * surf_usm_v(l)%pt1(m) +            &
     8231                                      lambda_surface_window * t_window_v(l)%t(nzb_wall,m)
     8232              ENDIF
     8233              IF ( ( humidity ) .AND. ( surf_usm_v(l)%frac(ind_pav_green,m) > 0.0_wp ) )  THEN
     8234                 coef_green_1 = surf_usm_v(l)%rad_net_l(m) +                      & ! coef +1 corresponds to -lwout
     8235                                                                                    ! included in calculation of radnet_l
     8236                 ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *  &
     8237                                      t_surf_green_v(l)%t(m) ** 4 +               & 
     8238                                      f_shf * surf_usm_v(l)%pt1(m) +     f_qsws * ( qv1 - q_s  &
     8239                                           + dq_s_dt * t_surf_green_v(l)%t(m) ) +              &
     8240                                      lambda_surface_green * t_wall_v(l)%t(nzb_wall,m)
     8241              ELSE
     8242                coef_green_1 = surf_usm_v(l)%rad_net_l(m) +                       & ! coef +1 corresponds to -lwout included
     8243                                                                                    ! in calculation of radnet_l
     8244                ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *  &
     8245                                      t_surf_green_v(l)%t(m) ** 4 +               & 
     8246                                      f_shf * surf_usm_v(l)%pt1(m) +              &
     8247                                      lambda_surface_green * t_wall_v(l)%t(nzb_wall,m)
     8248              ENDIF
     8249                                     
     8250!
    82158251!--           denominator of the prognostic equation
    8216               coef_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_veg_wall,m) * sigma_sb *           &
    8217                                 t_surf_wall_v(l)%t(m) ** 3                           &
    8218                               + lambda_surface + f_shf / exner(k) 
    8219 if ((.NOT. spinup).AND.(surf_usm_v(l)%frac(ind_wat_win,m).GT.0.0_wp)) then             
    8220               coef_window_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_wat_win,m) * sigma_sb *           &
    8221                                 t_surf_window_v(l)%t(m) ** 3                         &
    8222                               + lambda_surface_window + f_shf / exner(k)
    8223 endif
    8224            IF ( (humidity).and.(surf_usm_v(l)%frac(ind_pav_green,m).gt.0.0_wp) )  THEN
    8225                coef_green_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *     &
    8226                                 t_surf_green_v(l)%t(m) ** 3  + f_qsws * dq_s_dt      &
    8227                               + lambda_surface_green + f_shf / exner(k)
    8228            ELSE
    8229               coef_green_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *     &
    8230                                 t_surf_green_v(l)%t(m) ** 3                          &
    8231                               + lambda_surface_green + f_shf / exner(k)
    8232            ENDIF
    8233 
     8252              coef_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_veg_wall,m) * sigma_sb *   &
     8253                                 t_surf_wall_v(l)%t(m) ** 3                             &
     8254                               + lambda_surface + f_shf / exner(k) 
     8255              IF ( ( .NOT. spinup ) .AND. ( surf_usm_v(l)%frac(ind_wat_win,m) > 0.0_wp ) ) THEN             
     8256                 coef_window_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_wat_win,m) * sigma_sb *       &
     8257                                   t_surf_window_v(l)%t(m) ** 3                         &
     8258                                 + lambda_surface_window + f_shf / exner(k)
     8259              ENDIF
     8260              IF ( ( humidity ) .AND. ( surf_usm_v(l)%frac(ind_pav_green,m) > 0.0_wp ) )  THEN
     8261                  coef_green_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *     &
     8262                                   t_surf_green_v(l)%t(m) ** 3  + f_qsws * dq_s_dt      &
     8263                                 + lambda_surface_green + f_shf / exner(k)
     8264              ELSE
     8265                 coef_green_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *      &
     8266                                   t_surf_green_v(l)%t(m) ** 3                          &
     8267                                 + lambda_surface_green + f_shf / exner(k)
     8268              ENDIF
     8269!
    82348270!--           implicit solution when the surface layer has no heat capacity,
    82358271!--           otherwise use RK3 scheme.
    82368272              t_surf_wall_v_p(l)%t(m) = ( coef_1 * dt_3d * tsc(2) +                 &
    82378273                             surf_usm_v(l)%c_surface(m) * t_surf_wall_v(l)%t(m) ) / &
    8238                            ( surf_usm_v(l)%c_surface(m) + coef_2 * dt_3d * tsc(2) )
    8239 if ((.NOT. spinup).AND.(surf_usm_v(l)%frac(ind_wat_win,m).GT.0.0_wp)) then
    8240               t_surf_window_v_p(l)%t(m) = ( coef_window_1 * dt_3d * tsc(2) +                 &
    8241                              surf_usm_v(l)%c_surface_window(m) * t_surf_window_v(l)%t(m) ) / &
    8242                            ( surf_usm_v(l)%c_surface_window(m) + coef_window_2 * dt_3d * tsc(2) )
    8243 endif
     8274                             ( surf_usm_v(l)%c_surface(m) + coef_2 * dt_3d * tsc(2) )
     8275              IF ( ( .NOT. spinup ) .AND. ( surf_usm_v(l)%frac(ind_wat_win,m) > 0.0_wp ) ) THEN
     8276                 t_surf_window_v_p(l)%t(m) = ( coef_window_1 * dt_3d * tsc(2) +                 &
     8277                                surf_usm_v(l)%c_surface_window(m) * t_surf_window_v(l)%t(m) ) / &
     8278                              ( surf_usm_v(l)%c_surface_window(m) + coef_window_2 * dt_3d * tsc(2) )
     8279              ENDIF
    82448280              t_surf_green_v_p(l)%t(m) = ( coef_green_1 * dt_3d * tsc(2) +                 &
    82458281                             surf_usm_v(l)%c_surface_green(m) * t_surf_green_v(l)%t(m) ) / &
    82468282                           ( surf_usm_v(l)%c_surface_green(m) + coef_green_2 * dt_3d * tsc(2) )
    8247 
     8283!
    82488284!--           add RK3 term
    82498285              t_surf_wall_v_p(l)%t(m) = t_surf_wall_v_p(l)%t(m) + dt_3d * tsc(3) *         &
     
    82528288                                surf_usm_v(l)%tt_surface_window_m(m)
    82538289              t_surf_green_v_p(l)%t(m) = t_surf_green_v_p(l)%t(m) + dt_3d * tsc(3) *       &
    8254                                 surf_usm_v(l)%tt_surface_green_m(m)
     8290                                 surf_usm_v(l)%tt_surface_green_m(m)
    82558291!
    82568292!--           Store surface temperature. Further, in case humidity is used
     
    82588294!--           assumed to be the surface temperature.     
    82598295              surf_usm_v(l)%pt_surface(m) =  ( surf_usm_v(l)%frac(ind_veg_wall,m) * t_surf_wall_v_p(l)%t(m)  &
    8260                                       + surf_usm_v(l)%frac(ind_wat_win,m) * t_surf_window_v_p(l)%t(m)  &
    8261                                       + surf_usm_v(l)%frac(ind_pav_green,m) * t_surf_green_v_p(l)%t(m) ) &
     8296                                      + surf_usm_v(l)%frac(ind_wat_win,m) * t_surf_window_v_p(l)%t(m)        &
     8297                                      + surf_usm_v(l)%frac(ind_pav_green,m) * t_surf_green_v_p(l)%t(m) )     &
    82628298                                      / exner(k)
    8263                                      
     8299                                       
    82648300              IF ( humidity )  surf_usm_v(l)%vpt_surface(m) =                  &
    8265                                                     surf_usm_v(l)%pt_surface(m)
    8266 
     8301                                                     surf_usm_v(l)%pt_surface(m)
     8302!
    82678303!--           calculate true tendency
    8268               stend_wall = ( t_surf_wall_v_p(l)%t(m) - t_surf_wall_v(l)%t(m) - dt_3d * tsc(3) *&
     8304              stend_wall = ( t_surf_wall_v_p(l)%t(m) - t_surf_wall_v(l)%t(m) - dt_3d * tsc(3) *      &
    82698305                        surf_usm_v(l)%tt_surface_wall_m(m) ) / ( dt_3d  * tsc(2) )
    82708306              stend_window = ( t_surf_window_v_p(l)%t(m) - t_surf_window_v(l)%t(m) - dt_3d * tsc(3) *&
     
    82738309                        surf_usm_v(l)%tt_surface_green_m(m) ) / ( dt_3d  * tsc(2) )
    82748310
     8311!
    82758312!--           calculate t_surf_* tendencies for the next Runge-Kutta step
    82768313              IF ( timestep_scheme(1:5) == 'runge' )  THEN
     
    82908327              ENDIF
    82918328
     8329!
    82928330!--           in case of fast changes in the skin temperature, it is required to
    82938331!--           update the radiative fluxes in order to keep the solution stable
    8294 
     8332 
    82958333              IF ( ( ( ABS( t_surf_wall_v_p(l)%t(m)   - t_surf_wall_v(l)%t(m) )   > 1.0_wp ) .OR. &
    82968334                   (   ABS( t_surf_green_v_p(l)%t(m)  - t_surf_green_v(l)%t(m) )  > 1.0_wp ) .OR. &
     
    83008338              ENDIF
    83018339
     8340!
    83028341!--           calculate fluxes
    83038342!--           prognostic rad_net_l is used just for output!           
     
    83058344                                           ( surf_usm_v(l)%rad_net_l(m) +                            &
    83068345                                           3.0_wp * sigma_sb *                                       &
    8307                                            t_surf_wall_v(l)%t(m)**4 - 4.0_wp * sigma_sb *                 &
    8308                                            t_surf_wall_v(l)%t(m)**3 * t_surf_wall_v_p(l)%t(m) )                &
     8346                                           t_surf_wall_v(l)%t(m)**4 - 4.0_wp * sigma_sb *            &
     8347                                           t_surf_wall_v(l)%t(m)**3 * t_surf_wall_v_p(l)%t(m) )      &
    83098348                                         + surf_usm_v(l)%frac(ind_wat_win,m) *                       &
    83108349                                           ( surf_usm_v(l)%rad_net_l(m) +                            &
     
    83208359              surf_usm_v(l)%wghf_eb_window(m) = lambda_surface_window * &
    83218360                                                ( t_surf_window_v_p(l)%t(m) - t_window_v(l)%t(nzb_wall,m) )
    8322               surf_usm_v(l)%wghf_eb(m)   = lambda_surface *                    &
    8323                                      ( t_surf_wall_v_p(l)%t(m) - t_wall_v(l)%t(nzb_wall,m) )
     8361              surf_usm_v(l)%wghf_eb(m)   = lambda_surface *             &
     8362                                                ( t_surf_wall_v_p(l)%t(m) - t_wall_v(l)%t(nzb_wall,m) )
    83248363              surf_usm_v(l)%wghf_eb_green(m)  = lambda_surface_green *  &
    83258364                                                ( t_surf_green_v_p(l)%t(m) - t_green_v(l)%t(nzb_wall,m) )
    83268365
     8366!
    83278367!--           ground/wall/roof surface heat flux
    83288368              surf_usm_v(l)%wshf_eb(m)   =                                     &
     
    83398379              surf_usm_v(l)%shf(m) = surf_usm_v(l)%wshf_eb(m) / c_p
    83408380
    8341 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    8342 if (surf_usm_v(l)%frac(ind_pav_green,m).gt.0.0_wp) then !111
    8343 
    8344 ! print*, "tsurfroofgreen",m,t_surf_green_h_p(m),i,j,k,surf_usm_h%wghf_eb_green(m),surf_usm_h%rad_net_l(m),&
    8345 !         surf_usm_h%wshf_eb(m),f_qsws_veg,f_qsws_liq,dq_s_dt
    8346 ! print*, "B",surf_usm_h%rad_sw_in(m),surf_usm_h%rad_sw_out(m),surf_usm_h%rad_lw_in(m),surf_usm_h%rad_lw_out(m)
    8347 ! print*, "lambdasurface",lambda_surface_green,lambda_surface,i,j,k
    8348 ! print*, "fractions",i,j,k,surf_usm_h%frac(0:2,m)
    8349 if ((t_surf_green_v_p(l)%t(m).gt.370.0_wp).or.(t_surf_green_v_p(l)%t(m).lt.250.0_wp)) then
    8350   print*, t_surf_green_v_p(l)%t(m),m,i,j,k
    8351   stop
    8352 endif
    8353 
    8354        IF ( humidity )  THEN
    8355           surf_usm_v(l)%qsws_eb(m)  = - f_qsws * ( qv1 - q_s + dq_s_dt                     &
    8356                           * t_surf_green_v(l)%t(m) - dq_s_dt *               &
    8357                             t_surf_green_v_p(l)%t(m) )
    8358 
    8359           surf_usm_v(l)%qsws(m) = surf_usm_v(l)%qsws_eb(m) / rho_lv
    8360 
    8361           surf_usm_v(l)%qsws_veg(m)  = - f_qsws_veg  * ( qv1 - q_s                      &
    8362                               + dq_s_dt * t_surf_green_v(l)%t(m) - dq_s_dt   &
    8363                               * t_surf_green_v_p(l)%t(m) )
    8364 
    8365 !           surf_usm_h%qsws_liq(m)  = - f_qsws_liq  * ( qv1 - q_s                      &
    8366 !                               + dq_s_dt * t_surf_green_h(m) - dq_s_dt   &
    8367 !                               * t_surf_green_h_p(m) )
    8368        ENDIF
    8369 
    8370 !
    8371 !--    Calculate the true surface resistance
    8372        IF ( .NOT.  humidity )  THEN
    8373           surf_usm_v(l)%r_s(m) = 1.0E10_wp
    8374        ELSE
    8375           surf_usm_v(l)%r_s(m) = - rho_lv * ( qv1 - q_s + dq_s_dt                       &
    8376                           *  t_surf_green_v(l)%t(m) - dq_s_dt *               &
    8377                             t_surf_green_v_p(l)%t(m) ) /                     &
    8378                             (surf_usm_v(l)%qsws(m) + 1.0E-20)  - surf_usm_v(l)%r_a(m)
    8379        ENDIF
    8380 
     8381              IF ( surf_usm_v(l)%frac(ind_pav_green,m) > 0.0_wp ) THEN
     8382 
     8383
     8384                 IF ( humidity )  THEN
     8385                    surf_usm_v(l)%qsws_eb(m)  = - f_qsws * ( qv1 - q_s + dq_s_dt       &
     8386                                    * t_surf_green_v(l)%t(m) - dq_s_dt *               &
     8387                                      t_surf_green_v_p(l)%t(m) )
     8388         
     8389                    surf_usm_v(l)%qsws(m) = surf_usm_v(l)%qsws_eb(m) / rho_lv
     8390         
     8391                    surf_usm_v(l)%qsws_veg(m)  = - f_qsws_veg  * ( qv1 - q_s           &
     8392                                        + dq_s_dt * t_surf_green_v(l)%t(m) - dq_s_dt   &
     8393                                        * t_surf_green_v_p(l)%t(m) )
     8394         
     8395!                    surf_usm_h%qsws_liq(m)  = - f_qsws_liq  * ( qv1 - q_s         &
     8396!                                        + dq_s_dt * t_surf_green_h(m) - dq_s_dt   &
     8397!                                        * t_surf_green_h_p(m) )
     8398                 ENDIF
     8399 
     8400!
     8401!--              Calculate the true surface resistance
     8402                 IF ( .NOT.  humidity )  THEN
     8403                    surf_usm_v(l)%r_s(m) = 1.0E10_wp
     8404                 ELSE
     8405                    surf_usm_v(l)%r_s(m) = - rho_lv * ( qv1 - q_s + dq_s_dt             &
     8406                                    *  t_surf_green_v(l)%t(m) - dq_s_dt *               &
     8407                                      t_surf_green_v_p(l)%t(m) ) /                      &
     8408                                      (surf_usm_v(l)%qsws(m) + 1.0E-20)  - surf_usm_v(l)%r_a(m)
     8409                 ENDIF
     8410         
     8411!
     8412!--              Calculate change in liquid water reservoir due to dew fall or
     8413!--              evaporation of liquid water
     8414                 IF ( humidity )  THEN
     8415!
     8416!--                 If the air is saturated, check the reservoir water level
     8417                    IF ( surf_usm_v(l)%qsws(m) < 0.0_wp )  THEN
    83818418       
    83828419!
    8383 !--    Calculate change in liquid water reservoir due to dew fall or
    8384 !--    evaporation of liquid water
    8385        IF ( humidity )  THEN
    8386 !
    8387 !--       If the air is saturated, check the reservoir water level
    8388           IF ( surf_usm_v(l)%qsws(m) < 0.0_wp )  THEN
    8389        
    8390 !
    8391 !--          In case qsws_veg becomes negative (unphysical behavior),
    8392 !--          let the water enter the liquid water reservoir as dew on the
    8393 !--          plant
    8394              IF ( surf_usm_v(l)%qsws_veg(m) < 0.0_wp )  THEN
    8395 !                 surf_usm_h%qsws_liq(m) = surf_usm_h%qsws_liq(m) + surf_usm_h%qsws_veg(m)
    8396                 surf_usm_v(l)%qsws_veg(m) = 0.0_wp
    8397              ENDIF
    8398           ENDIF   
    8399     ENDIF
    8400 else
    8401   surf_usm_v(l)%r_s(m) = 1.0E10_wp
    8402 endif !111
    8403 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    8404 
     8420!--                    In case qsws_veg becomes negative (unphysical behavior),
     8421!--                    let the water enter the liquid water reservoir as dew on the
     8422!--                    plant
     8423                       IF ( surf_usm_v(l)%qsws_veg(m) < 0.0_wp )  THEN
     8424          !                 surf_usm_h%qsws_liq(m) = surf_usm_h%qsws_liq(m) + surf_usm_h%qsws_veg(m)
     8425                          surf_usm_v(l)%qsws_veg(m) = 0.0_wp
     8426                       ENDIF
     8427                    ENDIF
     8428                 
     8429                 ENDIF
     8430              ELSE
     8431                 surf_usm_v(l)%r_s(m) = 1.0E10_wp
     8432              ENDIF
    84058433
    84068434           ENDDO
    8407 
    8408         ENDDO
     8435 
     8436       ENDDO
    84098437!
    84108438!--     Add-up anthropogenic heat, for now only at upward-facing surfaces
    8411         IF ( usm_anthropogenic_heat  .AND.  &
    8412              intermediate_timestep_count == intermediate_timestep_count_max )  THEN
     8439         IF ( usm_anthropogenic_heat  .AND.  &
     8440              intermediate_timestep_count == intermediate_timestep_count_max )  THEN
     8441!
    84138442!--        application of the additional anthropogenic heat sources
    84148443!--        we considere the traffic for now so all heat is absorbed
    84158444!--        to the first layer, generalization would be worth.
    8416            
    84178445!--        calculation of actual profile coefficient
    84188446!--        ??? check time_since_reference_point ???
    8419            dtime = mod(simulated_time + time_utc_init, 24.0_wp*3600.0_wp)
    8420            dhour = INT(dtime/3600.0_wp)
    8421            DO i = nxl, nxr
    8422               DO j = nys, nyn
    8423                  DO k = nzub, min(nzut,naheatlayers)
    8424                     IF ( k > get_topography_top_index_ji( j, i, 's' ) ) THEN
     8447            dtime = mod(simulated_time + time_utc_init, 24.0_wp*3600.0_wp)
     8448            dhour = INT(dtime/3600.0_wp)
     8449            DO i = nxl, nxr
     8450               DO j = nys, nyn
     8451                  DO k = nzub, min(nzut,naheatlayers)
     8452                     IF ( k > get_topography_top_index_ji( j, i, 's' ) ) THEN
     8453!
    84258454!--                    increase of pt in box i,j,k in time dt_3d
    84268455!--                    given to anthropogenic heat aheat*acoef (W*m-2)
    84278456!--                    linear interpolation of coeficient
    8428                        acoef = (REAL(dhour+1,wp)-dtime/3600.0_wp)*aheatprof(k,dhour) + &
    8429                                (dtime/3600.0_wp-REAL(dhour,wp))*aheatprof(k,dhour+1)
    8430                        IF ( aheat(k,j,i) > 0.0_wp )  THEN
     8457                        acoef = (REAL(dhour+1,wp)-dtime/3600.0_wp)*aheatprof(k,dhour) + &
     8458                                (dtime/3600.0_wp-REAL(dhour,wp))*aheatprof(k,dhour+1)
     8459                        IF ( aheat(k,j,i) > 0.0_wp )  THEN
     8460!
    84318461!--                       calculate rho * c_p coefficient at layer k
    8432                           rho_cp  = c_p * hyp(k) / ( r_d * pt(k+1,j,i) * exner(k) )
    8433                           pt(k,j,i) = pt(k,j,i) + aheat(k,j,i)*acoef*dt_3d/(exner(k)*rho_cp*dz(1))
    8434                        ENDIF
    8435                     ENDIF
    8436                  ENDDO
    8437               ENDDO
    8438            ENDDO
    8439 
    8440         ENDIF
    8441        
     8462                           rho_cp  = c_p * hyp(k) / ( r_d * pt(k+1,j,i) * exner(k) )
     8463                           pt(k,j,i) = pt(k,j,i) + aheat(k,j,i)*acoef*dt_3d/(exner(k)*rho_cp*dz(1))
     8464                        ENDIF
     8465                     ENDIF
     8466                  ENDDO
     8467               ENDDO
     8468            ENDDO
     8469 
     8470         ENDIF
     8471!
    84428472!--     pt and shf are defined on nxlg:nxrg,nysg:nyng
    84438473!--     get the borders from neighbours
    8444         CALL exchange_horiz( pt, nbgp )
    8445 
     8474         CALL exchange_horiz( pt, nbgp )
     8475!
    84468476!--     calculation of force_radiation_call:
    84478477!--     Make logical OR for all processes.
    84488478!--     Force radiation call if at least one processor forces it.
    8449         IF ( intermediate_timestep_count == intermediate_timestep_count_max-1 )&
    8450         THEN
     8479         IF ( intermediate_timestep_count == intermediate_timestep_count_max-1 )&
     8480         THEN
    84518481#if defined( __parallel )
    8452           IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
    8453           CALL MPI_ALLREDUCE( force_radiation_call_l, force_radiation_call,    &
    8454                               1, MPI_LOGICAL, MPI_LOR, comm2d, ierr )
     8482           IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
     8483           CALL MPI_ALLREDUCE( force_radiation_call_l, force_radiation_call,    &
     8484                               1, MPI_LOGICAL, MPI_LOR, comm2d, ierr )
    84558485#else
    8456           force_radiation_call = force_radiation_call_l
     8486           force_radiation_call = force_radiation_call_l
    84578487#endif
    8458           force_radiation_call_l = .FALSE.
    8459        ENDIF
    8460 
     8488           force_radiation_call_l = .FALSE.
     8489         ENDIF
     8490 
    84618491! !
    84628492! !-- Calculate surface specific humidity
     
    84648494!        CALL calc_q_surface_usm
    84658495!     ENDIF
    8466 
    8467 
    8468     CONTAINS
    8469 !------------------------------------------------------------------------------!
    8470 ! Description:
    8471 ! ------------
    8472 !> Calculation of specific humidity of the skin layer (surface). It is assumend
    8473 !> that the skin is always saturated.
    8474 !------------------------------------------------------------------------------!
    8475        SUBROUTINE calc_q_surface_usm
    8476 
    8477           IMPLICIT NONE
    8478 
    8479           REAL(wp) :: resistance    !< aerodynamic and soil resistance term
    8480 
    8481           DO  m = 1, surf_usm_h%ns
    8482 
    8483              i   = surf_usm_h%i(m)           
    8484              j   = surf_usm_h%j(m)
    8485              k   = surf_usm_h%k(m)
    8486 
     8496 
     8497 
     8498     CONTAINS
     8499 !------------------------------------------------------------------------------!
     8500 ! Description:
     8501 ! ------------
     8502 !> Calculation of specific humidity of the skin layer (surface). It is assumend
     8503 !> that the skin is always saturated.
     8504 !------------------------------------------------------------------------------!
     8505        SUBROUTINE calc_q_surface_usm
     8506 
     8507           IMPLICIT NONE
     8508 
     8509           REAL(wp) :: resistance    !< aerodynamic and soil resistance term
     8510 
     8511           DO  m = 1, surf_usm_h%ns
     8512 
     8513              i   = surf_usm_h%i(m)           
     8514              j   = surf_usm_h%j(m)
     8515              k   = surf_usm_h%k(m)
     8516 
    84878517!
    84888518!--          Calculate water vapour pressure at saturation
    8489              e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp *                  &
    8490                                     ( t_surf_green_h_p(m) - 273.16_wp ) /  &
    8491                                     ( t_surf_green_h_p(m) - 35.86_wp  )    &
    8492                                          )
    8493 
     8519              e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp *                  &
     8520                                     ( t_surf_green_h_p(m) - 273.16_wp ) /  &
     8521                                     ( t_surf_green_h_p(m) - 35.86_wp  )    &
     8522                                          )
     8523 
    84948524!
    84958525!--          Calculate specific humidity at saturation
    8496              q_s = 0.622_wp * e_s / ( surface_pressure - e_s )
    8497 
    8498 !              surf_usm_h%r_a_green(m) = ( surf_usm_h%pt1(m) - t_surf_green_h(m) / exner(k) ) /                  &
     8526              q_s = 0.622_wp * e_s / ( surface_pressure - e_s )
     8527 
     8528!              surf_usm_h%r_a_green(m) = ( surf_usm_h%pt1(m) - t_surf_green_h(m) / exner(k) ) /  &
    84998529!                    ( surf_usm_h%ts(m) * surf_usm_h%us(m) + 1.0E-10_wp )
    85008530!                 
    85018531! !--          make sure that the resistance does not drop to zero
    85028532!              IF ( ABS(surf_usm_h%r_a_green(m)) < 1.0E-10_wp )  surf_usm_h%r_a_green(m) = 1.0E-10_wp
    8503 
    8504              resistance = surf_usm_h%r_a_green(m) / ( surf_usm_h%r_a_green(m) + surf_usm_h%r_s(m) + 1E-5_wp )
    8505 
     8533 
     8534              resistance = surf_usm_h%r_a_green(m) / ( surf_usm_h%r_a_green(m) + surf_usm_h%r_s(m) + 1E-5_wp )
     8535 
    85068536!
    85078537!--          Calculate specific humidity at surface
    8508              IF ( bulk_cloud_model )  THEN
    8509                 q(k,j,i) = resistance * q_s +                   &
    8510                                            ( 1.0_wp - resistance ) *              &
    8511                                            ( q(k,j,i) - ql(k,j,i) )
    8512              ELSE
    8513                 q(k,j,i) = resistance * q_s +                   &
    8514                                            ( 1.0_wp - resistance ) *              &
    8515                                              q(k,j,i)
    8516              ENDIF
    8517 
     8538              IF ( bulk_cloud_model )  THEN
     8539                 q(k,j,i) = resistance * q_s +                   &
     8540                                            ( 1.0_wp - resistance ) *              &
     8541                                            ( q(k,j,i) - ql(k,j,i) )
     8542              ELSE
     8543                 q(k,j,i) = resistance * q_s +                   &
     8544                                            ( 1.0_wp - resistance ) *              &
     8545                                              q(k,j,i)
     8546              ENDIF
     8547 
    85188548!
    85198549!--          Update virtual potential temperature
    8520              vpt(k,j,i) = pt(k,j,i) *         &
    8521                         ( 1.0_wp + 0.61_wp * q(k,j,i) )
    8522 
    8523           ENDDO
    8524 
     8550              vpt(k,j,i) = pt(k,j,i) *         &
     8551                         ( 1.0_wp + 0.61_wp * q(k,j,i) )
     8552 
     8553           ENDDO
     8554
     8555!
    85258556!--       Now, treat vertical surface elements
    8526           DO  l = 0, 3
    8527              DO  m = 1, surf_usm_v(l)%ns
     8557           DO  l = 0, 3
     8558              DO  m = 1, surf_usm_v(l)%ns
    85288559!
    85298560!--             Get indices of respective grid point
    8530                 i = surf_usm_v(l)%i(m)
    8531                 j = surf_usm_v(l)%j(m)
    8532                 k = surf_usm_v(l)%k(m)
    8533 
     8561                 i = surf_usm_v(l)%i(m)
     8562                 j = surf_usm_v(l)%j(m)
     8563                 k = surf_usm_v(l)%k(m)
     8564 
    85348565!
    85358566!--             Calculate water vapour pressure at saturation
    8536                 e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp *                       &
    8537                                        ( t_surf_green_v_p(l)%t(m) - 273.16_wp ) /  &
    8538                                        ( t_surf_green_v_p(l)%t(m) - 35.86_wp  )    &
    8539                                             )
    8540 
     8567                 e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp *                       &
     8568                                        ( t_surf_green_v_p(l)%t(m) - 273.16_wp ) /  &
     8569                                        ( t_surf_green_v_p(l)%t(m) - 35.86_wp  )    &
     8570                                             )
     8571 
    85418572!
    85428573!--             Calculate specific humidity at saturation
    8543                 q_s = 0.622_wp * e_s / ( surface_pressure -e_s )
    8544 
     8574                 q_s = 0.622_wp * e_s / ( surface_pressure -e_s )
     8575 
    85458576!
    85468577!--             Calculate specific humidity at surface
    8547                 IF ( bulk_cloud_model )  THEN
    8548                    q(k,j,i) = ( q(k,j,i) - ql(k,j,i) )
    8549                 ELSE
    8550                    q(k,j,i) = q(k,j,i)
    8551                 ENDIF
     8578                 IF ( bulk_cloud_model )  THEN
     8579                    q(k,j,i) = ( q(k,j,i) - ql(k,j,i) )
     8580                 ELSE
     8581                    q(k,j,i) = q(k,j,i)
     8582                 ENDIF
    85528583!
    85538584!--             Update virtual potential temperature
    8554                 vpt(k,j,i) = pt(k,j,i) *         &
    8555                            ( 1.0_wp + 0.61_wp * q(k,j,i) )
    8556 
    8557              ENDDO
    8558 
    8559           ENDDO
    8560 
    8561        END SUBROUTINE calc_q_surface_usm
    8562        
    8563     END SUBROUTINE usm_surface_energy_balance
    8564 
    8565 
     8585                 vpt(k,j,i) = pt(k,j,i) *         &
     8586                            ( 1.0_wp + 0.61_wp * q(k,j,i) )
     8587 
     8588              ENDDO
     8589 
     8590           ENDDO
     8591 
     8592        END SUBROUTINE calc_q_surface_usm
     8593        
     8594     END SUBROUTINE usm_surface_energy_balance
     8595 
     8596 
    85668597!------------------------------------------------------------------------------!
    85678598! Description:
     
    85708601!> called out from subroutine swap_timelevel
    85718602!------------------------------------------------------------------------------!
    8572     SUBROUTINE usm_swap_timelevel( mod_count )
    8573 
    8574        IMPLICIT NONE
    8575 
    8576        INTEGER(iwp), INTENT(IN) ::  mod_count
    8577 
    8578      
    8579        SELECT CASE ( mod_count )
    8580 
    8581           CASE ( 0 )
     8603     SUBROUTINE usm_swap_timelevel( mod_count )
     8604 
     8605        IMPLICIT NONE
     8606 
     8607        INTEGER(iwp), INTENT(IN) ::  mod_count
     8608 
     8609       
     8610        SELECT CASE ( mod_count )
     8611 
     8612           CASE ( 0 )
    85828613!
    85838614!--          Horizontal surfaces
    8584              t_surf_wall_h  => t_surf_wall_h_1; t_surf_wall_h_p  => t_surf_wall_h_2
    8585              t_wall_h     => t_wall_h_1;    t_wall_h_p     => t_wall_h_2
    8586              t_surf_window_h  => t_surf_window_h_1; t_surf_window_h_p  => t_surf_window_h_2
    8587              t_window_h     => t_window_h_1;    t_window_h_p     => t_window_h_2
    8588              t_surf_green_h  => t_surf_green_h_1; t_surf_green_h_p  => t_surf_green_h_2
    8589              t_green_h     => t_green_h_1;    t_green_h_p     => t_green_h_2
     8615              t_surf_wall_h    => t_surf_wall_h_1;   t_surf_wall_h_p    => t_surf_wall_h_2
     8616              t_wall_h         => t_wall_h_1;        t_wall_h_p         => t_wall_h_2
     8617              t_surf_window_h  => t_surf_window_h_1; t_surf_window_h_p  => t_surf_window_h_2
     8618              t_window_h       => t_window_h_1;      t_window_h_p       => t_window_h_2
     8619              t_surf_green_h   => t_surf_green_h_1;  t_surf_green_h_p   => t_surf_green_h_2
     8620              t_green_h        => t_green_h_1;       t_green_h_p        => t_green_h_2
    85908621!
    85918622!--          Vertical surfaces
    8592              t_surf_wall_v  => t_surf_wall_v_1; t_surf_wall_v_p  => t_surf_wall_v_2
    8593              t_wall_v     => t_wall_v_1;    t_wall_v_p     => t_wall_v_2
    8594              t_surf_window_v  => t_surf_window_v_1; t_surf_window_v_p  => t_surf_window_v_2
    8595              t_window_v     => t_window_v_1;    t_window_v_p     => t_window_v_2
    8596              t_surf_green_v  => t_surf_green_v_1; t_surf_green_v_p  => t_surf_green_v_2
    8597              t_green_v     => t_green_v_1;    t_green_v_p     => t_green_v_2
    8598           CASE ( 1 )
     8623              t_surf_wall_v    => t_surf_wall_v_1;   t_surf_wall_v_p    => t_surf_wall_v_2
     8624              t_wall_v         => t_wall_v_1;        t_wall_v_p         => t_wall_v_2
     8625              t_surf_window_v  => t_surf_window_v_1; t_surf_window_v_p  => t_surf_window_v_2
     8626              t_window_v       => t_window_v_1;      t_window_v_p       => t_window_v_2
     8627              t_surf_green_v   => t_surf_green_v_1;  t_surf_green_v_p   => t_surf_green_v_2
     8628              t_green_v        => t_green_v_1;       t_green_v_p        => t_green_v_2
     8629           CASE ( 1 )
    85998630!
    86008631!--          Horizontal surfaces
    8601              t_surf_wall_h  => t_surf_wall_h_2; t_surf_wall_h_p  => t_surf_wall_h_1
    8602              t_wall_h     => t_wall_h_2;    t_wall_h_p     => t_wall_h_1
    8603              t_surf_window_h  => t_surf_window_h_2; t_surf_window_h_p  => t_surf_window_h_1
    8604              t_window_h     => t_window_h_2;    t_window_h_p     => t_window_h_1
    8605              t_surf_green_h  => t_surf_green_h_2; t_surf_green_h_p  => t_surf_green_h_1
    8606              t_green_h     => t_green_h_2;    t_green_h_p     => t_green_h_1
     8632              t_surf_wall_h    => t_surf_wall_h_2;   t_surf_wall_h_p    => t_surf_wall_h_1
     8633              t_wall_h         => t_wall_h_2;        t_wall_h_p         => t_wall_h_1
     8634              t_surf_window_h  => t_surf_window_h_2; t_surf_window_h_p  => t_surf_window_h_1
     8635              t_window_h       => t_window_h_2;      t_window_h_p       => t_window_h_1
     8636              t_surf_green_h   => t_surf_green_h_2;  t_surf_green_h_p   => t_surf_green_h_1
     8637              t_green_h        => t_green_h_2;       t_green_h_p        => t_green_h_1
    86078638!
    86088639!--          Vertical surfaces
    8609              t_surf_wall_v  => t_surf_wall_v_2; t_surf_wall_v_p  => t_surf_wall_v_1
    8610              t_wall_v     => t_wall_v_2;    t_wall_v_p     => t_wall_v_1
    8611              t_surf_window_v  => t_surf_window_v_2; t_surf_window_v_p  => t_surf_window_v_1
    8612              t_window_v     => t_window_v_2;    t_window_v_p     => t_window_v_1
    8613              t_surf_green_v  => t_surf_green_v_2; t_surf_green_v_p  => t_surf_green_v_1
    8614              t_green_v     => t_green_v_2;    t_green_v_p     => t_green_v_1
    8615        END SELECT
    8616        
    8617     END SUBROUTINE usm_swap_timelevel
    8618 
     8640              t_surf_wall_v    => t_surf_wall_v_2;   t_surf_wall_v_p    => t_surf_wall_v_1
     8641              t_wall_v         => t_wall_v_2;        t_wall_v_p         => t_wall_v_1
     8642              t_surf_window_v  => t_surf_window_v_2; t_surf_window_v_p  => t_surf_window_v_1
     8643              t_window_v       => t_window_v_2;      t_window_v_p       => t_window_v_1
     8644              t_surf_green_v   => t_surf_green_v_2;  t_surf_green_v_p   => t_surf_green_v_1
     8645              t_green_v        => t_green_v_2;       t_green_v_p        => t_green_v_1
     8646        END SELECT
     8647         
     8648     END SUBROUTINE usm_swap_timelevel
     8649 
    86198650!------------------------------------------------------------------------------!
    86208651! Description:
     
    86228653!> Subroutine writes t_surf and t_wall data into restart files
    86238654!------------------------------------------------------------------------------!
    8624     SUBROUTINE usm_wrd_local
    8625 
    8626    
    8627        IMPLICIT NONE
    8628        
    8629        CHARACTER(LEN=1) ::  dum     !< dummy string to create output-variable name 
    8630        INTEGER(iwp)     ::  l       !< index surface type orientation
    8631 
    8632        CALL wrd_write_string( 'ns_h_on_file_usm' )
    8633        WRITE ( 14 )  surf_usm_h%ns
    8634 
    8635        CALL wrd_write_string( 'ns_v_on_file_usm' )
    8636        WRITE ( 14 )  surf_usm_v(0:3)%ns
    8637 
    8638        CALL wrd_write_string( 'usm_start_index_h' )
    8639        WRITE ( 14 )  surf_usm_h%start_index
    8640 
    8641        CALL wrd_write_string( 'usm_end_index_h' )
    8642        WRITE ( 14 )  surf_usm_h%end_index
    8643 
    8644        CALL wrd_write_string( 't_surf_wall_h' )
    8645        WRITE ( 14 )  t_surf_wall_h
    8646 
    8647        CALL wrd_write_string( 't_surf_window_h' )
    8648        WRITE ( 14 )  t_surf_window_h
    8649 
    8650        CALL wrd_write_string( 't_surf_green_h' )
    8651        WRITE ( 14 )  t_surf_green_h
    8652 
    8653        DO  l = 0, 3
    8654 
    8655           CALL wrd_write_string( 'usm_start_index_v' )
    8656           WRITE ( 14 )  surf_usm_v(l)%start_index
    8657 
    8658           CALL wrd_write_string( 'usm_end_index_v' )
    8659           WRITE ( 14 )  surf_usm_v(l)%end_index
    8660 
    8661           WRITE( dum, '(I1)')  l         
    8662 
    8663           CALL wrd_write_string( 't_surf_wall_v(' // dum // ')' )
    8664           WRITE ( 14 )  t_surf_wall_v(l)%t
    8665 
    8666           CALL wrd_write_string( 't_surf_window_v(' // dum // ')' )
    8667           WRITE ( 14 ) t_surf_window_v(l)%t     
    8668 
    8669           CALL wrd_write_string( 't_surf_green_v(' // dum // ')' )
    8670           WRITE ( 14 ) t_surf_green_v(l)%t   
    8671          
    8672        ENDDO
    8673 
    8674        CALL wrd_write_string( 'usm_start_index_h' )
    8675        WRITE ( 14 )  surf_usm_h%start_index
    8676 
    8677        CALL wrd_write_string( 'usm_end_index_h' )
    8678        WRITE ( 14 )  surf_usm_h%end_index
    8679 
    8680        CALL wrd_write_string( 't_wall_h' )
    8681        WRITE ( 14 )  t_wall_h
    8682 
    8683        CALL wrd_write_string( 't_window_h' )
    8684        WRITE ( 14 )  t_window_h
    8685 
    8686        CALL wrd_write_string( 't_green_h' )
    8687        WRITE ( 14 )  t_green_h
    8688 
    8689        DO  l = 0, 3
    8690 
    8691           CALL wrd_write_string( 'usm_start_index_v' )
    8692           WRITE ( 14 )  surf_usm_v(l)%start_index
    8693 
    8694           CALL wrd_write_string( 'usm_end_index_v' )
    8695           WRITE ( 14 )  surf_usm_v(l)%end_index
    8696 
    8697           WRITE( dum, '(I1)')  l     
    8698 
    8699           CALL wrd_write_string( 't_wall_v(' // dum // ')' )
    8700           WRITE ( 14 )  t_wall_v(l)%t
    8701 
    8702           CALL wrd_write_string( 't_window_v(' // dum // ')' )
    8703           WRITE ( 14 )  t_window_v(l)%t
    8704 
    8705           CALL wrd_write_string( 't_green_v(' // dum // ')' )
    8706           WRITE ( 14 )  t_green_v(l)%t
    8707        
    8708        ENDDO
    8709 
    8710        
    8711     END SUBROUTINE usm_wrd_local
    8712 
    8713  
    8714  END MODULE urban_surface_mod
     8655     SUBROUTINE usm_wrd_local
     8656 
     8657     
     8658        IMPLICIT NONE
     8659        
     8660        CHARACTER(LEN=1) ::  dum     !< dummy string to create output-variable name 
     8661        INTEGER(iwp)     ::  l       !< index surface type orientation
     8662 
     8663        CALL wrd_write_string( 'ns_h_on_file_usm' )
     8664        WRITE ( 14 )  surf_usm_h%ns
     8665 
     8666        CALL wrd_write_string( 'ns_v_on_file_usm' )
     8667        WRITE ( 14 )  surf_usm_v(0:3)%ns
     8668 
     8669        CALL wrd_write_string( 'usm_start_index_h' )
     8670        WRITE ( 14 )  surf_usm_h%start_index
     8671 
     8672        CALL wrd_write_string( 'usm_end_index_h' )
     8673        WRITE ( 14 )  surf_usm_h%end_index
     8674 
     8675        CALL wrd_write_string( 't_surf_wall_h' )
     8676        WRITE ( 14 )  t_surf_wall_h
     8677 
     8678        CALL wrd_write_string( 't_surf_window_h' )
     8679        WRITE ( 14 )  t_surf_window_h
     8680 
     8681        CALL wrd_write_string( 't_surf_green_h' )
     8682        WRITE ( 14 )  t_surf_green_h
     8683 
     8684        DO  l = 0, 3
     8685 
     8686           CALL wrd_write_string( 'usm_start_index_v' )
     8687           WRITE ( 14 )  surf_usm_v(l)%start_index
     8688 
     8689           CALL wrd_write_string( 'usm_end_index_v' )
     8690           WRITE ( 14 )  surf_usm_v(l)%end_index
     8691 
     8692           WRITE( dum, '(I1)')  l         
     8693 
     8694           CALL wrd_write_string( 't_surf_wall_v(' // dum // ')' )
     8695           WRITE ( 14 )  t_surf_wall_v(l)%t
     8696 
     8697           CALL wrd_write_string( 't_surf_window_v(' // dum // ')' )
     8698           WRITE ( 14 ) t_surf_window_v(l)%t     
     8699 
     8700           CALL wrd_write_string( 't_surf_green_v(' // dum // ')' )
     8701           WRITE ( 14 ) t_surf_green_v(l)%t   
     8702           
     8703        ENDDO
     8704 
     8705        CALL wrd_write_string( 'usm_start_index_h' )
     8706        WRITE ( 14 )  surf_usm_h%start_index
     8707 
     8708        CALL wrd_write_string( 'usm_end_index_h' )
     8709        WRITE ( 14 )  surf_usm_h%end_index
     8710 
     8711        CALL wrd_write_string( 't_wall_h' )
     8712        WRITE ( 14 )  t_wall_h
     8713 
     8714        CALL wrd_write_string( 't_window_h' )
     8715        WRITE ( 14 )  t_window_h
     8716 
     8717        CALL wrd_write_string( 't_green_h' )
     8718        WRITE ( 14 )  t_green_h
     8719 
     8720        DO  l = 0, 3
     8721 
     8722           CALL wrd_write_string( 'usm_start_index_v' )
     8723           WRITE ( 14 )  surf_usm_v(l)%start_index
     8724 
     8725           CALL wrd_write_string( 'usm_end_index_v' )
     8726           WRITE ( 14 )  surf_usm_v(l)%end_index
     8727 
     8728           WRITE( dum, '(I1)')  l     
     8729 
     8730           CALL wrd_write_string( 't_wall_v(' // dum // ')' )
     8731           WRITE ( 14 )  t_wall_v(l)%t
     8732 
     8733           CALL wrd_write_string( 't_window_v(' // dum // ')' )
     8734           WRITE ( 14 )  t_window_v(l)%t
     8735 
     8736           CALL wrd_write_string( 't_green_v(' // dum // ')' )
     8737           WRITE ( 14 )  t_green_v(l)%t
     8738        
     8739        ENDDO
     8740 
     8741        
     8742     END SUBROUTINE usm_wrd_local
     8743 
     8744   
     8745  END MODULE urban_surface_mod
Note: See TracChangeset for help on using the changeset viewer.