Index: palm/trunk/SOURCE/urban_surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/urban_surface_mod.f90	(revision 3711)
+++ palm/trunk/SOURCE/urban_surface_mod.f90	(revision 3712)
@@ -15,6 +15,6 @@
 ! PALM. If not, see <http://www.gnu.org/licenses/>.
 !
-! Copyright 2015-2018 Czech Technical University in Prague
-! Copyright 2015-2018 Institute of Computer Science of the 
+! Copyright 2015-2019 Czech Technical University in Prague
+! Copyright 2015-2019 Institute of Computer Science of the 
 !                     Czech Academy of Sciences, Prague
 ! Copyright 1997-2019 Leibniz Universitaet Hannover
@@ -28,4 +28,7 @@
 ! -----------------
 ! $Id$
+! Formatting and clean-up (rvtils)
+! 
+! 3710 2019-01-30 18:11:19Z suehring
 ! Check if building type is set within a valid range.
 ! 
@@ -477,11 +480,11 @@
 
     REAL(wp), PARAMETER ::                     &
-              b_ch               = 6.04_wp,    & ! Clapp & Hornberger exponent
-              lambda_h_green_dry = 0.19_wp,    & ! heat conductivity for dry soil   
-              lambda_h_green_sm  = 3.44_wp,    & ! heat conductivity of the soil matrix
-              lambda_h_water     = 0.57_wp,    & ! heat conductivity of water
-              psi_sat            = -0.388_wp,  & ! soil matrix potential at saturation
-              rho_c_soil         = 2.19E6_wp,  & ! volumetric heat capacity of soil
-              rho_c_water        = 4.20E6_wp !,  & ! volumetric heat capacity of water
+              b_ch               = 6.04_wp,    &  !< Clapp & Hornberger exponent
+              lambda_h_green_dry = 0.19_wp,    &  !< heat conductivity for dry soil   
+              lambda_h_green_sm  = 3.44_wp,    &  !< heat conductivity of the soil matrix
+              lambda_h_water     = 0.57_wp,    &  !< heat conductivity of water
+              psi_sat            = -0.388_wp,  &  !< soil matrix potential at saturation
+              rho_c_soil         = 2.19E6_wp,  &  !< volumetric heat capacity of soil
+              rho_c_water        = 4.20E6_wp      !< volumetric heat capacity of water
 !               m_max_depth        = 0.0002_wp     ! Maximum capacity of the water reservoir (m)
 
@@ -489,11 +492,11 @@
 !-- Soil parameters I           alpha_vg,      l_vg_green,    n_vg, gamma_w_green_sat
     REAL(wp), DIMENSION(0:3,1:7), PARAMETER :: soil_pars = RESHAPE( (/     &
-                                 3.83_wp,  1.250_wp, 1.38_wp,  6.94E-6_wp, & ! 1
-                                 3.14_wp, -2.342_wp, 1.28_wp,  1.16E-6_wp, & ! 2
-                                 0.83_wp, -0.588_wp, 1.25_wp,  0.26E-6_wp, & ! 3
-                                 3.67_wp, -1.977_wp, 1.10_wp,  2.87E-6_wp, & ! 4
-                                 2.65_wp,  2.500_wp, 1.10_wp,  1.74E-6_wp, & ! 5
-                                 1.30_wp,  0.400_wp, 1.20_wp,  0.93E-6_wp, & ! 6
-                                 0.00_wp,  0.00_wp,  0.00_wp,  0.57E-6_wp  & ! 7
+                                 3.83_wp,  1.250_wp, 1.38_wp,  6.94E-6_wp, &  !< soil 1
+                                 3.14_wp, -2.342_wp, 1.28_wp,  1.16E-6_wp, &  !< soil 2
+                                 0.83_wp, -0.588_wp, 1.25_wp,  0.26E-6_wp, &  !< soil 3
+                                 3.67_wp, -1.977_wp, 1.10_wp,  2.87E-6_wp, &  !< soil 4
+                                 2.65_wp,  2.500_wp, 1.10_wp,  1.74E-6_wp, &  !< soil 5
+                                 1.30_wp,  0.400_wp, 1.20_wp,  0.93E-6_wp, &  !< soil 6
+                                 0.00_wp,  0.00_wp,  0.00_wp,  0.57E-6_wp  &  !< soil 7
                                  /), (/ 4, 7 /) )
 
@@ -501,29 +504,30 @@
 !-- Soil parameters II              swc_sat,     fc,   wilt,    swc_res  
     REAL(wp), DIMENSION(0:3,1:7), PARAMETER :: m_soil_pars = RESHAPE( (/ &
-                                 0.403_wp, 0.244_wp, 0.059_wp, 0.025_wp, & ! 1
-                                 0.439_wp, 0.347_wp, 0.151_wp, 0.010_wp, & ! 2
-                                 0.430_wp, 0.383_wp, 0.133_wp, 0.010_wp, & ! 3
-                                 0.520_wp, 0.448_wp, 0.279_wp, 0.010_wp, & ! 4
-                                 0.614_wp, 0.541_wp, 0.335_wp, 0.010_wp, & ! 5
-                                 0.766_wp, 0.663_wp, 0.267_wp, 0.010_wp, & ! 6
-                                 0.472_wp, 0.323_wp, 0.171_wp, 0.000_wp  & ! 7
+                                 0.403_wp, 0.244_wp, 0.059_wp, 0.025_wp, &  !< soil 1
+                                 0.439_wp, 0.347_wp, 0.151_wp, 0.010_wp, &  !< soil 2
+                                 0.430_wp, 0.383_wp, 0.133_wp, 0.010_wp, &  !< soil 3
+                                 0.520_wp, 0.448_wp, 0.279_wp, 0.010_wp, &  !< soil 4
+                                 0.614_wp, 0.541_wp, 0.335_wp, 0.010_wp, &  !< soil 5
+                                 0.766_wp, 0.663_wp, 0.267_wp, 0.010_wp, &  !< soil 6
+                                 0.472_wp, 0.323_wp, 0.171_wp, 0.000_wp  &  !< soil 7
                                  /), (/ 4, 7 /) )
-                                
-    !   value 9999999.9_wp -> generic available or user-defined value must be set
-!   otherwise -> no generic variable and user setting is optional
-    REAL(wp) :: alpha_vangenuchten = 9999999.9_wp,      & !< NAMELIST alpha_vg
-                field_capacity = 9999999.9_wp,          & !< NAMELIST fc
-                hydraulic_conductivity = 9999999.9_wp,  & !< NAMELIST gamma_w_green_sat
-                lambda_h_green_sat = 0.0_wp,            & !< heat conductivity for saturated soil
-                l_vangenuchten = 9999999.9_wp,          & !< NAMELIST l_vg
-                n_vangenuchten = 9999999.9_wp,          & !< NAMELIST n_vg
-                residual_moisture = 9999999.9_wp,       & !< NAMELIST m_res
-                saturation_moisture = 9999999.9_wp,     & !< NAMELIST m_sat
-                wilting_point = 9999999.9_wp!,           & !< NAMELIST m_wilt
+!
+!-- value 9999999.9_wp -> generic available or user-defined value must be set
+!-- otherwise -> no generic variable and user setting is optional
+    REAL(wp) :: alpha_vangenuchten = 9999999.9_wp,      &  !< NAMELIST alpha_vg
+                field_capacity = 9999999.9_wp,          &  !< NAMELIST fc
+                hydraulic_conductivity = 9999999.9_wp,  &  !< NAMELIST gamma_w_green_sat
+                lambda_h_green_sat = 0.0_wp,            &  !< heat conductivity for saturated soil
+                l_vangenuchten = 9999999.9_wp,          &  !< NAMELIST l_vg
+                n_vangenuchten = 9999999.9_wp,          &  !< NAMELIST n_vg
+                residual_moisture = 9999999.9_wp,       &  !< NAMELIST m_res
+                saturation_moisture = 9999999.9_wp,     &  !< NAMELIST m_sat
+                wilting_point = 9999999.9_wp               !< NAMELIST m_wilt
     
-
+!
 !-- configuration parameters (they can be setup in PALM config)
     LOGICAL ::  usm_material_model = .TRUE.        !< flag parameter indicating wheather the  model of heat in materials is used
-    LOGICAL ::  usm_anthropogenic_heat = .FALSE.   !< flag parameter indicating wheather the anthropogenic heat sources (e.g.transportation) are used
+    LOGICAL ::  usm_anthropogenic_heat = .FALSE.   !< flag parameter indicating wheather the anthropogenic heat sources
+                                                   !< (e.g.transportation) are used
     LOGICAL ::  force_radiation_call_l = .FALSE.   !< flag parameter for unscheduled radiation model calls
     LOGICAL ::  indoor_model = .FALSE.             !< whether to use the indoor model
@@ -540,120 +544,143 @@
 !
 !-- Indices of input attributes for (above) ground floor level 
-    INTEGER(iwp) ::  ind_alb_wall_agfl     = 65  !< index in input list for albedo_type of wall above ground floor level
-    INTEGER(iwp) ::  ind_alb_wall_gfl      = 32  !< index in input list for albedo_type of wall ground floor level
-    INTEGER(iwp) ::  ind_alb_wall_r        = 96  !< index in input list for albedo_type of wall roof
-    INTEGER(iwp) ::  ind_alb_green_agfl    = 83  !< index in input list for albedo_type of green above ground floor level
-    INTEGER(iwp) ::  ind_alb_green_gfl     = 50  !< index in input list for albedo_type of green ground floor level
-    INTEGER(iwp) ::  ind_alb_green_r       = 115 !< index in input list for albedo_type of green roof
-    INTEGER(iwp) ::  ind_alb_win_agfl      = 79  !< index in input list for albedo_type of window fraction above ground floor level
-    INTEGER(iwp) ::  ind_alb_win_gfl       = 46  !< index in input list for albedo_type of window fraction ground floor level 
-    INTEGER(iwp) ::  ind_alb_win_r         = 110 !< index in input list for albedo_type of window fraction roof
-    INTEGER(iwp) ::  ind_emis_wall_agfl    = 64  !< index in input list for wall emissivity, above ground floor level
-    INTEGER(iwp) ::  ind_emis_wall_gfl     = 31  !< index in input list for wall emissivity, ground floor level
-    INTEGER(iwp) ::  ind_emis_wall_r       = 95  !< index in input list for wall emissivity, roof
-    INTEGER(iwp) ::  ind_emis_green_agfl   = 82  !< index in input list for green emissivity, above ground floor level
-    INTEGER(iwp) ::  ind_emis_green_gfl    = 49  !< index in input list for green emissivity, ground floor level
-    INTEGER(iwp) ::  ind_emis_green_r      = 114 !< index in input list for green emissivity, roof
-    INTEGER(iwp) ::  ind_emis_win_agfl     = 77  !< index in input list for window emissivity, above ground floor level
-    INTEGER(iwp) ::  ind_emis_win_gfl      = 44  !< index in input list for window emissivity, ground floor level
-    INTEGER(iwp) ::  ind_emis_win_r        = 108 !< index in input list for window emissivity, roof
-    INTEGER(iwp) ::  ind_green_frac_w_agfl = 80  !< index in input list for green fraction on wall, above ground floor level
-    INTEGER(iwp) ::  ind_green_frac_w_gfl  = 47  !< index in input list for green fraction on wall, ground floor level
-    INTEGER(iwp) ::  ind_green_frac_r_agfl = 112 !< index in input list for green fraction on roof, above ground floor level
-    INTEGER(iwp) ::  ind_green_frac_r_gfl  = 111 !< index in input list for green fraction on roof, ground floor level
-    INTEGER(iwp) ::  ind_hc1_agfl          = 58  !< index in input list for heat capacity at first wall layer, above ground floor level
-    INTEGER(iwp) ::  ind_hc1_gfl           = 25  !< index in input list for heat capacity at first wall layer, ground floor level
-    INTEGER(iwp) ::  ind_hc1_wall_r        = 89  !< index in input list for heat capacity at first wall layer, roof
-    INTEGER(iwp) ::  ind_hc1_win_agfl      = 71  !< index in input list for heat capacity at first window layer, above ground floor level
-    INTEGER(iwp) ::  ind_hc1_win_gfl       = 38  !< index in input list for heat capacity at first window layer, ground floor level
-    INTEGER(iwp) ::  ind_hc1_win_r         = 102 !< index in input list for heat capacity at first window layer, roof
-    INTEGER(iwp) ::  ind_hc2_agfl          = 59  !< index in input list for heat capacity at second wall layer, above ground floor level
-    INTEGER(iwp) ::  ind_hc2_gfl           = 26  !< index in input list for heat capacity at second wall layer, ground floor level
-    INTEGER(iwp) ::  ind_hc2_wall_r        = 90  !< index in input list for heat capacity at second wall layer, roof
-    INTEGER(iwp) ::  ind_hc2_win_agfl      = 72  !< index in input list for heat capacity at second window layer, above ground floor level
-    INTEGER(iwp) ::  ind_hc2_win_gfl       = 39  !< index in input list for heat capacity at second window layer, ground floor level
-    INTEGER(iwp) ::  ind_hc2_win_r         = 103 !< index in input list for heat capacity at second window layer, roof
-    INTEGER(iwp) ::  ind_hc3_agfl          = 60  !< index in input list for heat capacity at third wall layer, above ground floor level
-    INTEGER(iwp) ::  ind_hc3_gfl           = 27  !< index in input list for heat capacity at third wall layer, ground floor level
-    INTEGER(iwp) ::  ind_hc3_wall_r        = 91  !< index in input list for heat capacity at third wall layer, roof
-    INTEGER(iwp) ::  ind_hc3_win_agfl      = 73  !< index in input list for heat capacity at third window layer, above ground floor level
-    INTEGER(iwp) ::  ind_hc3_win_gfl       = 40  !< index in input list for heat capacity at third window layer, ground floor level
-    INTEGER(iwp) ::  ind_hc3_win_r         = 104 !< index in input list for heat capacity at third window layer, roof
-    INTEGER(iwp) ::  ind_gflh              = 17  !< index in input list for ground floor level height
-    INTEGER(iwp) ::  ind_lai_r_agfl        = 113 !< index in input list for LAI on roof, above ground floor level
+    INTEGER(iwp) ::  ind_alb_wall_agfl     = 65   !< index in input list for albedo_type of wall above ground floor level
+    INTEGER(iwp) ::  ind_alb_wall_gfl      = 32   !< index in input list for albedo_type of wall ground floor level
+    INTEGER(iwp) ::  ind_alb_wall_r        = 96   !< index in input list for albedo_type of wall roof
+    INTEGER(iwp) ::  ind_alb_green_agfl    = 83   !< index in input list for albedo_type of green above ground floor level
+    INTEGER(iwp) ::  ind_alb_green_gfl     = 50   !< index in input list for albedo_type of green ground floor level
+    INTEGER(iwp) ::  ind_alb_green_r       = 115  !< index in input list for albedo_type of green roof
+    INTEGER(iwp) ::  ind_alb_win_agfl      = 79   !< index in input list for albedo_type of window fraction
+                                                  !< above ground floor level
+    INTEGER(iwp) ::  ind_alb_win_gfl       = 46   !< index in input list for albedo_type of window fraction ground floor level
+    INTEGER(iwp) ::  ind_alb_win_r         = 110  !< index in input list for albedo_type of window fraction roof
+    INTEGER(iwp) ::  ind_emis_wall_agfl    = 64   !< index in input list for wall emissivity, above ground floor level
+    INTEGER(iwp) ::  ind_emis_wall_gfl     = 31   !< index in input list for wall emissivity, ground floor level
+    INTEGER(iwp) ::  ind_emis_wall_r       = 95   !< index in input list for wall emissivity, roof
+    INTEGER(iwp) ::  ind_emis_green_agfl   = 82   !< index in input list for green emissivity, above ground floor level
+    INTEGER(iwp) ::  ind_emis_green_gfl    = 49   !< index in input list for green emissivity, ground floor level
+    INTEGER(iwp) ::  ind_emis_green_r      = 114  !< index in input list for green emissivity, roof
+    INTEGER(iwp) ::  ind_emis_win_agfl     = 77   !< index in input list for window emissivity, above ground floor level
+    INTEGER(iwp) ::  ind_emis_win_gfl      = 44   !< index in input list for window emissivity, ground floor level
+    INTEGER(iwp) ::  ind_emis_win_r        = 108  !< index in input list for window emissivity, roof
+    INTEGER(iwp) ::  ind_green_frac_w_agfl = 80   !< index in input list for green fraction on wall, above ground floor level
+    INTEGER(iwp) ::  ind_green_frac_w_gfl  = 47   !< index in input list for green fraction on wall, ground floor level
+    INTEGER(iwp) ::  ind_green_frac_r_agfl = 112  !< index in input list for green fraction on roof, above ground floor level
+    INTEGER(iwp) ::  ind_green_frac_r_gfl  = 111  !< index in input list for green fraction on roof, ground floor level
+    INTEGER(iwp) ::  ind_hc1_agfl          = 58   !< index in input list for heat capacity at first wall layer,
+                                                  !< above ground floor level
+    INTEGER(iwp) ::  ind_hc1_gfl           = 25   !< index in input list for heat capacity at first wall layer, ground floor level
+    INTEGER(iwp) ::  ind_hc1_wall_r        = 89   !< index in input list for heat capacity at first wall layer, roof
+    INTEGER(iwp) ::  ind_hc1_win_agfl      = 71   !< index in input list for heat capacity at first window layer,
+                                                  !< above ground floor level
+    INTEGER(iwp) ::  ind_hc1_win_gfl       = 38   !< index in input list for heat capacity at first window layer,
+                                                  !< ground floor level
+    INTEGER(iwp) ::  ind_hc1_win_r         = 102  !< index in input list for heat capacity at first window layer, roof
+    INTEGER(iwp) ::  ind_hc2_agfl          = 59   !< index in input list for heat capacity at second wall layer,
+                                                  !< above ground floor level
+    INTEGER(iwp) ::  ind_hc2_gfl           = 26   !< index in input list for heat capacity at second wall layer, ground floor level
+    INTEGER(iwp) ::  ind_hc2_wall_r        = 90   !< index in input list for heat capacity at second wall layer, roof
+    INTEGER(iwp) ::  ind_hc2_win_agfl      = 72   !< index in input list for heat capacity at second window layer,
+                                                  !< above ground floor level
+    INTEGER(iwp) ::  ind_hc2_win_gfl       = 39   !< index in input list for heat capacity at second window layer,
+                                                  !< ground floor level
+    INTEGER(iwp) ::  ind_hc2_win_r         = 103  !< index in input list for heat capacity at second window layer, roof
+    INTEGER(iwp) ::  ind_hc3_agfl          = 60   !< index in input list for heat capacity at third wall layer,
+                                                  !< above ground floor level
+    INTEGER(iwp) ::  ind_hc3_gfl           = 27   !< index in input list for heat capacity at third wall layer, ground floor level
+    INTEGER(iwp) ::  ind_hc3_wall_r        = 91   !< index in input list for heat capacity at third wall layer, roof
+    INTEGER(iwp) ::  ind_hc3_win_agfl      = 73   !< index in input list for heat capacity at third window layer,
+                                                  !< above ground floor level
+    INTEGER(iwp) ::  ind_hc3_win_gfl       = 40   !< index in input list for heat capacity at third window layer,
+                                                  !< ground floor level
+    INTEGER(iwp) ::  ind_hc3_win_r         = 104  !< index in input list for heat capacity at third window layer, roof
+    INTEGER(iwp) ::  ind_gflh              = 17   !< index in input list for ground floor level height
+    INTEGER(iwp) ::  ind_lai_r_agfl        = 113  !< index in input list for LAI on roof, above ground floor level
     INTEGER(iwp) ::  ind_lai_r_gfl         = 113  !< index in input list for LAI on roof, ground floor level
-    INTEGER(iwp) ::  ind_lai_w_agfl        = 81  !< index in input list for LAI on wall, above ground floor level
-    INTEGER(iwp) ::  ind_lai_w_gfl         = 48  !< index in input list for LAI on wall, ground floor level
-    INTEGER(iwp) ::  ind_tc1_agfl          = 61  !< index in input list for thermal conductivity at first wall layer, above ground floor level
-    INTEGER(iwp) ::  ind_tc1_gfl           = 28  !< index in input list for thermal conductivity at first wall layer, ground floor level
-    INTEGER(iwp) ::  ind_tc1_wall_r        = 92  !< index in input list for thermal conductivity at first wall layer, roof
-    INTEGER(iwp) ::  ind_tc1_win_agfl      = 74  !< index in input list for thermal conductivity at first window layer, above ground floor level
-    INTEGER(iwp) ::  ind_tc1_win_gfl       = 41  !< index in input list for thermal conductivity at first window layer, ground floor level
-    INTEGER(iwp) ::  ind_tc1_win_r         = 105 !< index in input list for thermal conductivity at first window layer, roof
-    INTEGER(iwp) ::  ind_tc2_agfl          = 62  !< index in input list for thermal conductivity at second wall layer, above ground floor level
-    INTEGER(iwp) ::  ind_tc2_gfl           = 29  !< index in input list for thermal conductivity at second wall layer, ground floor level
-    INTEGER(iwp) ::  ind_tc2_wall_r        = 93  !< index in input list for thermal conductivity at second wall layer, roof
-    INTEGER(iwp) ::  ind_tc2_win_agfl      = 75  !< index in input list for thermal conductivity at second window layer, above ground floor level
-    INTEGER(iwp) ::  ind_tc2_win_gfl       = 42  !< index in input list for thermal conductivity at second window layer, ground floor level
-    INTEGER(iwp) ::  ind_tc2_win_r         = 106 !< index in input list for thermal conductivity at second window layer, ground floor level
-    INTEGER(iwp) ::  ind_tc3_agfl          = 63  !< index in input list for thermal conductivity at third wall layer, above ground floor level
-    INTEGER(iwp) ::  ind_tc3_gfl           = 30  !< index in input list for thermal conductivity at third wall layer, ground floor level
-    INTEGER(iwp) ::  ind_tc3_wall_r        = 94  !< index in input list for thermal conductivity at third wall layer, roof
-    INTEGER(iwp) ::  ind_tc3_win_agfl      = 76  !< index in input list for thermal conductivity at third window layer, above ground floor level
-    INTEGER(iwp) ::  ind_tc3_win_gfl       = 43  !< index in input list for thermal conductivity at third window layer, ground floor level
-    INTEGER(iwp) ::  ind_tc3_win_r         = 107 !< index in input list for thermal conductivity at third window layer, roof
-    INTEGER(iwp) ::  ind_thick_1_agfl      = 54  !< index for wall layer thickness - 1st layer above ground floor level
-    INTEGER(iwp) ::  ind_thick_1_gfl       = 21  !< index for wall layer thickness - 1st layer ground floor level
-    INTEGER(iwp) ::  ind_thick_1_wall_r    = 85  !< index for wall layer thickness - 1st layer roof
-    INTEGER(iwp) ::  ind_thick_1_win_agfl  = 67  !< index for window layer thickness - 1st layer above ground floor level
-    INTEGER(iwp) ::  ind_thick_1_win_gfl   = 34  !< index for window layer thickness - 1st layer ground floor level
-    INTEGER(iwp) ::  ind_thick_1_win_r     = 98  !< index for window layer thickness - 1st layer roof
-    INTEGER(iwp) ::  ind_thick_2_agfl      = 55  !< index for wall layer thickness - 2nd layer above ground floor level
-    INTEGER(iwp) ::  ind_thick_2_gfl       = 22  !< index for wall layer thickness - 2nd layer ground floor level
-    INTEGER(iwp) ::  ind_thick_2_wall_r    = 86  !< index for wall layer thickness - 2nd layer roof
-    INTEGER(iwp) ::  ind_thick_2_win_agfl  = 68  !< index for window layer thickness - 2nd layer above ground floor level
-    INTEGER(iwp) ::  ind_thick_2_win_gfl   = 35  !< index for window layer thickness - 2nd layer ground floor level
-    INTEGER(iwp) ::  ind_thick_2_win_r     = 99  !< index for window layer thickness - 2nd layer roof
-    INTEGER(iwp) ::  ind_thick_3_agfl      = 56  !< index for wall layer thickness - 3rd layer above ground floor level
-    INTEGER(iwp) ::  ind_thick_3_gfl       = 23  !< index for wall layer thickness - 3rd layer ground floor level
-    INTEGER(iwp) ::  ind_thick_3_wall_r    = 87  !< index for wall layer thickness - 3rd layer roof
-    INTEGER(iwp) ::  ind_thick_3_win_agfl  = 69  !< index for window layer thickness - 3rd layer above ground floor level
-    INTEGER(iwp) ::  ind_thick_3_win_gfl   = 36  !< index for window layer thickness - 3rd layer ground floor level  
-    INTEGER(iwp) ::  ind_thick_3_win_r     = 100 !< index for window layer thickness - 3rd layer roof
-    INTEGER(iwp) ::  ind_thick_4_agfl      = 57  !< index for wall layer thickness - 4th layer above ground floor level
-    INTEGER(iwp) ::  ind_thick_4_gfl       = 24  !< index for wall layer thickness - 4th layer ground floor level
-    INTEGER(iwp) ::  ind_thick_4_wall_r    = 88  !< index for wall layer thickness - 4st layer roof
-    INTEGER(iwp) ::  ind_thick_4_win_agfl  = 70  !< index for window layer thickness - 4th layer above ground floor level
-    INTEGER(iwp) ::  ind_thick_4_win_gfl   = 37  !< index for window layer thickness - 4th layer ground floor level
-    INTEGER(iwp) ::  ind_thick_4_win_r     = 101 !< index for window layer thickness - 4th layer roof
-    INTEGER(iwp) ::  ind_trans_agfl        = 78  !< index in input list for window transmissivity, above ground floor level
-    INTEGER(iwp) ::  ind_trans_gfl         = 45  !< index in input list for window transmissivity, ground floor level
-    INTEGER(iwp) ::  ind_trans_r           = 109 !< index in input list for window transmissivity, roof
-    INTEGER(iwp) ::  ind_wall_frac_agfl    = 53  !< index in input list for wall fraction, above ground floor level
-    INTEGER(iwp) ::  ind_wall_frac_gfl     = 20  !< index in input list for wall fraction, ground floor level
-    INTEGER(iwp) ::  ind_wall_frac_r       = 84  !< index in input list for wall fraction, roof
-    INTEGER(iwp) ::  ind_win_frac_agfl     = 66  !< index in input list for window fraction, above ground floor level
-    INTEGER(iwp) ::  ind_win_frac_gfl      = 33  !< index in input list for window fraction, ground floor level
-    INTEGER(iwp) ::  ind_win_frac_r        = 97  !< index in input list for window fraction, roof
-    INTEGER(iwp) ::  ind_z0_agfl           = 51  !< index in input list for z0, above ground floor level
-    INTEGER(iwp) ::  ind_z0_gfl            = 18  !< index in input list for z0, ground floor level
-    INTEGER(iwp) ::  ind_z0qh_agfl         = 52  !< index in input list for z0h / z0q, above ground floor level
-    INTEGER(iwp) ::  ind_z0qh_gfl          = 19  !< index in input list for z0h / z0q, ground floor level
-    INTEGER(iwp) ::  ind_green_type_roof   = 116 !< index in input list for type of green roof
-
-
-    REAL(wp)  ::  roof_height_limit = 4.0_wp          !< height for distinguish between land surfaces and roofs
+    INTEGER(iwp) ::  ind_lai_w_agfl        = 81   !< index in input list for LAI on wall, above ground floor level
+    INTEGER(iwp) ::  ind_lai_w_gfl         = 48   !< index in input list for LAI on wall, ground floor level
+    INTEGER(iwp) ::  ind_tc1_agfl          = 61   !< index in input list for thermal conductivity at first wall layer,
+                                                  !< above ground floor level
+    INTEGER(iwp) ::  ind_tc1_gfl           = 28   !< index in input list for thermal conductivity at first wall layer,
+                                                  !< ground floor level
+    INTEGER(iwp) ::  ind_tc1_wall_r        = 92   !< index in input list for thermal conductivity at first wall layer, roof
+    INTEGER(iwp) ::  ind_tc1_win_agfl      = 74   !< index in input list for thermal conductivity at first window layer,
+                                                  !< above ground floor level
+    INTEGER(iwp) ::  ind_tc1_win_gfl       = 41   !< index in input list for thermal conductivity at first window layer,
+                                                  !< ground floor level
+    INTEGER(iwp) ::  ind_tc1_win_r         = 105  !< index in input list for thermal conductivity at first window layer, roof
+    INTEGER(iwp) ::  ind_tc2_agfl          = 62   !< index in input list for thermal conductivity at second wall layer,
+                                                  !< above ground floor level
+    INTEGER(iwp) ::  ind_tc2_gfl           = 29   !< index in input list for thermal conductivity at second wall layer,
+                                                  !< ground floor level
+    INTEGER(iwp) ::  ind_tc2_wall_r        = 93   !< index in input list for thermal conductivity at second wall layer, roof
+    INTEGER(iwp) ::  ind_tc2_win_agfl      = 75   !< index in input list for thermal conductivity at second window layer,
+                                                  !< above ground floor level
+    INTEGER(iwp) ::  ind_tc2_win_gfl       = 42   !< index in input list for thermal conductivity at second window layer,
+                                                  !< ground floor level
+    INTEGER(iwp) ::  ind_tc2_win_r         = 106  !< index in input list for thermal conductivity at second window layer,
+                                                  !< ground floor level
+    INTEGER(iwp) ::  ind_tc3_agfl          = 63   !< index in input list for thermal conductivity at third wall layer,
+                                                  !< above ground floor level
+    INTEGER(iwp) ::  ind_tc3_gfl           = 30   !< index in input list for thermal conductivity at third wall layer,
+                                                  !< ground floor level
+    INTEGER(iwp) ::  ind_tc3_wall_r        = 94   !< index in input list for thermal conductivity at third wall layer, roof
+    INTEGER(iwp) ::  ind_tc3_win_agfl      = 76   !< index in input list for thermal conductivity at third window layer,
+                                                  !< above ground floor level
+    INTEGER(iwp) ::  ind_tc3_win_gfl       = 43   !< index in input list for thermal conductivity at third window layer,
+                                                  !< ground floor level
+    INTEGER(iwp) ::  ind_tc3_win_r         = 107  !< index in input list for thermal conductivity at third window layer, roof
+    INTEGER(iwp) ::  ind_thick_1_agfl      = 54   !< index for wall layer thickness - 1st layer above ground floor level
+    INTEGER(iwp) ::  ind_thick_1_gfl       = 21   !< index for wall layer thickness - 1st layer ground floor level
+    INTEGER(iwp) ::  ind_thick_1_wall_r    = 85   !< index for wall layer thickness - 1st layer roof
+    INTEGER(iwp) ::  ind_thick_1_win_agfl  = 67   !< index for window layer thickness - 1st layer above ground floor level
+    INTEGER(iwp) ::  ind_thick_1_win_gfl   = 34   !< index for window layer thickness - 1st layer ground floor level
+    INTEGER(iwp) ::  ind_thick_1_win_r     = 98   !< index for window layer thickness - 1st layer roof
+    INTEGER(iwp) ::  ind_thick_2_agfl      = 55   !< index for wall layer thickness - 2nd layer above ground floor level
+    INTEGER(iwp) ::  ind_thick_2_gfl       = 22   !< index for wall layer thickness - 2nd layer ground floor level
+    INTEGER(iwp) ::  ind_thick_2_wall_r    = 86   !< index for wall layer thickness - 2nd layer roof
+    INTEGER(iwp) ::  ind_thick_2_win_agfl  = 68   !< index for window layer thickness - 2nd layer above ground floor level
+    INTEGER(iwp) ::  ind_thick_2_win_gfl   = 35   !< index for window layer thickness - 2nd layer ground floor level
+    INTEGER(iwp) ::  ind_thick_2_win_r     = 99   !< index for window layer thickness - 2nd layer roof
+    INTEGER(iwp) ::  ind_thick_3_agfl      = 56   !< index for wall layer thickness - 3rd layer above ground floor level
+    INTEGER(iwp) ::  ind_thick_3_gfl       = 23   !< index for wall layer thickness - 3rd layer ground floor level
+    INTEGER(iwp) ::  ind_thick_3_wall_r    = 87   !< index for wall layer thickness - 3rd layer roof
+    INTEGER(iwp) ::  ind_thick_3_win_agfl  = 69   !< index for window layer thickness - 3rd layer above ground floor level
+    INTEGER(iwp) ::  ind_thick_3_win_gfl   = 36   !< index for window layer thickness - 3rd layer ground floor level  
+    INTEGER(iwp) ::  ind_thick_3_win_r     = 100  !< index for window layer thickness - 3rd layer roof
+    INTEGER(iwp) ::  ind_thick_4_agfl      = 57   !< index for wall layer thickness - 4th layer above ground floor level
+    INTEGER(iwp) ::  ind_thick_4_gfl       = 24   !< index for wall layer thickness - 4th layer ground floor level
+    INTEGER(iwp) ::  ind_thick_4_wall_r    = 88   !< index for wall layer thickness - 4st layer roof
+    INTEGER(iwp) ::  ind_thick_4_win_agfl  = 70   !< index for window layer thickness - 4th layer above ground floor level
+    INTEGER(iwp) ::  ind_thick_4_win_gfl   = 37   !< index for window layer thickness - 4th layer ground floor level
+    INTEGER(iwp) ::  ind_thick_4_win_r     = 101  !< index for window layer thickness - 4th layer roof
+    INTEGER(iwp) ::  ind_trans_agfl        = 78   !< index in input list for window transmissivity, above ground floor level
+    INTEGER(iwp) ::  ind_trans_gfl         = 45   !< index in input list for window transmissivity, ground floor level
+    INTEGER(iwp) ::  ind_trans_r           = 109  !< index in input list for window transmissivity, roof
+    INTEGER(iwp) ::  ind_wall_frac_agfl    = 53   !< index in input list for wall fraction, above ground floor level
+    INTEGER(iwp) ::  ind_wall_frac_gfl     = 20   !< index in input list for wall fraction, ground floor level
+    INTEGER(iwp) ::  ind_wall_frac_r       = 84   !< index in input list for wall fraction, roof
+    INTEGER(iwp) ::  ind_win_frac_agfl     = 66   !< index in input list for window fraction, above ground floor level
+    INTEGER(iwp) ::  ind_win_frac_gfl      = 33   !< index in input list for window fraction, ground floor level
+    INTEGER(iwp) ::  ind_win_frac_r        = 97   !< index in input list for window fraction, roof
+    INTEGER(iwp) ::  ind_z0_agfl           = 51   !< index in input list for z0, above ground floor level
+    INTEGER(iwp) ::  ind_z0_gfl            = 18   !< index in input list for z0, ground floor level
+    INTEGER(iwp) ::  ind_z0qh_agfl         = 52   !< index in input list for z0h / z0q, above ground floor level
+    INTEGER(iwp) ::  ind_z0qh_gfl          = 19   !< index in input list for z0h / z0q, ground floor level
+    INTEGER(iwp) ::  ind_green_type_roof   = 116  !< index in input list for type of green roof
+
+
+    REAL(wp)  ::  roof_height_limit = 4.0_wp         !< height for distinguish between land surfaces and roofs
     REAL(wp)  ::  ground_floor_level = 4.0_wp        !< default ground floor level
 
 
     CHARACTER(37), DIMENSION(0:7), PARAMETER :: building_type_name = (/     &
-                                   'user-defined                         ', & !  0 
-                                   'residential - 1950                   ', & !  1 
-                                   'residential 1951 - 2000              ', & !  2
-                                   'residential 2001 -                   ', & !  3
-                                   'office - 1950                        ', & !  4 
-                                   'office 1951 - 2000                   ', & !  5
-                                   'office 2001 -                        ', & !  6
-                                   'bridges                              '  & !  7
+                                   'user-defined                         ', &  !< type 0 
+                                   'residential - 1950                   ', &  !< type  1 
+                                   'residential 1951 - 2000              ', &  !< type  2
+                                   'residential 2001 -                   ', &  !< type  3
+                                   'office - 1950                        ', &  !< type  4 
+                                   'office 1951 - 2000                   ', &  !< type  5
+                                   'office 2001 -                        ', &  !< type  6
+                                   'bridges                              '  &  !< type  7
                                                                      /)
 !
@@ -744,5 +771,5 @@
         0.57_wp, 0.57_wp, 0.57_wp, 0.91_wp,                                    & !parameter 41-44
         0.75_wp, 27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp,                             & !parameter 45-49
-        5.0_wp, 0.001_wp, 0.0001_wp, 0.7_wp, 0.005_wp,                        & !parameter 50-54
+        5.0_wp, 0.001_wp, 0.0001_wp, 0.7_wp, 0.005_wp,                         & !parameter 50-54
         0.01_wp, 0.39_wp, 0.63_wp, 2200000.0_wp,                               & !parameter 55-58
         1400000.0_wp, 1300000.0_wp, 0.35_wp, 0.8_wp,                           & !parameter 59-62
@@ -757,5 +784,5 @@
         1736000.0_wp, 1736000.0_wp, 0.57_wp, 0.57_wp, 0.57_wp,                 & !parameter 103-107
         0.91_wp, 0.75_wp, 27.0_wp, 0.0_wp, 0.0_wp, 1.5_wp,                     & !parameter 108-113
-        0.86_wp, 5.0_wp, 0.0_wp,                                              & !parameter 114-116
+        0.86_wp, 5.0_wp, 0.0_wp,                                               & !parameter 114-116
         299.15_wp, 293.15_wp, 0.8_wp, 0.76_wp, 5.0_wp,                         & !parameter 117-121
         0.1_wp, 0.5_wp, 0.0_wp, 3.5_wp, 370000.0_wp, 4.5_wp,                   & !parameter 122-127
@@ -772,5 +799,5 @@
         0.11_wp, 0.11_wp, 0.11_wp, 0.11_wp,                                    & !parameter 41-44
         0.7_wp, 27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp,                              & !parameter 45-49
-        5.0_wp, 0.001_wp, 0.0001_wp, 0.73_wp, 0.005_wp,                       & !parameter 50-54
+        5.0_wp, 0.001_wp, 0.0001_wp, 0.73_wp, 0.005_wp,                        & !parameter 50-54
         0.01_wp, 0.31_wp, 0.43_wp, 2000000.0_wp,                               & !parameter 55-58
         103000.0_wp, 900000.0_wp, 0.35_wp, 0.38_wp,                            & !parameter 59-62
@@ -785,5 +812,5 @@
         1736000.0_wp, 1736000.0_wp, 0.11_wp, 0.11_wp, 0.11_wp,                 & !parameter 103-107
         0.87_wp, 0.7_wp, 27.0_wp, 0.0_wp, 0.0_wp, 1.5_wp,                      & !parameter 108-113
-        0.86_wp, 5.0_wp, 0.0_wp,                                              & !parameter 114-116
+        0.86_wp, 5.0_wp, 0.0_wp,                                               & !parameter 114-116
         299.15_wp, 293.15_wp, 0.8_wp, 0.6_wp, 3.0_wp,                          & !parameter 117-121
         0.1_wp, 0.5_wp, 0.0_wp, 2.5_wp, 165000.0_wp, 4.5_wp,                   & !parameter 122-127
@@ -798,7 +825,7 @@
         27.0_wp, 0.25_wp, 0.003_wp, 0.006_wp, 0.012_wp, 0.018_wp,              & !parameter 32-37
         1736000.0_wp, 1736000.0_wp, 1736000.0_wp,                              & !parameter 38-40
-        0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp,                                     & !parameter 41-44
+        0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp,                                  & !parameter 41-44
         0.6_wp, 27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp,                              & !parameter 45-49
-        5.0_wp, 0.001_wp, 0.0001_wp, 0.7_wp, 0.005_wp,                        & !parameter 50-54
+        5.0_wp, 0.001_wp, 0.0001_wp, 0.7_wp, 0.005_wp,                         & !parameter 50-54
         0.01_wp, 0.41_wp, 0.7_wp, 2000000.0_wp,                                & !parameter 55-58
         103000.0_wp, 900000.0_wp, 0.35_wp, 0.14_wp,                            & !parameter 59-62
@@ -806,12 +833,12 @@
         0.003_wp, 0.006_wp, 0.012_wp, 0.018_wp,                                & !parameter 67-70
         1736000.0_wp, 1736000.0_wp, 1736000.0_wp,                              & !parameter 71-73
-        0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp, 0.6_wp,                             & !parameter 74-78
+        0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp, 0.6_wp,                          & !parameter 74-78
         27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp, 5.0_wp, 1.0_wp,                      & !parameter 79-84
         0.005_wp, 0.01_wp, 0.41_wp, 0.7_wp, 2000000.0_wp, 103000.0_wp,         & !parameter 85-90
         900000.0_wp, 0.35_wp, 0.14_wp, 0.035_wp, 0.93_wp, 27.0_wp, 0.0_wp,     & !parameter 91-97
         0.003_wp, 0.006_wp, 0.012_wp, 0.018_wp, 1736000.0_wp,                  & !parameter 98-102 
-        1736000.0_wp, 1736000.0_wp, 0.037_wp, 0.037_wp, 0.037_wp,                 & !parameter 103-107
+        1736000.0_wp, 1736000.0_wp, 0.037_wp, 0.037_wp, 0.037_wp,              & !parameter 103-107
         0.8_wp, 0.6_wp, 27.0_wp, 0.0_wp, 0.0_wp, 1.5_wp,                       & !parameter 108-113
-        0.86_wp, 5.0_wp, 0.0_wp,                                              & !parameter 114-116
+        0.86_wp, 5.0_wp, 0.0_wp,                                               & !parameter 114-116
         299.15_wp, 293.15_wp, 0.8_wp, 0.5_wp, 0.6_wp,                          & !parameter 117-121
         0.1_wp, 0.5_wp, 0.8_wp, 2.5_wp, 80000.0_wp, 4.5_wp,                    & !parameter 122-127
@@ -828,5 +855,5 @@
         0.57_wp, 0.57_wp, 0.57_wp, 0.91_wp,                                    & !parameter 41-44
         0.75_wp, 27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp,                             & !parameter 45-49
-        5.0_wp, 0.001_wp, 0.0001_wp, 0.5_wp, 0.005_wp,                        & !parameter 50-54
+        5.0_wp, 0.001_wp, 0.0001_wp, 0.5_wp, 0.005_wp,                         & !parameter 50-54
         0.01_wp, 0.39_wp, 0.63_wp, 2200000.0_wp,                               & !parameter 55-58
         1400000.0_wp, 1300000.0_wp, 0.35_wp, 0.8_wp,                           & !parameter 59-62
@@ -841,5 +868,5 @@
         1736000.0_wp, 1736000.0_wp, 0.57_wp, 0.57_wp, 0.57_wp,                 & !parameter 103-107
         0.91_wp, 0.75_wp, 27.0_wp, 0.0_wp, 0.0_wp, 1.5_wp,                     & !parameter 108-113
-        0.86_wp, 5.0_wp, 0.0_wp,                                              & !parameter 114-116
+        0.86_wp, 5.0_wp, 0.0_wp,                                               & !parameter 114-116
         299.15_wp, 293.15_wp, 0.8_wp, 0.76_wp, 5.0_wp,                         & !parameter 117-121
         0.1_wp, 1.5_wp, 0.0_wp, 3.5_wp, 370000.0_wp, 4.5_wp,                   & !parameter 122-127
@@ -856,5 +883,5 @@
         0.11_wp, 0.11_wp, 0.11_wp, 0.87_wp,                                    & !parameter 41-44
         0.7_wp, 27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp,                              & !parameter 45-49
-        5.0_wp, 0.001_wp, 0.0001_wp, 0.5_wp, 0.005_wp,                        & !parameter 50-54
+        5.0_wp, 0.001_wp, 0.0001_wp, 0.5_wp, 0.005_wp,                         & !parameter 50-54
         0.01_wp, 0.31_wp, 0.43_wp, 2000000.0_wp,                               & !parameter 55-58
         103000.0_wp, 900000.0_wp, 0.35_wp, 0.38_wp,                            & !parameter 59-62
@@ -869,5 +896,5 @@
         1736000.0_wp, 1736000.0_wp, 0.11_wp, 0.11_wp, 0.11_wp,                 & !parameter 103-107
         0.87_wp, 0.7_wp, 27.0_wp, 0.0_wp, 0.0_wp, 1.5_wp,                      & !parameter 108-113
-        0.86_wp, 5.0_wp, 0.0_wp,                                              & !parameter 114-116
+        0.86_wp, 5.0_wp, 0.0_wp,                                               & !parameter 114-116
         299.15_wp, 293.15_wp, 0.8_wp, 0.6_wp, 3.0_wp,                          & !parameter 117-121
         0.1_wp, 1.5_wp, 0.65_wp, 2.5_wp, 165000.0_wp, 4.5_wp,                  & !parameter 122-127
@@ -882,7 +909,7 @@
         27.0_wp, 0.525_wp, 0.003_wp, 0.006_wp, 0.012_wp, 0.018_wp,             & !parameter 32-37
         1736000.0_wp, 1736000.0_wp, 1736000.0_wp,                              & !parameter 38-40
-        0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp,                                     & !parameter 41-44
+        0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp,                                  & !parameter 41-44
         0.6_wp, 27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp,                              & !parameter 45-49
-        5.0_wp, 0.001_wp, 0.0001_wp, 0.425_wp, 0.005_wp,                      & !parameter 50-54
+        5.0_wp, 0.001_wp, 0.0001_wp, 0.425_wp, 0.005_wp,                       & !parameter 50-54
         0.01_wp, 0.41_wp, 0.7_wp, 2000000.0_wp,                                & !parameter 55-58
         103000.0_wp, 900000.0_wp, 0.35_wp, 0.14_wp,                            & !parameter 59-62
@@ -890,12 +917,12 @@
         0.003_wp, 0.006_wp, 0.012_wp, 0.018_wp,                                & !parameter 67-70
         1736000.0_wp, 1736000.0_wp, 1736000.0_wp,                              & !parameter 71-73
-        0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp, 0.6_wp,                             & !parameter 74-78
+        0.037_wp, 0.037_wp, 0.037_wp, 0.8_wp, 0.6_wp,                          & !parameter 74-78
         27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp, 5.0_wp, 1.0_wp,                      & !parameter 79-84
         0.005_wp, 0.01_wp, 0.41_wp, 0.7_wp, 2000000.0_wp, 103000.0_wp,         & !parameter 85-90
         900000.0_wp, 0.35_wp, 0.14_wp, 0.035_wp, 0.91_wp, 27.0_wp, 0.0_wp,     & !parameter 91-97
         0.003_wp, 0.006_wp, 0.012_wp, 0.018_wp, 1736000.0_wp,                  & !parameter 98-102 
-        1736000.0_wp, 1736000.0_wp, 0.037_wp, 0.037_wp, 0.037_wp,                 & !parameter 103-107
+        1736000.0_wp, 1736000.0_wp, 0.037_wp, 0.037_wp, 0.037_wp,              & !parameter 103-107
         0.8_wp, 0.6_wp, 27.0_wp, 0.0_wp, 0.0_wp, 1.5_wp,                       & !parameter 108-113
-        0.86_wp, 5.0_wp, 0.0_wp,                                              & !parameter 114-116
+        0.86_wp, 5.0_wp, 0.0_wp,                                               & !parameter 114-116
         299.15_wp, 293.15_wp, 0.8_wp, 0.5_wp, 0.6_wp,                          & !parameter 117-121
         0.1_wp, 1.5_wp, 0.9_wp, 2.5_wp, 80000.0_wp, 4.5_wp,                    & !parameter 122-127
@@ -912,5 +939,5 @@
         0.57_wp, 0.57_wp, 0.57_wp, 0.8_wp,                                     & !parameter 41-44
         0.6_wp, 27.0_wp, 0.0_wp, 1.5_wp, 0.86_wp,                              & !parameter 45-49
-        5.0_wp, 0.001_wp, 0.0001_wp, 1.0_wp, 0.29_wp,                         & !parameter 50-54
+        5.0_wp, 0.001_wp, 0.0001_wp, 1.0_wp, 0.29_wp,                          & !parameter 50-54
         0.295_wp, 0.695_wp, 0.985_wp, 1950400.0_wp,                            & !parameter 55-58
         1848000.0_wp, 1848000.0_wp, 0.7_wp, 1.0_wp,                            & !parameter 59-62
@@ -925,5 +952,5 @@
         1736000.0_wp, 1736000.0_wp, 0.57_wp, 0.57_wp, 0.57_wp,                 & !parameter 103-107
         0.8_wp, 0.6_wp, 27.0_wp, 0.0_wp, 0.0_wp, 1.5_wp,                       & !parameter 108-113
-        0.86_wp, 5.0_wp, 0.0_wp,                                              & !parameter 114-116
+        0.86_wp, 5.0_wp, 0.0_wp,                                               & !parameter 114-116
         299.15_wp, 293.15_wp, 0.8_wp, 100.0_wp, 100.0_wp,                      & !parameter 117-121
         20.0_wp, 20.0_wp, 0.0_wp, 1.0_wp, 1.0_wp, 4.5_wp,                      & !parameter 122-127
@@ -944,36 +971,35 @@
 
     TYPE surf_type_usm
-       REAL(wp), DIMENSION(:),   ALLOCATABLE ::  var_usm_1d !< 1D prognostic variable
-       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  var_usm_2d !< 2D prognostic variable
+       REAL(wp), DIMENSION(:),   ALLOCATABLE ::  var_usm_1d  !< 1D prognostic variable
+       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  var_usm_2d  !< 2D prognostic variable
     END TYPE surf_type_usm
     
-    TYPE(surf_type_usm), POINTER  ::  m_liq_usm_h,        & !< liquid water reservoir (m), horizontal surface elements 
-                                      m_liq_usm_h_p         !< progn. liquid water reservoir (m), horizontal surface elements 
-
-    TYPE(surf_type_usm), TARGET   ::  m_liq_usm_h_1,      & !<
-                                      m_liq_usm_h_2         !<
-
-    TYPE(surf_type_usm), DIMENSION(:), POINTER  ::    &
-                                      m_liq_usm_v,        & !< liquid water reservoir (m), vertical surface elements 
-                                      m_liq_usm_v_p         !< progn. liquid water reservoir (m), vertical surface elements 
-
-    TYPE(surf_type_usm), DIMENSION(0:3), TARGET   ::  &
-                                      m_liq_usm_v_1,      & !<
-                                      m_liq_usm_v_2         !<
+    TYPE(surf_type_usm), POINTER  ::  m_liq_usm_h,        &  !< liquid water reservoir (m), horizontal surface elements 
+                                      m_liq_usm_h_p          !< progn. liquid water reservoir (m), horizontal surface elements 
+
+    TYPE(surf_type_usm), TARGET   ::  m_liq_usm_h_1,      &  !<
+                                      m_liq_usm_h_2          !<
+
+    TYPE(surf_type_usm), DIMENSION(:), POINTER  ::        &
+                                      m_liq_usm_v,        &  !< liquid water reservoir (m), vertical surface elements 
+                                      m_liq_usm_v_p          !< progn. liquid water reservoir (m), vertical surface elements 
+
+    TYPE(surf_type_usm), DIMENSION(0:3), TARGET   ::      &
+                                      m_liq_usm_v_1,      &  !<
+                                      m_liq_usm_v_2          !<
 
     TYPE(surf_type_usm), TARGET ::  tm_liq_usm_h_m      !< liquid water reservoir tendency (m), horizontal surface elements 
-    TYPE(surf_type_usm), DIMENSION(0:3), TARGET ::  tm_liq_usm_v_m      !< liquid water reservoir tendency (m), vertical surface elements 
-
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    TYPE(surf_type_usm), DIMENSION(0:3), TARGET ::  tm_liq_usm_v_m      !< liquid water reservoir tendency (m),
+                                                                        !< vertical surface elements
+
+!
 !-- anthropogenic heat sources
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     REAL(wp), DIMENSION(:,:,:), ALLOCATABLE        ::  aheat             !< daily average of anthropogenic heat (W/m2)
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE          ::  aheatprof         !< diurnal profiles of anthropogenic heat for particular layers
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE          ::  aheatprof         !< diurnal profiles of anthropogenic heat
+                                                                         !< for particular layers
     INTEGER(iwp)                                   ::  naheatlayers = 1  !< number of layers of anthropogenic heat
 
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
 !-- wall surface model
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 !-- wall surface model constants
     INTEGER(iwp), PARAMETER                        :: nzb_wall = 0       !< inner side of the wall model (to be switched)
@@ -981,28 +1007,24 @@
     INTEGER(iwp), PARAMETER                        :: nzw = 4            !< number of wall layers (fixed for now)
 
-    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default = (/0.0242_wp, 0.0969_wp, 0.346_wp, 1.0_wp /)
-                                                                         !< normalized soil, wall and roof layer depths (m/m)
-!    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default = (/0.33_wp, 0.66_wp, 1.0_wp /)
-    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_window = (/0.25_wp, 0.5_wp, 0.75_wp, 1.0_wp /)
-!    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_window = (/0.33_wp, 0.66_wp, 1.0_wp /)
-!    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_window = (/0.0242_wp, 0.0969_wp, 0.346_wp, 1.0_wp /)
-                                                                         !< normalized window layer depths (m/m)
-!    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_green = (/0.0242_wp, 0.0969_wp, 0.346_wp, 1.0_wp /)
-                                                                         !< normalized green layer depths (m/m)
-    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_green = (/0.25_wp, 0.5_wp, 0.75_wp, 1.0_wp /)
-!    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_green = (/0.33_wp, 0.66_wp, 1.0_wp /)
-
-
-    REAL(wp)                                       :: wall_inner_temperature = 295.0_wp    !< temperature of the inner wall surface (~22 degrees C) (K)
-    REAL(wp)                                       :: roof_inner_temperature = 295.0_wp    !< temperature of the inner roof surface (~22 degrees C) (K)
-    REAL(wp)                                       :: soil_inner_temperature = 288.0_wp    !< temperature of the deep soil (~15 degrees C) (K)
-    REAL(wp)                                       :: window_inner_temperature = 295.0_wp  !< temperature of the inner window surface (~22 degrees C) (K)
-
-    REAL(wp)                                       ::   m_total = 0.0_wp !< weighted total water content of the soil (m3/m3)
-    INTEGER(iwp)                                   ::   soil_type
-    
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default        = (/0.0242_wp, 0.0969_wp, 0.346_wp, 1.0_wp /)
+    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_window = (/0.25_wp,   0.5_wp,    0.75_wp,  1.0_wp /)
+    REAL(wp), DIMENSION(nzb_wall:nzt_wall)         :: zwn_default_green  = (/0.25_wp,   0.5_wp,    0.75_wp,  1.0_wp /)
+                                                                         !< normalized soil, wall and roof, window and
+                                                                         !<green layer depths (m/m)
+
+    REAL(wp)                                       :: wall_inner_temperature   = 295.0_wp    !< temperature of the inner wall
+                                                                                             !< surface (~22 degrees C) (K)
+    REAL(wp)                                       :: roof_inner_temperature   = 295.0_wp    !< temperature of the inner roof
+                                                                                             !< surface (~22 degrees C) (K)
+    REAL(wp)                                       :: soil_inner_temperature   = 288.0_wp    !< temperature of the deep soil
+                                                                                             !< (~15 degrees C) (K)
+    REAL(wp)                                       :: window_inner_temperature = 295.0_wp    !< temperature of the inner window
+                                                                                             !< surface (~22 degrees C) (K)
+
+    REAL(wp)                                       :: m_total = 0.0_wp  !< weighted total water content of the soil (m3/m3)
+    INTEGER(iwp)                                   :: soil_type
+
+!
 !-- surface and material model variables for walls, ground, roofs
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     REAL(wp), DIMENSION(:), ALLOCATABLE            :: zwn                !< normalized wall layer depths (m)
     REAL(wp), DIMENSION(:), ALLOCATABLE            :: zwn_window         !< normalized window layer depths (m)
@@ -1023,10 +1045,10 @@
     REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET    :: t_surf_green_h_2
 
-    TYPE(t_surf_vertical), DIMENSION(:), POINTER ::  t_surf_wall_v
-    TYPE(t_surf_vertical), DIMENSION(:), POINTER ::  t_surf_wall_v_p
-    TYPE(t_surf_vertical), DIMENSION(:), POINTER ::  t_surf_window_v
-    TYPE(t_surf_vertical), DIMENSION(:), POINTER ::  t_surf_window_v_p
-    TYPE(t_surf_vertical), DIMENSION(:), POINTER ::  t_surf_green_v
-    TYPE(t_surf_vertical), DIMENSION(:), POINTER ::  t_surf_green_v_p
+    TYPE(t_surf_vertical), DIMENSION(:), POINTER   ::  t_surf_wall_v
+    TYPE(t_surf_vertical), DIMENSION(:), POINTER   ::  t_surf_wall_v_p
+    TYPE(t_surf_vertical), DIMENSION(:), POINTER   ::  t_surf_window_v
+    TYPE(t_surf_vertical), DIMENSION(:), POINTER   ::  t_surf_window_v_p
+    TYPE(t_surf_vertical), DIMENSION(:), POINTER   ::  t_surf_green_v
+    TYPE(t_surf_vertical), DIMENSION(:), POINTER   ::  t_surf_green_v_p
 
     TYPE(t_surf_vertical), DIMENSION(0:3), TARGET  :: t_surf_wall_v_1
@@ -1037,7 +1059,6 @@
     TYPE(t_surf_vertical), DIMENSION(0:3), TARGET  :: t_surf_green_v_2
 
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
 !-- Energy balance variables
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 !-- parameters of the land, roof and wall surfaces
 
@@ -1062,23 +1083,32 @@
     TYPE(t_wall_vertical), DIMENSION(0:3), TARGET  :: swc_v_1, swc_v_2
 
+!
 !-- Surface and material parameters classes (surface_type)
 !-- albedo, emissivity, lambda_surf, roughness, thickness, volumetric heat capacity, thermal conductivity
-    INTEGER(iwp)                                   :: n_surface_types      !< number of the wall type categories
-    INTEGER(iwp), PARAMETER                        :: n_surface_params = 9 !< number of parameters for each type of the wall
-    INTEGER(iwp), PARAMETER                        :: ialbedo  = 1         !< albedo of the surface
-    INTEGER(iwp), PARAMETER                        :: iemiss   = 2         !< emissivity of the surface
-    INTEGER(iwp), PARAMETER                        :: ilambdas = 3         !< heat conductivity lambda S between surface and material ( W m-2 K-1 )
-    INTEGER(iwp), PARAMETER                        :: irough   = 4         !< roughness length z0 for movements
-    INTEGER(iwp), PARAMETER                        :: iroughh  = 5         !< roughness length z0h for scalars (heat, humidity,...)
-    INTEGER(iwp), PARAMETER                        :: icsurf   = 6         !< Surface skin layer heat capacity (J m-2 K-1 )
-    INTEGER(iwp), PARAMETER                        :: ithick   = 7         !< thickness of the surface (wall, roof, land)  ( m )
-    INTEGER(iwp), PARAMETER                        :: irhoC    = 8         !< volumetric heat capacity rho*C of the material ( J m-3 K-1 )
-    INTEGER(iwp), PARAMETER                        :: ilambdah = 9         !< thermal conductivity lambda H of the wall (W m-1 K-1 )
-    CHARACTER(12), DIMENSION(:), ALLOCATABLE       :: surface_type_names   !< names of wall types (used only for reports)
-    INTEGER(iwp), DIMENSION(:), ALLOCATABLE        :: surface_type_codes   !< codes of wall types
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE          :: surface_params       !< parameters of wall types
-
-    
+    INTEGER(iwp)                                   :: n_surface_types       !< number of the wall type categories
+    INTEGER(iwp), PARAMETER                        :: n_surface_params = 9  !< number of parameters for each type of the wall
+    INTEGER(iwp), PARAMETER                        :: ialbedo  = 1          !< albedo of the surface
+    INTEGER(iwp), PARAMETER                        :: iemiss   = 2          !< emissivity of the surface
+    INTEGER(iwp), PARAMETER                        :: ilambdas = 3          !< heat conductivity lambda S between surface
+                                                                            !< and material ( W m-2 K-1 )
+    INTEGER(iwp), PARAMETER                        :: irough   = 4          !< roughness length z0 for movements
+    INTEGER(iwp), PARAMETER                        :: iroughh  = 5          !< roughness length z0h for scalars
+                                                                            !< (heat, humidity,...)
+    INTEGER(iwp), PARAMETER                        :: icsurf   = 6          !< Surface skin layer heat capacity (J m-2 K-1 )
+    INTEGER(iwp), PARAMETER                        :: ithick   = 7          !< thickness of the surface (wall, roof, land)  ( m )
+    INTEGER(iwp), PARAMETER                        :: irhoC    = 8          !< volumetric heat capacity rho*C of
+                                                                            !< the material ( J m-3 K-1 )
+    INTEGER(iwp), PARAMETER                        :: ilambdah = 9          !< thermal conductivity lambda H
+                                                                            !< of the wall (W m-1 K-1 )
+    CHARACTER(12), DIMENSION(:), ALLOCATABLE       :: surface_type_names    !< names of wall types (used only for reports)
+    INTEGER(iwp), DIMENSION(:), ALLOCATABLE        :: surface_type_codes    !< codes of wall types
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE          :: surface_params        !< parameters of wall types
+
+!
 !-- interfaces of subroutines accessed from outside of this module
+    INTERFACE usm_3d_data_averaging
+       MODULE PROCEDURE usm_3d_data_averaging
+    END INTERFACE usm_3d_data_averaging
+
     INTERFACE usm_boundary_condition
        MODULE PROCEDURE usm_boundary_condition
@@ -1105,4 +1135,8 @@
     END INTERFACE usm_init
 
+    INTERFACE usm_init_arrays
+       MODULE PROCEDURE usm_init_arrays
+    END INTERFACE usm_init_arrays
+
     INTERFACE usm_material_heat_model
        MODULE PROCEDURE usm_material_heat_model
@@ -1133,29 +1167,23 @@
     END INTERFACE usm_wrd_local
 
-    INTERFACE usm_init_arrays
-       MODULE PROCEDURE usm_init_arrays
-    END INTERFACE usm_init_arrays
-
-    INTERFACE usm_3d_data_averaging
-       MODULE PROCEDURE usm_3d_data_averaging
-    END INTERFACE usm_3d_data_averaging
-
     
     SAVE
 
     PRIVATE 
-    
+
+!
 !-- Public functions
-    PUBLIC usm_boundary_condition, usm_check_parameters, usm_init,&
-           usm_rrd_local,                                                      & 
-           usm_surface_energy_balance, usm_material_heat_model,                &
-           usm_swap_timelevel, usm_check_data_output, usm_3d_data_averaging,   &
-           usm_data_output_3d, usm_define_netcdf_grid, usm_parin,              &
+    PUBLIC usm_boundary_condition, usm_check_parameters, usm_init,               &
+           usm_rrd_local,                                                        & 
+           usm_surface_energy_balance, usm_material_heat_model,                  &
+           usm_swap_timelevel, usm_check_data_output, usm_3d_data_averaging,     &
+           usm_data_output_3d, usm_define_netcdf_grid, usm_parin,                &
            usm_wrd_local, usm_init_arrays
 
+!
 !-- Public parameters, constants and initial values
-    PUBLIC usm_anthropogenic_heat, usm_material_model, usm_wall_mod,           &
-           usm_green_heat_model, building_pars,                                &
-           nzb_wall, nzt_wall, t_wall_h, t_wall_v,                             &
+    PUBLIC usm_anthropogenic_heat, usm_material_model, usm_wall_mod, &
+           usm_green_heat_model, building_pars,                      &
+           nzb_wall, nzt_wall, t_wall_h, t_wall_v,                   &
            t_window_h, t_window_v, building_type
 
@@ -1181,16 +1209,16 @@
 !--     Allocate radiation arrays which are part of the new data type. 
 !--     For horizontal surfaces.
-        ALLOCATE( surf_usm_h%surfhf(1:surf_usm_h%ns)    )
-        ALLOCATE( surf_usm_h%rad_net_l(1:surf_usm_h%ns) )
+        ALLOCATE ( surf_usm_h%surfhf(1:surf_usm_h%ns)    )
+        ALLOCATE ( surf_usm_h%rad_net_l(1:surf_usm_h%ns) )
 !
 !--     For vertical surfaces
         DO  l = 0, 3
-           ALLOCATE( surf_usm_v(l)%surfhf(1:surf_usm_v(l)%ns)    )
-           ALLOCATE( surf_usm_v(l)%rad_net_l(1:surf_usm_v(l)%ns) )
+           ALLOCATE ( surf_usm_v(l)%surfhf(1:surf_usm_v(l)%ns)    )
+           ALLOCATE ( surf_usm_v(l)%rad_net_l(1:surf_usm_v(l)%ns) )
         ENDDO
 
+!
 !--     Wall surface model
 !--     allocate arrays for wall surface model and define pointers
-       
 !--     allocate array of wall types and wall parameters
         ALLOCATE ( surf_usm_h%surface_types(1:surf_usm_h%ns)      )
@@ -1200,5 +1228,5 @@
         surf_usm_h%building_type_name = 'none'
         DO  l = 0, 3
-           ALLOCATE( surf_usm_v(l)%surface_types(1:surf_usm_v(l)%ns) )
+           ALLOCATE ( surf_usm_v(l)%surface_types(1:surf_usm_v(l)%ns)      )
            ALLOCATE ( surf_usm_v(l)%building_type(1:surf_usm_v(l)%ns)      )
            ALLOCATE ( surf_usm_v(l)%building_type_name(1:surf_usm_v(l)%ns) )
@@ -1209,21 +1237,20 @@
 !--     Allocate albedo_type and albedo. Each surface element
 !--     has 3 values, 0: wall fraction, 1: green fraction, 2: window fraction.
-        ALLOCATE( surf_usm_h%albedo_type(0:2,1:surf_usm_h%ns) )
-        ALLOCATE( surf_usm_h%albedo(0:2,1:surf_usm_h%ns)      )
+        ALLOCATE ( surf_usm_h%albedo_type(0:2,1:surf_usm_h%ns) )
+        ALLOCATE ( surf_usm_h%albedo(0:2,1:surf_usm_h%ns)      )
         surf_usm_h%albedo_type = albedo_type
         DO  l = 0, 3
-           ALLOCATE( surf_usm_v(l)%albedo_type(0:2,1:surf_usm_v(l)%ns) )
-           ALLOCATE( surf_usm_v(l)%albedo(0:2,1:surf_usm_v(l)%ns)      )
+           ALLOCATE ( surf_usm_v(l)%albedo_type(0:2,1:surf_usm_v(l)%ns) )
+           ALLOCATE ( surf_usm_v(l)%albedo(0:2,1:surf_usm_v(l)%ns)      )
            surf_usm_v(l)%albedo_type = albedo_type
         ENDDO       
 
-
 !
 !--     Allocate indoor target temperature for summer and winter
-        ALLOCATE( surf_usm_h%target_temp_summer(1:surf_usm_h%ns) )
-        ALLOCATE( surf_usm_h%target_temp_winter(1:surf_usm_h%ns) )
+        ALLOCATE ( surf_usm_h%target_temp_summer(1:surf_usm_h%ns) )
+        ALLOCATE ( surf_usm_h%target_temp_winter(1:surf_usm_h%ns) )
         DO  l = 0, 3
-           ALLOCATE( surf_usm_v(l)%target_temp_summer(1:surf_usm_v(l)%ns) )
-           ALLOCATE( surf_usm_v(l)%target_temp_winter(1:surf_usm_v(l)%ns) )
+           ALLOCATE ( surf_usm_v(l)%target_temp_summer(1:surf_usm_v(l)%ns) )
+           ALLOCATE ( surf_usm_v(l)%target_temp_winter(1:surf_usm_v(l)%ns) )
         ENDDO   
 !
@@ -1231,16 +1258,17 @@
         ALLOCATE ( surf_usm_h%ground_level(1:surf_usm_h%ns) ) 
         DO  l = 0, 3
-           ALLOCATE( surf_usm_v(l)%ground_level(1:surf_usm_v(l)%ns) )
+           ALLOCATE ( surf_usm_v(l)%ground_level(1:surf_usm_v(l)%ns) )
         ENDDO   
 !
 !--      Allocate arrays for relative surface fraction. 
 !--      0 - wall fraction, 1 - green fraction, 2 - window fraction
-         ALLOCATE( surf_usm_h%frac(0:2,1:surf_usm_h%ns) )
+         ALLOCATE ( surf_usm_h%frac(0:2,1:surf_usm_h%ns) )
          surf_usm_h%frac = 0.0_wp
          DO  l = 0, 3
-            ALLOCATE( surf_usm_v(l)%frac(0:2,1:surf_usm_v(l)%ns) )
+            ALLOCATE ( surf_usm_v(l)%frac(0:2,1:surf_usm_v(l)%ns) )
             surf_usm_v(l)%frac = 0.0_wp
          ENDDO
-       
+
+!
 !--     wall and roof surface parameters. First for horizontal surfaces
         ALLOCATE ( surf_usm_h%isroof_surf(1:surf_usm_h%ns)        )
@@ -1263,16 +1291,16 @@
 !--     For vertical surfaces.
         DO  l = 0, 3
-           ALLOCATE ( surf_usm_v(l)%lambda_surf(1:surf_usm_v(l)%ns)     )
-           ALLOCATE ( surf_usm_v(l)%c_surface(1:surf_usm_v(l)%ns)       )
+           ALLOCATE ( surf_usm_v(l)%lambda_surf(1:surf_usm_v(l)%ns)        )
+           ALLOCATE ( surf_usm_v(l)%c_surface(1:surf_usm_v(l)%ns)          )
            ALLOCATE ( surf_usm_v(l)%lambda_surf_window(1:surf_usm_v(l)%ns) )
            ALLOCATE ( surf_usm_v(l)%c_surface_window(1:surf_usm_v(l)%ns)   )
            ALLOCATE ( surf_usm_v(l)%lambda_surf_green(1:surf_usm_v(l)%ns)  )
            ALLOCATE ( surf_usm_v(l)%c_surface_green(1:surf_usm_v(l)%ns)    )
-           ALLOCATE ( surf_usm_v(l)%transmissivity(1:surf_usm_v(l)%ns)  )
-           ALLOCATE ( surf_usm_v(l)%lai(1:surf_usm_v(l)%ns)             )
-           ALLOCATE ( surf_usm_v(l)%emissivity(0:2,1:surf_usm_v(l)%ns)  )
-           ALLOCATE ( surf_usm_v(l)%r_a(1:surf_usm_v(l)%ns)             )
-           ALLOCATE ( surf_usm_v(l)%r_a_green(1:surf_usm_v(l)%ns)       )
-           ALLOCATE ( surf_usm_v(l)%r_a_window(1:surf_usm_v(l)%ns)      )           
+           ALLOCATE ( surf_usm_v(l)%transmissivity(1:surf_usm_v(l)%ns)     )
+           ALLOCATE ( surf_usm_v(l)%lai(1:surf_usm_v(l)%ns)                )
+           ALLOCATE ( surf_usm_v(l)%emissivity(0:2,1:surf_usm_v(l)%ns)     )
+           ALLOCATE ( surf_usm_v(l)%r_a(1:surf_usm_v(l)%ns)                )
+           ALLOCATE ( surf_usm_v(l)%r_a_green(1:surf_usm_v(l)%ns)          )
+           ALLOCATE ( surf_usm_v(l)%r_a_window(1:surf_usm_v(l)%ns)         )           
            ALLOCATE ( surf_usm_v(l)%r_s(1:surf_usm_v(l)%ns)                )
         ENDDO
@@ -1280,9 +1308,9 @@
 !       
 !--     allocate wall and roof material parameters. First for horizontal surfaces
-        ALLOCATE ( surf_usm_h%thickness_wall(1:surf_usm_h%ns)               )
+        ALLOCATE ( surf_usm_h%thickness_wall(1:surf_usm_h%ns)                    )
         ALLOCATE ( surf_usm_h%thickness_window(1:surf_usm_h%ns)                  )
         ALLOCATE ( surf_usm_h%thickness_green(1:surf_usm_h%ns)                   )
-        ALLOCATE ( surf_usm_h%lambda_h(nzb_wall:nzt_wall,1:surf_usm_h%ns)   )
-        ALLOCATE ( surf_usm_h%rho_c_wall(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
+        ALLOCATE ( surf_usm_h%lambda_h(nzb_wall:nzt_wall,1:surf_usm_h%ns)        )
+        ALLOCATE ( surf_usm_h%rho_c_wall(nzb_wall:nzt_wall,1:surf_usm_h%ns)      )
         ALLOCATE ( surf_usm_h%lambda_h_window(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
         ALLOCATE ( surf_usm_h%rho_c_window(nzb_wall:nzt_wall,1:surf_usm_h%ns)    )
@@ -1290,21 +1318,21 @@
         ALLOCATE ( surf_usm_h%rho_c_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)     )
 
-        ALLOCATE ( surf_usm_h%rho_c_total_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)     )
-        ALLOCATE ( surf_usm_h%n_vg_green(1:surf_usm_h%ns)     )
-        ALLOCATE ( surf_usm_h%alpha_vg_green(1:surf_usm_h%ns)     )
-        ALLOCATE ( surf_usm_h%l_vg_green(1:surf_usm_h%ns)     )
-        ALLOCATE ( surf_usm_h%gamma_w_green_sat(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)     )
-        ALLOCATE ( surf_usm_h%lambda_w_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)     )
-        ALLOCATE ( surf_usm_h%gamma_w_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)     )
-        ALLOCATE ( surf_usm_h%tswc_h_m(nzb_wall:nzt_wall,1:surf_usm_h%ns)     )
+        ALLOCATE ( surf_usm_h%rho_c_total_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)    )
+        ALLOCATE ( surf_usm_h%n_vg_green(1:surf_usm_h%ns)                             )
+        ALLOCATE ( surf_usm_h%alpha_vg_green(1:surf_usm_h%ns)                         )
+        ALLOCATE ( surf_usm_h%l_vg_green(1:surf_usm_h%ns)                             )
+        ALLOCATE ( surf_usm_h%gamma_w_green_sat(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)  )
+        ALLOCATE ( surf_usm_h%lambda_w_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)       )
+        ALLOCATE ( surf_usm_h%gamma_w_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)        )
+        ALLOCATE ( surf_usm_h%tswc_h_m(nzb_wall:nzt_wall,1:surf_usm_h%ns)             )
 
 !
 !--     For vertical surfaces.
         DO  l = 0, 3
-           ALLOCATE ( surf_usm_v(l)%thickness_wall(1:surf_usm_v(l)%ns)               )
+           ALLOCATE ( surf_usm_v(l)%thickness_wall(1:surf_usm_v(l)%ns)                    )
            ALLOCATE ( surf_usm_v(l)%thickness_window(1:surf_usm_v(l)%ns)                  )
            ALLOCATE ( surf_usm_v(l)%thickness_green(1:surf_usm_v(l)%ns)                   )
-           ALLOCATE ( surf_usm_v(l)%lambda_h(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)   )
-           ALLOCATE ( surf_usm_v(l)%rho_c_wall(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
+           ALLOCATE ( surf_usm_v(l)%lambda_h(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)        )
+           ALLOCATE ( surf_usm_v(l)%rho_c_wall(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)      )
            ALLOCATE ( surf_usm_v(l)%lambda_h_window(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
            ALLOCATE ( surf_usm_v(l)%rho_c_window(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)    )
@@ -1335,18 +1363,19 @@
           ALLOCATE ( surf_usm_v(l)%r_canopy(1:surf_usm_v(l)%ns)         )
           ALLOCATE ( surf_usm_v(l)%r_canopy_min(1:surf_usm_v(l)%ns)     )
-          ALLOCATE ( surf_usm_v(l)%pt_10cm(1:surf_usm_v(l)%ns)     )
+          ALLOCATE ( surf_usm_v(l)%pt_10cm(1:surf_usm_v(l)%ns)          )
         ENDDO
-        
+
+!
 !--     allocate wall and roof layers sizes. For horizontal surfaces.
-        ALLOCATE ( zwn(nzb_wall:nzt_wall) )
-        ALLOCATE ( surf_usm_h%dz_wall(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)     )
-        ALLOCATE ( zwn_window(nzb_wall:nzt_wall) )
+        ALLOCATE ( zwn(nzb_wall:nzt_wall)                                        )
+        ALLOCATE ( surf_usm_h%dz_wall(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)       )
+        ALLOCATE ( zwn_window(nzb_wall:nzt_wall)                                 )
         ALLOCATE ( surf_usm_h%dz_window(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)     )
-        ALLOCATE ( zwn_green(nzb_wall:nzt_wall) )
+        ALLOCATE ( zwn_green(nzb_wall:nzt_wall)                                  )
         ALLOCATE ( surf_usm_h%dz_green(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)      )
-        ALLOCATE ( surf_usm_h%ddz_wall(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)    )
-        ALLOCATE ( surf_usm_h%dz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_h%ns)  )
-        ALLOCATE ( surf_usm_h%ddz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
-        ALLOCATE ( surf_usm_h%zw(nzb_wall:nzt_wall,1:surf_usm_h%ns)            )
+        ALLOCATE ( surf_usm_h%ddz_wall(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)      )
+        ALLOCATE ( surf_usm_h%dz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_h%ns)    )
+        ALLOCATE ( surf_usm_h%ddz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_h%ns)   )
+        ALLOCATE ( surf_usm_h%zw(nzb_wall:nzt_wall,1:surf_usm_h%ns)              )
         ALLOCATE ( surf_usm_h%ddz_window(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)    )
         ALLOCATE ( surf_usm_h%dz_window_stag(nzb_wall:nzt_wall,1:surf_usm_h%ns)  )
@@ -1357,14 +1386,15 @@
         ALLOCATE ( surf_usm_h%ddz_green_stag(nzb_wall:nzt_wall,1:surf_usm_h%ns)  )
         ALLOCATE ( surf_usm_h%zw_green(nzb_wall:nzt_wall,1:surf_usm_h%ns)        )
+
 !
 !--     For vertical surfaces.
         DO  l = 0, 3
-           ALLOCATE ( surf_usm_v(l)%dz_wall(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)     )
+           ALLOCATE ( surf_usm_v(l)%dz_wall(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)       )
            ALLOCATE ( surf_usm_v(l)%dz_window(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)     )
            ALLOCATE ( surf_usm_v(l)%dz_green(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)      )
-           ALLOCATE ( surf_usm_v(l)%ddz_wall(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)    )
-           ALLOCATE ( surf_usm_v(l)%dz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)  )
-           ALLOCATE ( surf_usm_v(l)%ddz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
-           ALLOCATE ( surf_usm_v(l)%zw(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)            )
+           ALLOCATE ( surf_usm_v(l)%ddz_wall(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)      )
+           ALLOCATE ( surf_usm_v(l)%dz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)    )
+           ALLOCATE ( surf_usm_v(l)%ddz_wall_stag(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)   )
+           ALLOCATE ( surf_usm_v(l)%zw(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)              )
            ALLOCATE ( surf_usm_v(l)%ddz_window(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)    )
            ALLOCATE ( surf_usm_v(l)%dz_window_stag(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns)  )
@@ -1377,11 +1407,12 @@
         ENDDO
 
+!
 !--     allocate wall and roof temperature arrays, for horizontal walls
 !
 !--     Allocate if required. Note, in case of restarts, some of these arrays 
 !--     might be already allocated.
-        IF ( .NOT. ALLOCATED( t_surf_wall_h_1 ) )                                   &
+        IF ( .NOT. ALLOCATED( t_surf_wall_h_1 ) )                              &
            ALLOCATE ( t_surf_wall_h_1(1:surf_usm_h%ns) )
-        IF ( .NOT. ALLOCATED( t_surf_wall_h_2 ) )                                   &
+        IF ( .NOT. ALLOCATED( t_surf_wall_h_2 ) )                              &
            ALLOCATE ( t_surf_wall_h_2(1:surf_usm_h%ns) )
         IF ( .NOT. ALLOCATED( t_wall_h_1 ) )                                   &           
@@ -1405,5 +1436,5 @@
         IF ( .NOT. ALLOCATED( t_green_h_2 ) )                                  &           
            ALLOCATE ( t_green_h_2(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )          
-        IF ( .NOT. ALLOCATED( swc_h_1 ) )                                  &           
+        IF ( .NOT. ALLOCATED( swc_h_1 ) )                                      &           
            ALLOCATE ( swc_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) ) 
         IF ( .NOT. ALLOCATED( swc_sat_h_1 ) )                                  &           
@@ -1411,34 +1442,35 @@
         IF ( .NOT. ALLOCATED( swc_res_h_1 ) )                                  &           
            ALLOCATE ( swc_res_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) ) 
-        IF ( .NOT. ALLOCATED( swc_h_2 ) )                                  &           
+        IF ( .NOT. ALLOCATED( swc_h_2 ) )                                      &           
            ALLOCATE ( swc_h_2(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
-        IF ( .NOT. ALLOCATED( rootfr_h_1 ) )                                  &           
+        IF ( .NOT. ALLOCATED( rootfr_h_1 ) )                                   &           
            ALLOCATE ( rootfr_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) ) 
-        IF ( .NOT. ALLOCATED( wilt_h_1 ) )                                  &           
+        IF ( .NOT. ALLOCATED( wilt_h_1 ) )                                     &           
            ALLOCATE ( wilt_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) ) 
-        IF ( .NOT. ALLOCATED( fc_h_1 ) )                                  &           
+        IF ( .NOT. ALLOCATED( fc_h_1 ) )                                       &           
            ALLOCATE ( fc_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) ) 
 
-        IF ( .NOT. ALLOCATED( m_liq_usm_h_1%var_usm_1d ) )                         &
+        IF ( .NOT. ALLOCATED( m_liq_usm_h_1%var_usm_1d ) )                     &
            ALLOCATE ( m_liq_usm_h_1%var_usm_1d(1:surf_usm_h%ns) )
-        IF ( .NOT. ALLOCATED( m_liq_usm_h_2%var_usm_1d ) )                         &
+        IF ( .NOT. ALLOCATED( m_liq_usm_h_2%var_usm_1d ) )                     &
            ALLOCATE ( m_liq_usm_h_2%var_usm_1d(1:surf_usm_h%ns) )
            
 !           
 !--     initial assignment of the pointers
-        t_wall_h    => t_wall_h_1;    t_wall_h_p    => t_wall_h_2
-        t_window_h    => t_window_h_1;    t_window_h_p    => t_window_h_2
-        t_green_h    => t_green_h_1;    t_green_h_p    => t_green_h_2
-        t_surf_wall_h => t_surf_wall_h_1; t_surf_wall_h_p => t_surf_wall_h_2           
+        t_wall_h    => t_wall_h_1;   t_wall_h_p   => t_wall_h_2
+        t_window_h  => t_window_h_1; t_window_h_p => t_window_h_2
+        t_green_h   => t_green_h_1;  t_green_h_p  => t_green_h_2
+        t_surf_wall_h   => t_surf_wall_h_1;   t_surf_wall_h_p   => t_surf_wall_h_2           
         t_surf_window_h => t_surf_window_h_1; t_surf_window_h_p => t_surf_window_h_2  
-        t_surf_green_h => t_surf_green_h_1; t_surf_green_h_p => t_surf_green_h_2           
+        t_surf_green_h  => t_surf_green_h_1;  t_surf_green_h_p  => t_surf_green_h_2           
         m_liq_usm_h     => m_liq_usm_h_1;     m_liq_usm_h_p     => m_liq_usm_h_2
-        swc_h       => swc_h_1; swc_h_p     => swc_h_2
-        swc_sat_h    => swc_sat_h_1
-        swc_res_h    => swc_res_h_1
-        rootfr_h       => rootfr_h_1
-        wilt_h       => wilt_h_1
-        fc_h       => fc_h_1
-
+        swc_h     => swc_h_1; swc_h_p => swc_h_2
+        swc_sat_h => swc_sat_h_1
+        swc_res_h => swc_res_h_1
+        rootfr_h  => rootfr_h_1
+        wilt_h    => wilt_h_1
+        fc_h      => fc_h_1
+
+!
 !--     allocate wall and roof temperature arrays, for vertical walls if required
 !
@@ -1446,7 +1478,7 @@
 !--     might be already allocated.
         DO  l = 0, 3
-           IF ( .NOT. ALLOCATED( t_surf_wall_v_1(l)%t ) )                           &
+           IF ( .NOT. ALLOCATED( t_surf_wall_v_1(l)%t ) )                      &
               ALLOCATE ( t_surf_wall_v_1(l)%t(1:surf_usm_v(l)%ns) )
-           IF ( .NOT. ALLOCATED( t_surf_wall_v_2(l)%t ) )                           &
+           IF ( .NOT. ALLOCATED( t_surf_wall_v_2(l)%t ) )                      &
               ALLOCATE ( t_surf_wall_v_2(l)%t(1:surf_usm_v(l)%ns) )
            IF ( .NOT. ALLOCATED( t_wall_v_1(l)%t ) )                           &           
@@ -1470,28 +1502,28 @@
            IF ( .NOT. ALLOCATED( t_green_v_2(l)%t ) )                          &           
               ALLOCATE ( t_green_v_2(l)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) )  
-           IF ( .NOT. ALLOCATED( m_liq_usm_v_1(l)%var_usm_1d ) )              &
+           IF ( .NOT. ALLOCATED( m_liq_usm_v_1(l)%var_usm_1d ) )               &
               ALLOCATE ( m_liq_usm_v_1(l)%var_usm_1d(1:surf_usm_v(l)%ns) )
-           IF ( .NOT. ALLOCATED( m_liq_usm_v_2(l)%var_usm_1d ) )              &
+           IF ( .NOT. ALLOCATED( m_liq_usm_v_2(l)%var_usm_1d ) )               &
               ALLOCATE ( m_liq_usm_v_2(l)%var_usm_1d(1:surf_usm_v(l)%ns) )
-           IF ( .NOT. ALLOCATED( swc_v_1(l)%t ) )                           &           
+           IF ( .NOT. ALLOCATED( swc_v_1(l)%t ) )                              &           
               ALLOCATE ( swc_v_1(l)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) ) 
-           IF ( .NOT. ALLOCATED( swc_v_2(l)%t ) )                           &           
+           IF ( .NOT. ALLOCATED( swc_v_2(l)%t ) )                              &           
               ALLOCATE ( swc_v_2(l)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) )  
         ENDDO
 !
 !--     initial assignment of the pointers
-        t_wall_v    => t_wall_v_1;    t_wall_v_p    => t_wall_v_2
-        t_surf_wall_v => t_surf_wall_v_1; t_surf_wall_v_p => t_surf_wall_v_2
-        t_window_v    => t_window_v_1;    t_window_v_p    => t_window_v_2
-        t_green_v    => t_green_v_1;    t_green_v_p    => t_green_v_2
+        t_wall_v        => t_wall_v_1;        t_wall_v_p        => t_wall_v_2
+        t_surf_wall_v   => t_surf_wall_v_1;   t_surf_wall_v_p   => t_surf_wall_v_2
+        t_window_v      => t_window_v_1;      t_window_v_p      => t_window_v_2
+        t_green_v       => t_green_v_1;       t_green_v_p       => t_green_v_2
         t_surf_window_v => t_surf_window_v_1; t_surf_window_v_p => t_surf_window_v_2
-        t_surf_green_v => t_surf_green_v_1; t_surf_green_v_p => t_surf_green_v_2
+        t_surf_green_v  => t_surf_green_v_1;  t_surf_green_v_p  => t_surf_green_v_2
         m_liq_usm_v     => m_liq_usm_v_1;     m_liq_usm_v_p     => m_liq_usm_v_2
-        swc_v    => swc_v_1;    swc_v_p    => swc_v_2
+        swc_v           => swc_v_1;           swc_v_p           => swc_v_2
 
 !
 !--     Allocate intermediate timestep arrays. For horizontal surfaces.
-        ALLOCATE ( surf_usm_h%tt_surface_wall_m(1:surf_usm_h%ns)                  )
-        ALLOCATE ( surf_usm_h%tt_wall_m(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
+        ALLOCATE ( surf_usm_h%tt_surface_wall_m(1:surf_usm_h%ns)               )
+        ALLOCATE ( surf_usm_h%tt_wall_m(nzb_wall:nzt_wall+1,1:surf_usm_h%ns)   )
         ALLOCATE ( surf_usm_h%tt_surface_window_m(1:surf_usm_h%ns)             )
         ALLOCATE ( surf_usm_h%tt_window_m(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
@@ -1511,6 +1543,6 @@
 !
 !--     Set inital values for prognostic quantities
-        IF ( ALLOCATED( surf_usm_h%tt_surface_wall_m ) )  surf_usm_h%tt_surface_wall_m = 0.0_wp
-        IF ( ALLOCATED( surf_usm_h%tt_wall_m    ) )  surf_usm_h%tt_wall_m    = 0.0_wp
+        IF ( ALLOCATED( surf_usm_h%tt_surface_wall_m )   )  surf_usm_h%tt_surface_wall_m   = 0.0_wp
+        IF ( ALLOCATED( surf_usm_h%tt_wall_m )           )  surf_usm_h%tt_wall_m           = 0.0_wp
         IF ( ALLOCATED( surf_usm_h%tt_surface_window_m ) )  surf_usm_h%tt_surface_window_m = 0.0_wp
         IF ( ALLOCATED( surf_usm_h%tt_window_m    )      )  surf_usm_h%tt_window_m         = 0.0_wp
@@ -1520,6 +1552,6 @@
 !--     Now, for vertical surfaces
         DO  l = 0, 3
-           ALLOCATE ( surf_usm_v(l)%tt_surface_wall_m(1:surf_usm_v(l)%ns)                  )
-           ALLOCATE ( surf_usm_v(l)%tt_wall_m(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns) )
+           ALLOCATE ( surf_usm_v(l)%tt_surface_wall_m(1:surf_usm_v(l)%ns)               )
+           ALLOCATE ( surf_usm_v(l)%tt_wall_m(nzb_wall:nzt_wall+1,1:surf_usm_v(l)%ns)   )
            IF ( ALLOCATED( surf_usm_v(l)%tt_surface_wall_m ) )  surf_usm_v(l)%tt_surface_wall_m = 0.0_wp
            IF ( ALLOCATED( surf_usm_v(l)%tt_wall_m    ) )  surf_usm_v(l)%tt_wall_m    = 0.0_wp
@@ -1533,7 +1565,7 @@
            IF ( ALLOCATED( surf_usm_v(l)%tt_green_m   ) )  surf_usm_v(l)%tt_green_m    = 0.0_wp
         ENDDO
-
+!
 !--     allocate wall heat flux output array and set initial values. For horizontal surfaces
-!         ALLOCATE ( surf_usm_h%wshf(1:surf_usm_h%ns)    )  !can be removed 
+!        ALLOCATE ( surf_usm_h%wshf(1:surf_usm_h%ns)    )  !can be removed 
         ALLOCATE ( surf_usm_h%wshf_eb(1:surf_usm_h%ns) )
         ALLOCATE ( surf_usm_h%wghf_eb(1:surf_usm_h%ns) )
@@ -1552,5 +1584,5 @@
 !--     Now, for vertical surfaces
         DO  l = 0, 3
-!            ALLOCATE ( surf_usm_v(l)%wshf(1:surf_usm_v(l)%ns)    )    ! can be removed
+!           ALLOCATE ( surf_usm_v(l)%wshf(1:surf_usm_v(l)%ns)    )    ! can be removed
            ALLOCATE ( surf_usm_v(l)%wshf_eb(1:surf_usm_v(l)%ns) )
            ALLOCATE ( surf_usm_v(l)%wghf_eb(1:surf_usm_v(l)%ns) )
@@ -1569,5 +1601,5 @@
 
         CALL location_message( 'finished', .TRUE. )
-
+        
     END SUBROUTINE usm_init_arrays
 
@@ -1586,7 +1618,7 @@
         CHARACTER(LEN=*), INTENT(IN) :: variable
   
-        INTEGER(iwp)                                       :: i, j, k, l, m, ids, idsint, iwl, istat
-        CHARACTER(LEN=varnamelength)                       :: var
-        INTEGER(iwp), PARAMETER                            :: nd = 5
+        INTEGER(iwp)                                       :: i, j, k, l, m, ids, idsint, iwl, istat  !< runnin indices
+        CHARACTER(LEN=varnamelength)                       :: var                                     !< trimmed variable
+        INTEGER(iwp), PARAMETER                            :: nd = 5                                  !< number of directions
         CHARACTER(LEN=6), DIMENSION(0:nd-1), PARAMETER     :: dirname = (/ '_roof ', '_south', '_north', '_west ', '_east ' /)
         INTEGER(iwp), DIMENSION(0:nd-1), PARAMETER         :: dirint = (/ iup_u, isouth_u, inorth_u, iwest_u, ieast_u /)
@@ -1594,4 +1626,5 @@
         IF ( variable(1:4) == 'usm_' )  THEN  ! is such a check really rquired?
 
+!
 !--     find the real name of the variable
         ids = -1
@@ -1616,4 +1649,5 @@
         ENDIF
         IF ( var(1:11) == 'usm_t_wall_'  .AND.  len(TRIM(var)) >= 12 )  THEN
+!
 !--          wall layers
             READ(var(12:12), '(I1)', iostat=istat ) iwl
@@ -1621,4 +1655,5 @@
                 var = var(1:10)
             ELSE
+!
 !--             wrong wall layer index
                 RETURN
@@ -1626,4 +1661,5 @@
         ENDIF
         IF ( var(1:13) == 'usm_t_window_'  .AND.  len(TRIM(var)) >= 14 )  THEN
+!
 !--          wall layers
             READ(var(14:14), '(I1)', iostat=istat ) iwl
@@ -1631,4 +1667,5 @@
                 var = var(1:12)
             ELSE
+!
 !--             wrong window layer index
                 RETURN
@@ -1636,4 +1673,5 @@
         ENDIF
         IF ( var(1:12) == 'usm_t_green_'  .AND.  len(TRIM(var)) >= 13 )  THEN
+!
 !--          wall layers
             READ(var(13:13), '(I1)', iostat=istat ) iwl
@@ -1641,4 +1679,5 @@
                 var = var(1:11)
             ELSE
+!
 !--             wrong green layer index
                 RETURN
@@ -1646,4 +1685,5 @@
         ENDIF
         IF ( var(1:8) == 'usm_swc_'  .AND.  len(TRIM(var)) >= 9 )  THEN
+!
 !--          swc layers
             READ(var(9:9), '(I1)', iostat=istat ) iwl
@@ -1651,4 +1691,5 @@
                 var = var(1:7)
             ELSE
+!
 !--             wrong swc layer index
                 RETURN
@@ -1661,14 +1702,15 @@
 
                 CASE ( 'usm_wshf' )
+!
 !--                 array of sensible heat flux from surfaces
 !--                 land surfaces
                     IF ( l == -1 ) THEN
                        IF ( .NOT.  ALLOCATED(surf_usm_h%wshf_eb_av) )  THEN
-                          ALLOCATE( surf_usm_h%wshf_eb_av(1:surf_usm_h%ns) )
+                          ALLOCATE ( surf_usm_h%wshf_eb_av(1:surf_usm_h%ns) )
                           surf_usm_h%wshf_eb_av = 0.0_wp
                        ENDIF
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%wshf_eb_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%wshf_eb_av(1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%wshf_eb_av(1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%wshf_eb_av = 0.0_wp
                        ENDIF
@@ -1676,12 +1718,13 @@
                     
                 CASE ( 'usm_qsws' )
+!
 !--                 array of latent heat flux from surfaces
 !--                 land surfaces
                     IF ( l == -1 .AND. .NOT.  ALLOCATED(surf_usm_h%qsws_eb_av) )  THEN
-                        ALLOCATE( surf_usm_h%qsws_eb_av(1:surf_usm_h%ns) )
+                        ALLOCATE ( surf_usm_h%qsws_eb_av(1:surf_usm_h%ns) )
                         surf_usm_h%qsws_eb_av = 0.0_wp
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%qsws_eb_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%qsws_eb_av(1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%qsws_eb_av(1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%qsws_eb_av = 0.0_wp
                        ENDIF
@@ -1689,12 +1732,13 @@
                     
                 CASE ( 'usm_qsws_veg' )
+!
 !--                 array of latent heat flux from vegetation surfaces
 !--                 land surfaces
                     IF ( l == -1 .AND. .NOT.  ALLOCATED(surf_usm_h%qsws_veg_av) )  THEN
-                        ALLOCATE( surf_usm_h%qsws_veg_av(1:surf_usm_h%ns) )
+                        ALLOCATE ( surf_usm_h%qsws_veg_av(1:surf_usm_h%ns) )
                         surf_usm_h%qsws_veg_av = 0.0_wp
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%qsws_veg_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%qsws_veg_av(1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%qsws_veg_av(1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%qsws_veg_av = 0.0_wp
                        ENDIF
@@ -1702,12 +1746,13 @@
                     
                 CASE ( 'usm_qsws_liq' )
+!
 !--                 array of latent heat flux from surfaces with liquid
 !--                 land surfaces
                     IF ( l == -1 .AND. .NOT.  ALLOCATED(surf_usm_h%qsws_liq_av) )  THEN
-                        ALLOCATE( surf_usm_h%qsws_liq_av(1:surf_usm_h%ns) )
+                        ALLOCATE ( surf_usm_h%qsws_liq_av(1:surf_usm_h%ns) )
                         surf_usm_h%qsws_liq_av = 0.0_wp
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%qsws_liq_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%qsws_liq_av(1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%qsws_liq_av(1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%qsws_liq_av = 0.0_wp
                        ENDIF
@@ -1719,13 +1764,14 @@
 !--             accordingly in average_3d_data, sum_up_3d_data, etc..
                 CASE ( 'usm_wghf' )
+!
 !--                 array of heat flux from ground (wall, roof, land)
                     IF ( l == -1 ) THEN
                        IF ( .NOT.  ALLOCATED(surf_usm_h%wghf_eb_av) )  THEN
-                           ALLOCATE( surf_usm_h%wghf_eb_av(1:surf_usm_h%ns) )
+                           ALLOCATE ( surf_usm_h%wghf_eb_av(1:surf_usm_h%ns) )
                            surf_usm_h%wghf_eb_av = 0.0_wp
                        ENDIF
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%wghf_eb_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%wghf_eb_av(1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%wghf_eb_av(1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%wghf_eb_av = 0.0_wp
                        ENDIF
@@ -1733,13 +1779,14 @@
 
                 CASE ( 'usm_wghf_window' )
+!
 !--                 array of heat flux from window ground (wall, roof, land)
                     IF ( l == -1 ) THEN
                        IF ( .NOT.  ALLOCATED(surf_usm_h%wghf_eb_window_av) )  THEN
-                           ALLOCATE( surf_usm_h%wghf_eb_window_av(1:surf_usm_h%ns) )
+                           ALLOCATE ( surf_usm_h%wghf_eb_window_av(1:surf_usm_h%ns) )
                            surf_usm_h%wghf_eb_window_av = 0.0_wp
                        ENDIF
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%wghf_eb_window_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%wghf_eb_window_av(1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%wghf_eb_window_av(1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%wghf_eb_window_av = 0.0_wp
                        ENDIF
@@ -1747,13 +1794,14 @@
 
                 CASE ( 'usm_wghf_green' )
+!
 !--                 array of heat flux from green ground (wall, roof, land)
                     IF ( l == -1 ) THEN
                        IF ( .NOT.  ALLOCATED(surf_usm_h%wghf_eb_green_av) )  THEN
-                           ALLOCATE( surf_usm_h%wghf_eb_green_av(1:surf_usm_h%ns) )
+                           ALLOCATE ( surf_usm_h%wghf_eb_green_av(1:surf_usm_h%ns) )
                            surf_usm_h%wghf_eb_green_av = 0.0_wp
                        ENDIF
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%wghf_eb_green_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%wghf_eb_green_av(1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%wghf_eb_green_av(1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%wghf_eb_green_av = 0.0_wp
                        ENDIF
@@ -1761,13 +1809,14 @@
 
                 CASE ( 'usm_iwghf' )
+!
 !--                 array of heat flux from indoor ground (wall, roof, land)
                     IF ( l == -1 ) THEN
                        IF ( .NOT.  ALLOCATED(surf_usm_h%iwghf_eb_av) )  THEN
-                           ALLOCATE( surf_usm_h%iwghf_eb_av(1:surf_usm_h%ns) )
+                           ALLOCATE ( surf_usm_h%iwghf_eb_av(1:surf_usm_h%ns) )
                            surf_usm_h%iwghf_eb_av = 0.0_wp
                        ENDIF
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%iwghf_eb_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%iwghf_eb_av(1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%iwghf_eb_av(1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%iwghf_eb_av = 0.0_wp
                        ENDIF
@@ -1775,13 +1824,14 @@
 
                 CASE ( 'usm_iwghf_window' )
+!
 !--                 array of heat flux from indoor window ground (wall, roof, land)
                     IF ( l == -1 ) THEN
                        IF ( .NOT.  ALLOCATED(surf_usm_h%iwghf_eb_window_av) )  THEN
-                           ALLOCATE( surf_usm_h%iwghf_eb_window_av(1:surf_usm_h%ns) )
+                           ALLOCATE ( surf_usm_h%iwghf_eb_window_av(1:surf_usm_h%ns) )
                            surf_usm_h%iwghf_eb_window_av = 0.0_wp
                        ENDIF
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%iwghf_eb_window_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%iwghf_eb_window_av(1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%iwghf_eb_window_av(1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%iwghf_eb_window_av = 0.0_wp
                        ENDIF
@@ -1789,13 +1839,14 @@
 
                 CASE ( 'usm_t_surf_wall' )
+!
 !--                 surface temperature for surfaces
                     IF ( l == -1 ) THEN
                        IF ( .NOT.  ALLOCATED(surf_usm_h%t_surf_wall_av) )  THEN
-                           ALLOCATE( surf_usm_h%t_surf_wall_av(1:surf_usm_h%ns) )
+                           ALLOCATE ( surf_usm_h%t_surf_wall_av(1:surf_usm_h%ns) )
                            surf_usm_h%t_surf_wall_av = 0.0_wp
                        ENDIF
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%t_surf_wall_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%t_surf_wall_av(1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%t_surf_wall_av(1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%t_surf_wall_av = 0.0_wp
                        ENDIF
@@ -1803,13 +1854,14 @@
 
                 CASE ( 'usm_t_surf_window' )
+!
 !--                 surface temperature for window surfaces
                     IF ( l == -1 ) THEN
                        IF ( .NOT.  ALLOCATED(surf_usm_h%t_surf_window_av) )  THEN
-                           ALLOCATE( surf_usm_h%t_surf_window_av(1:surf_usm_h%ns) )
+                           ALLOCATE ( surf_usm_h%t_surf_window_av(1:surf_usm_h%ns) )
                            surf_usm_h%t_surf_window_av = 0.0_wp
                        ENDIF
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%t_surf_window_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%t_surf_window_av(1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%t_surf_window_av(1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%t_surf_window_av = 0.0_wp
                        ENDIF
@@ -1817,13 +1869,14 @@
                     
                 CASE ( 'usm_t_surf_green' )
+!
 !--                 surface temperature for green surfaces
                     IF ( l == -1 ) THEN
                        IF ( .NOT.  ALLOCATED(surf_usm_h%t_surf_green_av) )  THEN
-                           ALLOCATE( surf_usm_h%t_surf_green_av(1:surf_usm_h%ns) )
+                           ALLOCATE ( surf_usm_h%t_surf_green_av(1:surf_usm_h%ns) )
                            surf_usm_h%t_surf_green_av = 0.0_wp
                        ENDIF
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%t_surf_green_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%t_surf_green_av(1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%t_surf_green_av(1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%t_surf_green_av = 0.0_wp
                        ENDIF
@@ -1831,13 +1884,14 @@
                 
                 CASE ( 'usm_theta_10cm' )
+!
 !--                 near surface (10cm) temperature for whole surfaces
                     IF ( l == -1 ) THEN
                        IF ( .NOT.  ALLOCATED(surf_usm_h%pt_10cm_av) )  THEN
-                           ALLOCATE( surf_usm_h%pt_10cm_av(1:surf_usm_h%ns) )
+                           ALLOCATE ( surf_usm_h%pt_10cm_av(1:surf_usm_h%ns) )
                            surf_usm_h%pt_10cm_av = 0.0_wp
                        ENDIF
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%pt_10cm_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%pt_10cm_av(1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%pt_10cm_av(1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%pt_10cm_av = 0.0_wp
                        ENDIF
@@ -1845,13 +1899,14 @@
                  
                 CASE ( 'usm_t_wall' )
+!
 !--                 wall temperature for iwl layer of walls and land
                     IF ( l == -1 ) THEN
                        IF ( .NOT.  ALLOCATED(surf_usm_h%t_wall_av) )  THEN
-                           ALLOCATE( surf_usm_h%t_wall_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
+                           ALLOCATE ( surf_usm_h%t_wall_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
                            surf_usm_h%t_wall_av = 0.0_wp
                        ENDIF
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%t_wall_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%t_wall_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%t_wall_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%t_wall_av = 0.0_wp
                        ENDIF
@@ -1859,13 +1914,14 @@
 
                 CASE ( 'usm_t_window' )
+!
 !--                 window temperature for iwl layer of walls and land
                     IF ( l == -1 ) THEN
                        IF ( .NOT.  ALLOCATED(surf_usm_h%t_window_av) )  THEN
-                           ALLOCATE( surf_usm_h%t_window_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
+                           ALLOCATE ( surf_usm_h%t_window_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
                            surf_usm_h%t_window_av = 0.0_wp
                        ENDIF
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%t_window_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%t_window_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%t_window_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%t_window_av = 0.0_wp
                        ENDIF
@@ -1873,24 +1929,26 @@
 
                 CASE ( 'usm_t_green' )
+!
 !--                 green temperature for iwl layer of walls and land
                     IF ( l == -1 ) THEN
                        IF ( .NOT.  ALLOCATED(surf_usm_h%t_green_av) )  THEN
-                           ALLOCATE( surf_usm_h%t_green_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
+                           ALLOCATE ( surf_usm_h%t_green_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
                            surf_usm_h%t_green_av = 0.0_wp
                        ENDIF
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%t_green_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%t_green_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%t_green_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%t_green_av = 0.0_wp
                        ENDIF
                     ENDIF
                 CASE ( 'usm_swc' )
+!
 !--                 soil water content for iwl layer of walls and land
                     IF ( l == -1 .AND. .NOT.  ALLOCATED(surf_usm_h%swc_av) )  THEN
-                        ALLOCATE( surf_usm_h%swc_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
+                        ALLOCATE ( surf_usm_h%swc_av(nzb_wall:nzt_wall,1:surf_usm_h%ns) )
                         surf_usm_h%swc_av = 0.0_wp
                     ELSE
                        IF ( .NOT.  ALLOCATED(surf_usm_v(l)%swc_av) )  THEN
-                           ALLOCATE( surf_usm_v(l)%swc_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
+                           ALLOCATE ( surf_usm_v(l)%swc_av(nzb_wall:nzt_wall,1:surf_usm_v(l)%ns) )
                            surf_usm_v(l)%swc_av = 0.0_wp
                        ENDIF
@@ -1907,4 +1965,5 @@
 
                 CASE ( 'usm_wshf' )
+!
 !--                 array of sensible heat flux from surfaces (land, roof, wall)
                     IF ( l == -1 ) THEN
@@ -1923,4 +1982,5 @@
                     
                 CASE ( 'usm_qsws' )
+!
 !--                 array of latent heat flux from surfaces (land, roof, wall)
                     IF ( l == -1 ) THEN
@@ -1939,4 +1999,5 @@
                     
                 CASE ( 'usm_qsws_veg' )
+!
 !--                 array of latent heat flux from vegetation surfaces (land, roof, wall)
                     IF ( l == -1 ) THEN
@@ -1955,4 +2016,5 @@
                     
                 CASE ( 'usm_qsws_liq' )
+!
 !--                 array of latent heat flux from surfaces with liquid (land, roof, wall)
                     IF ( l == -1 ) THEN
@@ -1971,4 +2033,5 @@
                     
                 CASE ( 'usm_wghf' )
+!
 !--                 array of heat flux from ground (wall, roof, land)
                     IF ( l == -1 ) THEN
@@ -1987,4 +2050,5 @@
                     
                 CASE ( 'usm_wghf_window' )
+!
 !--                 array of heat flux from window ground (wall, roof, land)
                     IF ( l == -1 ) THEN
@@ -2003,4 +2067,5 @@
 
                 CASE ( 'usm_wghf_green' )
+!
 !--                 array of heat flux from green ground (wall, roof, land)
                     IF ( l == -1 ) THEN
@@ -2019,4 +2084,5 @@
                     
                 CASE ( 'usm_iwghf' )
+!
 !--                 array of heat flux from indoor ground (wall, roof, land)
                     IF ( l == -1 ) THEN
@@ -2035,4 +2101,5 @@
                     
                 CASE ( 'usm_iwghf_window' )
+!
 !--                 array of heat flux from indoor window ground (wall, roof, land)
                     IF ( l == -1 ) THEN
@@ -2051,4 +2118,5 @@
                     
                 CASE ( 'usm_t_surf_wall' )
+!
 !--                 surface temperature for surfaces
                     IF ( l == -1 ) THEN
@@ -2067,4 +2135,5 @@
                     
                 CASE ( 'usm_t_surf_window' )
+!
 !--                 surface temperature for window surfaces
                     IF ( l == -1 ) THEN
@@ -2083,4 +2152,5 @@
                     
                 CASE ( 'usm_t_surf_green' )
+!
 !--                 surface temperature for green surfaces
                     IF ( l == -1 ) THEN
@@ -2099,4 +2169,5 @@
                 
                 CASE ( 'usm_theta_10cm' )
+!
 !--                 near surface temperature for whole surfaces
                     IF ( l == -1 ) THEN
@@ -2115,4 +2186,5 @@
                     
                 CASE ( 'usm_t_wall' )
+!
 !--                 wall temperature for  iwl layer of walls and land
                     IF ( l == -1 ) THEN
@@ -2131,4 +2203,5 @@
                     
                 CASE ( 'usm_t_window' )
+!
 !--                 window temperature for  iwl layer of walls and land
                     IF ( l == -1 ) THEN
@@ -2147,4 +2220,5 @@
 
                 CASE ( 'usm_t_green' )
+!
 !--                 green temperature for  iwl layer of walls and land
                     IF ( l == -1 ) THEN
@@ -2163,4 +2237,5 @@
 
                 CASE ( 'usm_swc' )
+!
 !--                 soil water content for  iwl layer of walls and land
                     IF ( l == -1 ) THEN
@@ -2188,4 +2263,5 @@
 
                 CASE ( 'usm_wshf' )
+!
 !--                 array of sensible heat flux from surfaces (land, roof, wall)
                     IF ( l == -1 ) THEN
@@ -2204,4 +2280,5 @@
                     
                 CASE ( 'usm_qsws' )
+!
 !--                 array of latent heat flux from surfaces (land, roof, wall)
                     IF ( l == -1 ) THEN
@@ -2220,4 +2297,5 @@
 
                 CASE ( 'usm_qsws_veg' )
+!
 !--                 array of latent heat flux from vegetation surfaces (land, roof, wall)
                     IF ( l == -1 ) THEN
@@ -2236,4 +2314,5 @@
                     
                 CASE ( 'usm_qsws_liq' )
+!
 !--                 array of latent heat flux from surfaces with liquid (land, roof, wall)
                     IF ( l == -1 ) THEN
@@ -2252,4 +2331,5 @@
                     
                 CASE ( 'usm_wghf' )
+!
 !--                 array of heat flux from ground (wall, roof, land)
                     IF ( l == -1 ) THEN
@@ -2268,4 +2348,5 @@
                     
                 CASE ( 'usm_wghf_window' )
+!
 !--                 array of heat flux from window ground (wall, roof, land)
                     IF ( l == -1 ) THEN
@@ -2284,4 +2365,5 @@
 
                 CASE ( 'usm_wghf_green' )
+!
 !--                 array of heat flux from green ground (wall, roof, land)
                     IF ( l == -1 ) THEN
@@ -2300,4 +2382,5 @@
 
                 CASE ( 'usm_iwghf' )
+!
 !--                 array of heat flux from indoor ground (wall, roof, land)
                     IF ( l == -1 ) THEN
@@ -2316,4 +2399,5 @@
                     
                 CASE ( 'usm_iwghf_window' )
+!
 !--                 array of heat flux from indoor window ground (wall, roof, land)
                     IF ( l == -1 ) THEN
@@ -2332,4 +2416,5 @@
                     
                 CASE ( 'usm_t_surf_wall' )
+!
 !--                 surface temperature for surfaces
                     IF ( l == -1 ) THEN
@@ -2348,4 +2433,5 @@
                     
                 CASE ( 'usm_t_surf_window' )
+!
 !--                 surface temperature for window surfaces
                     IF ( l == -1 ) THEN
@@ -2364,4 +2450,5 @@
                     
                 CASE ( 'usm_t_surf_green' )
+!
 !--                 surface temperature for green surfaces
                     IF ( l == -1 ) THEN
@@ -2380,4 +2467,5 @@
                     
                 CASE ( 'usm_theta_10cm' )
+!
 !--                 near surface temperature for whole surfaces
                     IF ( l == -1 ) THEN
@@ -2397,4 +2485,5 @@
                     
                 CASE ( 'usm_t_wall' )
+!
 !--                 wall temperature for  iwl layer of walls and land
                     IF ( l == -1 ) THEN
@@ -2413,4 +2502,5 @@
 
                 CASE ( 'usm_t_window' )
+!
 !--                 window temperature for  iwl layer of walls and land
                     IF ( l == -1 ) THEN
@@ -2429,4 +2519,5 @@
 
                 CASE ( 'usm_t_green' )
+!
 !--                 green temperature for  iwl layer of walls and land
                     IF ( l == -1 ) THEN
@@ -2445,4 +2536,5 @@
                     
                 CASE ( 'usm_swc' )
+!
 !--                 soil water content for  iwl layer of walls and land
                     IF ( l == -1 ) THEN
@@ -2526,9 +2618,9 @@
         CHARACTER(LEN=*),INTENT(OUT)   ::  unit       !<
 
-        INTEGER(iwp)                                  :: i,j,l        !< index
+        INTEGER(iwp)                                  :: i,j,l         !< index
         CHARACTER(LEN=2)                              :: ls
-        CHARACTER(LEN=varnamelength)                  :: var          !< TRIM(variable)
-        INTEGER(iwp), PARAMETER                       :: nl1 = 16     !< number of directional usm variables
-        CHARACTER(LEN=varnamelength), DIMENSION(nl1)  :: varlist1 = & !< list of directional usm variables
+        CHARACTER(LEN=varnamelength)                  :: var           !< TRIM(variable)
+        INTEGER(iwp), PARAMETER                       :: nl1 = 16      !< number of directional usm variables
+        CHARACTER(LEN=varnamelength), DIMENSION(nl1)  :: varlist1 = &  !< list of directional usm variables
                   (/'usm_wshf                      ', &
                     'usm_wghf                      ', &
@@ -2548,6 +2640,6 @@
                     'usm_theta_10cm                '/)
 
-        INTEGER(iwp), PARAMETER                       :: nl2 = 3      !< number of directional layer usm variables
-        CHARACTER(LEN=varnamelength), DIMENSION(nl2)  :: varlist2 = & !< list of directional layer usm variables
+        INTEGER(iwp), PARAMETER                       :: nl2 = 3       !< number of directional layer usm variables
+        CHARACTER(LEN=varnamelength), DIMENSION(nl2)  :: varlist2 = &  !< list of directional layer usm variables
                   (/'usm_t_wall                    ', &
                     'usm_t_window                  ', &
@@ -2564,6 +2656,7 @@
         var = TRIM(variable)
 
+!
 !--     check if variable exists
-!       directional variables
+!--     directional variables
         DO i = 1, nl1
            DO j = 1, nd
@@ -2576,5 +2669,6 @@
         ENDDO
         IF ( lfound ) GOTO 10
-!       directional layer variables
+!
+!--     directional layer variables
         DO i = 1, nl2
            DO j = 1, nd
@@ -2624,16 +2718,17 @@
 !------------------------------------------------------------------------------!
     SUBROUTINE usm_check_parameters
-    
+
        USE control_parameters,                                                 &
            ONLY:  bc_pt_b, bc_q_b, constant_flux_layer, large_scale_forcing,   &
                   lsf_surf, topography
-                  
+
        USE netcdf_data_input_mod,                                             &
             ONLY:  building_type_f
 
-       IMPLICIT NONE           
-                  
+       IMPLICIT NONE
+
        INTEGER(iwp) ::  i        !< running index, x-dimension
        INTEGER(iwp) ::  j        !< running index, y-dimension
+
 !
 !--    Dirichlet boundary conditions are required as the surface fluxes are
@@ -2680,6 +2775,6 @@
        ENDIF
 !
-!--    Check if building types are set within a valid range.   
-       IF ( building_type < LBOUND( building_pars, 2 )  .AND.                 &
+!--    Check if building types are set within a valid range.
+       IF ( building_type < LBOUND( building_pars, 2 )  .AND.                  &
             building_type > UBOUND( building_pars, 2 ) )  THEN
           WRITE( message_string, * ) 'building_type = ', building_type,        &
@@ -2696,10 +2791,9 @@
                    WRITE( message_string, * ) 'building_type = is out of ' //  &
                                         'the valid range at (j,i) = ', j, i
-                   CALL message( 'usm_check_parameters', 'PA0529', 2, 2, 0, 6, 0 ) 
+                   CALL message( 'usm_check_parameters', 'PA0529', 2, 2, 0, 6, 0 )
                 ENDIF
              ENDDO
           ENDDO
        ENDIF
-
     END SUBROUTINE usm_check_parameters
 
@@ -2719,6 +2813,6 @@
         IMPLICIT NONE
 
-        INTEGER(iwp), INTENT(IN)       ::  av        !< 
-        CHARACTER (len=*), INTENT(IN)  ::  variable  !< 
+        INTEGER(iwp), INTENT(IN)       ::  av        !< flag if averaged
+        CHARACTER (len=*), INTENT(IN)  ::  variable  !< variable name
         INTEGER(iwp), INTENT(IN)       ::  nzb_do    !< lower limit of the data output (usually 0)
         INTEGER(iwp), INTENT(IN)       ::  nzt_do    !< vertical upper limit of the data output (usually nz_do3d)
@@ -2727,6 +2821,6 @@
         REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr)     ::  temp_pf    !< temp array for urban surface output procedure
         
-        CHARACTER (len=varnamelength)                          :: var
-        INTEGER(iwp), PARAMETER                                :: nd = 5
+        CHARACTER (len=varnamelength)                          :: var     !< trimmed variable name
+        INTEGER(iwp), PARAMETER                                :: nd = 5  !< number of directions
         CHARACTER(len=6), DIMENSION(0:nd-1), PARAMETER         :: dirname = (/ '_roof ', '_south', '_north', '_west ', '_east ' /)
         INTEGER(iwp), DIMENSION(0:nd-1), PARAMETER             :: dirint =  (/    iup_u, isouth_u, inorth_u,  iwest_u,  ieast_u /)
@@ -2734,5 +2828,5 @@
                                                                      !< index for surf_*_v: 0:3 = (North, South, East, West)
         INTEGER(iwp)                                           :: ids,idsint,idsidx,isvf
-        INTEGER(iwp)                                           :: i,j,k,iwl,istat, l, m
+        INTEGER(iwp)                                           :: i,j,k,iwl,istat, l, m  !< running indices
 
         found = .TRUE.
@@ -2756,4 +2850,5 @@
         ENDIF
         IF ( var(1:11) == 'usm_t_wall_'  .AND.  len(TRIM(var)) >= 12 )  THEN
+!
 !--         wall layers
             READ(var(12:12), '(I1)', iostat=istat ) iwl
@@ -2763,4 +2858,5 @@
         ENDIF
         IF ( var(1:13) == 'usm_t_window_'  .AND.  len(TRIM(var)) >= 14 )  THEN
+!
 !--         window layers
             READ(var(14:14), '(I1)', iostat=istat ) iwl
@@ -2770,4 +2866,5 @@
         ENDIF
         IF ( var(1:12) == 'usm_t_green_'  .AND.  len(TRIM(var)) >= 13 )  THEN
+!
 !--         green layers
             READ(var(13:13), '(I1)', iostat=istat ) iwl
@@ -2777,4 +2874,5 @@
         ENDIF
         IF ( var(1:8) == 'usm_swc_'  .AND.  len(TRIM(var)) >= 9 )  THEN
+!
 !--         green layers soil water content
             READ(var(9:9), '(I1)', iostat=istat ) iwl
@@ -2787,4 +2885,5 @@
 
           CASE ( 'usm_surfz' )
+!
 !--           array of surface height (z)
               IF ( idsint == iup_u )  THEN
@@ -2806,4 +2905,5 @@
 
           CASE ( 'usm_surfcat' )
+!
 !--           surface category
               IF ( idsint == iup_u )  THEN
@@ -2825,4 +2925,5 @@
               
           CASE ( 'usm_surfalb' )
+!
 !--           surface albedo, weighted average
               IF ( idsint == iup_u )  THEN
@@ -2854,4 +2955,5 @@
               
           CASE ( 'usm_surfemis' )
+!
 !--           surface emissivity, weighted average
               IF ( idsint == iup_u )  THEN
@@ -2883,4 +2985,5 @@
 
           CASE ( 'usm_surfwintrans' )
+!
 !--           transmissivity window tiles
               IF ( idsint == iup_u )  THEN
@@ -2902,4 +3005,5 @@
 
           CASE ( 'usm_wshf' )
+!
 !--           array of sensible heat flux from surfaces
               IF ( av == 0 )  THEN
@@ -2941,4 +3045,5 @@
               
           CASE ( 'usm_qsws' )
+!
 !--           array of latent heat flux from surfaces
               IF ( av == 0 )  THEN
@@ -2979,4 +3084,5 @@
               
           CASE ( 'usm_qsws_veg' )
+!
 !--           array of latent heat flux from vegetation surfaces
               IF ( av == 0 )  THEN
@@ -3017,4 +3123,5 @@
               
           CASE ( 'usm_qsws_liq' )
+!
 !--           array of latent heat flux from surfaces with liquid
               IF ( av == 0 )  THEN
@@ -3055,4 +3162,5 @@
 
           CASE ( 'usm_wghf' )
+!
 !--           array of heat flux from ground (land, wall, roof)
               IF ( av == 0 )  THEN
@@ -3093,6 +3201,6 @@
 
           CASE ( 'usm_wghf_window' )
+!
 !--           array of heat flux from window ground (land, wall, roof)
-
               IF ( av == 0 )  THEN
                  IF ( idsint == iup_u )  THEN
@@ -3132,6 +3240,6 @@
 
           CASE ( 'usm_wghf_green' )
+!
 !--           array of heat flux from green ground (land, wall, roof)
-
               IF ( av == 0 )  THEN
                  IF ( idsint == iup_u )  THEN
@@ -3171,4 +3279,5 @@
 
           CASE ( 'usm_iwghf' )
+!
 !--           array of heat flux from indoor ground (land, wall, roof)
               IF ( av == 0 )  THEN
@@ -3209,6 +3318,6 @@
 
           CASE ( 'usm_iwghf_window' )
+!
 !--           array of heat flux from indoor window ground (land, wall, roof)
-
               IF ( av == 0 )  THEN
                  IF ( idsint == iup_u )  THEN
@@ -3248,4 +3357,5 @@
               
           CASE ( 'usm_t_surf_wall' )
+!
 !--           surface temperature for surfaces
               IF ( av == 0 )  THEN
@@ -3286,6 +3396,6 @@
               
           CASE ( 'usm_t_surf_window' )
+!
 !--           surface temperature for window surfaces
-
               IF ( av == 0 )  THEN
                  IF ( idsint == iup_u )  THEN
@@ -3328,6 +3438,6 @@
 
           CASE ( 'usm_t_surf_green' )
+!
 !--           surface temperature for green surfaces
-
               IF ( av == 0 )  THEN
                  IF ( idsint == iup_u )  THEN
@@ -3370,6 +3480,6 @@
 
           CASE ( 'usm_theta_10cm' )
+!
 !--           near surface temperature for whole surfaces
-
               IF ( av == 0 )  THEN
                  IF ( idsint == iup_u )  THEN
@@ -3412,4 +3522,5 @@
              
           CASE ( 'usm_t_wall' )
+!
 !--           wall temperature for  iwl layer of walls and land
               IF ( av == 0 )  THEN
@@ -3450,4 +3561,5 @@
              
           CASE ( 'usm_t_window' )
+!
 !--           window temperature for iwl layer of walls and land
               IF ( av == 0 )  THEN
@@ -3488,4 +3600,5 @@
 
           CASE ( 'usm_t_green' )
+!
 !--           green temperature for  iwl layer of walls and land
               IF ( av == 0 )  THEN
@@ -3526,4 +3639,5 @@
               
               CASE ( 'usm_swc' )
+!
 !--           soil water content for  iwl layer of walls and land
               IF ( av == 0 )  THEN
@@ -3612,5 +3726,5 @@
              var(1:16) == 'usm_t_surf_green'  .OR. var(1:11) == 'usm_t_green' .OR.          &
              var(1:15) == 'usm_theta_10cm' .OR.                                             &
-             var(1:9) == 'usm_surfz'  .OR.  var(1:11) == 'usm_surfcat'  .OR.                  &
+             var(1:9) == 'usm_surfz'  .OR.  var(1:11) == 'usm_surfcat'  .OR.                &
              var(1:11) == 'usm_surfalb'  .OR.  var(1:12) == 'usm_surfemis'  .OR.            &
              var(1:16) == 'usm_surfwintrans'  .OR. var(1:7) == 'usm_swc' ) THEN
@@ -3642,5 +3756,6 @@
         
         CALL location_message( '    initialization of wall surface model', .TRUE. )
-       
+
+!
 !--     Calculate wall grid spacings. 
 !--     Temperature is defined at the center of the wall layers,
@@ -3659,9 +3774,4 @@
                                          surf_usm_h%zw_window(k-1,m)
            ENDDO
-!            surf_usm_h%dz_green(nzb_wall,m) = surf_usm_h%zw_green(nzb_wall,m)
-!            DO k = nzb_wall+1, nzt_wall
-!                surf_usm_h%dz_green(k,m) = surf_usm_h%zw_green(k,m) -           &
-!                                          surf_usm_h%zw_green(k-1,m)
-!            ENDDO
            
            surf_usm_h%dz_wall(nzt_wall+1,m) = surf_usm_h%dz_wall(nzt_wall,m)
@@ -3681,28 +3791,26 @@
            surf_usm_h%dz_window_stag(nzt_wall,m) = surf_usm_h%dz_window(nzt_wall,m)
 
-!            surf_usm_h%dz_green(nzt_wall+1,m) = surf_usm_h%dz_green(nzt_wall,m)
-! 
-!            DO k = nzb_wall, nzt_wall-1
-!                surf_usm_h%dz_green_stag(k,m) = 0.5 * (                         &
-!                            surf_usm_h%dz_green(k+1,m) + surf_usm_h%dz_green(k,m) )
-!            ENDDO
-!            surf_usm_h%dz_green_stag(nzt_wall,m) = surf_usm_h%dz_green(nzt_wall,m)
-!-------------           
-           IF (surf_usm_h%green_type_roof(m) == 2.0_wp ) then
-             soil_type = 3 !extensiv green roof
-             surf_usm_h%lai(m) = 2.0_wp
+           IF (surf_usm_h%green_type_roof(m) == 2.0_wp ) THEN
+!
+!-- extensive green roof
+!-- set ratio of substrate layer thickness, soil-type and LAI
+              soil_type = 3
+              surf_usm_h%lai(m) = 2.0_wp
              
-           surf_usm_h%zw_green(nzb_wall,m)         = 0.05_wp
-           surf_usm_h%zw_green(nzb_wall+1,m)       = 0.10_wp
-           surf_usm_h%zw_green(nzb_wall+2,m)       = 0.15_wp
-           surf_usm_h%zw_green(nzb_wall+3,m)       = 0.20_wp
+              surf_usm_h%zw_green(nzb_wall,m)   = 0.05_wp
+              surf_usm_h%zw_green(nzb_wall+1,m) = 0.10_wp
+              surf_usm_h%zw_green(nzb_wall+2,m) = 0.15_wp
+              surf_usm_h%zw_green(nzb_wall+3,m) = 0.20_wp
            ELSE
-             soil_type = 6 !intensiv green roof
-             surf_usm_h%lai(m) = 4.0_wp
+!
+!-- intensiv green roof
+!-- set ratio of substrate layer thickness, soil-type and LAI
+              soil_type = 6
+              surf_usm_h%lai(m) = 4.0_wp
              
-           surf_usm_h%zw_green(nzb_wall,m)         = 0.05_wp
-           surf_usm_h%zw_green(nzb_wall+1,m)       = 0.10_wp
-           surf_usm_h%zw_green(nzb_wall+2,m)       = 0.40_wp
-           surf_usm_h%zw_green(nzb_wall+3,m)       = 0.80_wp
+              surf_usm_h%zw_green(nzb_wall,m)   = 0.05_wp
+              surf_usm_h%zw_green(nzb_wall+1,m) = 0.10_wp
+              surf_usm_h%zw_green(nzb_wall+2,m) = 0.40_wp
+              surf_usm_h%zw_green(nzb_wall+3,m) = 0.80_wp
            ENDIF
            
@@ -3758,5 +3866,5 @@
              surf_usm_h%l_vg_green(m)          = l_vangenuchten
              surf_usm_h%n_vg_green(m)          = n_vangenuchten 
-             surf_usm_h%gamma_w_green_sat(k,m)   = hydraulic_conductivity
+             surf_usm_h%gamma_w_green_sat(k,m) = hydraulic_conductivity
              swc_sat_h(k,m)                    = saturation_moisture
              fc_h(k,m)                         = field_capacity
@@ -3764,6 +3872,7 @@
              swc_res_h(k,m)                    = residual_moisture
           ENDDO
-!-------------------------------           
+
         ENDDO
+
         surf_usm_h%ddz_wall        = 1.0_wp / surf_usm_h%dz_wall
         surf_usm_h%ddz_wall_stag   = 1.0_wp / surf_usm_h%dz_wall_stag
@@ -3802,5 +3911,5 @@
               surf_usm_v(l)%dz_wall_stag(nzt_wall,m) =                         &
                                               surf_usm_v(l)%dz_wall(nzt_wall,m)
-              surf_usm_v(l)%dz_window(nzt_wall+1,m) =                            &
+              surf_usm_v(l)%dz_window(nzt_wall+1,m) =                          &
                                               surf_usm_v(l)%dz_window(nzt_wall,m)
 
@@ -3812,5 +3921,5 @@
               surf_usm_v(l)%dz_window_stag(nzt_wall,m) =                         &
                                               surf_usm_v(l)%dz_window(nzt_wall,m)
-              surf_usm_v(l)%dz_green(nzt_wall+1,m) =                            &
+              surf_usm_v(l)%dz_green(nzt_wall+1,m) =                             &
                                               surf_usm_v(l)%dz_green(nzt_wall,m)
 
@@ -3831,72 +3940,4 @@
         ENDDO      
 
-        
-!     soil_type = 6
-! !--    Initialize standard soil types. It is possible to overwrite each
-! !--    parameter by setting the respecticy NAMELIST variable to a 
-! !--    value /= 9999999.9. 
-!        IF ( soil_type /= 0 )  THEN  
-!  
-!           IF ( alpha_vangenuchten == 9999999.9_wp )  THEN
-!              alpha_vangenuchten = soil_pars(0,soil_type)
-!           ENDIF
-! 
-!           IF ( l_vangenuchten == 9999999.9_wp )  THEN
-!              l_vangenuchten = soil_pars(1,soil_type)
-!           ENDIF
-! 
-!           IF ( n_vangenuchten == 9999999.9_wp )  THEN
-!              n_vangenuchten = soil_pars(2,soil_type)            
-!           ENDIF
-! 
-!           IF ( hydraulic_conductivity == 9999999.9_wp )  THEN
-!              hydraulic_conductivity = soil_pars(3,soil_type)            
-!           ENDIF
-! 
-!           IF ( saturation_moisture == 9999999.9_wp )  THEN
-!              saturation_moisture = m_soil_pars(0,soil_type)           
-!           ENDIF
-! 
-!           IF ( field_capacity == 9999999.9_wp )  THEN
-!              field_capacity = m_soil_pars(1,soil_type)           
-!           ENDIF
-! 
-!           IF ( wilting_point == 9999999.9_wp )  THEN
-!              wilting_point = m_soil_pars(2,soil_type)            
-!           ENDIF
-! 
-!           IF ( residual_moisture == 9999999.9_wp )  THEN
-!              residual_moisture = m_soil_pars(3,soil_type)       
-!           ENDIF
-!           
-!             DO  m = 1, surf_usm_h%ns
-!                DO k = nzb_wall, nzt_wall+1
-!                    swc_h(k,m) = field_capacity
-!                    rootfr_h(k,m) = 0.5_wp
-!                ENDDO
-!             ENDDO
-! ! !
-! ! !--         Vertical surfaces
-! !             DO  l = 0, 3
-! !                DO  m = 1, surf_usm_v(l)%ns
-! !                   DO k = nzb_wall, nzt_wall+1
-! !                      swc_v(l)%t(k,m) = 0.5_wp
-! !                   ENDDO
-! !                ENDDO
-! !             ENDDO
-! 
-!        ENDIF
-! 
-! !
-! !--    Map values to the respective 2D arrays
-!        surf_usm_h%alpha_vg_green      = alpha_vangenuchten
-!        surf_usm_h%l_vg_green          = l_vangenuchten
-!        surf_usm_h%n_vg_green          = n_vangenuchten 
-!        surf_usm_h%gamma_w_green_sat   = hydraulic_conductivity
-!        swc_sat_h         = saturation_moisture
-!        fc_h          = field_capacity
-!        wilt_h        = wilting_point
-!        swc_res_h         = residual_moisture
-! !        r_soil_min    = min_soil_resistance
         
         CALL location_message( '    wall structures filed out', .TRUE. )
@@ -3971,4 +4012,5 @@
 
         CALL cpu_log( log_point_s(78), 'usm_init', 'start' )
+!
 !--     surface forcing have to be disabled for LSF 
 !--     in case of enabled urban surface module
@@ -4037,5 +4079,5 @@
 !
 !--           Set flag for ground level
-              IF ( z_agl <= ground_floor_level_l )                                &
+              IF ( z_agl <= ground_floor_level_l )                             &
                  surf_usm_v(l)%ground_level(m) = .TRUE.
 
@@ -4057,10 +4099,9 @@
         ENDDO
         
-!---------------------------------------------------------------------------------------------
 !
 !--    Map values onto horizontal elemements
        DO  m = 1, surf_usm_h%ns
-             surf_usm_h%r_canopy_min(m)     = 200.0_wp !min_canopy_resistance
-             surf_usm_h%g_d(m)              = 0.0_wp !canopy_resistance_coefficient
+             surf_usm_h%r_canopy_min(m)     = 200.0_wp !< min_canopy_resistance
+             surf_usm_h%g_d(m)              = 0.0_wp   !< canopy_resistance_coefficient
        ENDDO
 !
@@ -4069,10 +4110,9 @@
        DO  l = 0, 3
           DO  m = 1, surf_usm_v(l)%ns
-                surf_usm_v(l)%r_canopy_min(m)     = 200.0_wp !min_canopy_resistance
-                surf_usm_v(l)%g_d(m)              = 0.0_wp !canopy_resistance_coefficient
+                surf_usm_v(l)%r_canopy_min(m)     = 200.0_wp !< min_canopy_resistance
+                surf_usm_v(l)%g_d(m)              = 0.0_wp   !< canopy_resistance_coefficient
           ENDDO
        ENDDO
-!---------------------------------------------------------------------------------------------
-!
+
 !
 !--     Initialize urban-type surface attribute. According to initialization in 
@@ -4637,5 +4677,5 @@
               IF ( building_pars_f%pars_xy(ind_wall_frac_r,j,i) /= building_pars_f%fill )    &
                  surf_usm_h%frac(ind_veg_wall,m)  = building_pars_f%pars_xy(ind_wall_frac_r,j,i)   
-              IF ( building_pars_f%pars_xy(ind_green_frac_r,j,i) /= building_pars_f%fill ) & 
+              IF ( building_pars_f%pars_xy(ind_green_frac_r,j,i) /= building_pars_f%fill )   & 
                  surf_usm_h%frac(ind_pav_green,m) = building_pars_f%pars_xy(ind_green_frac_r,j,i) 
               IF ( building_pars_f%pars_xy(ind_win_frac_r,j,i) /= building_pars_f%fill )     & 
@@ -4643,5 +4683,5 @@
 
  
-              IF ( building_pars_f%pars_xy(ind_lai_r,j,i) /= building_pars_f%fill )        &
+              IF ( building_pars_f%pars_xy(ind_lai_r,j,i) /= building_pars_f%fill )          &
                  surf_usm_h%lai(m)             = building_pars_f%pars_xy(ind_lai_r,j,i)
 
@@ -4720,7 +4760,7 @@
               IF ( building_pars_f%pars_xy(ind_alb_wall_r,j,i) /= building_pars_f%fill )    & 
                  surf_usm_h%albedo_type(ind_veg_wall,m)  = building_pars_f%pars_xy(ind_alb_wall_r,j,i)
-              IF ( building_pars_f%pars_xy(ind_alb_green_r,j,i) /= building_pars_f%fill )    & 
+              IF ( building_pars_f%pars_xy(ind_alb_green_r,j,i) /= building_pars_f%fill )   & 
                  surf_usm_h%albedo_type(ind_pav_green,m) = building_pars_f%pars_xy(ind_alb_green_r,j,i)
-              IF ( building_pars_f%pars_xy(ind_alb_win_r,j,i) /= building_pars_f%fill )    & 
+              IF ( building_pars_f%pars_xy(ind_alb_win_r,j,i) /= building_pars_f%fill )     & 
                  surf_usm_h%albedo_type(ind_wat_win,m)   = building_pars_f%pars_xy(ind_alb_win_r,j,i)
 
@@ -4741,11 +4781,11 @@
               IF ( building_pars_f%pars_xy(ind_thick_4_wall_r,j,i) /= building_pars_f%fill )    & 
                  surf_usm_h%zw_green(nzb_wall+3,m) = building_pars_f%pars_xy(ind_thick_4_wall_r,j,i)
-              IF ( building_pars_f%pars_xy(ind_thick_1_win_r,j,i) /= building_pars_f%fill )    & 
+              IF ( building_pars_f%pars_xy(ind_thick_1_win_r,j,i) /= building_pars_f%fill )     & 
                  surf_usm_h%zw_window(nzb_wall,m) = building_pars_f%pars_xy(ind_thick_1_win_r,j,i)
-              IF ( building_pars_f%pars_xy(ind_thick_2_win_r,j,i) /= building_pars_f%fill )    & 
+              IF ( building_pars_f%pars_xy(ind_thick_2_win_r,j,i) /= building_pars_f%fill )     & 
                  surf_usm_h%zw_window(nzb_wall+1,m) = building_pars_f%pars_xy(ind_thick_2_win_r,j,i)
-              IF ( building_pars_f%pars_xy(ind_thick_3_win_r,j,i) /= building_pars_f%fill )    & 
+              IF ( building_pars_f%pars_xy(ind_thick_3_win_r,j,i) /= building_pars_f%fill )     & 
                  surf_usm_h%zw_window(nzb_wall+2,m) = building_pars_f%pars_xy(ind_thick_3_win_r,j,i)
-              IF ( building_pars_f%pars_xy(ind_thick_4_win_r,j,i) /= building_pars_f%fill )    & 
+              IF ( building_pars_f%pars_xy(ind_thick_4_win_r,j,i) /= building_pars_f%fill )     & 
                  surf_usm_h%zw_window(nzb_wall+3,m) = building_pars_f%pars_xy(ind_thick_4_win_r,j,i)
 
@@ -4783,5 +4823,5 @@
                  ind_alb_win      = MERGE( ind_alb_win_gfl,      ind_alb_win_agfl,      &
                                            surf_usm_v(l)%ground_level(m) )
-                 ind_wall_frac    = MERGE( ind_wall_frac_gfl,    ind_wall_frac_agfl,     &
+                 ind_wall_frac    = MERGE( ind_wall_frac_gfl,    ind_wall_frac_agfl,    &
                                            surf_usm_v(l)%ground_level(m) )
                  ind_win_frac     = MERGE( ind_win_frac_gfl,     ind_win_frac_agfl,     &
@@ -4947,7 +4987,7 @@
                  IF ( building_pars_f%pars_xy(ind_alb_wall,j,i) /= building_pars_f%fill )    & 
                     surf_usm_v(l)%albedo_type(ind_veg_wall,m)  = building_pars_f%pars_xy(ind_alb_wall,j,i)
-                 IF ( building_pars_f%pars_xy(ind_alb_green,j,i) /= building_pars_f%fill )    & 
+                 IF ( building_pars_f%pars_xy(ind_alb_green,j,i) /= building_pars_f%fill )   & 
                     surf_usm_v(l)%albedo_type(ind_pav_green,m) = building_pars_f%pars_xy(ind_alb_green,j,i)
-                 IF ( building_pars_f%pars_xy(ind_alb_win,j,i) /= building_pars_f%fill )    & 
+                 IF ( building_pars_f%pars_xy(ind_alb_win,j,i) /= building_pars_f%fill )     & 
                     surf_usm_v(l)%albedo_type(ind_wat_win,m)   = building_pars_f%pars_xy(ind_alb_win,j,i)
 
@@ -5001,9 +5041,9 @@
         CALL usm_read_urban_surface_types()
         
-!--     init material heat model
         CALL usm_init_material_model()
-        
+!        
 !--     init anthropogenic sources of heat
         IF ( usm_anthropogenic_heat )  THEN
+!
 !--         init anthropogenic sources of heat (from transportation for now)
             CALL usm_read_anthropogenic_heat()
@@ -5046,10 +5086,10 @@
                 surf_usm_v(l)%z0(m) = 0.9_wp * surf_usm_v(l)%z_mo(m)
              
-                WRITE( message_string, * ) 'z0 exceeds surface-layer height '//&
-                            'at vertical urban surface and is ' //             &
-                            'decreased appropriately at grid point (i,j) = ',  &
-                            surf_usm_v(l)%i(m)+surf_usm_v(l)%ioff,             &
+                WRITE( message_string, * ) 'z0 exceeds surface-layer height '// &
+                            'at vertical urban surface and is ' //              &
+                            'decreased appropriately at grid point (i,j) = ',   &
+                            surf_usm_v(l)%i(m)+surf_usm_v(l)%ioff,              &
                             surf_usm_v(l)%j(m)+surf_usm_v(l)%joff
-                CALL message( 'urban_surface_model_mod', 'PA0503',             &
+                CALL message( 'urban_surface_model_mod', 'PA0503',              &
                             0, 0, 0, 6, 0 )
              ENDIF
@@ -5059,17 +5099,18 @@
                 surf_usm_v(l)%z0q(m) = 0.9_wp * surf_usm_v(l)%z_mo(m)
              
-                WRITE( message_string, * ) 'z0h exceeds surface-layer height '//&
-                            'at vertical urban surface and is ' //             &
-                            'decreased appropriately at grid point (i,j) = ',  &
-                            surf_usm_v(l)%i(m)+surf_usm_v(l)%ioff,             &
+                WRITE( message_string, * ) 'z0h exceeds surface-layer height '// &
+                            'at vertical urban surface and is ' //               &
+                            'decreased appropriately at grid point (i,j) = ',    &
+                            surf_usm_v(l)%i(m)+surf_usm_v(l)%ioff,               &
                             surf_usm_v(l)%j(m)+surf_usm_v(l)%joff
-                CALL message( 'urban_surface_model_mod', 'PA0507',             &
+                CALL message( 'urban_surface_model_mod', 'PA0507',               &
                             0, 0, 0, 6, 0 )
              ENDIF
           ENDDO
-       ENDDO    
-
+       ENDDO
+
+!
 !--     Intitialization of the surface and wall/ground/roof temperature
-
+!
 !--     Initialization for restart runs
         IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.        &
@@ -5117,5 +5158,5 @@
                ENDDO
             ENDIF
-      
+!
 !--         initial values for t_wall
 !--         outer value is set to surface temperature
@@ -5172,4 +5213,5 @@
         ENDIF
 
+!
 !--     If specified, replace constant wall temperatures with fully 3D values from file
         IF ( read_wall_temp_3d )  CALL usm_read_wall_temperature()
@@ -5179,4 +5221,5 @@
         CALL user_init_urban_surface
 
+!
 !--     initialize prognostic values for the first timestep
         t_surf_wall_h_p = t_surf_wall_h
@@ -5194,4 +5237,5 @@
         t_green_v_p = t_green_v
 
+!
 !--     Adjust radiative fluxes for urban surface at model start
         !CALL radiation_interaction
@@ -5201,5 +5245,4 @@
         m_liq_usm_h_p     = m_liq_usm_h
         m_liq_usm_v_p     = m_liq_usm_v
-!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 !
 !--    Set initial values for prognostic quantities
@@ -5230,9 +5273,8 @@
           ENDDO
        ENDIF
-!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++        
-
-       CALL cpu_log( log_point_s(78), 'usm_init', 'stop' )
-
-       CALL location_message( 'finished', .TRUE. )
+
+        CALL cpu_log( log_point_s(78), 'usm_init', 'stop' )
+
+        CALL location_message( 'finished', .TRUE. )
 
     END SUBROUTINE usm_init
@@ -5243,6 +5285,8 @@
 ! ------------
 !
-!> Wall model as part of the urban surface model. The model predicts wall
-!> temperature.
+!> Wall model as part of the urban surface model. The model predicts vertical
+!> and horizontal wall / roof temperatures and window layer temperatures.
+!> No window layer temperature calculactions during spinup to increase
+!> possible timestep.
 !------------------------------------------------------------------------------!
     SUBROUTINE usm_material_heat_model( spinup )
@@ -5254,15 +5298,15 @@
 
         REAL(wp), DIMENSION(nzb_wall:nzt_wall) :: wtend, wintend  !< tendency
-        REAL(wp)     :: win_absorp !absorption coefficient from transmissivity
+        REAL(wp)     :: win_absorp  !< absorption coefficient from transmissivity
         REAL(wp), DIMENSION(nzb_wall:nzt_wall) :: wall_mod
 
-        LOGICAL      :: spinup !if true, no calculation of window temperatures
+        LOGICAL      :: spinup  !< if true, no calculation of window temperatures
 
         wall_mod=1.0_wp
-        if (usm_wall_mod .AND. spinup) then
-          do kw=nzb_wall,nzb_wall+1
-            wall_mod(kw)=0.1_wp
-          enddo
-        endif
+        IF (usm_wall_mod .AND. spinup) THEN
+           DO  kw=nzb_wall,nzb_wall+1
+               wall_mod(kw)=0.1_wp
+           ENDDO
+        ENDIF
 
 !
@@ -5291,5 +5335,5 @@
                                          * ( surf_usm_h%lambda_h_green(nzt_wall,m)* wall_mod(nzt_wall) &
                                            * surf_usm_h%ddz_green(nzt_wall,m)      &
-                                           + surf_usm_h%lambda_h(nzb_wall,m) * wall_mod(nzb_wall)        &
+                                           + surf_usm_h%lambda_h(nzb_wall,m) * wall_mod(nzb_wall)      &
                                            * surf_usm_h%ddz_wall(nzb_wall,m) )     &
                                          / ( surf_usm_h%ddz_green(nzt_wall,m)      &
@@ -5298,12 +5342,13 @@
                                            - t_green_h(nzt_wall,m) ) ) *           &
                                        surf_usm_h%ddz_wall_stag(nzb_wall,m)
-
-           IF ( indoor_model ) then 
+!
+!-- if indoor model ist used inner wall layer is calculated by using iwghf (indoor wall ground heat flux)
+           IF ( indoor_model ) THEN 
               DO  kw = nzb_wall+1, nzt_wall-1
                   wtend(kw) = (1.0_wp / surf_usm_h%rho_c_wall(kw,m))              &
-                                 * (   surf_usm_h%lambda_h(kw,m) * wall_mod(kw)                 &
+                                 * (   surf_usm_h%lambda_h(kw,m) * wall_mod(kw)   &
                                     * ( t_wall_h(kw+1,m) - t_wall_h(kw,m) )       &
                                     * surf_usm_h%ddz_wall(kw+1,m)                 &
-                                 - surf_usm_h%lambda_h(kw-1,m) * wall_mod(kw-1)                     &
+                                 - surf_usm_h%lambda_h(kw-1,m) * wall_mod(kw-1)   &
                                     * ( t_wall_h(kw,m) - t_wall_h(kw-1,m) )       &
                                     * surf_usm_h%ddz_wall(kw,m)                   &
@@ -5311,5 +5356,5 @@
               ENDDO
               wtend(nzt_wall) = (1.0_wp / surf_usm_h%rho_c_wall(nzt_wall,m)) *    &
-                                         ( -surf_usm_h%lambda_h(nzt_wall-1,m) * wall_mod(nzt_wall-1) *     &
+                                         ( -surf_usm_h%lambda_h(nzt_wall-1,m) * wall_mod(nzt_wall-1) * &
                                            ( t_wall_h(nzt_wall,m)                 &
                                            - t_wall_h(nzt_wall-1,m) ) *           &
@@ -5320,8 +5365,8 @@
               DO  kw = nzb_wall+1, nzt_wall
                   wtend(kw) = (1.0_wp / surf_usm_h%rho_c_wall(kw,m))              &
-                                 * (   surf_usm_h%lambda_h(kw,m)  * wall_mod(kw)                &
+                                 * (   surf_usm_h%lambda_h(kw,m)  * wall_mod(kw)  &
                                     * ( t_wall_h(kw+1,m) - t_wall_h(kw,m) )       &
                                     * surf_usm_h%ddz_wall(kw+1,m)                 &
-                                 - surf_usm_h%lambda_h(kw-1,m) * wall_mod(kw-1)                   &
+                                 - surf_usm_h%lambda_h(kw-1,m) * wall_mod(kw-1)   &
                                     * ( t_wall_h(kw,m) - t_wall_h(kw-1,m) )       &
                                     * surf_usm_h%ddz_wall(kw,m)                   &
@@ -5335,73 +5380,77 @@
                                  * surf_usm_h%tt_wall_m(nzb_wall:nzt_wall,m) )   
 
-if (.NOT. spinup) then
-           win_absorp = -log(surf_usm_h%transmissivity(m)) / surf_usm_h%zw_window(nzt_wall,m)
-!--        prognostic equation for ground/roof window temperature t_window_h
-           wintend(:) = 0.0_wp
-           wintend(nzb_wall) = (1.0_wp / surf_usm_h%rho_c_window(nzb_wall,m)) *   &
-                                      ( surf_usm_h%lambda_h_window(nzb_wall,m) *  &
-                                        ( t_window_h(nzb_wall+1,m)                &
-                                        - t_window_h(nzb_wall,m) ) *              &
-                                        surf_usm_h%ddz_window(nzb_wall+1,m)       &
-                                      + surf_usm_h%wghf_eb_window(m)              &
-                                      + surf_usm_h%rad_sw_in(m)                   &
-                                        * (1.0_wp - exp(-win_absorp               &
-                                        * surf_usm_h%zw_window(nzb_wall,m) ) )    &
-                                      ) * surf_usm_h%ddz_window_stag(nzb_wall,m)
-
-           IF ( indoor_model ) then 
-              DO  kw = nzb_wall+1, nzt_wall-1
-                  wintend(kw) = (1.0_wp / surf_usm_h%rho_c_window(kw,m))          &
-                                 * (   surf_usm_h%lambda_h_window(kw,m)           &
-                                    * ( t_window_h(kw+1,m) - t_window_h(kw,m) )   &
-                                    * surf_usm_h%ddz_window(kw+1,m)               &
-                                 - surf_usm_h%lambda_h_window(kw-1,m)             &
-                                    * ( t_window_h(kw,m) - t_window_h(kw-1,m) )   &
-                                    * surf_usm_h%ddz_window(kw,m)                 &
-                                 + surf_usm_h%rad_sw_in(m)                        &
-                                    * (exp(-win_absorp                            &
-                                        * surf_usm_h%zw_window(kw-1,m) )          &
-                                        - exp(-win_absorp                         &
-                                        * surf_usm_h%zw_window(kw,m) ) )          &
-                                   ) * surf_usm_h%ddz_window_stag(kw,m)
-
-              ENDDO
-              wintend(nzt_wall) = (1.0_wp / surf_usm_h%rho_c_window(nzt_wall,m)) *       &
-                                         ( -surf_usm_h%lambda_h_window(nzt_wall-1,m) *   &
-                                           ( t_window_h(nzt_wall,m)                      &
-                                           - t_window_h(nzt_wall-1,m) ) *                &
-                                           surf_usm_h%ddz_window(nzt_wall,m)             &
-                                         + surf_usm_h%iwghf_eb_window(m)                 &
-                                         + surf_usm_h%rad_sw_in(m)                       &
-                                           * (exp(-win_absorp                            &
-                                           * surf_usm_h%zw_window(nzt_wall-1,m) )        &
-                                           - exp(-win_absorp                             &
-                                           * surf_usm_h%zw_window(nzt_wall,m) ) )        &
-                                         ) * surf_usm_h%ddz_window_stag(nzt_wall,m)
-           ELSE
-              DO  kw = nzb_wall+1, nzt_wall
-                  wintend(kw) = (1.0_wp / surf_usm_h%rho_c_window(kw,m))          &
-                                 * (   surf_usm_h%lambda_h_window(kw,m)           &
-                                    * ( t_window_h(kw+1,m) - t_window_h(kw,m) )   &
-                                    * surf_usm_h%ddz_window(kw+1,m)               &
-                                 - surf_usm_h%lambda_h_window(kw-1,m)             &
-                                    * ( t_window_h(kw,m) - t_window_h(kw-1,m) )   &
-                                    * surf_usm_h%ddz_window(kw,m)                 &
-                                 + surf_usm_h%rad_sw_in(m)                        &
-                                    * (exp(-win_absorp                            &
-                                        * surf_usm_h%zw_window(kw-1,m) )          &
-                                        - exp(-win_absorp                         &
-                                        * surf_usm_h%zw_window(kw,m) ) )          &
-                                   ) * surf_usm_h%ddz_window_stag(kw,m)
-
-              ENDDO
-           ENDIF
-
-           t_window_h_p(nzb_wall:nzt_wall,m) = t_window_h(nzb_wall:nzt_wall,m)    &
+!
+!-- during spinup the tempeature inside window layers is not calculated to make larger timesteps possible
+           IF ( .NOT. spinup) THEN
+              win_absorp = -log(surf_usm_h%transmissivity(m)) / surf_usm_h%zw_window(nzt_wall,m)
+!
+!--           prognostic equation for ground/roof window temperature t_window_h
+!--           takes absorption of shortwave radiation into account
+              wintend(:) = 0.0_wp
+              wintend(nzb_wall) = (1.0_wp / surf_usm_h%rho_c_window(nzb_wall,m)) *   &
+                                         ( surf_usm_h%lambda_h_window(nzb_wall,m) *  &
+                                           ( t_window_h(nzb_wall+1,m)                &
+                                           - t_window_h(nzb_wall,m) ) *              &
+                                           surf_usm_h%ddz_window(nzb_wall+1,m)       &
+                                         + surf_usm_h%wghf_eb_window(m)              &
+                                         + surf_usm_h%rad_sw_in(m)                   &
+                                           * (1.0_wp - exp(-win_absorp               &
+                                           * surf_usm_h%zw_window(nzb_wall,m) ) )    &
+                                         ) * surf_usm_h%ddz_window_stag(nzb_wall,m)
+   
+              IF ( indoor_model ) THEN 
+                 DO  kw = nzb_wall+1, nzt_wall-1
+                     wintend(kw) = (1.0_wp / surf_usm_h%rho_c_window(kw,m))          &
+                                    * (   surf_usm_h%lambda_h_window(kw,m)           &
+                                       * ( t_window_h(kw+1,m) - t_window_h(kw,m) )   &
+                                       * surf_usm_h%ddz_window(kw+1,m)               &
+                                    - surf_usm_h%lambda_h_window(kw-1,m)             &
+                                       * ( t_window_h(kw,m) - t_window_h(kw-1,m) )   &
+                                       * surf_usm_h%ddz_window(kw,m)                 &
+                                    + surf_usm_h%rad_sw_in(m)                        &
+                                       * (exp(-win_absorp                            &
+                                           * surf_usm_h%zw_window(kw-1,m) )          &
+                                           - exp(-win_absorp                         &
+                                           * surf_usm_h%zw_window(kw,m) ) )          &
+                                      ) * surf_usm_h%ddz_window_stag(kw,m)
+   
+                 ENDDO
+                 wintend(nzt_wall) = (1.0_wp / surf_usm_h%rho_c_window(nzt_wall,m)) *       &
+                                            ( -surf_usm_h%lambda_h_window(nzt_wall-1,m) *   &
+                                              ( t_window_h(nzt_wall,m)                      &
+                                              - t_window_h(nzt_wall-1,m) ) *                &
+                                              surf_usm_h%ddz_window(nzt_wall,m)             &
+                                            + surf_usm_h%iwghf_eb_window(m)                 &
+                                            + surf_usm_h%rad_sw_in(m)                       &
+                                              * (exp(-win_absorp                            &
+                                              * surf_usm_h%zw_window(nzt_wall-1,m) )        &
+                                              - exp(-win_absorp                             &
+                                              * surf_usm_h%zw_window(nzt_wall,m) ) )        &
+                                            ) * surf_usm_h%ddz_window_stag(nzt_wall,m)
+              ELSE
+                 DO  kw = nzb_wall+1, nzt_wall
+                     wintend(kw) = (1.0_wp / surf_usm_h%rho_c_window(kw,m))          &
+                                    * (   surf_usm_h%lambda_h_window(kw,m)           &
+                                       * ( t_window_h(kw+1,m) - t_window_h(kw,m) )   &
+                                       * surf_usm_h%ddz_window(kw+1,m)               &
+                                    - surf_usm_h%lambda_h_window(kw-1,m)             &
+                                       * ( t_window_h(kw,m) - t_window_h(kw-1,m) )   &
+                                       * surf_usm_h%ddz_window(kw,m)                 &
+                                    + surf_usm_h%rad_sw_in(m)                        &
+                                       * (exp(-win_absorp                            &
+                                           * surf_usm_h%zw_window(kw-1,m) )          &
+                                           - exp(-win_absorp                         &
+                                           * surf_usm_h%zw_window(kw,m) ) )          &
+                                      ) * surf_usm_h%ddz_window_stag(kw,m)
+   
+                 ENDDO
+              ENDIF
+
+              t_window_h_p(nzb_wall:nzt_wall,m) = t_window_h(nzb_wall:nzt_wall,m) &
                                  + dt_3d * ( tsc(2)                               &
                                  * wintend(nzb_wall:nzt_wall) + tsc(3)            &
                                  * surf_usm_h%tt_window_m(nzb_wall:nzt_wall,m) )   
 
-endif
+           ENDIF
 
 !
@@ -5421,21 +5470,21 @@
            ENDIF
 
-if (.NOT. spinup) then
-!--        calculate t_window tendencies for the next Runge-Kutta step
-           IF ( timestep_scheme(1:5) == 'runge' )  THEN
-               IF ( intermediate_timestep_count == 1 )  THEN
-                  DO  kw = nzb_wall, nzt_wall
-                     surf_usm_h%tt_window_m(kw,m) = wintend(kw)
-                  ENDDO
-               ELSEIF ( intermediate_timestep_count <                          &
-                        intermediate_timestep_count_max )  THEN
-                   DO  kw = nzb_wall, nzt_wall
-                      surf_usm_h%tt_window_m(kw,m) = -9.5625_wp * wintend(kw) +    &
-                                         5.3125_wp * surf_usm_h%tt_window_m(kw,m)
-                   ENDDO
-               ENDIF
+           IF (.NOT. spinup) THEN
+!
+!--           calculate t_window tendencies for the next Runge-Kutta step
+              IF ( timestep_scheme(1:5) == 'runge' )  THEN
+                  IF ( intermediate_timestep_count == 1 )  THEN
+                     DO  kw = nzb_wall, nzt_wall
+                        surf_usm_h%tt_window_m(kw,m) = wintend(kw)
+                     ENDDO
+                  ELSEIF ( intermediate_timestep_count <                            &
+                           intermediate_timestep_count_max )  THEN
+                      DO  kw = nzb_wall, nzt_wall
+                         surf_usm_h%tt_window_m(kw,m) = -9.5625_wp * wintend(kw) +  &
+                                            5.3125_wp * surf_usm_h%tt_window_m(kw,m)
+                      ENDDO
+                  ENDIF
+              ENDIF
            ENDIF
-
-endif
 
         ENDDO
@@ -5454,33 +5503,33 @@
               wtend(:) = 0.0_wp
 
-               wtend(nzb_wall) = (1.0_wp / surf_usm_v(l)%rho_c_wall(nzb_wall,m)) *    &
-                                       ( surf_usm_v(l)%lambda_h(nzb_wall,m) * wall_mod(nzb_wall)  *      &
-                                         ( t_wall_v(l)%t(nzb_wall+1,m)                &
-                                         - t_wall_v(l)%t(nzb_wall,m) ) *              &
-                                         surf_usm_v(l)%ddz_wall(nzb_wall+1,m)         &
-                                       + surf_usm_v(l)%frac(ind_veg_wall,m)           &
-                                         / (surf_usm_v(l)%frac(ind_veg_wall,m)        &
-                                           + surf_usm_v(l)%frac(ind_pav_green,m) )    &
-                                         * surf_usm_v(l)%wghf_eb(m)                   &
-                                       - surf_usm_v(l)%frac(ind_pav_green,m)          &
-                                         / (surf_usm_v(l)%frac(ind_veg_wall,m)        &
-                                           + surf_usm_v(l)%frac(ind_pav_green,m) )    &
-                                         * ( surf_usm_v(l)%lambda_h_green(nzt_wall,m)* wall_mod(nzt_wall) &
-                                           * surf_usm_v(l)%ddz_green(nzt_wall,m)      &
-                                           + surf_usm_v(l)%lambda_h(nzb_wall,m)* wall_mod(nzb_wall)       &
-                                           * surf_usm_v(l)%ddz_wall(nzb_wall,m) )     &
-                                         / ( surf_usm_v(l)%ddz_green(nzt_wall,m)      &
-                                           + surf_usm_v(l)%ddz_wall(nzb_wall,m) )     &
-                                         * ( t_wall_v(l)%t(nzb_wall,m)                &
-                                           - t_green_v(l)%t(nzt_wall,m) ) ) *         &
-                                         surf_usm_v(l)%ddz_wall_stag(nzb_wall,m)
-
-              IF ( indoor_model ) then 
+              wtend(nzb_wall) = (1.0_wp / surf_usm_v(l)%rho_c_wall(nzb_wall,m)) *    &
+                                      ( surf_usm_v(l)%lambda_h(nzb_wall,m) * wall_mod(nzb_wall)  *      &
+                                        ( t_wall_v(l)%t(nzb_wall+1,m)                &
+                                        - t_wall_v(l)%t(nzb_wall,m) ) *              &
+                                        surf_usm_v(l)%ddz_wall(nzb_wall+1,m)         &
+                                      + surf_usm_v(l)%frac(ind_veg_wall,m)           &
+                                        / (surf_usm_v(l)%frac(ind_veg_wall,m)        &
+                                          + surf_usm_v(l)%frac(ind_pav_green,m) )    &
+                                        * surf_usm_v(l)%wghf_eb(m)                   &
+                                      - surf_usm_v(l)%frac(ind_pav_green,m)          &
+                                        / (surf_usm_v(l)%frac(ind_veg_wall,m)        &
+                                          + surf_usm_v(l)%frac(ind_pav_green,m) )    &
+                                        * ( surf_usm_v(l)%lambda_h_green(nzt_wall,m)* wall_mod(nzt_wall) &
+                                          * surf_usm_v(l)%ddz_green(nzt_wall,m)      &
+                                          + surf_usm_v(l)%lambda_h(nzb_wall,m)* wall_mod(nzb_wall)       &
+                                          * surf_usm_v(l)%ddz_wall(nzb_wall,m) )     &
+                                        / ( surf_usm_v(l)%ddz_green(nzt_wall,m)      &
+                                          + surf_usm_v(l)%ddz_wall(nzb_wall,m) )     &
+                                        * ( t_wall_v(l)%t(nzb_wall,m)                &
+                                          - t_green_v(l)%t(nzt_wall,m) ) ) *         &
+                                        surf_usm_v(l)%ddz_wall_stag(nzb_wall,m)
+
+              IF ( indoor_model ) THEN 
                  DO  kw = nzb_wall+1, nzt_wall-1
                      wtend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_wall(kw,m))        &
-                              * (   surf_usm_v(l)%lambda_h(kw,m)  * wall_mod(kw)                &
+                              * (   surf_usm_v(l)%lambda_h(kw,m)  * wall_mod(kw)  &
                                  * ( t_wall_v(l)%t(kw+1,m) - t_wall_v(l)%t(kw,m) )&
                                  * surf_usm_v(l)%ddz_wall(kw+1,m)                 &
-                              - surf_usm_v(l)%lambda_h(kw-1,m)  * wall_mod(kw-1)                  &
+                              - surf_usm_v(l)%lambda_h(kw-1,m)  * wall_mod(kw-1)  &
                                  * ( t_wall_v(l)%t(kw,m) - t_wall_v(l)%t(kw-1,m) )&
                                  * surf_usm_v(l)%ddz_wall(kw,m)                   &
@@ -5497,8 +5546,8 @@
                  DO  kw = nzb_wall+1, nzt_wall
                      wtend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_wall(kw,m))        &
-                              * (   surf_usm_v(l)%lambda_h(kw,m) * wall_mod(kw)                 &
+                              * (   surf_usm_v(l)%lambda_h(kw,m) * wall_mod(kw)   &
                                  * ( t_wall_v(l)%t(kw+1,m) - t_wall_v(l)%t(kw,m) )&
                                  * surf_usm_v(l)%ddz_wall(kw+1,m)                 &
-                              - surf_usm_v(l)%lambda_h(kw-1,m)  * wall_mod(kw-1)                  &
+                              - surf_usm_v(l)%lambda_h(kw-1,m)  * wall_mod(kw-1)  &
                                  * ( t_wall_v(l)%t(kw,m) - t_wall_v(l)%t(kw-1,m) )&
                                  * surf_usm_v(l)%ddz_wall(kw,m)                   &
@@ -5513,71 +5562,72 @@
                                  * surf_usm_v(l)%tt_wall_m(nzb_wall:nzt_wall,m) )   
 
-if (.NOT. spinup) then
-              win_absorp = -log(surf_usm_v(l)%transmissivity(m)) / surf_usm_v(l)%zw_window(nzt_wall,m)
-!--           prognostic equation for window temperature t_window_v
-              wintend(:) = 0.0_wp
-              wintend(nzb_wall) = (1.0_wp / surf_usm_v(l)%rho_c_window(nzb_wall,m)) * &
-                                      ( surf_usm_v(l)%lambda_h_window(nzb_wall,m) *   &
-                                        ( t_window_v(l)%t(nzb_wall+1,m)               &
-                                        - t_window_v(l)%t(nzb_wall,m) ) *             &
-                                        surf_usm_v(l)%ddz_window(nzb_wall+1,m)        &
-                                      + surf_usm_v(l)%wghf_eb_window(m)               &
-                                      + surf_usm_v(l)%rad_sw_in(m)                    &
-                                        * (1.0_wp - exp(-win_absorp                   &
-                                        * surf_usm_v(l)%zw_window(nzb_wall,m) ) )     &
-                                      ) * surf_usm_v(l)%ddz_window_stag(nzb_wall,m)
-
-              IF ( indoor_model ) then 
-                 DO  kw = nzb_wall+1, nzt_wall -1
-                     wintend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_window(kw,m))         &
-                              * (   surf_usm_v(l)%lambda_h_window(kw,m)                &
-                                 * ( t_window_v(l)%t(kw+1,m) - t_window_v(l)%t(kw,m) ) &
-                                 * surf_usm_v(l)%ddz_window(kw+1,m)                    &
-                              - surf_usm_v(l)%lambda_h_window(kw-1,m)                  &
-                                 * ( t_window_v(l)%t(kw,m) - t_window_v(l)%t(kw-1,m) ) &
-                                 * surf_usm_v(l)%ddz_window(kw,m)                      &
-                              + surf_usm_v(l)%rad_sw_in(m)                             &
-                                 * (exp(-win_absorp                                    &
-                                    * surf_usm_v(l)%zw_window(kw-1,m)       )          &
-                                        - exp(-win_absorp                              &
-                                        * surf_usm_v(l)%zw_window(kw,m) ) )            &
-                                 ) * surf_usm_v(l)%ddz_window_stag(kw,m)
-                  ENDDO
-                  wintend(nzt_wall) = (1.0_wp / surf_usm_v(l)%rho_c_window(nzt_wall,m)) *  &
-                                          ( -surf_usm_v(l)%lambda_h_window(nzt_wall-1,m) * &
-                                            ( t_window_v(l)%t(nzt_wall,m)                  &
-                                            - t_window_v(l)%t(nzt_wall-1,m) ) *            &
-                                            surf_usm_v(l)%ddz_window(nzt_wall,m)           &
-                                          + surf_usm_v(l)%iwghf_eb_window(m)               &
-                                          + surf_usm_v(l)%rad_sw_in(m)                     &
-                                            * (exp(-win_absorp                             &
-                                          * surf_usm_v(l)%zw_window(nzt_wall-1,m) )        &
-                                        - exp(-win_absorp                                  &
-                                            * surf_usm_v(l)%zw_window(nzt_wall,m) ) )      &
-                                          ) * surf_usm_v(l)%ddz_window_stag(nzt_wall,m)
-              ELSE
-                 DO  kw = nzb_wall+1, nzt_wall
-                     wintend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_window(kw,m))         &
-                              * (   surf_usm_v(l)%lambda_h_window(kw,m)                &
-                                 * ( t_window_v(l)%t(kw+1,m) - t_window_v(l)%t(kw,m) ) &
-                                 * surf_usm_v(l)%ddz_window(kw+1,m)                    &
-                              - surf_usm_v(l)%lambda_h_window(kw-1,m)                  &
-                                 * ( t_window_v(l)%t(kw,m) - t_window_v(l)%t(kw-1,m) ) &
-                                 * surf_usm_v(l)%ddz_window(kw,m)                      &
-                              + surf_usm_v(l)%rad_sw_in(m)                             &
-                                 * (exp(-win_absorp                                    &
-                                    * surf_usm_v(l)%zw_window(kw-1,m)       )          &
-                                        - exp(-win_absorp                              &
-                                        * surf_usm_v(l)%zw_window(kw,m) ) )            &
-                                 ) * surf_usm_v(l)%ddz_window_stag(kw,m)
-                 ENDDO
+              IF (.NOT. spinup) THEN
+                 win_absorp = -log(surf_usm_v(l)%transmissivity(m)) / surf_usm_v(l)%zw_window(nzt_wall,m)
+!
+!--              prognostic equation for window temperature t_window_v
+                 wintend(:) = 0.0_wp
+                 wintend(nzb_wall) = (1.0_wp / surf_usm_v(l)%rho_c_window(nzb_wall,m)) * &
+                                         ( surf_usm_v(l)%lambda_h_window(nzb_wall,m) *   &
+                                           ( t_window_v(l)%t(nzb_wall+1,m)               &
+                                           - t_window_v(l)%t(nzb_wall,m) ) *             &
+                                           surf_usm_v(l)%ddz_window(nzb_wall+1,m)        &
+                                         + surf_usm_v(l)%wghf_eb_window(m)               &
+                                         + surf_usm_v(l)%rad_sw_in(m)                    &
+                                           * (1.0_wp - exp(-win_absorp                   &
+                                           * surf_usm_v(l)%zw_window(nzb_wall,m) ) )     &
+                                         ) * surf_usm_v(l)%ddz_window_stag(nzb_wall,m)
+   
+                 IF ( indoor_model ) THEN 
+                    DO  kw = nzb_wall+1, nzt_wall -1
+                        wintend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_window(kw,m))         &
+                                 * (   surf_usm_v(l)%lambda_h_window(kw,m)                &
+                                    * ( t_window_v(l)%t(kw+1,m) - t_window_v(l)%t(kw,m) ) &
+                                    * surf_usm_v(l)%ddz_window(kw+1,m)                    &
+                                 - surf_usm_v(l)%lambda_h_window(kw-1,m)                  &
+                                    * ( t_window_v(l)%t(kw,m) - t_window_v(l)%t(kw-1,m) ) &
+                                    * surf_usm_v(l)%ddz_window(kw,m)                      &
+                                 + surf_usm_v(l)%rad_sw_in(m)                             &
+                                    * (exp(-win_absorp                                    &
+                                       * surf_usm_v(l)%zw_window(kw-1,m)       )          &
+                                           - exp(-win_absorp                              &
+                                           * surf_usm_v(l)%zw_window(kw,m) ) )            &
+                                    ) * surf_usm_v(l)%ddz_window_stag(kw,m)
+                     ENDDO
+                     wintend(nzt_wall) = (1.0_wp / surf_usm_v(l)%rho_c_window(nzt_wall,m)) *  &
+                                             ( -surf_usm_v(l)%lambda_h_window(nzt_wall-1,m) * &
+                                               ( t_window_v(l)%t(nzt_wall,m)                  &
+                                               - t_window_v(l)%t(nzt_wall-1,m) ) *            &
+                                               surf_usm_v(l)%ddz_window(nzt_wall,m)           &
+                                             + surf_usm_v(l)%iwghf_eb_window(m)               &
+                                             + surf_usm_v(l)%rad_sw_in(m)                     &
+                                               * (exp(-win_absorp                             &
+                                             * surf_usm_v(l)%zw_window(nzt_wall-1,m) )        &
+                                           - exp(-win_absorp                                  &
+                                               * surf_usm_v(l)%zw_window(nzt_wall,m) ) )      &
+                                             ) * surf_usm_v(l)%ddz_window_stag(nzt_wall,m)
+                 ELSE
+                    DO  kw = nzb_wall+1, nzt_wall
+                        wintend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_window(kw,m))         &
+                                 * (   surf_usm_v(l)%lambda_h_window(kw,m)                &
+                                    * ( t_window_v(l)%t(kw+1,m) - t_window_v(l)%t(kw,m) ) &
+                                    * surf_usm_v(l)%ddz_window(kw+1,m)                    &
+                                 - surf_usm_v(l)%lambda_h_window(kw-1,m)                  &
+                                    * ( t_window_v(l)%t(kw,m) - t_window_v(l)%t(kw-1,m) ) &
+                                    * surf_usm_v(l)%ddz_window(kw,m)                      &
+                                 + surf_usm_v(l)%rad_sw_in(m)                             &
+                                    * (exp(-win_absorp                                    &
+                                       * surf_usm_v(l)%zw_window(kw-1,m)       )          &
+                                           - exp(-win_absorp                              &
+                                           * surf_usm_v(l)%zw_window(kw,m) ) )            &
+                                    ) * surf_usm_v(l)%ddz_window_stag(kw,m)
+                    ENDDO
+                 ENDIF
+   
+                 t_window_v_p(l)%t(nzb_wall:nzt_wall,m) =                           &
+                                      t_window_v(l)%t(nzb_wall:nzt_wall,m)          &
+                                    + dt_3d * ( tsc(2)                              &
+                                    * wintend(nzb_wall:nzt_wall) + tsc(3)           &
+                                    * surf_usm_v(l)%tt_window_m(nzb_wall:nzt_wall,m) )   
               ENDIF
-
-              t_window_v_p(l)%t(nzb_wall:nzt_wall,m) =                           &
-                                   t_window_v(l)%t(nzb_wall:nzt_wall,m)          &
-                                 + dt_3d * ( tsc(2)                              &
-                                 * wintend(nzb_wall:nzt_wall) + tsc(3)           &
-                                 * surf_usm_v(l)%tt_window_m(nzb_wall:nzt_wall,m) )   
-endif
 
 !
@@ -5599,21 +5649,22 @@
 
 
-if (.NOT. spinup) then
-!--           calculate t_window tendencies for the next Runge-Kutta step
-              IF ( timestep_scheme(1:5) == 'runge' )  THEN
-                  IF ( intermediate_timestep_count == 1 )  THEN
-                     DO  kw = nzb_wall, nzt_wall
-                        surf_usm_v(l)%tt_window_m(kw,m) = wintend(kw)
-                     ENDDO
-                  ELSEIF ( intermediate_timestep_count <                       &
-                           intermediate_timestep_count_max )  THEN
-                      DO  kw = nzb_wall, nzt_wall
-                         surf_usm_v(l)%tt_window_m(kw,m) =                     &
-                                     - 9.5625_wp * wintend(kw) +               &
-                                       5.3125_wp * surf_usm_v(l)%tt_window_m(kw,m)
-                      ENDDO
-                  ENDIF
+              IF (.NOT. spinup) THEN
+!
+!--              calculate t_window tendencies for the next Runge-Kutta step
+                 IF ( timestep_scheme(1:5) == 'runge' )  THEN
+                     IF ( intermediate_timestep_count == 1 )  THEN
+                        DO  kw = nzb_wall, nzt_wall
+                           surf_usm_v(l)%tt_window_m(kw,m) = wintend(kw)
+                        ENDDO
+                     ELSEIF ( intermediate_timestep_count <                       &
+                              intermediate_timestep_count_max )  THEN
+                         DO  kw = nzb_wall, nzt_wall
+                            surf_usm_v(l)%tt_window_m(kw,m) =                     &
+                                        - 9.5625_wp * wintend(kw) +               &
+                                          5.3125_wp * surf_usm_v(l)%tt_window_m(kw,m)
+                         ENDDO
+                     ENDIF
+                 ENDIF
               ENDIF
-endif
 
            ENDDO
@@ -5634,9 +5685,9 @@
         IMPLICIT NONE
 
-        INTEGER(iwp) ::  i,j,k,l,kw, m                      !< running indices
-
-        REAL(wp)     :: ke, lambda_h_green_sat
-        REAL(wp)     :: h_vg !< Van Genuchten coef. h
-        REAL(wp)     :: drho_l_lv
+        INTEGER(iwp) ::  i,j,k,l,kw, m              !< running indices
+
+        REAL(wp)     :: ke, lambda_h_green_sat      !< heat conductivity for saturated soil
+        REAL(wp)     :: h_vg                        !< Van Genuchten coef. h
+        REAL(wp)     :: drho_l_lv                   !< frequently used parameter
 
         REAL(wp), DIMENSION(nzb_wall:nzt_wall) :: gtend,tend  !< tendency
@@ -5644,6 +5695,6 @@
         REAL(wp), DIMENSION(nzb_wall:nzt_wall) :: root_extr_green
 
-        REAL(wp), DIMENSION(nzb_wall:nzt_wall+1) :: lambda_green_temp !< temp. lambda
-        REAL(wp), DIMENSION(nzb_wall:nzt_wall+1) :: gamma_green_temp !< temp. gamma
+        REAL(wp), DIMENSION(nzb_wall:nzt_wall+1) :: lambda_green_temp  !< temp. lambda
+        REAL(wp), DIMENSION(nzb_wall:nzt_wall+1) :: gamma_green_temp   !< temp. gamma
 
         LOGICAL :: conserve_water_content = .true.
@@ -5656,318 +5707,318 @@
         DO  m = 1, surf_usm_h%ns
 
-if (surf_usm_h%frac(ind_pav_green,m).gt.0.0_wp) then
-!
-!--        Obtain indices
-           i = surf_usm_h%i(m)            
-           j = surf_usm_h%j(m)
-           k = surf_usm_h%k(m)
-
-           DO  kw = nzb_wall, nzt_wall
-!
-!--           Calculate volumetric heat capacity of the soil, taking 
-!--           into account water content 
-              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)) &
-                                   + rho_c_water * swc_h(kw,m))
+           IF (surf_usm_h%frac(ind_pav_green,m) > 0.0_wp) THEN
+!
+!--           Obtain indices
+              i = surf_usm_h%i(m)            
+              j = surf_usm_h%j(m)
+              k = surf_usm_h%k(m)
    
-!
-!--           Calculate soil heat conductivity at the center of the soil
-!--           layers
-              lambda_h_green_sat = lambda_h_green_sm ** (1.0_wp - swc_sat_h(kw,m)) *    &
-                             lambda_h_water ** swc_h(kw,m)
+              DO  kw = nzb_wall, nzt_wall
+!
+!--              Calculate volumetric heat capacity of the soil, taking 
+!--              into account water content 
+                 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)) &
+                                      + rho_c_water * swc_h(kw,m))
+      
+!
+!--              Calculate soil heat conductivity at the center of the soil
+!--              layers
+                 lambda_h_green_sat = lambda_h_green_sm ** (1.0_wp - swc_sat_h(kw,m)) *    &
+                                lambda_h_water ** swc_h(kw,m)
+      
+                 ke = 1.0_wp + LOG10(MAX(0.1_wp,swc_h(kw,m)             &
+                      / swc_sat_h(kw,m)))
+      
+                 lambda_green_temp(kw) = ke * (lambda_h_green_sat - lambda_h_green_dry) +    &
+                                  lambda_h_green_dry
    
-              ke = 1.0_wp + LOG10(MAX(0.1_wp,swc_h(kw,m)             &
-                   / swc_sat_h(kw,m)))
+              ENDDO
    
-              lambda_green_temp(kw) = ke * (lambda_h_green_sat - lambda_h_green_dry) +    &
-                               lambda_h_green_dry
-
-           ENDDO
-
-
-!
-!--        Calculate soil heat conductivity (lambda_h) at the _stag level 
-!--        using linear interpolation. For pavement surface, the
-!--        true pavement depth is considered
-           DO  kw = nzb_wall, nzt_wall
-             surf_usm_h%lambda_h_green(kw,m) = ( lambda_green_temp(kw+1) + lambda_green_temp(kw) )  &
-                                   * 0.5_wp
-           ENDDO
-!           surf_usm_h%lambda_h_green(nzt_wall+1,m) = lambda_green_temp(nzt_wall+1)           
-!--------------------------------------------------------------------------
-           
-           t_green_h(nzt_wall+1,m) = t_wall_h(nzb_wall,m)
+   
+!
+!--           Calculate soil heat conductivity (lambda_h) at the _stag level 
+!--           using linear interpolation. For pavement surface, the
+!--           true pavement depth is considered
+              DO  kw = nzb_wall, nzt_wall
+                surf_usm_h%lambda_h_green(kw,m) = ( lambda_green_temp(kw+1) + lambda_green_temp(kw) )  &
+                                      * 0.5_wp
+              ENDDO
+
+              t_green_h(nzt_wall+1,m) = t_wall_h(nzb_wall,m)
 !
 !--        prognostic equation for ground/roof temperature t_green_h
-           gtend(:) = 0.0_wp
-           gtend(nzb_wall) = (1.0_wp / surf_usm_h%rho_c_total_green(nzb_wall,m)) *    &
-                                      ( surf_usm_h%lambda_h_green(nzb_wall,m) * &
-                                        ( t_green_h(nzb_wall+1,m)               &
-                                        - t_green_h(nzb_wall,m) ) *             &
-                                        surf_usm_h%ddz_green(nzb_wall+1,m)      &
-                                      + surf_usm_h%wghf_eb_green(m) ) *         &
-                                        surf_usm_h%ddz_green_stag(nzb_wall,m)
-           
-            DO  kw = nzb_wall+1, nzt_wall
-                gtend(kw) = (1.0_wp / surf_usm_h%rho_c_total_green(kw,m))             &
-                               * (   surf_usm_h%lambda_h_green(kw,m)            &
-                                  * ( t_green_h(kw+1,m) - t_green_h(kw,m) )     &
-                                  * surf_usm_h%ddz_green(kw+1,m)                &
-                               - surf_usm_h%lambda_h_green(kw-1,m)              &
-                                  * ( t_green_h(kw,m) - t_green_h(kw-1,m) )     &
-                                  * surf_usm_h%ddz_green(kw,m)                  &
-                                 ) * surf_usm_h%ddz_green_stag(kw,m)
-            ENDDO
-
-           t_green_h_p(nzb_wall:nzt_wall,m) = t_green_h(nzb_wall:nzt_wall,m)    &
-                                 + dt_3d * ( tsc(2)                             &
-                                 * gtend(nzb_wall:nzt_wall) + tsc(3)            &
-                                 * surf_usm_h%tt_green_m(nzb_wall:nzt_wall,m) )   
-
-          
+              gtend(:) = 0.0_wp
+              gtend(nzb_wall) = (1.0_wp / surf_usm_h%rho_c_total_green(nzb_wall,m)) *    &
+                                         ( surf_usm_h%lambda_h_green(nzb_wall,m) * &
+                                           ( t_green_h(nzb_wall+1,m)               &
+                                           - t_green_h(nzb_wall,m) ) *             &
+                                           surf_usm_h%ddz_green(nzb_wall+1,m)      &
+                                         + surf_usm_h%wghf_eb_green(m) ) *         &
+                                           surf_usm_h%ddz_green_stag(nzb_wall,m)
+              
+               DO  kw = nzb_wall+1, nzt_wall
+                   gtend(kw) = (1.0_wp / surf_usm_h%rho_c_total_green(kw,m))       &
+                                  * (   surf_usm_h%lambda_h_green(kw,m)            &
+                                     * ( t_green_h(kw+1,m) - t_green_h(kw,m) )     &
+                                     * surf_usm_h%ddz_green(kw+1,m)                &
+                                  - surf_usm_h%lambda_h_green(kw-1,m)              &
+                                     * ( t_green_h(kw,m) - t_green_h(kw-1,m) )     &
+                                     * surf_usm_h%ddz_green(kw,m)                  &
+                                    ) * surf_usm_h%ddz_green_stag(kw,m)
+               ENDDO
+   
+              t_green_h_p(nzb_wall:nzt_wall,m) = t_green_h(nzb_wall:nzt_wall,m)    &
+                                    + dt_3d * ( tsc(2)                             &
+                                    * gtend(nzb_wall:nzt_wall) + tsc(3)            &
+                                    * surf_usm_h%tt_green_m(nzb_wall:nzt_wall,m) )   
+   
+             
 !
 !--        calculate t_green tendencies for the next Runge-Kutta step
-           IF ( timestep_scheme(1:5) == 'runge' )  THEN
-               IF ( intermediate_timestep_count == 1 )  THEN
-                  DO  kw = nzb_wall, nzt_wall
-                     surf_usm_h%tt_green_m(kw,m) = gtend(kw)
-                  ENDDO
-               ELSEIF ( intermediate_timestep_count <                           &
-                        intermediate_timestep_count_max )  THEN
-                   DO  kw = nzb_wall, nzt_wall
-                      surf_usm_h%tt_green_m(kw,m) = -9.5625_wp * gtend(kw) +    &
-                                         5.3125_wp * surf_usm_h%tt_green_m(kw,m)
-                   ENDDO
-               ENDIF
-           ENDIF
-
-!--------------------------------------------------------------
-                DO  kw = nzb_wall, nzt_wall
-
-!
-!--                Calculate soil diffusivity at the center of the soil layers
-                   lambda_green_temp(kw) = (- b_ch * surf_usm_h%gamma_w_green_sat(kw,m) * psi_sat       &
-                                     / swc_sat_h(kw,m) ) * ( MAX( swc_h(kw,m),    &
-                                     wilt_h(kw,m) ) / swc_sat_h(kw,m) )**(           &
-                                     b_ch + 2.0_wp )
-
-!
-!--                Parametrization of Van Genuchten
-                   IF ( soil_type /= 7 )  THEN
-!
-!--                   Calculate the hydraulic conductivity after Van Genuchten 
-!--                   (1980)
-                      h_vg = ( ( (swc_res_h(kw,m) - swc_sat_h(kw,m)) / ( swc_res_h(kw,m) -    &
-                                 MAX( swc_h(kw,m), wilt_h(kw,m) ) ) )**(      &
-                                 surf_usm_h%n_vg_green(m) / (surf_usm_h%n_vg_green(m) - 1.0_wp ) ) - 1.0_wp  &
-                             )**( 1.0_wp / surf_usm_h%n_vg_green(m) ) / surf_usm_h%alpha_vg_green(m)
-
-
-                      gamma_green_temp(kw) = surf_usm_h%gamma_w_green_sat(kw,m) * ( ( (1.0_wp +         &
-                                      ( surf_usm_h%alpha_vg_green(m) * h_vg )**surf_usm_h%n_vg_green(m))**(  &
-                                      1.0_wp - 1.0_wp / surf_usm_h%n_vg_green(m) ) - (        &
-                                      surf_usm_h%alpha_vg_green(m) * h_vg )**( surf_usm_h%n_vg_green(m)      &
-                                      - 1.0_wp) )**2 )                         &
-                                      / ( ( 1.0_wp + ( surf_usm_h%alpha_vg_green(m) * h_vg    &
-                                      )**surf_usm_h%n_vg_green(m) )**( ( 1.0_wp  - 1.0_wp     &
-                                      / surf_usm_h%n_vg_green(m) ) *( surf_usm_h%l_vg_green(m) + 2.0_wp) ) )
-
-!
-!--                Parametrization of Clapp & Hornberger
-                   ELSE
-                      gamma_green_temp(kw) = surf_usm_h%gamma_w_green_sat(kw,m) * ( swc_h(kw,m)       &
-                                      / swc_sat_h(kw,m) )**(2.0_wp * b_ch + 3.0_wp)
-                   ENDIF
-
-                ENDDO
-
-!
-!--             Prognostic equation for soil moisture content. Only performed,
-!--             when humidity is enabled in the atmosphere
-                IF ( humidity )  THEN
-!
-!--                Calculate soil diffusivity (lambda_w) at the _stag level 
-!--                using linear interpolation. To do: replace this with
-!--                ECMWF-IFS Eq. 8.81
-                   DO  kw = nzb_wall, nzt_wall-1
-                     
-                      surf_usm_h%lambda_w_green(kw,m) = ( lambda_green_temp(kw+1) + lambda_green_temp(kw) )  &
-                                        * 0.5_wp
-                      surf_usm_h%gamma_w_green(kw,m)  = ( gamma_green_temp(kw+1) + gamma_green_temp(kw) )    &
-                                        * 0.5_wp
-
-                   ENDDO
-
-!
-!
-!--                In case of a closed bottom (= water content is conserved), 
-!--                set hydraulic conductivity to zero to that no water will be 
-!--                lost in the bottom layer.
-                   IF ( conserve_water_content )  THEN
-                      surf_usm_h%gamma_w_green(kw,m) = 0.0_wp
-                   ELSE
-                      surf_usm_h%gamma_w_green(kw,m) = gamma_green_temp(nzt_wall)
-                   ENDIF     
-
-!--                The root extraction (= root_extr * qsws_veg / (rho_l     
-!--                * l_v)) ensures the mass conservation for water. The         
-!--                transpiration of plants equals the cumulative withdrawals by 
-!--                the roots in the soil. The scheme takes into account the 
-!--                availability of water in the soil layers as well as the root 
-!--                fraction in the respective layer. Layer with moisture below 
-!--                wilting point will not contribute, which reflects the 
-!--                preference of plants to take water from moister layers.
-
-!
-!--                Calculate the root extraction (ECMWF 7.69, the sum of 
-!--                root_extr = 1). The energy balance solver guarantees a 
-!--                positive transpiration, so that there is no need for an 
-!--                additional check.
-                   m_total = 0.0_wp
-                   DO  kw = nzb_wall, nzt_wall
-                       IF ( swc_h(kw,m) > wilt_h(kw,m) )  THEN
-                          m_total = m_total + rootfr_h(kw,m) * swc_h(kw,m)
-                       ENDIF
-                   ENDDO  
-
-                   IF ( m_total > 0.0_wp )  THEN
-                      DO  kw = nzb_wall, nzt_wall
-                         IF ( swc_h(kw,m) > wilt_h(kw,m) )  THEN
-                            root_extr_green(kw) = rootfr_h(kw,m) * swc_h(kw,m)      &
-                                                            / m_total
-                         ELSE
-                            root_extr_green(kw) = 0.0_wp
-                         ENDIF
-                      ENDDO
-                   ENDIF
-
-!
-!--                Prognostic equation for soil water content m_soil.
-                   tend(:) = 0.0_wp
-
-                   tend(nzb_wall) = ( surf_usm_h%lambda_w_green(nzb_wall,m) * (               &
-                            swc_h(nzb_wall+1,m) - swc_h(nzb_wall,m) )    &
-                            * surf_usm_h%ddz_green(nzb_wall+1,m) - surf_usm_h%gamma_w_green(nzb_wall,m) - ( &
-                               root_extr_green(nzb_wall) * surf_usm_h%qsws_veg(m)          &
-!                                + surf_usm_h%qsws_soil_green(m)
-                                  ) * drho_l_lv )             &
-                                 * surf_usm_h%ddz_green_stag(nzb_wall,m)
-
-                   DO  kw = nzb_wall+1, nzt_wall-1
-                      tend(kw) = ( surf_usm_h%lambda_w_green(kw,m) * ( swc_h(kw+1,m)          &
-                                - swc_h(kw,m) ) * surf_usm_h%ddz_green(kw+1,m)              &
-                                - surf_usm_h%gamma_w_green(kw,m)                               &
-                                - surf_usm_h%lambda_w_green(kw-1,m) * (swc_h(kw,m) -         &
-                                swc_h(kw-1,m)) * surf_usm_h%ddz_green(kw,m)                 &
-                                + surf_usm_h%gamma_w_green(kw-1,m) - (root_extr_green(kw)             &
-                                * surf_usm_h%qsws_veg(m) * drho_l_lv)                &
-                                ) * surf_usm_h%ddz_green_stag(kw,m)
-
-                   ENDDO
-                   tend(nzt_wall) = ( - surf_usm_h%gamma_w_green(nzt_wall,m)                  &
-                                           - surf_usm_h%lambda_w_green(nzt_wall-1,m)          &
-                                           * (swc_h(nzt_wall,m)             &
-                                           - swc_h(nzt_wall-1,m))           &
-                                           * surf_usm_h%ddz_green(nzt_wall,m)                &
-                                           + surf_usm_h%gamma_w_green(nzt_wall-1,m) - (       &
-                                             root_extr_green(nzt_wall)               &
-                                           * surf_usm_h%qsws_veg(m) * drho_l_lv  )   &
-                                     ) * surf_usm_h%ddz_green_stag(nzt_wall,m)             
-
-                   swc_h_p(nzb_wall:nzt_wall,m) = swc_h(nzb_wall:nzt_wall,m)&
-                                                   + dt_3d * ( tsc(2) * tend(:)   &
-                                                   + tsc(3) * surf_usm_h%tswc_h_m(:,m) )   
-   
-!
-!--                Account for dry soils (find a better solution here!)
-                   DO  kw = nzb_wall, nzt_wall
-                      IF ( swc_h_p(kw,m) < 0.0_wp )  swc_h_p(kw,m) = 0.0_wp
-                   ENDDO
-
-!
-!--                Calculate m_soil tendencies for the next Runge-Kutta step
-                   IF ( timestep_scheme(1:5) == 'runge' )  THEN
-                      IF ( intermediate_timestep_count == 1 )  THEN
-                         DO  kw = nzb_wall, nzt_wall
-                            surf_usm_h%tswc_h_m(kw,m) = tend(kw)
-                         ENDDO
-                      ELSEIF ( intermediate_timestep_count <                   &
-                               intermediate_timestep_count_max )  THEN
-                         DO  kw = nzb_wall, nzt_wall
-                            surf_usm_h%tswc_h_m(kw,m) = -9.5625_wp * tend(kw) + 5.3125_wp&
-                                     * surf_usm_h%tswc_h_m(kw,m)
-                         ENDDO
-                      ENDIF
-                   ENDIF
-                ENDIF
-!--------------------------------------------------------------
-ENDIF
-           
-        ENDDO
-
-!
-!--     For vertical surfaces     
-        DO  l = 0, 3                              
-           DO  m = 1, surf_usm_v(l)%ns
-
-if (surf_usm_v(l)%frac(ind_pav_green,m).gt.0.0_wp) then
-  if (1.gt.2) then
-!
-!--           Obtain indices
-              i = surf_usm_v(l)%i(m)            
-              j = surf_usm_v(l)%j(m)
-              k = surf_usm_v(l)%k(m)
-
-              t_green_v(l)%t(nzt_wall+1,m) = t_wall_v(l)%t(nzb_wall,m)
-!
-!--           prognostic equation for green temperature t_green_v
-              gtend(:) = 0.0_wp
-              gtend(nzb_wall) = (1.0_wp / surf_usm_v(l)%rho_c_green(nzb_wall,m)) * &
-                                      ( surf_usm_v(l)%lambda_h_green(nzb_wall,m) * &
-                                        ( t_green_v(l)%t(nzb_wall+1,m)             &
-                                        - t_green_v(l)%t(nzb_wall,m) ) *           &
-                                        surf_usm_v(l)%ddz_green(nzb_wall+1,m)      &
-                                      + surf_usm_v(l)%wghf_eb(m) ) *               &
-                                        surf_usm_v(l)%ddz_green_stag(nzb_wall,m)
-            
-              DO  kw = nzb_wall+1, nzt_wall
-                 gtend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_green(kw,m))          &
-                           * (   surf_usm_v(l)%lambda_h_green(kw,m)              &
-                             * ( t_green_v(l)%t(kw+1,m) - t_green_v(l)%t(kw,m) ) &
-                             * surf_usm_v(l)%ddz_green(kw+1,m)                   &
-                           - surf_usm_v(l)%lambda_h(kw-1,m)                      &
-                             * ( t_green_v(l)%t(kw,m) - t_green_v(l)%t(kw-1,m) ) &
-                             * surf_usm_v(l)%ddz_green(kw,m) )                   &
-                           * surf_usm_v(l)%ddz_green_stag(kw,m)
-              ENDDO
-
-              t_green_v_p(l)%t(nzb_wall:nzt_wall,m) =                              &
-                                   t_green_v(l)%t(nzb_wall:nzt_wall,m)             &
-                                 + dt_3d * ( tsc(2)                                &
-                                 * gtend(nzb_wall:nzt_wall) + tsc(3)               &
-                                 * surf_usm_v(l)%tt_green_m(nzb_wall:nzt_wall,m) )   
-
-!
-!--           calculate t_green tendencies for the next Runge-Kutta step
               IF ( timestep_scheme(1:5) == 'runge' )  THEN
                   IF ( intermediate_timestep_count == 1 )  THEN
                      DO  kw = nzb_wall, nzt_wall
-                        surf_usm_v(l)%tt_green_m(kw,m) = gtend(kw)
+                        surf_usm_h%tt_green_m(kw,m) = gtend(kw)
                      ENDDO
                   ELSEIF ( intermediate_timestep_count <                           &
                            intermediate_timestep_count_max )  THEN
                       DO  kw = nzb_wall, nzt_wall
-                         surf_usm_v(l)%tt_green_m(kw,m) =                          &
-                                     - 9.5625_wp * gtend(kw) +                     &
-                                       5.3125_wp * surf_usm_v(l)%tt_green_m(kw,m)
+                         surf_usm_h%tt_green_m(kw,m) = -9.5625_wp * gtend(kw) +    &
+                                            5.3125_wp * surf_usm_h%tt_green_m(kw,m)
                       ENDDO
                   ENDIF
               ENDIF
-endif
-
-DO  kw = nzb_wall, nzt_wall+1
-t_green_v(l)%t(kw,m) = t_wall_v(l)%t(nzb_wall,m)
-ENDDO
+
+              DO  kw = nzb_wall, nzt_wall
+
+!
+!--              Calculate soil diffusivity at the center of the soil layers
+                 lambda_green_temp(kw) = (- b_ch * surf_usm_h%gamma_w_green_sat(kw,m) * psi_sat       &
+                                   / swc_sat_h(kw,m) ) * ( MAX( swc_h(kw,m),    &
+                                   wilt_h(kw,m) ) / swc_sat_h(kw,m) )**(        &
+                                   b_ch + 2.0_wp )
+
+!
+!--              Parametrization of Van Genuchten
+                 IF ( soil_type /= 7 )  THEN
+!
+!--                 Calculate the hydraulic conductivity after Van Genuchten 
+!--                 (1980)
+                    h_vg = ( ( (swc_res_h(kw,m) - swc_sat_h(kw,m)) / ( swc_res_h(kw,m) -    &
+                               MAX( swc_h(kw,m), wilt_h(kw,m) ) ) )**(      &
+                               surf_usm_h%n_vg_green(m) / (surf_usm_h%n_vg_green(m) - 1.0_wp ) ) - 1.0_wp  &
+                           )**( 1.0_wp / surf_usm_h%n_vg_green(m) ) / surf_usm_h%alpha_vg_green(m)
+
+
+                    gamma_green_temp(kw) = surf_usm_h%gamma_w_green_sat(kw,m) * ( ( (1.0_wp +         &
+                                    ( surf_usm_h%alpha_vg_green(m) * h_vg )**surf_usm_h%n_vg_green(m))**(  &
+                                    1.0_wp - 1.0_wp / surf_usm_h%n_vg_green(m) ) - (        &
+                                    surf_usm_h%alpha_vg_green(m) * h_vg )**( surf_usm_h%n_vg_green(m)      &
+                                    - 1.0_wp) )**2 )                         &
+                                    / ( ( 1.0_wp + ( surf_usm_h%alpha_vg_green(m) * h_vg    &
+                                    )**surf_usm_h%n_vg_green(m) )**( ( 1.0_wp  - 1.0_wp     &
+                                    / surf_usm_h%n_vg_green(m) ) *( surf_usm_h%l_vg_green(m) + 2.0_wp) ) )
+
+!
+!--              Parametrization of Clapp & Hornberger
+                 ELSE
+                    gamma_green_temp(kw) = surf_usm_h%gamma_w_green_sat(kw,m) * ( swc_h(kw,m)       &
+                                    / swc_sat_h(kw,m) )**(2.0_wp * b_ch + 3.0_wp)
+                 ENDIF
+
+              ENDDO
+
+!
+!--           Prognostic equation for soil moisture content. Only performed,
+!--           when humidity is enabled in the atmosphere
+              IF ( humidity )  THEN
+!
+!--              Calculate soil diffusivity (lambda_w) at the _stag level 
+!--              using linear interpolation. To do: replace this with
+!--              ECMWF-IFS Eq. 8.81
+                 DO  kw = nzb_wall, nzt_wall-1
+                   
+                    surf_usm_h%lambda_w_green(kw,m) = ( lambda_green_temp(kw+1) + lambda_green_temp(kw) )  &
+                                      * 0.5_wp
+                    surf_usm_h%gamma_w_green(kw,m)  = ( gamma_green_temp(kw+1) + gamma_green_temp(kw) )    &
+                                      * 0.5_wp
+
+                 ENDDO
+
+!
+!--              In case of a closed bottom (= water content is conserved), 
+!--              set hydraulic conductivity to zero to that no water will be 
+!--              lost in the bottom layer.
+                 IF ( conserve_water_content )  THEN
+                    surf_usm_h%gamma_w_green(kw,m) = 0.0_wp
+                 ELSE
+                    surf_usm_h%gamma_w_green(kw,m) = gamma_green_temp(nzt_wall)
+                 ENDIF     
+
+!--              The root extraction (= root_extr * qsws_veg / (rho_l     
+!--              * l_v)) ensures the mass conservation for water. The         
+!--              transpiration of plants equals the cumulative withdrawals by 
+!--              the roots in the soil. The scheme takes into account the 
+!--              availability of water in the soil layers as well as the root 
+!--              fraction in the respective layer. Layer with moisture below 
+!--              wilting point will not contribute, which reflects the 
+!--              preference of plants to take water from moister layers.
+
+!
+!--              Calculate the root extraction (ECMWF 7.69, the sum of 
+!--              root_extr = 1). The energy balance solver guarantees a 
+!--              positive transpiration, so that there is no need for an 
+!--              additional check.
+                 m_total = 0.0_wp
+                 DO  kw = nzb_wall, nzt_wall
+                     IF ( swc_h(kw,m) > wilt_h(kw,m) )  THEN
+                        m_total = m_total + rootfr_h(kw,m) * swc_h(kw,m)
+                     ENDIF
+                 ENDDO  
+
+                 IF ( m_total > 0.0_wp )  THEN
+                    DO  kw = nzb_wall, nzt_wall
+                       IF ( swc_h(kw,m) > wilt_h(kw,m) )  THEN
+                          root_extr_green(kw) = rootfr_h(kw,m) * swc_h(kw,m)      &
+                                                          / m_total
+                       ELSE
+                          root_extr_green(kw) = 0.0_wp
+                       ENDIF
+                    ENDDO
+                 ENDIF
+
+!
+!--              Prognostic equation for soil water content m_soil.
+                 tend(:) = 0.0_wp
+
+                 tend(nzb_wall) = ( surf_usm_h%lambda_w_green(nzb_wall,m) * (            &
+                          swc_h(nzb_wall+1,m) - swc_h(nzb_wall,m) )    &
+                          * surf_usm_h%ddz_green(nzb_wall+1,m) - surf_usm_h%gamma_w_green(nzb_wall,m) - ( &
+                             root_extr_green(nzb_wall) * surf_usm_h%qsws_veg(m)          &
+!                                + surf_usm_h%qsws_soil_green(m)
+                                ) * drho_l_lv )             &
+                               * surf_usm_h%ddz_green_stag(nzb_wall,m)
+
+                 DO  kw = nzb_wall+1, nzt_wall-1
+                    tend(kw) = ( surf_usm_h%lambda_w_green(kw,m) * ( swc_h(kw+1,m)        &
+                              - swc_h(kw,m) ) * surf_usm_h%ddz_green(kw+1,m)              &
+                              - surf_usm_h%gamma_w_green(kw,m)                            &
+                              - surf_usm_h%lambda_w_green(kw-1,m) * (swc_h(kw,m) -        &
+                              swc_h(kw-1,m)) * surf_usm_h%ddz_green(kw,m)                 &
+                              + surf_usm_h%gamma_w_green(kw-1,m) - (root_extr_green(kw)   &
+                              * surf_usm_h%qsws_veg(m) * drho_l_lv)                       &
+                              ) * surf_usm_h%ddz_green_stag(kw,m)
+
+                 ENDDO
+                 tend(nzt_wall) = ( - surf_usm_h%gamma_w_green(nzt_wall,m)                  &
+                                         - surf_usm_h%lambda_w_green(nzt_wall-1,m)          &
+                                         * (swc_h(nzt_wall,m)             &
+                                         - swc_h(nzt_wall-1,m))           &
+                                         * surf_usm_h%ddz_green(nzt_wall,m)                 &
+                                         + surf_usm_h%gamma_w_green(nzt_wall-1,m) - (       &
+                                           root_extr_green(nzt_wall)               &
+                                         * surf_usm_h%qsws_veg(m) * drho_l_lv  )   &
+                                   ) * surf_usm_h%ddz_green_stag(nzt_wall,m)             
+
+                 swc_h_p(nzb_wall:nzt_wall,m) = swc_h(nzb_wall:nzt_wall,m)&
+                                                 + dt_3d * ( tsc(2) * tend(:)   &
+                                                 + tsc(3) * surf_usm_h%tswc_h_m(:,m) )   
+ 
+!
+!--              Account for dry soils (find a better solution here!)
+                 DO  kw = nzb_wall, nzt_wall
+                    IF ( swc_h_p(kw,m) < 0.0_wp )  swc_h_p(kw,m) = 0.0_wp
+                 ENDDO
+
+!
+!--              Calculate m_soil tendencies for the next Runge-Kutta step
+                 IF ( timestep_scheme(1:5) == 'runge' )  THEN
+                    IF ( intermediate_timestep_count == 1 )  THEN
+                       DO  kw = nzb_wall, nzt_wall
+                          surf_usm_h%tswc_h_m(kw,m) = tend(kw)
+                       ENDDO
+                    ELSEIF ( intermediate_timestep_count <                   &
+                             intermediate_timestep_count_max )  THEN
+                       DO  kw = nzb_wall, nzt_wall
+                          surf_usm_h%tswc_h_m(kw,m) = -9.5625_wp * tend(kw) + 5.3125_wp&
+                                   * surf_usm_h%tswc_h_m(kw,m)
+                       ENDDO
+                    ENDIF
+                 ENDIF
+              ENDIF
+
+           ENDIF
+           
+        ENDDO
+
+!
+!--     For vertical surfaces     
+        DO  l = 0, 3                              
+           DO  m = 1, surf_usm_v(l)%ns
+
+              IF (surf_usm_v(l)%frac(ind_pav_green,m) > 0.0_wp) THEN
+!
+!-- no substrate layer for green walls / only groundbase green walls (ivy i.e.) -> green layers get same
+!-- temperature as first wall layer
+!-- there fore no temperature calculations for vertical green substrate layers now
+
+! 
+! !
+! !--              Obtain indices
+!                  i = surf_usm_v(l)%i(m)            
+!                  j = surf_usm_v(l)%j(m)
+!                  k = surf_usm_v(l)%k(m)
+!    
+!                  t_green_v(l)%t(nzt_wall+1,m) = t_wall_v(l)%t(nzb_wall,m)
+! !
+! !--              prognostic equation for green temperature t_green_v
+!                  gtend(:) = 0.0_wp
+!                  gtend(nzb_wall) = (1.0_wp / surf_usm_v(l)%rho_c_green(nzb_wall,m)) * &
+!                                          ( surf_usm_v(l)%lambda_h_green(nzb_wall,m) * &
+!                                            ( t_green_v(l)%t(nzb_wall+1,m)             &
+!                                            - t_green_v(l)%t(nzb_wall,m) ) *           &
+!                                            surf_usm_v(l)%ddz_green(nzb_wall+1,m)      &
+!                                          + surf_usm_v(l)%wghf_eb(m) ) *               &
+!                                            surf_usm_v(l)%ddz_green_stag(nzb_wall,m)
+!                
+!                  DO  kw = nzb_wall+1, nzt_wall
+!                     gtend(kw) = (1.0_wp / surf_usm_v(l)%rho_c_green(kw,m))          &
+!                               * (   surf_usm_v(l)%lambda_h_green(kw,m)              &
+!                                 * ( t_green_v(l)%t(kw+1,m) - t_green_v(l)%t(kw,m) ) &
+!                                 * surf_usm_v(l)%ddz_green(kw+1,m)                   &
+!                               - surf_usm_v(l)%lambda_h(kw-1,m)                      &
+!                                 * ( t_green_v(l)%t(kw,m) - t_green_v(l)%t(kw-1,m) ) &
+!                                 * surf_usm_v(l)%ddz_green(kw,m) )                   &
+!                               * surf_usm_v(l)%ddz_green_stag(kw,m)
+!                  ENDDO
+!    
+!                  t_green_v_p(l)%t(nzb_wall:nzt_wall,m) =                              &
+!                                       t_green_v(l)%t(nzb_wall:nzt_wall,m)             &
+!                                     + dt_3d * ( tsc(2)                                &
+!                                     * gtend(nzb_wall:nzt_wall) + tsc(3)               &
+!                                     * surf_usm_v(l)%tt_green_m(nzb_wall:nzt_wall,m) )   
+!    
+! !
+! !--              calculate t_green tendencies for the next Runge-Kutta step
+!                  IF ( timestep_scheme(1:5) == 'runge' )  THEN
+!                      IF ( intermediate_timestep_count == 1 )  THEN
+!                         DO  kw = nzb_wall, nzt_wall
+!                            surf_usm_v(l)%tt_green_m(kw,m) = gtend(kw)
+!                         ENDDO
+!                      ELSEIF ( intermediate_timestep_count <                           &
+!                               intermediate_timestep_count_max )  THEN
+!                          DO  kw = nzb_wall, nzt_wall
+!                             surf_usm_v(l)%tt_green_m(kw,m) =                          &
+!                                         - 9.5625_wp * gtend(kw) +                     &
+!                                           5.3125_wp * surf_usm_v(l)%tt_green_m(kw,m)
+!                          ENDDO
+!                      ENDIF
+!                  ENDIF
+
+                 DO  kw = nzb_wall, nzt_wall+1
+                     t_green_v(l)%t(kw,m) = t_wall_v(l)%t(nzb_wall,m)
+                 ENDDO
               
-ENDIF
+              ENDIF
 
            ENDDO
@@ -6025,5 +6076,4 @@
                            usm_wall_mod
                            
-                           
   
 !
@@ -6094,14 +6144,14 @@
     SUBROUTINE usm_read_anthropogenic_heat
     
-        INTEGER(iwp)                  :: i,j,k,ii
-        REAL(wp)                      :: heat
-
+        INTEGER(iwp)                  :: i,j,k,ii  !< running indices
+        REAL(wp)                      :: heat      !< anthropogenic heat
+
+!
 !--     allocation of array of sources of anthropogenic heat and their diural profile
         ALLOCATE( aheat(naheatlayers,nys:nyn,nxl:nxr) )
         ALLOCATE( aheatprof(naheatlayers,0:24) )
 
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
 !--     read daily amount of heat and its daily cycle
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
         aheat = 0.0_wp
         DO  ii = 0, io_blocks-1
@@ -6136,11 +6186,10 @@
         ENDDO
         
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
 !--     read diurnal profiles of heat sources
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
         aheatprof = 0.0_wp
         DO  ii = 0, io_blocks-1
             IF ( ii == io_group )  THEN
-
+!
 !--             open anthropogenic heat profile file 
                 OPEN( 151, file='ANTHROPOGENIC_HEAT_PROFILE'//TRIM(coupling_char), action='read', &
@@ -6188,22 +6237,22 @@
        IMPLICIT NONE
 
-       INTEGER(iwp)       ::  l                !< index variable for surface type
-       INTEGER(iwp)       ::  i                !< running index over input files
-       INTEGER(iwp)       ::  k                !< running index over previous input files covering current local domain
-       INTEGER(iwp)       ::  ns_h_on_file_usm !< number of horizontal surface elements (urban type) on file
-       INTEGER(iwp)       ::  nxlc             !< index of left boundary on current subdomain
-       INTEGER(iwp)       ::  nxlf             !< index of left boundary on former subdomain 
-       INTEGER(iwp)       ::  nxl_on_file      !< index of left boundary on former local domain 
-       INTEGER(iwp)       ::  nxrc             !< index of right boundary on current subdomain
-       INTEGER(iwp)       ::  nxrf             !< index of right boundary on former subdomain
-       INTEGER(iwp)       ::  nxr_on_file      !< index of right boundary on former local domain 
-       INTEGER(iwp)       ::  nync             !< index of north boundary on current subdomain
-       INTEGER(iwp)       ::  nynf             !< index of north boundary on former subdomain
-       INTEGER(iwp)       ::  nyn_on_file      !< index of north boundary on former local domain 
-       INTEGER(iwp)       ::  nysc             !< index of south boundary on current subdomain 
-       INTEGER(iwp)       ::  nysf             !< index of south boundary on former subdomain
-       INTEGER(iwp)       ::  nys_on_file      !< index of south boundary on former local domain
+       INTEGER(iwp)       ::  l                 !< index variable for surface type
+       INTEGER(iwp)       ::  i                 !< running index over input files
+       INTEGER(iwp)       ::  k                 !< running index over previous input files covering current local domain
+       INTEGER(iwp)       ::  ns_h_on_file_usm  !< number of horizontal surface elements (urban type) on file
+       INTEGER(iwp)       ::  nxlc              !< index of left boundary on current subdomain
+       INTEGER(iwp)       ::  nxlf              !< index of left boundary on former subdomain 
+       INTEGER(iwp)       ::  nxl_on_file       !< index of left boundary on former local domain 
+       INTEGER(iwp)       ::  nxrc              !< index of right boundary on current subdomain
+       INTEGER(iwp)       ::  nxrf              !< index of right boundary on former subdomain
+       INTEGER(iwp)       ::  nxr_on_file       !< index of right boundary on former local domain 
+       INTEGER(iwp)       ::  nync              !< index of north boundary on current subdomain
+       INTEGER(iwp)       ::  nynf              !< index of north boundary on former subdomain
+       INTEGER(iwp)       ::  nyn_on_file       !< index of north boundary on former local domain 
+       INTEGER(iwp)       ::  nysc              !< index of south boundary on current subdomain 
+       INTEGER(iwp)       ::  nysf              !< index of south boundary on former subdomain
+       INTEGER(iwp)       ::  nys_on_file       !< index of south boundary on former local domain
        
-       INTEGER(iwp)       ::  ns_v_on_file_usm(0:3) !< number of vertical surface elements (urban type) on file
+       INTEGER(iwp)       ::  ns_v_on_file_usm(0:3)  !< number of vertical surface elements (urban type) on file
        
        INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  start_index_on_file 
@@ -6260,5 +6309,5 @@
 
                    DO  l = 0, 3
-                      IF ( ALLOCATED( tmp_surf_wall_v(l)%t ) )                      &
+                      IF ( ALLOCATED( tmp_surf_wall_v(l)%t ) )                 &
                          DEALLOCATE( tmp_surf_wall_v(l)%t )
                       IF ( ALLOCATED( tmp_wall_v(l)%t ) )                      &
@@ -6322,5 +6371,5 @@
              CASE ( 't_surf_wall_h' )
                 IF ( k == 1 )  THEN
-                   IF ( .NOT.  ALLOCATED( t_surf_wall_h_1 ) )                       &
+                   IF ( .NOT.  ALLOCATED( t_surf_wall_h_1 ) )                  &
                       ALLOCATE( t_surf_wall_h_1(1:surf_usm_h%ns) )
                    READ ( 13 )  tmp_surf_wall_h
@@ -6338,5 +6387,5 @@
              CASE ( 't_surf_wall_v(0)' )
                 IF ( k == 1 )  THEN
-                   IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(0)%t ) )                  &
+                   IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(0)%t ) )             &
                       ALLOCATE( t_surf_wall_v_1(0)%t(1:surf_usm_v(0)%ns) )
                    READ ( 13 )  tmp_surf_wall_v(0)%t
@@ -6354,5 +6403,5 @@
              CASE ( 't_surf_wall_v(1)' )
                 IF ( k == 1 )  THEN
-                   IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(1)%t ) )                  &
+                   IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(1)%t ) )             &
                       ALLOCATE( t_surf_wall_v_1(1)%t(1:surf_usm_v(1)%ns) )
                    READ ( 13 )  tmp_surf_wall_v(1)%t
@@ -6370,5 +6419,5 @@
              CASE ( 't_surf_wall_v(2)' )
                 IF ( k == 1 )  THEN
-                   IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(2)%t ) )                  &
+                   IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(2)%t ) )             &
                       ALLOCATE( t_surf_wall_v_1(2)%t(1:surf_usm_v(2)%ns) )
                    READ ( 13 )  tmp_surf_wall_v(2)%t
@@ -6386,5 +6435,5 @@
              CASE ( 't_surf_wall_v(3)' )
                 IF ( k == 1 )  THEN
-                   IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(3)%t ) )                  &
+                   IF ( .NOT.  ALLOCATED( t_surf_wall_v_1(3)%t ) )             &
                       ALLOCATE( t_surf_wall_v_1(3)%t(1:surf_usm_v(3)%ns) )
                    READ ( 13 )  tmp_surf_wall_v(3)%t
@@ -6835,5 +6884,4 @@
        
     END SUBROUTINE usm_rrd_local
-    
 
     
@@ -6883,13 +6931,13 @@
         IF ( .NOT. ascii_file )  RETURN
 
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
 !--     read categories of walls and their parameters
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
         DO  ii = 0, io_blocks-1
             IF ( ii == io_group )  THEN
-
+!
 !--             open urban surface file 
                 OPEN( 151, file='SURFACE_PARAMETERS'//coupling_char, action='read', &
-                           status='old', form='formatted', err=15 ) 
+                           status='old', form='formatted', err=15 )
+!
 !--             first test and get n_surface_types
                 k = 0
@@ -6906,4 +6954,5 @@
                 ALLOCATE( surface_type_codes(n_surface_types) )
                 ALLOCATE( surface_params(n_surface_params, n_surface_types) )
+!
 !--             real reading
                 rewind( 151 )
@@ -6927,12 +6976,11 @@
         ENDDO
     
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
 !--     read types of surfaces
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
         usm_par = 0
         DO  ii = 0, io_blocks-1
             IF ( ii == io_group )  THEN
 
-                !
+!
 !--             open csv urban surface file 
                 OPEN( 151, file='URBAN_SURFACE'//TRIM(coupling_char), action='read', &
@@ -6942,4 +6990,5 @@
                 DO
                     l = l+1
+!
 !--                 i, j, height, nz, roof, dirwe, dirsn, category, soilcat,
 !--                 weheight1, wecat1, snheight1, sncat1, weheight2, wecat2, snheight2, sncat2,
@@ -6955,8 +7004,10 @@
 
                     IF ( i >= nxlg  .AND.  i <= nxrg  .AND.  j >= nysg  .AND.  j <= nyng )  THEN
+!
 !--                     write integer variables into array
                         usm_par(:,j,i) = (/1, nz, roof, dirwe, dirsn, category,                      &
                                           weheight1, wecat1, weheight2, wecat2, weheight3, wecat3,   &
                                           snheight1, sncat1, snheight2, sncat2, snheight3, sncat3 /)
+!
 !--                     write real values into array
                         usm_val(:,j,i) = (/ albedo, thick,                                           &
@@ -7003,4 +7054,5 @@
                      usm_par(16,j,i) > nzt                &  !< incorrect wall or roof level height for south-north wall
                     ) )  THEN
+!
 !--                 incorrect input data
                     WRITE (message_string, "(A,2I5)") 'missing or incorrect data in file URBAN_SURFACE'// &
@@ -7063,4 +7115,5 @@
            ENDDO
            IF ( ip == -99999 )  THEN
+!
 !--           land/roof category not found
               WRITE (9,"(A,I5,A,3I5)") 'land/roof category ', it,     &
@@ -7079,4 +7132,5 @@
               ENDDO
               IF ( ip == -99999 )  THEN
+!
 !--              default land/roof category not found
                  WRITE (9,"(A,I5,A,3I5)") 'Default land/roof category', category, ' not found!'
@@ -7090,6 +7144,8 @@
               surf_usm_h%albedo(:,m) = surface_params(ialbedo,ip)
            ENDIF
+!
 !--        Albedo type is 0 (custom), others are replaced later
            surf_usm_h%albedo_type(:,m) = 0
+!
 !--        Transmissivity
            IF ( surf_usm_h%transmissivity(m) < 0.0_wp )  THEN
@@ -7175,4 +7231,5 @@
 
               IF ( iw < 0 .OR. jw < 0 ) THEN
+!
 !--              wall on west or south border of the domain - assign default category
                  IF ( kw <= roof_height_limit ) THEN
@@ -7181,62 +7238,65 @@
                      surf_usm_v(l)%surface_types(m) = roof_category   !< default category for wall surface in roof zone
                  END IF
-                 surf_usm_v(l)%albedo(:,m)    = -1.0_wp
-                 surf_usm_v(l)%thickness_wall(m) = -1.0_wp
-                 surf_usm_v(l)%thickness_window(m)   = -1.0_wp
-                 surf_usm_v(l)%thickness_green(m)    = -1.0_wp
-                 surf_usm_v(l)%transmissivity(m)  = -1.0_wp
+                 surf_usm_v(l)%albedo(:,m)         = -1.0_wp
+                 surf_usm_v(l)%thickness_wall(m)   = -1.0_wp
+                 surf_usm_v(l)%thickness_window(m) = -1.0_wp
+                 surf_usm_v(l)%thickness_green(m)  = -1.0_wp
+                 surf_usm_v(l)%transmissivity(m)   = -1.0_wp
               ELSE IF ( kw <= usm_par(ii,jw,iw) )  THEN
+!
 !--                 pedestrian zone
                  IF ( usm_par(ii+1,jw,iw) == 0 )  THEN
-                     surf_usm_v(l)%surface_types(m)  = pedestrian_category   !< default category for wall surface in pedestrian zone
-                     surf_usm_v(l)%albedo(:,m)    = -1.0_wp
-                     surf_usm_v(l)%thickness_wall(m) = -1.0_wp
-                     surf_usm_v(l)%thickness_window(m)   = -1.0_wp
-                     surf_usm_v(l)%thickness_green(m)    = -1.0_wp
-                     surf_usm_v(l)%transmissivity(m)  = -1.0_wp
+                     surf_usm_v(l)%surface_types(m)  = pedestrian_category   !< default category for wall surface in
+                                                                             !<pedestrian zone
+                     surf_usm_v(l)%albedo(:,m)         = -1.0_wp
+                     surf_usm_v(l)%thickness_wall(m)   = -1.0_wp
+                     surf_usm_v(l)%thickness_window(m) = -1.0_wp
+                     surf_usm_v(l)%thickness_green(m)  = -1.0_wp
+                     surf_usm_v(l)%transmissivity(m)   = -1.0_wp
                  ELSE
-                     surf_usm_v(l)%surface_types(m)  = usm_par(ii+1,jw,iw)
-                     surf_usm_v(l)%albedo(:,m)    = usm_val(ij,jw,iw)
-                     surf_usm_v(l)%thickness_wall(m) = usm_val(ij+1,jw,iw)
-                     surf_usm_v(l)%thickness_window(m)   = usm_val(ij+1,jw,iw)
-                     surf_usm_v(l)%thickness_green(m)    = usm_val(ij+1,jw,iw)
-                     surf_usm_v(l)%transmissivity(m)  = 0.0_wp
+                     surf_usm_v(l)%surface_types(m)    = usm_par(ii+1,jw,iw)
+                     surf_usm_v(l)%albedo(:,m)         = usm_val(ij,jw,iw)
+                     surf_usm_v(l)%thickness_wall(m)   = usm_val(ij+1,jw,iw)
+                     surf_usm_v(l)%thickness_window(m) = usm_val(ij+1,jw,iw)
+                     surf_usm_v(l)%thickness_green(m)  = usm_val(ij+1,jw,iw)
+                     surf_usm_v(l)%transmissivity(m)   = 0.0_wp
                  ENDIF
               ELSE IF ( kw <= usm_par(ii+2,jw,iw) )  THEN
+!
 !--              wall zone
                  IF ( usm_par(ii+3,jw,iw) == 0 )  THEN
-                     surf_usm_v(l)%surface_types(m)  = wall_category         !< default category for wall surface
-                     surf_usm_v(l)%albedo(:,m)    = -1.0_wp
-                     surf_usm_v(l)%thickness_wall(m) = -1.0_wp
-                     surf_usm_v(l)%thickness_window(m)   = -1.0_wp
-                     surf_usm_v(l)%thickness_green(m)    = -1.0_wp
-                     surf_usm_v(l)%transmissivity(m)  = -1.0_wp
+                     surf_usm_v(l)%surface_types(m)    = wall_category         !< default category for wall surface
+                     surf_usm_v(l)%albedo(:,m)         = -1.0_wp
+                     surf_usm_v(l)%thickness_wall(m)   = -1.0_wp
+                     surf_usm_v(l)%thickness_window(m) = -1.0_wp
+                     surf_usm_v(l)%thickness_green(m)  = -1.0_wp
+                     surf_usm_v(l)%transmissivity(m)   = -1.0_wp
                  ELSE
-                     surf_usm_v(l)%surface_types(m)  = usm_par(ii+3,jw,iw)
-                     surf_usm_v(l)%albedo(:,m)    = usm_val(ij+2,jw,iw)
-                     surf_usm_v(l)%thickness_wall(m) = usm_val(ij+3,jw,iw)
-                     surf_usm_v(l)%thickness_window(m)   = usm_val(ij+3,jw,iw)
-                     surf_usm_v(l)%thickness_green(m)    = usm_val(ij+3,jw,iw)
-                     surf_usm_v(l)%transmissivity(m)  = 0.0_wp
+                     surf_usm_v(l)%surface_types(m)    = usm_par(ii+3,jw,iw)
+                     surf_usm_v(l)%albedo(:,m)         = usm_val(ij+2,jw,iw)
+                     surf_usm_v(l)%thickness_wall(m)   = usm_val(ij+3,jw,iw)
+                     surf_usm_v(l)%thickness_window(m) = usm_val(ij+3,jw,iw)
+                     surf_usm_v(l)%thickness_green(m)  = usm_val(ij+3,jw,iw)
+                     surf_usm_v(l)%transmissivity(m)   = 0.0_wp
                  ENDIF
               ELSE IF ( kw <= usm_par(ii+4,jw,iw) )  THEN
+!
 !--              roof zone
                  IF ( usm_par(ii+5,jw,iw) == 0 )  THEN
-                     surf_usm_v(l)%surface_types(m)  = roof_category         !< default category for roof surface
-                     surf_usm_v(l)%albedo(:,m)    = -1.0_wp
-                     surf_usm_v(l)%thickness_wall(m) = -1.0_wp
-                     surf_usm_v(l)%thickness_window(m)   = -1.0_wp
-                     surf_usm_v(l)%thickness_green(m)    = -1.0_wp
-                     surf_usm_v(l)%transmissivity(m)  = -1.0_wp
+                     surf_usm_v(l)%surface_types(m)    = roof_category         !< default category for roof surface
+                     surf_usm_v(l)%albedo(:,m)         = -1.0_wp
+                     surf_usm_v(l)%thickness_wall(m)   = -1.0_wp
+                     surf_usm_v(l)%thickness_window(m) = -1.0_wp
+                     surf_usm_v(l)%thickness_green(m)  = -1.0_wp
+                     surf_usm_v(l)%transmissivity(m)   = -1.0_wp
                  ELSE
-                     surf_usm_v(l)%surface_types(m)  = usm_par(ii+5,jw,iw)
-                     surf_usm_v(l)%albedo(:,m)    = usm_val(ij+4,jw,iw)
-                     surf_usm_v(l)%thickness_wall(m) = usm_val(ij+5,jw,iw)
-                     surf_usm_v(l)%thickness_window(m)   = usm_val(ij+5,jw,iw)
-                     surf_usm_v(l)%thickness_green(m)    = usm_val(ij+5,jw,iw)
-                     surf_usm_v(l)%transmissivity(m)  = 0.0_wp
+                     surf_usm_v(l)%surface_types(m)    = usm_par(ii+5,jw,iw)
+                     surf_usm_v(l)%albedo(:,m)         = usm_val(ij+4,jw,iw)
+                     surf_usm_v(l)%thickness_wall(m)   = usm_val(ij+5,jw,iw)
+                     surf_usm_v(l)%thickness_window(m) = usm_val(ij+5,jw,iw)
+                     surf_usm_v(l)%thickness_green(m)  = usm_val(ij+5,jw,iw)
+                     surf_usm_v(l)%transmissivity(m)   = 0.0_wp
                  ENDIF
               ELSE
-!
                  WRITE(9,*) 'Problem reading USM data:'
                  WRITE(9,*) l,i,j,kw,get_topography_top_index_ji( j, i, 's' )
@@ -7247,4 +7307,5 @@
                  WRITE(9,*) kw,roof_height_limit,wall_category,roof_category
                  FLUSH(9)
+!
 !--              supply the default category
                  IF ( kw <= roof_height_limit ) THEN
@@ -7253,9 +7314,9 @@
                      surf_usm_v(l)%surface_types(m) = roof_category   !< default category for wall surface in roof zone
                  END IF
-                 surf_usm_v(l)%albedo(:,m)    = -1.0_wp
-                 surf_usm_v(l)%thickness_wall(m) = -1.0_wp
+                 surf_usm_v(l)%albedo(:,m)         = -1.0_wp
+                 surf_usm_v(l)%thickness_wall(m)   = -1.0_wp
                  surf_usm_v(l)%thickness_window(m) = -1.0_wp
-                 surf_usm_v(l)%thickness_green(m) = -1.0_wp
-                 surf_usm_v(l)%transmissivity(m)  = -1.0_wp
+                 surf_usm_v(l)%thickness_green(m)  = -1.0_wp
+                 surf_usm_v(l)%transmissivity(m)   = -1.0_wp
               ENDIF
 !
@@ -7270,4 +7331,5 @@
               ENDDO
               IF ( ip == -99999 )  THEN
+!
 !--              wall category not found
                  WRITE (9, "(A,I7,A,3I5)") 'wall category ', it,  &
@@ -7282,4 +7344,5 @@
                  ENDDO
                  IF ( ip == -99999 )  THEN
+!
 !--                 default wall category not found
                     WRITE (9, "(A,I5,A,3I5)") 'Default wall category', category, ' not found!'
@@ -7405,5 +7468,5 @@
            ENDDO
         ENDIF
-
+!
 !--     coordinate not found
         isurfl = -1
@@ -7423,5 +7486,5 @@
     SUBROUTINE usm_read_wall_temperature
 
-        INTEGER(iwp)                                          :: i, j, k, d, ii, iline
+        INTEGER(iwp)                                          :: i, j, k, d, ii, iline  !> running indices
         INTEGER(iwp)                                          :: isurfl
         REAL(wp)                                              :: rtsurf
@@ -7429,9 +7492,7 @@
 
 
-
-
         DO  ii = 0, io_blocks-1
             IF ( ii == io_group )  THEN
-
+!
 !--             open wall temperature file
                 OPEN( 152, file='WALL_TEMPERATURE'//coupling_char, action='read', &
@@ -7454,5 +7515,5 @@
                             CALL message( 'usm_read_wall_temperature', 'PA0521', 1, 2, 0, 6, 0 )
                         ENDIF
-
+!
 !--                     assign temperatures
                         IF ( d == 0 ) THEN
@@ -7498,4 +7559,6 @@
 !> with many simplifications and adjustments.
 !> TODO better description
+!> No calculation of window surface temperatures during spinup to increase
+!> maximum possible timstep
 !------------------------------------------------------------------------------!
     SUBROUTINE usm_surface_energy_balance( spinup )
@@ -7504,5 +7567,5 @@
         IMPLICIT NONE
 
-        INTEGER(iwp) :: i, j, k, l, m   !< running indices
+        INTEGER(iwp)                          :: i, j, k, l, m   !< running indices
         
         INTEGER(iwp) ::  i_off     !< offset to determine index of surface element, seen from atmospheric grid point, for x
@@ -7512,5 +7575,5 @@
         LOGICAL                               :: spinup             !true during spinup
         
-        REAL(wp)                              :: stend_wall              !< surface tendency
+        REAL(wp)                              :: stend_wall         !< surface tendency
         
         REAL(wp)                              :: stend_window       !< surface tendency
@@ -7526,28 +7589,31 @@
         REAL(wp)                              :: f_shf_window       !< factor for shf_eb window
         REAL(wp)                              :: f_shf_green        !< factor for shf_eb green wall
-        REAL(wp)                              :: lambda_surface     !< current value of lambda_surface (heat conductivity between air and wall)
-        REAL(wp)                              :: lambda_surface_window !< current value of lambda_surface (heat conductivity between air and window)
-        REAL(wp)                              :: lambda_surface_green  !< current value of lambda_surface (heat conductivity between air and greeb wall)
+        REAL(wp)                              :: lambda_surface     !< current value of lambda_surface (heat conductivity
+                                                                    !<between air and wall)
+        REAL(wp)                              :: lambda_surface_window  !< current value of lambda_surface (heat conductivity
+                                                                        !< between air and window)
+        REAL(wp)                              :: lambda_surface_green   !< current value of lambda_surface (heat conductivity
+                                                                        !< between air and greeb wall)
         
         REAL(wp)                              :: dtime              !< simulated time of day (in UTC)
         INTEGER(iwp)                          :: dhour              !< simulated hour of day (in UTC)
         REAL(wp)                              :: acoef              !< actual coefficient of diurnal profile of anthropogenic heat
-        REAL(wp) ::  f1,          & !< resistance correction term 1
-                     f2,          & !< resistance correction term 2
-                     f3,          & !< resistance correction term 3
-                     e,           & !< water vapour pressure
-                     e_s,         & !< water vapour saturation pressure
-                     e_s_dt,      & !< derivate of e_s with respect to T
-                     tend,        & !< tendency
-                     dq_s_dt,     & !< derivate of q_s with respect to T
-                     f_qsws,      & !< factor for qsws
-                     f_qsws_veg,  & !< factor for qsws_veg
-                     f_qsws_liq,  & !< factor for qsws_liq
-                     m_liq_max,   & !< maxmimum value of the liq. water reservoir
-                     qv1,         & !< specific humidity at first grid level
-                     m_max_depth = 0.0002_wp, & ! Maximum capacity of the water reservoir (m)
-                     rho_lv,      &
-                     drho_l_lv,   &
-                     q_s
+        REAL(wp) ::  f1,          &  !< resistance correction term 1
+                     f2,          &  !< resistance correction term 2
+                     f3,          &  !< resistance correction term 3
+                     e,           &  !< water vapour pressure
+                     e_s,         &  !< water vapour saturation pressure
+                     e_s_dt,      &  !< derivate of e_s with respect to T
+                     tend,        &  !< tendency
+                     dq_s_dt,     &  !< derivate of q_s with respect to T
+                     f_qsws,      &  !< factor for qsws
+                     f_qsws_veg,  &  !< factor for qsws_veg
+                     f_qsws_liq,  &  !< factor for qsws_liq
+                     m_liq_max,   &  !< maxmimum value of the liq. water reservoir
+                     qv1,         &  !< specific humidity at first grid level
+                     m_max_depth = 0.0002_wp, &  !< Maximum capacity of the water reservoir (m)
+                     rho_lv,      &  !< frequently used parameter for green layers
+                     drho_l_lv,   &  !< frequently used parameter for green layers
+                     q_s             !< saturation specific humidity
 
 !
@@ -7602,5 +7668,5 @@
 !--        pt, us, ts are not available for the prognostic time step,
 !--        data from the last time step is used here.
-
+!
 !--        Workaround: use single r_a as stability is only treated for the
 !--        average temperature
@@ -7621,5 +7687,5 @@
                surf_usm_h%r_a(m)        = 1.0_wp
            IF ( surf_usm_h%r_a_green(m)  < 1.0_wp )                            &
-               surf_usm_h%r_a_green(m) = 1.0_wp
+               surf_usm_h%r_a_green(m)  = 1.0_wp
            IF ( surf_usm_h%r_a_window(m) < 1.0_wp )                            &
                surf_usm_h%r_a_window(m) = 1.0_wp
@@ -7631,9 +7697,9 @@
                surf_usm_h%r_a(m)        = 300.0_wp
            IF ( surf_usm_h%r_a_green(m)  > 300.0_wp )                          &
-               surf_usm_h%r_a_green(m) = 300.0_wp
+               surf_usm_h%r_a_green(m)  = 300.0_wp
            IF ( surf_usm_h%r_a_window(m) > 300.0_wp )                          &
                surf_usm_h%r_a_window(m) = 300.0_wp                
                 
-                
+!
 !--        factor for shf_eb
            f_shf  = rho_cp / surf_usm_h%r_a(m)
@@ -7641,94 +7707,94 @@
            f_shf_green  = rho_cp / surf_usm_h%r_a_green(m)
         
-!***************************************************************************************
-if (surf_usm_h%frac(ind_pav_green,m).gt.0.0_wp) then
-!--    Adapted from LSM:
-!--    Second step: calculate canopy resistance r_canopy
-!--    f1-f3 here are defined as 1/f1-f3 as in ECMWF documentation
+
+           IF ( surf_usm_h%frac(ind_pav_green,m) > 0.0_wp ) THEN
+!--           Adapted from LSM:
+!--           Second step: calculate canopy resistance r_canopy
+!--           f1-f3 here are defined as 1/f1-f3 as in ECMWF documentation
  
-!--    f1: correction for incoming shortwave radiation (stomata close at 
-!--    night)
-       f1 = MIN( 1.0_wp, ( 0.004_wp * surf_usm_h%rad_sw_in(m) + 0.05_wp ) / &
-                        (0.81_wp * (0.004_wp * surf_usm_h%rad_sw_in(m)      &
-                         + 1.0_wp)) )
-!
-!--    f2: correction for soil moisture availability to plants (the 
-!--    integrated soil moisture must thus be considered here)
-!--    f2 = 0 for very dry soils
-          m_total = 0.0_wp
-          DO  k = nzb_wall, nzt_wall+1
-              m_total = m_total + rootfr_h(nzb_wall,m)                              &
-                        * MAX(swc_h(nzb_wall,m),wilt_h(nzb_wall,m))
-          ENDDO 
-
-          IF ( m_total > wilt_h(nzb_wall,m)  .AND.  m_total < fc_h(nzb_wall,m) )  THEN
-             f2 = ( m_total - wilt_h(nzb_wall,m) ) / (fc_h(nzb_wall,m) - wilt_h(nzb_wall,m) )
-          ELSEIF ( m_total >= fc_h(nzb_wall,m) )  THEN
-             f2 = 1.0_wp
-          ELSE
-             f2 = 1.0E-20_wp
-          ENDIF
-
-!
-!--    Calculate water vapour pressure at saturation 
-       e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp * ( t_surf_green_h(m) &
-                     - 273.16_wp ) / ( t_surf_green_h(m) - 35.86_wp ) )
-!
-!--    f3: correction for vapour pressure deficit
-       IF ( surf_usm_h%g_d(m) /= 0.0_wp )  THEN
-!
-!--       Calculate vapour pressure
-          e  = qv1 * surface_pressure / ( qv1 + 0.622_wp )
-          f3 = EXP ( - surf_usm_h%g_d(m) * (e_s - e) )
-       ELSE
-          f3 = 1.0_wp
-       ENDIF
-
-!
-!--    Calculate canopy resistance. In case that c_veg is 0 (bare soils),
-!--    this calculation is obsolete, as r_canopy is not used below.
-!--    To do: check for very dry soil -> r_canopy goes to infinity
-       surf_usm_h%r_canopy(m) = surf_usm_h%r_canopy_min(m) /                               &
+!--           f1: correction for incoming shortwave radiation (stomata close at 
+!--           night)
+              f1 = MIN( 1.0_wp, ( 0.004_wp * surf_usm_h%rad_sw_in(m) + 0.05_wp ) / &
+                               (0.81_wp * (0.004_wp * surf_usm_h%rad_sw_in(m)      &
+                                + 1.0_wp)) )
+!
+!--           f2: correction for soil moisture availability to plants (the 
+!--           integrated soil moisture must thus be considered here)
+!--           f2 = 0 for very dry soils
+              m_total = 0.0_wp
+              DO  k = nzb_wall, nzt_wall+1
+                  m_total = m_total + rootfr_h(nzb_wall,m)                              &
+                            * MAX(swc_h(nzb_wall,m),wilt_h(nzb_wall,m))
+              ENDDO 
+    
+              IF ( m_total > wilt_h(nzb_wall,m)  .AND.  m_total < fc_h(nzb_wall,m) )  THEN
+                 f2 = ( m_total - wilt_h(nzb_wall,m) ) / (fc_h(nzb_wall,m) - wilt_h(nzb_wall,m) )
+              ELSEIF ( m_total >= fc_h(nzb_wall,m) )  THEN
+                 f2 = 1.0_wp
+              ELSE
+                 f2 = 1.0E-20_wp
+              ENDIF
+       
+!
+!--          Calculate water vapour pressure at saturation 
+              e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp * ( t_surf_green_h(m) &
+                            - 273.16_wp ) / ( t_surf_green_h(m) - 35.86_wp ) )
+!
+!--           f3: correction for vapour pressure deficit
+              IF ( surf_usm_h%g_d(m) /= 0.0_wp )  THEN
+!
+!--           Calculate vapour pressure
+                 e  = qv1 * surface_pressure / ( qv1 + 0.622_wp )
+                 f3 = EXP ( - surf_usm_h%g_d(m) * (e_s - e) )
+              ELSE
+                 f3 = 1.0_wp
+              ENDIF
+
+!
+!--           Calculate canopy resistance. In case that c_veg is 0 (bare soils),
+!--           this calculation is obsolete, as r_canopy is not used below.
+!--           To do: check for very dry soil -> r_canopy goes to infinity
+              surf_usm_h%r_canopy(m) = surf_usm_h%r_canopy_min(m) /                   &
                               ( surf_usm_h%lai(m) * f1 * f2 * f3 + 1.0E-20_wp )
 
 !
-!--    Calculate the maximum possible liquid water amount on plants and
-!--    bare surface. For vegetated surfaces, a maximum depth of 0.2 mm is
-!--    assumed, while paved surfaces might hold up 1 mm of water. The 
-!--    liquid water fraction for paved surfaces is calculated after 
-!--    Noilhan & Planton (1989), while the ECMWF formulation is used for
-!--    vegetated surfaces and bare soils.
-       m_liq_max = m_max_depth * ( surf_usm_h%lai(m) )
-       surf_usm_h%c_liq(m) = MIN( 1.0_wp, ( m_liq_usm_h%var_usm_1d(m) / m_liq_max )**0.67 )
-!
-!--    Calculate saturation specific humidity
-       q_s = 0.622_wp * e_s / ( surface_pressure - e_s )
-!
-!--    In case of dewfall, set evapotranspiration to zero
-!--    All super-saturated water is then removed from the air
-       IF ( humidity  .AND.  q_s <= qv1 )  THEN
-          surf_usm_h%r_canopy(m) = 0.0_wp
-       ENDIF
-
-!
-!--    Calculate coefficients for the total evapotranspiration 
-!--    In case of water surface, set vegetation and soil fluxes to zero.
-!--    For pavements, only evaporation of liquid water is possible.
-       f_qsws_veg  = rho_lv *                                &
-                         ( 1.0_wp        - surf_usm_h%c_liq(m)    ) /   &
-                         ( surf_usm_h%r_a_green(m) + surf_usm_h%r_canopy(m) )
-       f_qsws_liq  = rho_lv * surf_usm_h%c_liq(m)   /             &
-                           surf_usm_h%r_a_green(m)
-
-       f_qsws = f_qsws_veg + f_qsws_liq
-!
-!--    Calculate derivative of q_s for Taylor series expansion
-       e_s_dt = e_s * ( 17.269_wp / ( t_surf_green_h(m) - 35.86_wp) -   &
-                        17.269_wp*( t_surf_green_h(m) - 273.16_wp)      &
-                       / ( t_surf_green_h(m) - 35.86_wp)**2 )
-
-       dq_s_dt = 0.622_wp * e_s_dt / ( surface_pressure - e_s_dt )
-endif
-!***********************************************************************************
+!--           Calculate the maximum possible liquid water amount on plants and
+!--           bare surface. For vegetated surfaces, a maximum depth of 0.2 mm is
+!--           assumed, while paved surfaces might hold up 1 mm of water. The 
+!--           liquid water fraction for paved surfaces is calculated after 
+!--           Noilhan & Planton (1989), while the ECMWF formulation is used for
+!--           vegetated surfaces and bare soils.
+              m_liq_max = m_max_depth * ( surf_usm_h%lai(m) )
+              surf_usm_h%c_liq(m) = MIN( 1.0_wp, ( m_liq_usm_h%var_usm_1d(m) / m_liq_max )**0.67 )
+!
+!--           Calculate saturation specific humidity
+              q_s = 0.622_wp * e_s / ( surface_pressure - e_s )
+!
+!--           In case of dewfall, set evapotranspiration to zero
+!--           All super-saturated water is then removed from the air
+              IF ( humidity  .AND.  q_s <= qv1 )  THEN
+                 surf_usm_h%r_canopy(m) = 0.0_wp
+              ENDIF
+
+!
+!--           Calculate coefficients for the total evapotranspiration 
+!--           In case of water surface, set vegetation and soil fluxes to zero.
+!--           For pavements, only evaporation of liquid water is possible.
+              f_qsws_veg  = rho_lv *                                           &
+                                ( 1.0_wp        - surf_usm_h%c_liq(m)    ) /   &
+                                ( surf_usm_h%r_a_green(m) + surf_usm_h%r_canopy(m) )
+              f_qsws_liq  = rho_lv * surf_usm_h%c_liq(m)   /                   &
+                                  surf_usm_h%r_a_green(m)
+       
+              f_qsws = f_qsws_veg + f_qsws_liq
+!
+!--           Calculate derivative of q_s for Taylor series expansion
+              e_s_dt = e_s * ( 17.269_wp / ( t_surf_green_h(m) - 35.86_wp) -   &
+                               17.269_wp*( t_surf_green_h(m) - 273.16_wp)      &
+                              / ( t_surf_green_h(m) - 35.86_wp)**2 )
+       
+              dq_s_dt = 0.622_wp * e_s_dt / ( surface_pressure - e_s_dt )
+           ENDIF
+!
 !--        add LW up so that it can be removed in prognostic equation
            surf_usm_h%rad_net_l(m) = surf_usm_h%rad_sw_in(m)  -                &
@@ -7736,22 +7802,22 @@
                                      surf_usm_h%rad_lw_in(m)  -                &
                                      surf_usm_h%rad_lw_out(m)
-
-!--        numerator of the prognostic equation
+!
+!--     numerator of the prognostic equation
 !--     Todo: Adjust to tile approach. So far, emissivity for wall (element 0)
-!--           is used
+!--     is used
            coef_1 = surf_usm_h%rad_net_l(m) +                                  & 
                  ( 3.0_wp + 1.0_wp ) * surf_usm_h%emissivity(ind_veg_wall,m) * &
-                                       sigma_sb * t_surf_wall_h(m) ** 4 +           &  
+                                       sigma_sb * t_surf_wall_h(m) ** 4 +      &  
                                        f_shf * surf_usm_h%pt1(m) +             &
                                        lambda_surface * t_wall_h(nzb_wall,m)
-if ((.NOT. spinup).AND.(surf_usm_h%frac(ind_wat_win,m).GT.0.0_wp)) then
-           coef_window_1 = surf_usm_h%rad_net_l(m) +                           & 
-                   ( 3.0_wp + 1.0_wp ) * surf_usm_h%emissivity(ind_wat_win,m)  &
-                                       * sigma_sb * t_surf_window_h(m) ** 4 +  &  
-                                       f_shf_window * surf_usm_h%pt1(m) +      &
-                                       lambda_surface_window * t_window_h(nzb_wall,m)
-endif                 
-         IF ( (humidity).and.(surf_usm_h%frac(ind_pav_green,m).gt.0.0_wp) )  THEN
-                    coef_green_1 = surf_usm_h%rad_net_l(m) +                              & 
+           IF ( ( .NOT. spinup ) .AND. (surf_usm_h%frac(ind_wat_win,m) > 0.0_wp ) ) THEN
+              coef_window_1 = surf_usm_h%rad_net_l(m) +                           & 
+                      ( 3.0_wp + 1.0_wp ) * surf_usm_h%emissivity(ind_wat_win,m)  &
+                                          * sigma_sb * t_surf_window_h(m) ** 4 +  &  
+                                          f_shf_window * surf_usm_h%pt1(m) +      &
+                                          lambda_surface_window * t_window_h(nzb_wall,m)
+           ENDIF                 
+           IF ( ( humidity ) .AND. ( surf_usm_h%frac(ind_pav_green,m) > 0.0_wp ) )  THEN
+                    coef_green_1 = surf_usm_h%rad_net_l(m) +                                 & 
                    ( 3.0_wp + 1.0_wp ) * surf_usm_h%emissivity(ind_pav_green,m) * sigma_sb * &
                                        t_surf_green_h(m) ** 4 +                  &  
@@ -7766,24 +7832,24 @@
                                        lambda_surface_green * t_green_h(nzb_wall,m)
           ENDIF
-
+!
 !--        denominator of the prognostic equation
            coef_2 = 4.0_wp * surf_usm_h%emissivity(ind_veg_wall,m) *           &
-                             sigma_sb * t_surf_wall_h(m) ** 3                       &
+                             sigma_sb * t_surf_wall_h(m) ** 3                  &
                            + lambda_surface + f_shf / exner(k)
-if ((.NOT. spinup).AND.(surf_usm_h%frac(ind_wat_win,m).GT.0.0_wp)) then
-           coef_window_2 = 4.0_wp * surf_usm_h%emissivity(ind_wat_win,m) *     &
-                             sigma_sb * t_surf_window_h(m) ** 3                &
-                           + lambda_surface_window + f_shf_window / exner(k)
-endif
-           IF ( (humidity).and.(surf_usm_h%frac(ind_pav_green,m).gt.0.0_wp) )  THEN
+           IF ( ( .NOT. spinup ) .AND. ( surf_usm_h%frac(ind_wat_win,m) > 0.0_wp ) ) THEN
+              coef_window_2 = 4.0_wp * surf_usm_h%emissivity(ind_wat_win,m) *     &
+                                sigma_sb * t_surf_window_h(m) ** 3                &
+                              + lambda_surface_window + f_shf_window / exner(k)
+           ENDIF
+           IF ( ( humidity ) .AND. ( surf_usm_h%frac(ind_pav_green,m) > 0.0_wp ) )  THEN
               coef_green_2 = 4.0_wp * surf_usm_h%emissivity(ind_pav_green,m) * sigma_sb *    &
-                                t_surf_green_h(m) ** 3 + f_qsws * dq_s_dt        &
+                                t_surf_green_h(m) ** 3 + f_qsws * dq_s_dt                    &
                               + lambda_surface_green + f_shf_green / exner(k)
            ELSE
            coef_green_2 = 4.0_wp * surf_usm_h%emissivity(ind_pav_green,m) * sigma_sb *    &
-                             t_surf_green_h(m) ** 3                           &
+                             t_surf_green_h(m) ** 3                                       &
                            + lambda_surface_green + f_shf_green / exner(k)
            ENDIF
-
+!
 !--        implicit solution when the surface layer has no heat capacity,
 !--        otherwise use RK3 scheme.
@@ -7791,15 +7857,15 @@
                              surf_usm_h%c_surface(m) * t_surf_wall_h(m) ) /        & 
                            ( surf_usm_h%c_surface(m) + coef_2 * dt_3d * tsc(2) ) 
-if ((.NOT. spinup).AND.(surf_usm_h%frac(ind_wat_win,m).GT.0.0_wp)) then
-           t_surf_window_h_p(m) = ( coef_window_1 * dt_3d * tsc(2) +                        &
-                             surf_usm_h%c_surface_window(m) * t_surf_window_h(m) ) /        & 
-                           ( surf_usm_h%c_surface_window(m) + coef_window_2 * dt_3d * tsc(2) )
-endif
+           IF ((.NOT. spinup).AND.(surf_usm_h%frac(ind_wat_win,m) > 0.0_wp)) THEN
+              t_surf_window_h_p(m) = ( coef_window_1 * dt_3d * tsc(2) +                        &
+                                surf_usm_h%c_surface_window(m) * t_surf_window_h(m) ) /        & 
+                              ( surf_usm_h%c_surface_window(m) + coef_window_2 * dt_3d * tsc(2) )
+           ENDIF
            t_surf_green_h_p(m) = ( coef_green_1 * dt_3d * tsc(2) +                        &
                              surf_usm_h%c_surface_green(m) * t_surf_green_h(m) ) /        & 
                            ( surf_usm_h%c_surface_green(m) + coef_green_2 * dt_3d * tsc(2) ) 
-
+!
 !--        add RK3 term
-           t_surf_wall_h_p(m) = t_surf_wall_h_p(m) + dt_3d * tsc(3) *                   &
+           t_surf_wall_h_p(m) = t_surf_wall_h_p(m) + dt_3d * tsc(3) *         &
                            surf_usm_h%tt_surface_wall_m(m)
 
@@ -7814,13 +7880,13 @@
 !--        assumed to be the surface temperature.
            surf_usm_h%pt_surface(m) = ( surf_usm_h%frac(ind_veg_wall,m) * t_surf_wall_h_p(m)   &
-                               + surf_usm_h%frac(ind_wat_win,m) * t_surf_window_h_p(m)   &
-                               + surf_usm_h%frac(ind_pav_green,m) * t_surf_green_h_p(m) )  &
+                               + surf_usm_h%frac(ind_wat_win,m) * t_surf_window_h_p(m)         &
+                               + surf_usm_h%frac(ind_pav_green,m) * t_surf_green_h_p(m) )      &
                                / exner(k)
                                
            IF ( humidity )  surf_usm_h%vpt_surface(m) =                        &
                                                    surf_usm_h%pt_surface(m)
-
+!
 !--        calculate true tendency
-           stend_wall = ( t_surf_wall_h_p(m) - t_surf_wall_h(m) - dt_3d * tsc(3) *           &
+           stend_wall = ( t_surf_wall_h_p(m) - t_surf_wall_h(m) - dt_3d * tsc(3) *              &
                      surf_usm_h%tt_surface_wall_m(m)) / ( dt_3d  * tsc(2) )
            stend_window = ( t_surf_window_h_p(m) - t_surf_window_h(m) - dt_3d * tsc(3) *        &
@@ -7828,5 +7894,5 @@
            stend_green = ( t_surf_green_h_p(m) - t_surf_green_h(m) - dt_3d * tsc(3) *           &
                      surf_usm_h%tt_surface_green_m(m)) / ( dt_3d  * tsc(2) )
-
+!
 !--        calculate t_surf tendencies for the next Runge-Kutta step
            IF ( timestep_scheme(1:5) == 'runge' )  THEN
@@ -7837,5 +7903,5 @@
               ELSEIF ( intermediate_timestep_count <                          &
                         intermediate_timestep_count_max )  THEN
-                 surf_usm_h%tt_surface_wall_m(m) = -9.5625_wp * stend_wall +            &
+                 surf_usm_h%tt_surface_wall_m(m) = -9.5625_wp * stend_wall +       &
                                      5.3125_wp * surf_usm_h%tt_surface_wall_m(m)
                  surf_usm_h%tt_surface_window_m(m) = -9.5625_wp * stend_window +   &
@@ -7845,5 +7911,5 @@
               ENDIF
            ENDIF
-
+!
 !--        in case of fast changes in the skin temperature, it is required to
 !--        update the radiative fluxes in order to keep the solution stable
@@ -7860,5 +7926,5 @@
                                      surf_usm_h%frac(ind_veg_wall,m) *                   &
                                      sigma_sb * surf_usm_h%emissivity(ind_veg_wall,m) *  &
-                                     ( t_surf_wall_h_p(m)**4 - t_surf_wall_h(m)**4 )               &
+                                     ( t_surf_wall_h_p(m)**4 - t_surf_wall_h(m)**4 )     &
                                     + surf_usm_h%frac(ind_wat_win,m) *                   &
                                      sigma_sb * surf_usm_h%emissivity(ind_wat_win,m) *   &
@@ -7868,5 +7934,5 @@
                                      ( t_surf_green_h_p(m)**4 - t_surf_green_h(m)**4 )
 
-           surf_usm_h%wghf_eb(m)   = lambda_surface *                         &
+           surf_usm_h%wghf_eb(m)   = lambda_surface *                                    &
                                       ( t_surf_wall_h_p(m) - t_wall_h(nzb_wall,m) )
            surf_usm_h%wghf_eb_green(m)  = lambda_surface_green *                         &
@@ -7877,5 +7943,5 @@
 !
 !--        ground/wall/roof surface heat flux
-           surf_usm_h%wshf_eb(m)   = - f_shf  * ( surf_usm_h%pt1(m) - t_surf_wall_h_p(m) / exner(k) ) *               &
+           surf_usm_h%wshf_eb(m)   = - f_shf  * ( surf_usm_h%pt1(m) - t_surf_wall_h_p(m) / exner(k) ) *          &
                                        surf_usm_h%frac(ind_veg_wall,m)         &
                                      - f_shf_window  * ( surf_usm_h%pt1(m) - t_surf_window_h_p(m) / exner(k) ) * &
@@ -7888,135 +7954,124 @@
            surf_usm_h%shf(m) = surf_usm_h%wshf_eb(m) / c_p
       
-!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-if (surf_usm_h%frac(ind_pav_green,m).gt.0.0_wp) then
-
-! 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),&
-!         surf_usm_h%wshf_eb(m),f_qsws_veg,f_qsws_liq,dq_s_dt
-! 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)
-! print*, "lambdasurface",lambda_surface_green,lambda_surface,i,j,k
-! print*, "fractions",i,j,k,surf_usm_h%frac(0:2,m)
-if ((t_surf_green_h_p(m).gt.370.0_wp).or.(t_surf_green_h_p(m).lt.250.0_wp)) then
-  print*, t_surf_green_h_p(m),m,i,j,k
-  stop
-endif
-
-       IF ( humidity )  THEN
-          surf_usm_h%qsws_eb(m)  = - f_qsws * ( qv1 - q_s + dq_s_dt                     &
-                          * t_surf_green_h(m) - dq_s_dt *               &
-                            t_surf_green_h_p(m) )
-
-          surf_usm_h%qsws(m) = surf_usm_h%qsws_eb(m) / rho_lv
-
-          surf_usm_h%qsws_veg(m)  = - f_qsws_veg  * ( qv1 - q_s                      &
-                              + dq_s_dt * t_surf_green_h(m) - dq_s_dt   &
-                              * t_surf_green_h_p(m) )
-
-          surf_usm_h%qsws_liq(m)  = - f_qsws_liq  * ( qv1 - q_s                      &
-                              + dq_s_dt * t_surf_green_h(m) - dq_s_dt   &
-                              * t_surf_green_h_p(m) )
-       ENDIF
-
-!
-!--    Calculate the true surface resistance
-       IF ( .NOT.  humidity )  THEN
-          surf_usm_h%r_s(m) = 1.0E10_wp
-       ELSE
-          surf_usm_h%r_s(m) = - rho_lv * ( qv1 - q_s + dq_s_dt                       &
-                          *  t_surf_green_h(m) - dq_s_dt *               &
-                            t_surf_green_h_p(m) ) /                     &
-                            (surf_usm_h%qsws(m) + 1.0E-20)  - surf_usm_h%r_a_green(m)
-       ENDIF
-
-!
-!--    Calculate change in liquid water reservoir due to dew fall or 
-!--    evaporation of liquid water
-       IF ( humidity )  THEN
-!
-!--       If precipitation is activated, add rain water to qsws_liq
-!--       and qsws_soil according the the vegetation coverage.
-!--       precipitation_rate is given in mm.
-          IF ( precipitation )  THEN
-
-!
-!--          Add precipitation to liquid water reservoir, if possible.
-!--          Otherwise, add the water to soil. In case of
-!--          pavements, the exceeding water amount is implicitely removed 
-!--          as runoff as qsws_soil is then not used in the soil model
-             IF ( m_liq_usm_h%var_usm_1d(m) /= m_liq_max )  THEN
-                surf_usm_h%qsws_liq(m) = surf_usm_h%qsws_liq(m)                            &
-                                 + surf_usm_h%frac(ind_pav_green,m) * prr(k+k_off,j+j_off,i+i_off)&
-                                 * hyrho(k+k_off)                              &
-                                 * 0.001_wp * rho_l * l_v
-             ENDIF
-
-          ENDIF
-
-!
-!--       If the air is saturated, check the reservoir water level
-          IF ( surf_usm_h%qsws(m) < 0.0_wp )  THEN
-!
-!--          Check if reservoir is full (avoid values > m_liq_max)
-!--          In that case, qsws_liq goes to qsws_soil. In this 
-!--          case qsws_veg is zero anyway (because c_liq = 1),       
-!--          so that tend is zero and no further check is needed
-             IF ( m_liq_usm_h%var_usm_1d(m) == m_liq_max )  THEN
-!                 surf_usm_h%qsws_soil(m) = surf_usm_h%qsws_soil(m) + surf_usm_h%qsws_liq(m)
-
-                surf_usm_h%qsws_liq(m)  = 0.0_wp
-             ENDIF
-
-!
-!--          In case qsws_veg becomes negative (unphysical behavior), 
-!--          let the water enter the liquid water reservoir as dew on the
-!--          plant
-             IF ( surf_usm_h%qsws_veg(m) < 0.0_wp )  THEN
-                surf_usm_h%qsws_liq(m) = surf_usm_h%qsws_liq(m) + surf_usm_h%qsws_veg(m)
-                surf_usm_h%qsws_veg(m) = 0.0_wp
-             ENDIF
-          ENDIF                    
+
+           IF (surf_usm_h%frac(ind_pav_green,m) > 0.0_wp) THEN
+
+              IF ( humidity )  THEN
+                 surf_usm_h%qsws_eb(m)  = - f_qsws * ( qv1 - q_s + dq_s_dt                  &
+                                 * t_surf_green_h(m) - dq_s_dt *               &
+                                   t_surf_green_h_p(m) )
+       
+                 surf_usm_h%qsws(m) = surf_usm_h%qsws_eb(m) / rho_lv
+       
+                 surf_usm_h%qsws_veg(m)  = - f_qsws_veg  * ( qv1 - q_s                      &
+                                     + dq_s_dt * t_surf_green_h(m) - dq_s_dt   &
+                                     * t_surf_green_h_p(m) )
+       
+                 surf_usm_h%qsws_liq(m)  = - f_qsws_liq  * ( qv1 - q_s                      &
+                                     + dq_s_dt * t_surf_green_h(m) - dq_s_dt   &
+                                     * t_surf_green_h_p(m) )
+              ENDIF
  
-          surf_usm_h%qsws(m) = surf_usm_h%qsws(m) / l_v
+!
+!--           Calculate the true surface resistance
+              IF ( .NOT.  humidity )  THEN
+                 surf_usm_h%r_s(m) = 1.0E10_wp
+              ELSE
+                 surf_usm_h%r_s(m) = - rho_lv * ( qv1 - q_s + dq_s_dt                       &
+                                 *  t_surf_green_h(m) - dq_s_dt *              &
+                                   t_surf_green_h_p(m) ) /                     &
+                                   (surf_usm_h%qsws(m) + 1.0E-20)  - surf_usm_h%r_a_green(m)
+              ENDIF
  
-          tend = - surf_usm_h%qsws_liq(m) * drho_l_lv
-          m_liq_usm_h_p%var_usm_1d(m) = m_liq_usm_h%var_usm_1d(m) + dt_3d *    &
-                                        ( tsc(2) * tend +                      &
-                                          tsc(3) * tm_liq_usm_h_m%var_usm_1d(m) )
-!
-!--       Check if reservoir is overfull -> reduce to maximum
-!--       (conservation of water is violated here)
-          m_liq_usm_h_p%var_usm_1d(m) = MIN( m_liq_usm_h_p%var_usm_1d(m),m_liq_max )
-
-!
-!--       Check if reservoir is empty (avoid values < 0.0)
-!--       (conservation of water is violated here)
-          m_liq_usm_h_p%var_usm_1d(m) = MAX( m_liq_usm_h_p%var_usm_1d(m), 0.0_wp )
-!
-!--       Calculate m_liq tendencies for the next Runge-Kutta step
-          IF ( timestep_scheme(1:5) == 'runge' )  THEN
-             IF ( intermediate_timestep_count == 1 )  THEN
-                tm_liq_usm_h_m%var_usm_1d(m) = tend
-             ELSEIF ( intermediate_timestep_count <                            &
-                      intermediate_timestep_count_max )  THEN
-                tm_liq_usm_h_m%var_usm_1d(m) = -9.5625_wp * tend +             &
-                                              5.3125_wp * tm_liq_usm_h_m%var_usm_1d(m)
-             ENDIF
-          ENDIF
-
-       ENDIF
-else
-  surf_usm_h%r_s(m) = 1.0E10_wp
-endif
-
+!
+!--           Calculate change in liquid water reservoir due to dew fall or 
+!--           evaporation of liquid water
+              IF ( humidity )  THEN
+!
+!--              If precipitation is activated, add rain water to qsws_liq
+!--              and qsws_soil according the the vegetation coverage.
+!--              precipitation_rate is given in mm.
+                 IF ( precipitation )  THEN
+
+!
+!--                 Add precipitation to liquid water reservoir, if possible.
+!--                 Otherwise, add the water to soil. In case of
+!--                 pavements, the exceeding water amount is implicitely removed 
+!--                 as runoff as qsws_soil is then not used in the soil model
+                    IF ( m_liq_usm_h%var_usm_1d(m) /= m_liq_max )  THEN
+                       surf_usm_h%qsws_liq(m) = surf_usm_h%qsws_liq(m)                &
+                                        + surf_usm_h%frac(ind_pav_green,m) * prr(k+k_off,j+j_off,i+i_off)&
+                                        * hyrho(k+k_off)                              &
+                                        * 0.001_wp * rho_l * l_v
+                   ENDIF
+
+                 ENDIF
+
+!
+!--              If the air is saturated, check the reservoir water level
+                 IF ( surf_usm_h%qsws(m) < 0.0_wp )  THEN
+!
+!--                 Check if reservoir is full (avoid values > m_liq_max)
+!--                 In that case, qsws_liq goes to qsws_soil. In this 
+!--                 case qsws_veg is zero anyway (because c_liq = 1),       
+!--                 so that tend is zero and no further check is needed
+                    IF ( m_liq_usm_h%var_usm_1d(m) == m_liq_max )  THEN
+!                      surf_usm_h%qsws_soil(m) = surf_usm_h%qsws_soil(m) + surf_usm_h%qsws_liq(m)
+                       surf_usm_h%qsws_liq(m)  = 0.0_wp
+                    ENDIF
+
+!
+!--                 In case qsws_veg becomes negative (unphysical behavior), 
+!--                 let the water enter the liquid water reservoir as dew on the
+!--                 plant
+                    IF ( surf_usm_h%qsws_veg(m) < 0.0_wp )  THEN
+                       surf_usm_h%qsws_liq(m) = surf_usm_h%qsws_liq(m) + surf_usm_h%qsws_veg(m)
+                       surf_usm_h%qsws_veg(m) = 0.0_wp
+                    ENDIF
+                 ENDIF                    
+  
+                 surf_usm_h%qsws(m) = surf_usm_h%qsws(m) / l_v
+        
+                 tend = - surf_usm_h%qsws_liq(m) * drho_l_lv
+                 m_liq_usm_h_p%var_usm_1d(m) = m_liq_usm_h%var_usm_1d(m) + dt_3d *    &
+                                               ( tsc(2) * tend +                      &
+                                                 tsc(3) * tm_liq_usm_h_m%var_usm_1d(m) )
+!
+!--             Check if reservoir is overfull -> reduce to maximum
+!--             (conservation of water is violated here)
+                 m_liq_usm_h_p%var_usm_1d(m) = MIN( m_liq_usm_h_p%var_usm_1d(m),m_liq_max )
+ 
+!
+!--             Check if reservoir is empty (avoid values < 0.0)
+!--             (conservation of water is violated here)
+                 m_liq_usm_h_p%var_usm_1d(m) = MAX( m_liq_usm_h_p%var_usm_1d(m), 0.0_wp )
+!
+!--             Calculate m_liq tendencies for the next Runge-Kutta step
+                 IF ( timestep_scheme(1:5) == 'runge' )  THEN
+                    IF ( intermediate_timestep_count == 1 )  THEN
+                       tm_liq_usm_h_m%var_usm_1d(m) = tend
+                    ELSEIF ( intermediate_timestep_count <                            &
+                             intermediate_timestep_count_max )  THEN
+                       tm_liq_usm_h_m%var_usm_1d(m) = -9.5625_wp * tend +             &
+                                                     5.3125_wp * tm_liq_usm_h_m%var_usm_1d(m)
+                    ENDIF
+                 ENDIF
+ 
+              ENDIF
+           ELSE
+              surf_usm_h%r_s(m) = 1.0E10_wp
+           ENDIF
+ 
        ENDDO
 !
-!--    Now, treat vertical surface elements
+!--   Now, treat vertical surface elements
        DO  l = 0, 3
-          DO  m = 1, surf_usm_v(l)%ns
+           DO  m = 1, surf_usm_v(l)%ns
 !
 !--          Get indices of respective grid point
-             i = surf_usm_v(l)%i(m)
-             j = surf_usm_v(l)%j(m)
-             k = surf_usm_v(l)%k(m)
-
+              i = surf_usm_v(l)%i(m)
+              j = surf_usm_v(l)%j(m)
+              k = surf_usm_v(l)%k(m)
+ 
 !
 !--          TODO - how to calculate lambda_surface for horizontal (??? do you mean verical ???) surfaces
@@ -8024,25 +8079,25 @@
 !--          Please note, for vertical surfaces no ol is defined, since 
 !--          stratification is not considered in this case.
-             lambda_surface = surf_usm_v(l)%lambda_surf(m)
-             lambda_surface_window = surf_usm_v(l)%lambda_surf_window(m)
-             lambda_surface_green = surf_usm_v(l)%lambda_surf_green(m)
-
+              lambda_surface = surf_usm_v(l)%lambda_surf(m)
+              lambda_surface_window = surf_usm_v(l)%lambda_surf_window(m)
+              lambda_surface_green = surf_usm_v(l)%lambda_surf_green(m)
+ 
 !            pt1  = pt(k,j,i)
-           IF ( humidity )  THEN
-              qv1 = q(k,j,i)
-           ELSE
-              qv1 = 0.0_wp
-           ENDIF
+              IF ( humidity )  THEN
+                 qv1 = q(k,j,i)
+              ELSE
+                 qv1 = 0.0_wp
+              ENDIF
 !
 !--          calculate rho * c_p coefficient at wall layer
-             rho_cp  = c_p * hyp(k) / ( r_d * surf_usm_v(l)%pt1(m) * exner(k) )
-             
-            IF (surf_usm_v(l)%frac(1,m) > 0.0_wp )  THEN
+              rho_cp  = c_p * hyp(k) / ( r_d * surf_usm_v(l)%pt1(m) * exner(k) )
+              
+              IF (surf_usm_v(l)%frac(1,m) > 0.0_wp )  THEN
 !
 !--            Calculate frequently used parameters
-               rho_lv    = rho_cp / c_p * l_v
-               drho_l_lv = 1.0_wp / (rho_l * l_v)
-            ENDIF
-
+                 rho_lv    = rho_cp / c_p * l_v
+                 drho_l_lv = 1.0_wp / (rho_l * l_v)
+              ENDIF
+ 
 !--          Calculation of r_a for vertical surfaces
 !--
@@ -8063,5 +8118,4 @@
 !--                zH: height of the convective layer
 !--                wstar = (g/Tcan*Qs*zH)**(1./3.)
-                
 !--          Effective velocity components must always 
 !--          be defined at scalar grid point. The wall normal component is 
@@ -8070,180 +8124,162 @@
 !--          Parameter roughness_concrete (default value = 0.001) is used
 !--          to calculation of roughness relative to concrete
-             surf_usm_v(l)%r_a(m) = rho_cp / ( surf_usm_v(l)%z0(m) /           &
-                        roughness_concrete * ( 11.8_wp + 4.2_wp *              &
-                        SQRT( MAX( ( ( u(k,j,i) + u(k,j,i+1) ) * 0.5_wp )**2 + &
-                                   ( ( v(k,j,i) + v(k,j+1,i) ) * 0.5_wp )**2 + &
-                                   ( ( w(k,j,i) + w(k-1,j,i) ) * 0.5_wp )**2,  &
-                              0.01_wp ) )                                      &
-                           )  - 4.0_wp  ) 
+              surf_usm_v(l)%r_a(m) = rho_cp / ( surf_usm_v(l)%z0(m) /           &
+                         roughness_concrete * ( 11.8_wp + 4.2_wp *              &
+                         SQRT( MAX( ( ( u(k,j,i) + u(k,j,i+1) ) * 0.5_wp )**2 + &
+                                    ( ( v(k,j,i) + v(k,j+1,i) ) * 0.5_wp )**2 + &
+                                    ( ( w(k,j,i) + w(k-1,j,i) ) * 0.5_wp )**2,  &
+                               0.01_wp ) )                                      &
+                            )  - 4.0_wp  ) 
 !
 !--          Limit aerodynamic resistance
-             IF ( surf_usm_v(l)%r_a(m) < 1.0_wp )  surf_usm_v(l)%r_a(m) = 1.0_wp   
-             
-                           
-             f_shf         = rho_cp / surf_usm_v(l)%r_a(m)
-             f_shf_window  = rho_cp / surf_usm_v(l)%r_a(m)
-             f_shf_green   = rho_cp / surf_usm_v(l)%r_a(m)
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-if (surf_usm_v(l)%frac(1,m).gt.0.0_wp) then
-!--    Adapted from LSM:
-!--    Second step: calculate canopy resistance r_canopy
-!--    f1-f3 here are defined as 1/f1-f3 as in ECMWF documentation
+              IF ( surf_usm_v(l)%r_a(m) < 1.0_wp )  surf_usm_v(l)%r_a(m) = 1.0_wp   
+              
+                            
+              f_shf         = rho_cp / surf_usm_v(l)%r_a(m)
+              f_shf_window  = rho_cp / surf_usm_v(l)%r_a(m)
+              f_shf_green   = rho_cp / surf_usm_v(l)%r_a(m)
  
-!--    f1: correction for incoming shortwave radiation (stomata close at 
-!--    night)
-       f1 = MIN( 1.0_wp, ( 0.004_wp * surf_usm_v(l)%rad_sw_in(m) + 0.05_wp ) / &
-                        (0.81_wp * (0.004_wp * surf_usm_v(l)%rad_sw_in(m)      &
-                         + 1.0_wp)) )
-!
-!--    f2: correction for soil moisture availability to plants (the 
-!--    integrated soil moisture must thus be considered here)
-!--    f2 = 0 for very dry soils
-
-f2=1.0_wp
-!           m_total = 0.0_wp
-!           DO  k = nzb_wall, nzt_wall+1
-!               m_total = m_total + rootfr_h(nzb_wall,m)                              &
-!                         * MAX(swc_h(nzb_wall,m),wilt_h(nzb_wall,m))
-!           ENDDO 
-! 
-!           IF ( m_total > wilt_h(nzb_wall,m)  .AND.  m_total < fc_h(nzb_wall,m) )  THEN
-!              f2 = ( m_total - wilt_h(nzb_wall,m) ) / (fc_h(nzb_wall,m) - wilt_h(nzb_wall,m) )
-!           ELSEIF ( m_total >= fc_h(nzb_wall,m) )  THEN
-!              f2 = 1.0_wp
-!           ELSE
-!              f2 = 1.0E-20_wp
-!           ENDIF
-
-!
-!--    Calculate water vapour pressure at saturation 
-       e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp * (  t_surf_green_v_p(l)%t(m) &
-                     - 273.16_wp ) / (  t_surf_green_v_p(l)%t(m) - 35.86_wp ) )
-!
-!--    f3: correction for vapour pressure deficit
-       IF ( surf_usm_v(l)%g_d(m) /= 0.0_wp )  THEN
-!
-!--       Calculate vapour pressure
-          e  = qv1 * surface_pressure / ( qv1 + 0.622_wp )
-          f3 = EXP ( - surf_usm_v(l)%g_d(m) * (e_s - e) )
-       ELSE
-          f3 = 1.0_wp
-       ENDIF
-!
-!--    Calculate canopy resistance. In case that c_veg is 0 (bare soils),
-!--    this calculation is obsolete, as r_canopy is not used below.
-!--    To do: check for very dry soil -> r_canopy goes to infinity
-       surf_usm_v(l)%r_canopy(m) = surf_usm_v(l)%r_canopy_min(m) /                               &
-                              ( surf_usm_v(l)%lai(m) * f1 * f2 * f3 + 1.0E-20_wp )
-                              
-! !--    Calculate the maximum possible liquid water amount on plants and
-! !--    bare surface. For vegetated surfaces, a maximum depth of 0.2 mm is
-! !--    assumed, while paved surfaces might hold up 1 mm of water. The 
-! !--    liquid water fraction for paved surfaces is calculated after 
-! !--    Noilhan & Planton (1989), while the ECMWF formulation is used for
-! !--    vegetated surfaces and bare soils.
-! ! surf_usm_h%lai(m)=4.0_wp
-!        m_liq_max = m_max_depth * ( surf_usm_h%lai(m) )
-!        surf_usm_h%c_liq(m) = MIN( 1.0_wp, ( m_liq_usm_h%var_usm_1d(m) / m_liq_max )**0.67 )
-!
-!--    Calculate saturation specific humidity
-       q_s = 0.622_wp * e_s / ( surface_pressure - e_s )
-!
-!--    In case of dewfall, set evapotranspiration to zero
-!--    All super-saturated water is then removed from the air
-       IF ( humidity  .AND.  q_s <= qv1 )  THEN
-          surf_usm_v(l)%r_canopy(m) = 0.0_wp
-       ENDIF
-
-!
-!--    Calculate coefficients for the total evapotranspiration 
-!--    In case of water surface, set vegetation and soil fluxes to zero.
-!--    For pavements, only evaporation of liquid water is possible.
-       f_qsws_veg  = rho_lv *                                &
-                         ( 1.0_wp        - 0.0_wp ) / & !surf_usm_h%c_liq(m)    ) /   &
-                         ( surf_usm_v(l)%r_a(m) + surf_usm_v(l)%r_canopy(m) )
-!        f_qsws_liq  = rho_lv * surf_usm_h%c_liq(m)   /             &
-!                            surf_usm_h%r_a_green(m)
-
-       f_qsws = f_qsws_veg! + f_qsws_liq
-!
-!--    Calculate derivative of q_s for Taylor series expansion
-       e_s_dt = e_s * ( 17.269_wp / ( t_surf_green_v_p(l)%t(m) - 35.86_wp) -   &
-                        17.269_wp*( t_surf_green_v_p(l)%t(m) - 273.16_wp)      &
-                       / ( t_surf_green_v_p(l)%t(m) - 35.86_wp)**2 )
-
-       dq_s_dt = 0.622_wp * e_s_dt / ( surface_pressure - e_s_dt )
-endif
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-                
-!--          add LW up so that it can be removed in prognostic equation
-             surf_usm_v(l)%rad_net_l(m) = surf_usm_v(l)%rad_sw_in(m)  -        &
-                                          surf_usm_v(l)%rad_sw_out(m) +        &
-                                          surf_usm_v(l)%rad_lw_in(m)  -        &
-                                          surf_usm_v(l)%rad_lw_out(m)
-
+
+              IF ( surf_usm_v(l)%frac(1,m) > 0.0_wp ) THEN
+!
+!--             Adapted from LSM:
+!--             Second step: calculate canopy resistance r_canopy
+!--             f1-f3 here are defined as 1/f1-f3 as in ECMWF documentation
+!--             f1: correction for incoming shortwave radiation (stomata close at 
+!--             night)
+                 f1 = MIN( 1.0_wp, ( 0.004_wp * surf_usm_v(l)%rad_sw_in(m) + 0.05_wp ) / &
+                                  (0.81_wp * (0.004_wp * surf_usm_v(l)%rad_sw_in(m)      &
+                                   + 1.0_wp)) )
+!
+!--             f2: correction for soil moisture availability to plants (the 
+!--             integrated soil moisture must thus be considered here)
+!--             f2 = 0 for very dry soils
+ 
+                 f2=1.0_wp
+ 
+!
+!--              Calculate water vapour pressure at saturation 
+                 e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp * (  t_surf_green_v_p(l)%t(m) &
+                               - 273.16_wp ) / (  t_surf_green_v_p(l)%t(m) - 35.86_wp ) )
+!
+!--              f3: correction for vapour pressure deficit
+                 IF ( surf_usm_v(l)%g_d(m) /= 0.0_wp )  THEN
+!
+!--                 Calculate vapour pressure
+                    e  = qv1 * surface_pressure / ( qv1 + 0.622_wp )
+                    f3 = EXP ( - surf_usm_v(l)%g_d(m) * (e_s - e) )
+                 ELSE
+                    f3 = 1.0_wp
+                 ENDIF
+!
+!--              Calculate canopy resistance. In case that c_veg is 0 (bare soils),
+!--              this calculation is obsolete, as r_canopy is not used below.
+!--              To do: check for very dry soil -> r_canopy goes to infinity
+                 surf_usm_v(l)%r_canopy(m) = surf_usm_v(l)%r_canopy_min(m) /                  &
+                                        ( surf_usm_v(l)%lai(m) * f1 * f2 * f3 + 1.0E-20_wp )
+                               
+!
+!--              Calculate saturation specific humidity
+                 q_s = 0.622_wp * e_s / ( surface_pressure - e_s )
+!
+!--              In case of dewfall, set evapotranspiration to zero
+!--              All super-saturated water is then removed from the air
+                 IF ( humidity  .AND.  q_s <= qv1 )  THEN
+                    surf_usm_v(l)%r_canopy(m) = 0.0_wp
+                 ENDIF
+ 
+!
+!--              Calculate coefficients for the total evapotranspiration 
+!--              In case of water surface, set vegetation and soil fluxes to zero.
+!--              For pavements, only evaporation of liquid water is possible.
+                 f_qsws_veg  = rho_lv *                                &
+                                   ( 1.0_wp        - 0.0_wp ) / & !surf_usm_h%c_liq(m)    ) /   &
+                                   ( surf_usm_v(l)%r_a(m) + surf_usm_v(l)%r_canopy(m) )
+!                f_qsws_liq  = rho_lv * surf_usm_h%c_liq(m)   /             &
+!                              surf_usm_h%r_a_green(m)
+          
+                 f_qsws = f_qsws_veg! + f_qsws_liq
+!
+!--              Calculate derivative of q_s for Taylor series expansion
+                 e_s_dt = e_s * ( 17.269_wp / ( t_surf_green_v_p(l)%t(m) - 35.86_wp) -   &
+                                  17.269_wp*( t_surf_green_v_p(l)%t(m) - 273.16_wp)      &
+                                 / ( t_surf_green_v_p(l)%t(m) - 35.86_wp)**2 )
+          
+                 dq_s_dt = 0.622_wp * e_s_dt / ( surface_pressure - e_s_dt )
+              ENDIF
+
+!
+!--           add LW up so that it can be removed in prognostic equation
+              surf_usm_v(l)%rad_net_l(m) = surf_usm_v(l)%rad_sw_in(m)  -        &
+                                           surf_usm_v(l)%rad_sw_out(m) +        &
+                                           surf_usm_v(l)%rad_lw_in(m)  -        &
+                                           surf_usm_v(l)%rad_lw_out(m)
+!
 !--           numerator of the prognostic equation
-              coef_1 = surf_usm_v(l)%rad_net_l(m) +                            & ! coef +1 corresponds to -lwout included in calculation of radnet_l
-             ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_veg_wall,m) *  &
-                                     sigma_sb *  t_surf_wall_v(l)%t(m) ** 4 +       &  
-                                     f_shf * surf_usm_v(l)%pt1(m) +            &
-                                     lambda_surface * t_wall_v(l)%t(nzb_wall,m)
-if ((.NOT. spinup).AND.(surf_usm_v(l)%frac(ind_wat_win,m).GT.0.0_wp)) then
-              coef_window_1 = surf_usm_v(l)%rad_net_l(m) +                     & ! coef +1 corresponds to -lwout included in calculation of radnet_l
-               ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_wat_win,m) * &
-                                     sigma_sb * t_surf_window_v(l)%t(m) ** 4 + &  
-                                     f_shf * surf_usm_v(l)%pt1(m) +            &
-                                     lambda_surface_window * t_window_v(l)%t(nzb_wall,m)
-endif
-           IF ( (humidity).and.(surf_usm_v(l)%frac(ind_pav_green,m).gt.0.0_wp) )  THEN
-              coef_green_1 = surf_usm_v(l)%rad_net_l(m) +                      & ! coef +1 corresponds to -lwout included in calculation of radnet_l
-               ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *  &
-                                     t_surf_green_v(l)%t(m) ** 4 +               &  
-                                     f_shf * surf_usm_v(l)%pt1(m) +     f_qsws * ( qv1 - q_s    &
-                                          + dq_s_dt * t_surf_green_v(l)%t(m) ) +            &
-                                     lambda_surface_green * t_wall_v(l)%t(nzb_wall,m)
-           ELSE
-              coef_green_1 = surf_usm_v(l)%rad_net_l(m) +                        & ! coef +1 corresponds to -lwout included in calculation of radnet_l
-               ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *  &
-                                     t_surf_green_v(l)%t(m) ** 4 +               &  
-                                     f_shf * surf_usm_v(l)%pt1(m) +            &
-                                     lambda_surface_green * t_wall_v(l)%t(nzb_wall,m)
-           ENDIF
-                                     
-
+              coef_1 = surf_usm_v(l)%rad_net_l(m) +                             & ! coef +1 corresponds to -lwout
+                                                                                  ! included in calculation of radnet_l
+              ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_veg_wall,m) *  &
+                                      sigma_sb *  t_surf_wall_v(l)%t(m) ** 4 +  &  
+                                      f_shf * surf_usm_v(l)%pt1(m) +            &
+                                      lambda_surface * t_wall_v(l)%t(nzb_wall,m)
+              IF ( ( .NOT. spinup ) .AND. ( surf_usm_v(l)%frac(ind_wat_win,m) > 0.0_wp ) ) THEN
+                 coef_window_1 = surf_usm_v(l)%rad_net_l(m) +                   & ! coef +1 corresponds to -lwout
+                                                                                  ! included in calculation of radnet_l
+                ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_wat_win,m) * &
+                                      sigma_sb * t_surf_window_v(l)%t(m) ** 4 + &  
+                                      f_shf * surf_usm_v(l)%pt1(m) +            &
+                                      lambda_surface_window * t_window_v(l)%t(nzb_wall,m)
+              ENDIF
+              IF ( ( humidity ) .AND. ( surf_usm_v(l)%frac(ind_pav_green,m) > 0.0_wp ) )  THEN
+                 coef_green_1 = surf_usm_v(l)%rad_net_l(m) +                      & ! coef +1 corresponds to -lwout
+                                                                                    ! included in calculation of radnet_l
+                 ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *  &
+                                      t_surf_green_v(l)%t(m) ** 4 +               &  
+                                      f_shf * surf_usm_v(l)%pt1(m) +     f_qsws * ( qv1 - q_s  &
+                                           + dq_s_dt * t_surf_green_v(l)%t(m) ) +              &
+                                      lambda_surface_green * t_wall_v(l)%t(nzb_wall,m)
+              ELSE
+                coef_green_1 = surf_usm_v(l)%rad_net_l(m) +                       & ! coef +1 corresponds to -lwout included
+                                                                                    ! in calculation of radnet_l
+                ( 3.0_wp + 1.0_wp ) * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *  &
+                                      t_surf_green_v(l)%t(m) ** 4 +               &  
+                                      f_shf * surf_usm_v(l)%pt1(m) +              &
+                                      lambda_surface_green * t_wall_v(l)%t(nzb_wall,m)
+              ENDIF
+                                      
+!
 !--           denominator of the prognostic equation
-              coef_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_veg_wall,m) * sigma_sb *           &
-                                t_surf_wall_v(l)%t(m) ** 3                           &
-                              + lambda_surface + f_shf / exner(k)  
-if ((.NOT. spinup).AND.(surf_usm_v(l)%frac(ind_wat_win,m).GT.0.0_wp)) then             
-              coef_window_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_wat_win,m) * sigma_sb *           &
-                                t_surf_window_v(l)%t(m) ** 3                         &
-                              + lambda_surface_window + f_shf / exner(k)
-endif
-           IF ( (humidity).and.(surf_usm_v(l)%frac(ind_pav_green,m).gt.0.0_wp) )  THEN
-               coef_green_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *     &
-                                t_surf_green_v(l)%t(m) ** 3  + f_qsws * dq_s_dt      &
-                              + lambda_surface_green + f_shf / exner(k)
-           ELSE
-              coef_green_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *     &
-                                t_surf_green_v(l)%t(m) ** 3                          &
-                              + lambda_surface_green + f_shf / exner(k)
-           ENDIF
-
+              coef_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_veg_wall,m) * sigma_sb *   &
+                                 t_surf_wall_v(l)%t(m) ** 3                             &
+                               + lambda_surface + f_shf / exner(k)  
+              IF ( ( .NOT. spinup ) .AND. ( surf_usm_v(l)%frac(ind_wat_win,m) > 0.0_wp ) ) THEN             
+                 coef_window_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_wat_win,m) * sigma_sb *       &
+                                   t_surf_window_v(l)%t(m) ** 3                         &
+                                 + lambda_surface_window + f_shf / exner(k)
+              ENDIF
+              IF ( ( humidity ) .AND. ( surf_usm_v(l)%frac(ind_pav_green,m) > 0.0_wp ) )  THEN
+                  coef_green_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *     &
+                                   t_surf_green_v(l)%t(m) ** 3  + f_qsws * dq_s_dt      &
+                                 + lambda_surface_green + f_shf / exner(k)
+              ELSE
+                 coef_green_2 = 4.0_wp * surf_usm_v(l)%emissivity(ind_pav_green,m) * sigma_sb *      &
+                                   t_surf_green_v(l)%t(m) ** 3                          &
+                                 + lambda_surface_green + f_shf / exner(k)
+              ENDIF
+!
 !--           implicit solution when the surface layer has no heat capacity,
 !--           otherwise use RK3 scheme.
               t_surf_wall_v_p(l)%t(m) = ( coef_1 * dt_3d * tsc(2) +                 &
                              surf_usm_v(l)%c_surface(m) * t_surf_wall_v(l)%t(m) ) / & 
-                           ( surf_usm_v(l)%c_surface(m) + coef_2 * dt_3d * tsc(2) ) 
-if ((.NOT. spinup).AND.(surf_usm_v(l)%frac(ind_wat_win,m).GT.0.0_wp)) then
-              t_surf_window_v_p(l)%t(m) = ( coef_window_1 * dt_3d * tsc(2) +                 &
-                             surf_usm_v(l)%c_surface_window(m) * t_surf_window_v(l)%t(m) ) / & 
-                           ( surf_usm_v(l)%c_surface_window(m) + coef_window_2 * dt_3d * tsc(2) ) 
-endif
+                             ( surf_usm_v(l)%c_surface(m) + coef_2 * dt_3d * tsc(2) ) 
+              IF ( ( .NOT. spinup ) .AND. ( surf_usm_v(l)%frac(ind_wat_win,m) > 0.0_wp ) ) THEN
+                 t_surf_window_v_p(l)%t(m) = ( coef_window_1 * dt_3d * tsc(2) +                 &
+                                surf_usm_v(l)%c_surface_window(m) * t_surf_window_v(l)%t(m) ) / & 
+                              ( surf_usm_v(l)%c_surface_window(m) + coef_window_2 * dt_3d * tsc(2) ) 
+              ENDIF
               t_surf_green_v_p(l)%t(m) = ( coef_green_1 * dt_3d * tsc(2) +                 &
                              surf_usm_v(l)%c_surface_green(m) * t_surf_green_v(l)%t(m) ) / & 
                            ( surf_usm_v(l)%c_surface_green(m) + coef_green_2 * dt_3d * tsc(2) ) 
-
+!
 !--           add RK3 term
               t_surf_wall_v_p(l)%t(m) = t_surf_wall_v_p(l)%t(m) + dt_3d * tsc(3) *         &
@@ -8252,5 +8288,5 @@
                                 surf_usm_v(l)%tt_surface_window_m(m)
               t_surf_green_v_p(l)%t(m) = t_surf_green_v_p(l)%t(m) + dt_3d * tsc(3) *       &
-                                surf_usm_v(l)%tt_surface_green_m(m)
+                                 surf_usm_v(l)%tt_surface_green_m(m)
 !
 !--           Store surface temperature. Further, in case humidity is used
@@ -8258,13 +8294,13 @@
 !--           assumed to be the surface temperature.     
               surf_usm_v(l)%pt_surface(m) =  ( surf_usm_v(l)%frac(ind_veg_wall,m) * t_surf_wall_v_p(l)%t(m)  &
-                                      + surf_usm_v(l)%frac(ind_wat_win,m) * t_surf_window_v_p(l)%t(m)  &
-                                      + surf_usm_v(l)%frac(ind_pav_green,m) * t_surf_green_v_p(l)%t(m) ) &
+                                      + surf_usm_v(l)%frac(ind_wat_win,m) * t_surf_window_v_p(l)%t(m)        &
+                                      + surf_usm_v(l)%frac(ind_pav_green,m) * t_surf_green_v_p(l)%t(m) )     &
                                       / exner(k)
-                                      
+                                       
               IF ( humidity )  surf_usm_v(l)%vpt_surface(m) =                  &
-                                                    surf_usm_v(l)%pt_surface(m)
-
+                                                     surf_usm_v(l)%pt_surface(m)
+!
 !--           calculate true tendency
-              stend_wall = ( t_surf_wall_v_p(l)%t(m) - t_surf_wall_v(l)%t(m) - dt_3d * tsc(3) *&
+              stend_wall = ( t_surf_wall_v_p(l)%t(m) - t_surf_wall_v(l)%t(m) - dt_3d * tsc(3) *      &
                         surf_usm_v(l)%tt_surface_wall_m(m) ) / ( dt_3d  * tsc(2) )
               stend_window = ( t_surf_window_v_p(l)%t(m) - t_surf_window_v(l)%t(m) - dt_3d * tsc(3) *&
@@ -8273,4 +8309,5 @@
                         surf_usm_v(l)%tt_surface_green_m(m) ) / ( dt_3d  * tsc(2) )
 
+!
 !--           calculate t_surf_* tendencies for the next Runge-Kutta step
               IF ( timestep_scheme(1:5) == 'runge' )  THEN
@@ -8290,7 +8327,8 @@
               ENDIF
 
+!
 !--           in case of fast changes in the skin temperature, it is required to
 !--           update the radiative fluxes in order to keep the solution stable
-
+ 
               IF ( ( ( ABS( t_surf_wall_v_p(l)%t(m)   - t_surf_wall_v(l)%t(m) )   > 1.0_wp ) .OR. &
                    (   ABS( t_surf_green_v_p(l)%t(m)  - t_surf_green_v(l)%t(m) )  > 1.0_wp ) .OR. &
@@ -8300,4 +8338,5 @@
               ENDIF
 
+!
 !--           calculate fluxes
 !--           prognostic rad_net_l is used just for output!           
@@ -8305,6 +8344,6 @@
                                            ( surf_usm_v(l)%rad_net_l(m) +                            &
                                            3.0_wp * sigma_sb *                                       &
-                                           t_surf_wall_v(l)%t(m)**4 - 4.0_wp * sigma_sb *                 &
-                                           t_surf_wall_v(l)%t(m)**3 * t_surf_wall_v_p(l)%t(m) )                &
+                                           t_surf_wall_v(l)%t(m)**4 - 4.0_wp * sigma_sb *            &
+                                           t_surf_wall_v(l)%t(m)**3 * t_surf_wall_v_p(l)%t(m) )      &
                                          + surf_usm_v(l)%frac(ind_wat_win,m) *                       &
                                            ( surf_usm_v(l)%rad_net_l(m) +                            &
@@ -8320,9 +8359,10 @@
               surf_usm_v(l)%wghf_eb_window(m) = lambda_surface_window * &
                                                 ( t_surf_window_v_p(l)%t(m) - t_window_v(l)%t(nzb_wall,m) )
-              surf_usm_v(l)%wghf_eb(m)   = lambda_surface *                    &
-                                     ( t_surf_wall_v_p(l)%t(m) - t_wall_v(l)%t(nzb_wall,m) )
+              surf_usm_v(l)%wghf_eb(m)   = lambda_surface *             &
+                                                ( t_surf_wall_v_p(l)%t(m) - t_wall_v(l)%t(nzb_wall,m) )
               surf_usm_v(l)%wghf_eb_green(m)  = lambda_surface_green *  &
                                                 ( t_surf_green_v_p(l)%t(m) - t_green_v(l)%t(nzb_wall,m) )
 
+!
 !--           ground/wall/roof surface heat flux
               surf_usm_v(l)%wshf_eb(m)   =                                     &
@@ -8339,124 +8379,114 @@
               surf_usm_v(l)%shf(m) = surf_usm_v(l)%wshf_eb(m) / c_p
 
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-if (surf_usm_v(l)%frac(ind_pav_green,m).gt.0.0_wp) then !111
-
-! 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),&
-!         surf_usm_h%wshf_eb(m),f_qsws_veg,f_qsws_liq,dq_s_dt
-! 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)
-! print*, "lambdasurface",lambda_surface_green,lambda_surface,i,j,k
-! print*, "fractions",i,j,k,surf_usm_h%frac(0:2,m)
-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
-  print*, t_surf_green_v_p(l)%t(m),m,i,j,k
-  stop
-endif
-
-       IF ( humidity )  THEN
-          surf_usm_v(l)%qsws_eb(m)  = - f_qsws * ( qv1 - q_s + dq_s_dt                     &
-                          * t_surf_green_v(l)%t(m) - dq_s_dt *               &
-                            t_surf_green_v_p(l)%t(m) )
-
-          surf_usm_v(l)%qsws(m) = surf_usm_v(l)%qsws_eb(m) / rho_lv
-
-          surf_usm_v(l)%qsws_veg(m)  = - f_qsws_veg  * ( qv1 - q_s                      &
-                              + dq_s_dt * t_surf_green_v(l)%t(m) - dq_s_dt   &
-                              * t_surf_green_v_p(l)%t(m) )
-
-!           surf_usm_h%qsws_liq(m)  = - f_qsws_liq  * ( qv1 - q_s                      &
-!                               + dq_s_dt * t_surf_green_h(m) - dq_s_dt   &
-!                               * t_surf_green_h_p(m) )
-       ENDIF
-
-!
-!--    Calculate the true surface resistance
-       IF ( .NOT.  humidity )  THEN
-          surf_usm_v(l)%r_s(m) = 1.0E10_wp
-       ELSE
-          surf_usm_v(l)%r_s(m) = - rho_lv * ( qv1 - q_s + dq_s_dt                       &
-                          *  t_surf_green_v(l)%t(m) - dq_s_dt *               &
-                            t_surf_green_v_p(l)%t(m) ) /                     &
-                            (surf_usm_v(l)%qsws(m) + 1.0E-20)  - surf_usm_v(l)%r_a(m)
-       ENDIF
-
+              IF ( surf_usm_v(l)%frac(ind_pav_green,m) > 0.0_wp ) THEN
+ 
+
+                 IF ( humidity )  THEN
+                    surf_usm_v(l)%qsws_eb(m)  = - f_qsws * ( qv1 - q_s + dq_s_dt       &
+                                    * t_surf_green_v(l)%t(m) - dq_s_dt *               &
+                                      t_surf_green_v_p(l)%t(m) )
+          
+                    surf_usm_v(l)%qsws(m) = surf_usm_v(l)%qsws_eb(m) / rho_lv
+          
+                    surf_usm_v(l)%qsws_veg(m)  = - f_qsws_veg  * ( qv1 - q_s           &
+                                        + dq_s_dt * t_surf_green_v(l)%t(m) - dq_s_dt   &
+                                        * t_surf_green_v_p(l)%t(m) )
+          
+!                    surf_usm_h%qsws_liq(m)  = - f_qsws_liq  * ( qv1 - q_s         &
+!                                        + dq_s_dt * t_surf_green_h(m) - dq_s_dt   &
+!                                        * t_surf_green_h_p(m) )
+                 ENDIF
+ 
+!
+!--              Calculate the true surface resistance
+                 IF ( .NOT.  humidity )  THEN
+                    surf_usm_v(l)%r_s(m) = 1.0E10_wp
+                 ELSE
+                    surf_usm_v(l)%r_s(m) = - rho_lv * ( qv1 - q_s + dq_s_dt             &
+                                    *  t_surf_green_v(l)%t(m) - dq_s_dt *               &
+                                      t_surf_green_v_p(l)%t(m) ) /                      &
+                                      (surf_usm_v(l)%qsws(m) + 1.0E-20)  - surf_usm_v(l)%r_a(m)
+                 ENDIF
+         
+!
+!--              Calculate change in liquid water reservoir due to dew fall or 
+!--              evaporation of liquid water
+                 IF ( humidity )  THEN
+!
+!--                 If the air is saturated, check the reservoir water level
+                    IF ( surf_usm_v(l)%qsws(m) < 0.0_wp )  THEN
        
 !
-!--    Calculate change in liquid water reservoir due to dew fall or 
-!--    evaporation of liquid water
-       IF ( humidity )  THEN
-!
-!--       If the air is saturated, check the reservoir water level
-          IF ( surf_usm_v(l)%qsws(m) < 0.0_wp )  THEN
-       
-!
-!--          In case qsws_veg becomes negative (unphysical behavior), 
-!--          let the water enter the liquid water reservoir as dew on the
-!--          plant
-             IF ( surf_usm_v(l)%qsws_veg(m) < 0.0_wp )  THEN
-!                 surf_usm_h%qsws_liq(m) = surf_usm_h%qsws_liq(m) + surf_usm_h%qsws_veg(m)
-                surf_usm_v(l)%qsws_veg(m) = 0.0_wp
-             ENDIF
-          ENDIF   
-    ENDIF
-else
-  surf_usm_v(l)%r_s(m) = 1.0E10_wp
-endif !111
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
+!--                    In case qsws_veg becomes negative (unphysical behavior), 
+!--                    let the water enter the liquid water reservoir as dew on the
+!--                    plant
+                       IF ( surf_usm_v(l)%qsws_veg(m) < 0.0_wp )  THEN
+          !                 surf_usm_h%qsws_liq(m) = surf_usm_h%qsws_liq(m) + surf_usm_h%qsws_veg(m)
+                          surf_usm_v(l)%qsws_veg(m) = 0.0_wp
+                       ENDIF
+                    ENDIF
+                 
+                 ENDIF
+              ELSE
+                 surf_usm_v(l)%r_s(m) = 1.0E10_wp
+              ENDIF
 
            ENDDO
-
-        ENDDO
+ 
+       ENDDO
 !
 !--     Add-up anthropogenic heat, for now only at upward-facing surfaces
-        IF ( usm_anthropogenic_heat  .AND.  &
-             intermediate_timestep_count == intermediate_timestep_count_max )  THEN
+         IF ( usm_anthropogenic_heat  .AND.  &
+              intermediate_timestep_count == intermediate_timestep_count_max )  THEN
+!
 !--        application of the additional anthropogenic heat sources
 !--        we considere the traffic for now so all heat is absorbed
 !--        to the first layer, generalization would be worth. 
-            
 !--        calculation of actual profile coefficient
 !--        ??? check time_since_reference_point ???
-           dtime = mod(simulated_time + time_utc_init, 24.0_wp*3600.0_wp)
-           dhour = INT(dtime/3600.0_wp)
-           DO i = nxl, nxr
-              DO j = nys, nyn
-                 DO k = nzub, min(nzut,naheatlayers)
-                    IF ( k > get_topography_top_index_ji( j, i, 's' ) ) THEN
+            dtime = mod(simulated_time + time_utc_init, 24.0_wp*3600.0_wp)
+            dhour = INT(dtime/3600.0_wp)
+            DO i = nxl, nxr
+               DO j = nys, nyn
+                  DO k = nzub, min(nzut,naheatlayers)
+                     IF ( k > get_topography_top_index_ji( j, i, 's' ) ) THEN
+!
 !--                    increase of pt in box i,j,k in time dt_3d 
 !--                    given to anthropogenic heat aheat*acoef (W*m-2)
 !--                    linear interpolation of coeficient
-                       acoef = (REAL(dhour+1,wp)-dtime/3600.0_wp)*aheatprof(k,dhour) + &
-                               (dtime/3600.0_wp-REAL(dhour,wp))*aheatprof(k,dhour+1)
-                       IF ( aheat(k,j,i) > 0.0_wp )  THEN
+                        acoef = (REAL(dhour+1,wp)-dtime/3600.0_wp)*aheatprof(k,dhour) + &
+                                (dtime/3600.0_wp-REAL(dhour,wp))*aheatprof(k,dhour+1)
+                        IF ( aheat(k,j,i) > 0.0_wp )  THEN
+!
 !--                       calculate rho * c_p coefficient at layer k
-                          rho_cp  = c_p * hyp(k) / ( r_d * pt(k+1,j,i) * exner(k) )
-                          pt(k,j,i) = pt(k,j,i) + aheat(k,j,i)*acoef*dt_3d/(exner(k)*rho_cp*dz(1))
-                       ENDIF
-                    ENDIF
-                 ENDDO
-              ENDDO
-           ENDDO
-
-        ENDIF
-        
+                           rho_cp  = c_p * hyp(k) / ( r_d * pt(k+1,j,i) * exner(k) )
+                           pt(k,j,i) = pt(k,j,i) + aheat(k,j,i)*acoef*dt_3d/(exner(k)*rho_cp*dz(1))
+                        ENDIF
+                     ENDIF
+                  ENDDO
+               ENDDO
+            ENDDO
+ 
+         ENDIF
+!
 !--     pt and shf are defined on nxlg:nxrg,nysg:nyng
 !--     get the borders from neighbours
-        CALL exchange_horiz( pt, nbgp )
-
+         CALL exchange_horiz( pt, nbgp )
+! 
 !--     calculation of force_radiation_call:
 !--     Make logical OR for all processes.
 !--     Force radiation call if at least one processor forces it.
-        IF ( intermediate_timestep_count == intermediate_timestep_count_max-1 )&
-        THEN
+         IF ( intermediate_timestep_count == intermediate_timestep_count_max-1 )&
+         THEN
 #if defined( __parallel )
-          IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
-          CALL MPI_ALLREDUCE( force_radiation_call_l, force_radiation_call,    &
-                              1, MPI_LOGICAL, MPI_LOR, comm2d, ierr )
+           IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
+           CALL MPI_ALLREDUCE( force_radiation_call_l, force_radiation_call,    &
+                               1, MPI_LOGICAL, MPI_LOR, comm2d, ierr )
 #else
-          force_radiation_call = force_radiation_call_l
+           force_radiation_call = force_radiation_call_l
 #endif
-          force_radiation_call_l = .FALSE.
-       ENDIF
-
+           force_radiation_call_l = .FALSE.
+         ENDIF
+ 
 ! !
 ! !-- Calculate surface specific humidity
@@ -8464,104 +8494,105 @@
 !        CALL calc_q_surface_usm
 !     ENDIF
-
-
-    CONTAINS
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Calculation of specific humidity of the skin layer (surface). It is assumend
-!> that the skin is always saturated.
-!------------------------------------------------------------------------------!
-       SUBROUTINE calc_q_surface_usm
-
-          IMPLICIT NONE
-
-          REAL(wp) :: resistance    !< aerodynamic and soil resistance term
-
-          DO  m = 1, surf_usm_h%ns
-
-             i   = surf_usm_h%i(m)            
-             j   = surf_usm_h%j(m)
-             k   = surf_usm_h%k(m)
-
+ 
+ 
+     CONTAINS
+ !------------------------------------------------------------------------------!
+ ! Description:
+ ! ------------
+ !> Calculation of specific humidity of the skin layer (surface). It is assumend
+ !> that the skin is always saturated.
+ !------------------------------------------------------------------------------!
+        SUBROUTINE calc_q_surface_usm
+ 
+           IMPLICIT NONE
+ 
+           REAL(wp) :: resistance    !< aerodynamic and soil resistance term
+ 
+           DO  m = 1, surf_usm_h%ns
+ 
+              i   = surf_usm_h%i(m)            
+              j   = surf_usm_h%j(m)
+              k   = surf_usm_h%k(m)
+ 
 !
 !--          Calculate water vapour pressure at saturation
-             e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp *                  &
-                                    ( t_surf_green_h_p(m) - 273.16_wp ) /  &
-                                    ( t_surf_green_h_p(m) - 35.86_wp  )    &
-                                         )
-
+              e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp *                  &
+                                     ( t_surf_green_h_p(m) - 273.16_wp ) /  &
+                                     ( t_surf_green_h_p(m) - 35.86_wp  )    &
+                                          )
+ 
 !
 !--          Calculate specific humidity at saturation
-             q_s = 0.622_wp * e_s / ( surface_pressure - e_s )
-
-!              surf_usm_h%r_a_green(m) = ( surf_usm_h%pt1(m) - t_surf_green_h(m) / exner(k) ) /                  &
+              q_s = 0.622_wp * e_s / ( surface_pressure - e_s )
+ 
+!              surf_usm_h%r_a_green(m) = ( surf_usm_h%pt1(m) - t_surf_green_h(m) / exner(k) ) /  &
 !                    ( surf_usm_h%ts(m) * surf_usm_h%us(m) + 1.0E-10_wp )
 !                 
 ! !--          make sure that the resistance does not drop to zero
 !              IF ( ABS(surf_usm_h%r_a_green(m)) < 1.0E-10_wp )  surf_usm_h%r_a_green(m) = 1.0E-10_wp
-
-             resistance = surf_usm_h%r_a_green(m) / ( surf_usm_h%r_a_green(m) + surf_usm_h%r_s(m) + 1E-5_wp )
-
+ 
+              resistance = surf_usm_h%r_a_green(m) / ( surf_usm_h%r_a_green(m) + surf_usm_h%r_s(m) + 1E-5_wp )
+ 
 !
 !--          Calculate specific humidity at surface
-             IF ( bulk_cloud_model )  THEN
-                q(k,j,i) = resistance * q_s +                   &
-                                           ( 1.0_wp - resistance ) *              &
-                                           ( q(k,j,i) - ql(k,j,i) )
-             ELSE
-                q(k,j,i) = resistance * q_s +                   &
-                                           ( 1.0_wp - resistance ) *              &
-                                             q(k,j,i)
-             ENDIF
-
+              IF ( bulk_cloud_model )  THEN
+                 q(k,j,i) = resistance * q_s +                   &
+                                            ( 1.0_wp - resistance ) *              &
+                                            ( q(k,j,i) - ql(k,j,i) )
+              ELSE
+                 q(k,j,i) = resistance * q_s +                   &
+                                            ( 1.0_wp - resistance ) *              &
+                                              q(k,j,i)
+              ENDIF
+ 
 !
 !--          Update virtual potential temperature
-             vpt(k,j,i) = pt(k,j,i) *         &
-                        ( 1.0_wp + 0.61_wp * q(k,j,i) )
-
-          ENDDO
-
+              vpt(k,j,i) = pt(k,j,i) *         &
+                         ( 1.0_wp + 0.61_wp * q(k,j,i) )
+ 
+           ENDDO
+
+!
 !--       Now, treat vertical surface elements
-          DO  l = 0, 3
-             DO  m = 1, surf_usm_v(l)%ns
+           DO  l = 0, 3
+              DO  m = 1, surf_usm_v(l)%ns
 !
 !--             Get indices of respective grid point
-                i = surf_usm_v(l)%i(m)
-                j = surf_usm_v(l)%j(m)
-                k = surf_usm_v(l)%k(m)
-
+                 i = surf_usm_v(l)%i(m)
+                 j = surf_usm_v(l)%j(m)
+                 k = surf_usm_v(l)%k(m)
+ 
 !
 !--             Calculate water vapour pressure at saturation
-                e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp *                       &
-                                       ( t_surf_green_v_p(l)%t(m) - 273.16_wp ) /  &
-                                       ( t_surf_green_v_p(l)%t(m) - 35.86_wp  )    &
-                                            )
-
+                 e_s = 0.01_wp * 610.78_wp * EXP( 17.269_wp *                       &
+                                        ( t_surf_green_v_p(l)%t(m) - 273.16_wp ) /  &
+                                        ( t_surf_green_v_p(l)%t(m) - 35.86_wp  )    &
+                                             )
+ 
 !
 !--             Calculate specific humidity at saturation
-                q_s = 0.622_wp * e_s / ( surface_pressure -e_s )
-
+                 q_s = 0.622_wp * e_s / ( surface_pressure -e_s )
+ 
 !
 !--             Calculate specific humidity at surface
-                IF ( bulk_cloud_model )  THEN
-                   q(k,j,i) = ( q(k,j,i) - ql(k,j,i) )
-                ELSE
-                   q(k,j,i) = q(k,j,i)
-                ENDIF
+                 IF ( bulk_cloud_model )  THEN
+                    q(k,j,i) = ( q(k,j,i) - ql(k,j,i) )
+                 ELSE
+                    q(k,j,i) = q(k,j,i)
+                 ENDIF
 !
 !--             Update virtual potential temperature
-                vpt(k,j,i) = pt(k,j,i) *         &
-                           ( 1.0_wp + 0.61_wp * q(k,j,i) )
-
-             ENDDO
-
-          ENDDO
-
-       END SUBROUTINE calc_q_surface_usm
-       
-    END SUBROUTINE usm_surface_energy_balance
-
-
+                 vpt(k,j,i) = pt(k,j,i) *         &
+                            ( 1.0_wp + 0.61_wp * q(k,j,i) )
+ 
+              ENDDO
+ 
+           ENDDO
+ 
+        END SUBROUTINE calc_q_surface_usm
+        
+     END SUBROUTINE usm_surface_energy_balance
+ 
+ 
 !------------------------------------------------------------------------------!
 ! Description:
@@ -8570,51 +8601,51 @@
 !> called out from subroutine swap_timelevel
 !------------------------------------------------------------------------------!
-    SUBROUTINE usm_swap_timelevel( mod_count )
-
-       IMPLICIT NONE
-
-       INTEGER(iwp), INTENT(IN) ::  mod_count
-
-      
-       SELECT CASE ( mod_count )
-
-          CASE ( 0 )
+     SUBROUTINE usm_swap_timelevel( mod_count )
+ 
+        IMPLICIT NONE
+ 
+        INTEGER(iwp), INTENT(IN) ::  mod_count
+ 
+       
+        SELECT CASE ( mod_count )
+ 
+           CASE ( 0 )
 !
 !--          Horizontal surfaces
-             t_surf_wall_h  => t_surf_wall_h_1; t_surf_wall_h_p  => t_surf_wall_h_2
-             t_wall_h     => t_wall_h_1;    t_wall_h_p     => t_wall_h_2
-             t_surf_window_h  => t_surf_window_h_1; t_surf_window_h_p  => t_surf_window_h_2
-             t_window_h     => t_window_h_1;    t_window_h_p     => t_window_h_2
-             t_surf_green_h  => t_surf_green_h_1; t_surf_green_h_p  => t_surf_green_h_2
-             t_green_h     => t_green_h_1;    t_green_h_p     => t_green_h_2
+              t_surf_wall_h    => t_surf_wall_h_1;   t_surf_wall_h_p    => t_surf_wall_h_2
+              t_wall_h         => t_wall_h_1;        t_wall_h_p         => t_wall_h_2
+              t_surf_window_h  => t_surf_window_h_1; t_surf_window_h_p  => t_surf_window_h_2
+              t_window_h       => t_window_h_1;      t_window_h_p       => t_window_h_2
+              t_surf_green_h   => t_surf_green_h_1;  t_surf_green_h_p   => t_surf_green_h_2
+              t_green_h        => t_green_h_1;       t_green_h_p        => t_green_h_2
 !
 !--          Vertical surfaces
-             t_surf_wall_v  => t_surf_wall_v_1; t_surf_wall_v_p  => t_surf_wall_v_2
-             t_wall_v     => t_wall_v_1;    t_wall_v_p     => t_wall_v_2
-             t_surf_window_v  => t_surf_window_v_1; t_surf_window_v_p  => t_surf_window_v_2
-             t_window_v     => t_window_v_1;    t_window_v_p     => t_window_v_2
-             t_surf_green_v  => t_surf_green_v_1; t_surf_green_v_p  => t_surf_green_v_2
-             t_green_v     => t_green_v_1;    t_green_v_p     => t_green_v_2
-          CASE ( 1 )
+              t_surf_wall_v    => t_surf_wall_v_1;   t_surf_wall_v_p    => t_surf_wall_v_2
+              t_wall_v         => t_wall_v_1;        t_wall_v_p         => t_wall_v_2
+              t_surf_window_v  => t_surf_window_v_1; t_surf_window_v_p  => t_surf_window_v_2
+              t_window_v       => t_window_v_1;      t_window_v_p       => t_window_v_2
+              t_surf_green_v   => t_surf_green_v_1;  t_surf_green_v_p   => t_surf_green_v_2
+              t_green_v        => t_green_v_1;       t_green_v_p        => t_green_v_2
+           CASE ( 1 )
 !
 !--          Horizontal surfaces
-             t_surf_wall_h  => t_surf_wall_h_2; t_surf_wall_h_p  => t_surf_wall_h_1
-             t_wall_h     => t_wall_h_2;    t_wall_h_p     => t_wall_h_1
-             t_surf_window_h  => t_surf_window_h_2; t_surf_window_h_p  => t_surf_window_h_1
-             t_window_h     => t_window_h_2;    t_window_h_p     => t_window_h_1
-             t_surf_green_h  => t_surf_green_h_2; t_surf_green_h_p  => t_surf_green_h_1
-             t_green_h     => t_green_h_2;    t_green_h_p     => t_green_h_1
+              t_surf_wall_h    => t_surf_wall_h_2;   t_surf_wall_h_p    => t_surf_wall_h_1
+              t_wall_h         => t_wall_h_2;        t_wall_h_p         => t_wall_h_1
+              t_surf_window_h  => t_surf_window_h_2; t_surf_window_h_p  => t_surf_window_h_1
+              t_window_h       => t_window_h_2;      t_window_h_p       => t_window_h_1
+              t_surf_green_h   => t_surf_green_h_2;  t_surf_green_h_p   => t_surf_green_h_1
+              t_green_h        => t_green_h_2;       t_green_h_p        => t_green_h_1
 !
 !--          Vertical surfaces
-             t_surf_wall_v  => t_surf_wall_v_2; t_surf_wall_v_p  => t_surf_wall_v_1
-             t_wall_v     => t_wall_v_2;    t_wall_v_p     => t_wall_v_1
-             t_surf_window_v  => t_surf_window_v_2; t_surf_window_v_p  => t_surf_window_v_1
-             t_window_v     => t_window_v_2;    t_window_v_p     => t_window_v_1
-             t_surf_green_v  => t_surf_green_v_2; t_surf_green_v_p  => t_surf_green_v_1
-             t_green_v     => t_green_v_2;    t_green_v_p     => t_green_v_1
-       END SELECT
-        
-    END SUBROUTINE usm_swap_timelevel
-
+              t_surf_wall_v    => t_surf_wall_v_2;   t_surf_wall_v_p    => t_surf_wall_v_1
+              t_wall_v         => t_wall_v_2;        t_wall_v_p         => t_wall_v_1
+              t_surf_window_v  => t_surf_window_v_2; t_surf_window_v_p  => t_surf_window_v_1
+              t_window_v       => t_window_v_2;      t_window_v_p       => t_window_v_1
+              t_surf_green_v   => t_surf_green_v_2;  t_surf_green_v_p   => t_surf_green_v_1
+              t_green_v        => t_green_v_2;       t_green_v_p        => t_green_v_1
+        END SELECT
+         
+     END SUBROUTINE usm_swap_timelevel
+ 
 !------------------------------------------------------------------------------!
 ! Description:
@@ -8622,93 +8653,93 @@
 !> Subroutine writes t_surf and t_wall data into restart files
 !------------------------------------------------------------------------------!
-    SUBROUTINE usm_wrd_local
-
-    
-       IMPLICIT NONE
-       
-       CHARACTER(LEN=1) ::  dum     !< dummy string to create output-variable name  
-       INTEGER(iwp)     ::  l       !< index surface type orientation
-
-       CALL wrd_write_string( 'ns_h_on_file_usm' )
-       WRITE ( 14 )  surf_usm_h%ns
-
-       CALL wrd_write_string( 'ns_v_on_file_usm' )
-       WRITE ( 14 )  surf_usm_v(0:3)%ns
-
-       CALL wrd_write_string( 'usm_start_index_h' )
-       WRITE ( 14 )  surf_usm_h%start_index
-
-       CALL wrd_write_string( 'usm_end_index_h' )
-       WRITE ( 14 )  surf_usm_h%end_index
-
-       CALL wrd_write_string( 't_surf_wall_h' )
-       WRITE ( 14 )  t_surf_wall_h
-
-       CALL wrd_write_string( 't_surf_window_h' )
-       WRITE ( 14 )  t_surf_window_h
-
-       CALL wrd_write_string( 't_surf_green_h' )
-       WRITE ( 14 )  t_surf_green_h
-
-       DO  l = 0, 3
-
-          CALL wrd_write_string( 'usm_start_index_v' )
-          WRITE ( 14 )  surf_usm_v(l)%start_index
-
-          CALL wrd_write_string( 'usm_end_index_v' )
-          WRITE ( 14 )  surf_usm_v(l)%end_index
-
-          WRITE( dum, '(I1)')  l          
-
-          CALL wrd_write_string( 't_surf_wall_v(' // dum // ')' )
-          WRITE ( 14 )  t_surf_wall_v(l)%t
-
-          CALL wrd_write_string( 't_surf_window_v(' // dum // ')' )
-          WRITE ( 14 ) t_surf_window_v(l)%t     
-
-          CALL wrd_write_string( 't_surf_green_v(' // dum // ')' )
-          WRITE ( 14 ) t_surf_green_v(l)%t    
-          
-       ENDDO
-
-       CALL wrd_write_string( 'usm_start_index_h' )
-       WRITE ( 14 )  surf_usm_h%start_index
-
-       CALL wrd_write_string( 'usm_end_index_h' )
-       WRITE ( 14 )  surf_usm_h%end_index
-
-       CALL wrd_write_string( 't_wall_h' )
-       WRITE ( 14 )  t_wall_h
-
-       CALL wrd_write_string( 't_window_h' )
-       WRITE ( 14 )  t_window_h
-
-       CALL wrd_write_string( 't_green_h' )
-       WRITE ( 14 )  t_green_h
-
-       DO  l = 0, 3
-
-          CALL wrd_write_string( 'usm_start_index_v' )
-          WRITE ( 14 )  surf_usm_v(l)%start_index
-
-          CALL wrd_write_string( 'usm_end_index_v' )
-          WRITE ( 14 )  surf_usm_v(l)%end_index
-
-          WRITE( dum, '(I1)')  l     
-
-          CALL wrd_write_string( 't_wall_v(' // dum // ')' )
-          WRITE ( 14 )  t_wall_v(l)%t
-
-          CALL wrd_write_string( 't_window_v(' // dum // ')' )
-          WRITE ( 14 )  t_window_v(l)%t
-
-          CALL wrd_write_string( 't_green_v(' // dum // ')' )
-          WRITE ( 14 )  t_green_v(l)%t
-       
-       ENDDO
-
-       
-    END SUBROUTINE usm_wrd_local
-
-  
- END MODULE urban_surface_mod
+     SUBROUTINE usm_wrd_local
+ 
+     
+        IMPLICIT NONE
+        
+        CHARACTER(LEN=1) ::  dum     !< dummy string to create output-variable name  
+        INTEGER(iwp)     ::  l       !< index surface type orientation
+ 
+        CALL wrd_write_string( 'ns_h_on_file_usm' )
+        WRITE ( 14 )  surf_usm_h%ns
+ 
+        CALL wrd_write_string( 'ns_v_on_file_usm' )
+        WRITE ( 14 )  surf_usm_v(0:3)%ns
+ 
+        CALL wrd_write_string( 'usm_start_index_h' )
+        WRITE ( 14 )  surf_usm_h%start_index
+ 
+        CALL wrd_write_string( 'usm_end_index_h' )
+        WRITE ( 14 )  surf_usm_h%end_index
+ 
+        CALL wrd_write_string( 't_surf_wall_h' )
+        WRITE ( 14 )  t_surf_wall_h
+ 
+        CALL wrd_write_string( 't_surf_window_h' )
+        WRITE ( 14 )  t_surf_window_h
+ 
+        CALL wrd_write_string( 't_surf_green_h' )
+        WRITE ( 14 )  t_surf_green_h
+ 
+        DO  l = 0, 3
+ 
+           CALL wrd_write_string( 'usm_start_index_v' )
+           WRITE ( 14 )  surf_usm_v(l)%start_index
+ 
+           CALL wrd_write_string( 'usm_end_index_v' )
+           WRITE ( 14 )  surf_usm_v(l)%end_index
+ 
+           WRITE( dum, '(I1)')  l          
+ 
+           CALL wrd_write_string( 't_surf_wall_v(' // dum // ')' )
+           WRITE ( 14 )  t_surf_wall_v(l)%t
+ 
+           CALL wrd_write_string( 't_surf_window_v(' // dum // ')' )
+           WRITE ( 14 ) t_surf_window_v(l)%t     
+ 
+           CALL wrd_write_string( 't_surf_green_v(' // dum // ')' )
+           WRITE ( 14 ) t_surf_green_v(l)%t    
+           
+        ENDDO
+ 
+        CALL wrd_write_string( 'usm_start_index_h' )
+        WRITE ( 14 )  surf_usm_h%start_index
+ 
+        CALL wrd_write_string( 'usm_end_index_h' )
+        WRITE ( 14 )  surf_usm_h%end_index
+ 
+        CALL wrd_write_string( 't_wall_h' )
+        WRITE ( 14 )  t_wall_h
+ 
+        CALL wrd_write_string( 't_window_h' )
+        WRITE ( 14 )  t_window_h
+ 
+        CALL wrd_write_string( 't_green_h' )
+        WRITE ( 14 )  t_green_h
+ 
+        DO  l = 0, 3
+ 
+           CALL wrd_write_string( 'usm_start_index_v' )
+           WRITE ( 14 )  surf_usm_v(l)%start_index
+ 
+           CALL wrd_write_string( 'usm_end_index_v' )
+           WRITE ( 14 )  surf_usm_v(l)%end_index
+ 
+           WRITE( dum, '(I1)')  l     
+ 
+           CALL wrd_write_string( 't_wall_v(' // dum // ')' )
+           WRITE ( 14 )  t_wall_v(l)%t
+ 
+           CALL wrd_write_string( 't_window_v(' // dum // ')' )
+           WRITE ( 14 )  t_window_v(l)%t
+ 
+           CALL wrd_write_string( 't_green_v(' // dum // ')' )
+           WRITE ( 14 )  t_green_v(l)%t
+        
+        ENDDO
+ 
+        
+     END SUBROUTINE usm_wrd_local
+ 
+   
+  END MODULE urban_surface_mod
