Index: palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 2282)
+++ palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 2296)
@@ -25,4 +25,9 @@
 ! -----------------
 ! $Id$
+! Bugfix in calculation of bare soil heat capacity.
+! Bugfix in calculation of shf
+! Added support for spinups
+! 
+! 2282 2017-06-13 11:38:46Z schwenkel
 ! Bugfix for check of saturation moisture
 ! 
@@ -226,8 +231,10 @@
 
     USE control_parameters,                                                    &
-        ONLY:  cloud_physics, dt_3d, humidity, intermediate_timestep_count,    &
+        ONLY:  cloud_physics, coupling_start_time, dt_3d, end_time, humidity,  &
+               intermediate_timestep_count,                                    &
                initializing_actions, intermediate_timestep_count_max,          &
                land_surface, max_masks, precipitation, pt_surface,             &
-               rho_surface, surface_pressure, timestep_scheme, tsc,            &
+               rho_surface, spinup, spinup_pt_mean, spinup_time,               &
+               surface_pressure, timestep_scheme, tsc,                         &
                time_since_reference_point
 
@@ -1230,5 +1237,5 @@
        ENDIF
     ENDDO
-  
+ 
  END SUBROUTINE lsm_check_parameters
  
@@ -1374,5 +1381,5 @@
           c_surface_tmp = (rho_c_soil * ( 1.0_wp - surf%m_sat(nzb_soil,m) )    &
                            + rho_c_water * surf_m_soil%var_2d(nzb_soil,m) )    &
-                           * dz_soil_layer(nzb_soil) * 0.25_wp               
+                           * dz_soil_layer(nzb_soil) * 0.5_wp               
 
        ELSEIF ( surf_t_surface%var_1d(m) >= surf_t_soil%var_2d(nzb_soil,m)) &
@@ -2069,8 +2076,5 @@
        dz_soil_layer(nzb_soil) = 2.0_wp * zs(nzb_soil)
        zs_layer(nzb_soil)      = 2.0_wp * zs(nzb_soil)
-
-
-       
-       
+  
        DO  k = nzb_soil+1, nzt_soil
           dz_soil_layer(k) = ( zs(k) - zs_layer(k-1) ) * 2.0_wp
@@ -2322,6 +2326,5 @@
                 DO  k = nzb_soil, nzt_soil  
                    t_soil_h%var_2d(k,m)   = soil_temperature(k)
-                   m_soil_h%var_2d(k,m)   = MAX(soil_moisture(k),surf_lsm_h%m_wilt(k,m))
-                   soil_moisture(k)       = MAX(soil_moisture(k),wilting_point)           
+                   m_soil_h%var_2d(k,m)   = soil_moisture(k)
                 ENDDO
                 t_soil_h%var_2d(nzt_soil+1,m) = soil_temperature(nzt_soil+1)
@@ -2343,6 +2346,5 @@
                 DO  k = nzb_soil, nzt_soil                        
                    t_soil_h%var_2d(k,m)   = soil_temperature(k)
-                   m_soil_h%var_2d(k,m)   = MAX(soil_moisture(k),surf_lsm_h%m_wilt(k,m))
-                   soil_moisture(k)       = MAX(soil_moisture(k),wilting_point)         
+                   m_soil_h%var_2d(k,m)   = soil_moisture(k)       
                 ENDDO 
                 t_soil_h%var_2d(nzt_soil+1,m) = soil_temperature(nzt_soil+1)
@@ -2411,7 +2413,6 @@
                    surf_lsm_v(l)%z0q(m)         = z0h_pavement  
                    DO  k = nzb_soil, nzt_soil  
-                      t_soil_v(l)%var_2d(k,m)      = soil_temperature(k)
-                      m_soil_v(l)%var_2d(k,m)   = MAX(soil_moisture(k),surf_lsm_v(l)%m_wilt(k,m))
-                      soil_moisture(k)          = MAX(soil_moisture(k),wilting_point)   
+                      t_soil_v(l)%var_2d(k,m)   = soil_temperature(k)
+                      m_soil_v(l)%var_2d(k,m)   = soil_moisture(k) 
                    ENDDO
                    t_soil_v(l)%var_2d(nzt_soil+1,m)  = soil_temperature(nzt_soil+1)
@@ -2433,6 +2434,5 @@
                    DO  k = nzb_soil, nzt_soil                        
                       t_soil_v(l)%var_2d(k,m)   = soil_temperature(k)
-                      m_soil_v(l)%var_2d(k,m)   = MAX(soil_moisture(k),surf_lsm_v(l)%m_wilt(k,m))
-                      soil_moisture(k)          = MAX(soil_moisture(k),wilting_point)         
+                      m_soil_v(l)%var_2d(k,m)   = soil_moisture(k)       
                    ENDDO 
                    t_soil_v(l)%var_2d(nzt_soil+1,m) = soil_temperature(nzt_soil+1)
@@ -2857,4 +2857,16 @@
        land_surface = .TRUE.
 
+!
+!--    Activate spinup
+       IF ( spinup_time > 0.0_wp )  THEN
+          coupling_start_time = spinup_time
+          end_time = end_time + spinup_time
+          IF ( spinup_pt_mean == 9999999.9_wp )  THEN
+             spinup_pt_mean = pt_surface
+          ENDIF
+          spinup = .TRUE.
+       ENDIF
+
+
  10    CONTINUE
        
