Index: palm/trunk/SOURCE/indoor_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/indoor_model_mod.f90	(revision 4730)
+++ palm/trunk/SOURCE/indoor_model_mod.f90	(revision 4750)
@@ -25,4 +25,11 @@
 ! -----------------
 ! $Id$
+! - Namelist parameter added to switch-off/on the indoor model during wall/soil spinup
+! - Bugfix in window-wall treatment during spinup - in the urban-surface model the window fraction
+!   is set to zero during spinup, so it is done here also
+! - Bugfix in wall treatment - inner wall temperature was too low due to wrong weighting of
+!   wall/green/window fractions
+!
+! 4730 2020-10-07 10:48:51Z suehring
 ! Bugfix - avoid divisions by zero
 ! 
@@ -271,5 +278,11 @@
     TYPE(build), DIMENSION(:), ALLOCATABLE ::  buildings   !< building array
 
-    INTEGER(iwp) ::  num_build   !< total number of buildings in domain
+    INTEGER(iwp) ::  cooling_on              !< Indoor cooling flag (0=off, 1=on)
+    INTEGER(iwp) ::  heating_on              !< Indoor heating flag (0=off, 1=on)
+    INTEGER(iwp) ::  num_build               !< total number of buildings in domain
+    INTEGER(iwp) ::  solar_protection_off    !< Solar protection off
+    INTEGER(iwp) ::  solar_protection_on     !< Solar protection on
+
+    LOGICAL ::  indoor_during_spinup = .FALSE.      !< namelist parameter used to switch-off/on the indoor model during spinup
 !
 !-- Declare all global variables within the module
@@ -289,10 +302,4 @@
     REAL(wp), PARAMETER ::  params_solar_protection  = 300.0_wp    !< [W/m2] chap. G.5.3.1 sun protection closed, if the radiation
                                                                    !< on facade exceeds this value
-
-    INTEGER(iwp) ::  cooling_on              !< Indoor cooling flag (0=off, 1=on)
-    INTEGER(iwp) ::  heating_on              !< Indoor heating flag (0=off, 1=on)
-    INTEGER(iwp) ::  solar_protection_off    !< Solar protection off
-    INTEGER(iwp) ::  solar_protection_on     !< Solar protection on
-
 
     REAL(wp) ::  a_m                                 !< [m2] the effective mass-related area
@@ -416,5 +423,8 @@
 !
 !-- Add VARIABLES that must be available to other modules
-    PUBLIC dt_indoor, skip_time_do_indoor, time_indoor
+    PUBLIC dt_indoor,                                                                              &
+           indoor_during_spinup,                                                                   &
+           skip_time_do_indoor,                                                                    &
+           time_indoor
 
 !
@@ -1198,8 +1208,19 @@
 
     USE surface_mod,                                                                               &
-        ONLY:  ind_veg_wall, ind_wat_win, surf_usm_h, surf_usm_v
+        ONLY:  ind_pav_green,                                                                      &
+               ind_veg_wall,                                                                       &
+               ind_wat_win,                                                                        &
+               surf_usm_h,                                                                         &
+               surf_usm_v
 
     USE urban_surface_mod,                                                                         &
-        ONLY:  building_type, nzt_wall, t_wall_h, t_wall_v, t_window_h, t_window_v
+        ONLY:  building_type,                                                                      &
+               nzt_wall,                                                                           &
+               t_green_h,                                                                          &
+               t_green_v,                                                                          &
+               t_wall_h,                                                                           &
+               t_wall_v,                                                                           &
+               t_window_h,                                                                         &
+               t_window_v
 
 
@@ -1213,8 +1234,11 @@
     INTEGER(iwp) ::  nb   !< running index for buildings
 
-    REAL(wp) ::  indoor_wall_window_temperature   !< weighted temperature of innermost wall/window layer
-    
-    REAL(wp) ::  indoor_wall_temperature   !< temperature of innermost wall layer evtl in im_calc_temperatures einfÃŒgen
-    
+    LOGICAL  ::  during_spinup                    !< flag indicating that the simulation is still in wall/soil spinup
+
+    REAL(wp) ::  frac_green                       !< dummy for green fraction
+    REAL(wp) ::  frac_wall                        !< dummy for wall fraction
+    REAL(wp) ::  frac_win                         !< dummy for window fraction
+!     REAL(wp) ::  indoor_wall_window_temperature   !< weighted temperature of innermost wall/window layer
+    REAL(wp) ::  indoor_wall_temperature          !< temperature of innermost wall layer evtl in im_calc_temperatures einfÃŒgen
     REAL(wp) ::  near_facade_temperature          !< outside air temperature 10cm away from facade
     REAL(wp) ::  second_of_day                    !< second of the current day
@@ -1227,4 +1251,7 @@
     CALL get_date_time( time_since_reference_point, second_of_day=second_of_day )
     time_utc_hour = second_of_day / seconds_per_hour
+!
+!-- Check if the simulation is still in wall/soil spinup mode
+    during_spinup = MERGE( .TRUE., .FALSE., time_since_reference_point < 0.0_wp )
 !
 !-- Following calculations must be done for each facade element.
@@ -1272,4 +1299,12 @@
              m = buildings(nb)%m_h(fa)
 !
+!--          During spinup set window fraction to zero and add these to wall fraction.
+             frac_win   = MERGE( surf_usm_h(l)%frac(m,ind_wat_win), 0.0_wp, .NOT. during_spinup )
+             frac_wall  = MERGE( surf_usm_h(l)%frac(m,ind_veg_wall),                               &
+                                 surf_usm_h(l)%frac(m,ind_veg_wall) +                              &
+                                 surf_usm_h(l)%frac(m,ind_wat_win),                                &
+                                 .NOT. during_spinup )
+             frac_green = surf_usm_h(l)%frac(m,ind_pav_green)
+!
 !--          Determine building height level index.
              kk = surf_usm_h(l)%k(m) + surf_usm_h(l)%koff
@@ -1281,7 +1316,6 @@
              buildings(nb)%area_facade    = facade_element_area *                                  &
                                             ( buildings(nb)%num_facades_per_building_h +           &
-                                              buildings(nb)%num_facades_per_building_v )              !< [m2] area of total facade
-             window_area_per_facade       = surf_usm_h(l)%frac(m,ind_wat_win)  * facade_element_area  !< [m2] window area per facade
-                                                                                                      !< element
+                                              buildings(nb)%num_facades_per_building_v ) !< [m2] area of total facade
+             window_area_per_facade       = frac_win  * facade_element_area              !< [m2] window area per facade element
 
              buildings(nb)%net_floor_area = buildings(nb)%vol_tot / ( buildings(nb)%height_storey )
@@ -1338,8 +1372,10 @@
              k = surf_usm_h(l)%k(m)
              near_facade_temperature = surf_usm_h(l)%pt_10cm(m)
-             indoor_wall_window_temperature =                                                             &
-                                            surf_usm_h(l)%frac(m,ind_veg_wall) * t_wall_h(l)%val(nzt_wall,m) &
-                                          + surf_usm_h(l)%frac(m,ind_wat_win)  * t_window_h(l)%val(nzt_wall,m)
-             indoor_wall_temperature = surf_usm_h(l)%frac(m,ind_veg_wall) * t_wall_h(l)%val(nzt_wall,m)
+!              indoor_wall_window_temperature = frac_wall  * t_wall_h(l)%val(nzt_wall,m)             &
+!                                             + frac_win   * t_window_h(l)%val(nzt_wall,m)           &
+!                                             + frac_green * t_green_h(l)%val(nzt_wall,m)
+             indoor_wall_temperature = frac_wall  * t_wall_h(l)%val(nzt_wall,m)                    &
+                                     + frac_win   * t_window_h(l)%val(nzt_wall,m)                  &
+                                     + frac_green * t_green_h(l)%val(nzt_wall,m)
 !
 !--          Solar thermal gains. If net_sw_in larger than sun-protection threshold parameter
@@ -1510,4 +1546,12 @@
              m = buildings(nb)%m_v(fa)
 !
+!--          During spinup set window fraction to zero and add these to wall fraction.
+             frac_win   = MERGE( surf_usm_v(l)%frac(m,ind_wat_win), 0.0_wp, .NOT. during_spinup )
+             frac_wall  = MERGE( surf_usm_v(l)%frac(m,ind_veg_wall),                               &
+                                 surf_usm_v(l)%frac(m,ind_veg_wall) +                              &
+                                 surf_usm_v(l)%frac(m,ind_wat_win),                                &
+                                 .NOT. during_spinup )
+             frac_green = surf_usm_v(l)%frac(m,ind_pav_green)
+!
 !--          Determine building height level index.
              kk = surf_usm_v(l)%k(m) + surf_usm_v(l)%koff
@@ -1523,7 +1567,6 @@
              buildings(nb)%area_facade    = facade_element_area *                                  &
                                             ( buildings(nb)%num_facades_per_building_h +           &
-                                              buildings(nb)%num_facades_per_building_v )              !< [m2] area of total facade
-             window_area_per_facade       = surf_usm_v(l)%frac(m,ind_wat_win) * facade_element_area   !< [m2] window area per
-                                                                                                      !< facade element
+                                              buildings(nb)%num_facades_per_building_v )  !< [m2] area of total facade
+             window_area_per_facade       = frac_win * facade_element_area                !< [m2] window area per facade element
 
              buildings(nb)%net_floor_area = buildings(nb)%vol_tot / ( buildings(nb)%height_storey )
@@ -1562,5 +1605,5 @@
 !--          (air_change_high)
              air_change = ( buildings(nb)%air_change_high * schedule_d +                           &
-                          buildings(nb)%air_change_low )
+                            buildings(nb)%air_change_low )
 !
 !--          Heat transfer of ventilation.
@@ -1584,8 +1627,12 @@
              k = surf_usm_v(l)%k(m)
              near_facade_temperature = surf_usm_v(l)%pt_10cm(m)
-             indoor_wall_window_temperature =                                                          &
-                                    surf_usm_v(l)%frac(m,ind_veg_wall) * t_wall_v(l)%val(nzt_wall,m)   &
-                                  + surf_usm_v(l)%frac(m,ind_wat_win)  * t_window_v(l)%val(nzt_wall,m)
-             indoor_wall_temperature = surf_usm_v(l)%frac(m,ind_veg_wall) * t_wall_v(l)%val(nzt_wall,m) 
+
+!              indoor_wall_window_temperature = frac_wall  * t_wall_v(l)%val(nzt_wall,m)             &
+!                                             + frac_win   * t_window_v(l)%val(nzt_wall,m)           &
+!                                             + frac_green * t_green_v(l)%val(nzt_wall,m)
+
+             indoor_wall_temperature = frac_wall  * t_wall_v(l)%val(nzt_wall,m)                    &
+                                     + frac_win   * t_window_v(l)%val(nzt_wall,m)                  &
+                                     + frac_green * t_green_v(l)%val(nzt_wall,m)
 
 !
@@ -1725,4 +1772,6 @@
              surf_usm_v(l)%iwghf_eb(m)        = - q_wall
              surf_usm_v(l)%iwghf_eb_window(m) = - q_win
+
+!              print*, "wwfjg", surf_usm_v(l)%iwghf_eb(m), surf_usm_v(l)%iwghf_eb_window(m)
 !
 !--          Sum up operational indoor temperature per kk-level. Further below, this temperature is
@@ -2070,5 +2119,6 @@
     CHARACTER (LEN=80) ::  line  !< string containing current line of file PARIN
 
-    NAMELIST /indoor_parameters/  initial_indoor_temperature
+    NAMELIST /indoor_parameters/  indoor_during_spinup,                                            &
+                                  initial_indoor_temperature
 
 
