Index: palm/trunk/SOURCE/biometeorology_mod.f90
===================================================================
--- palm/trunk/SOURCE/biometeorology_mod.f90	(revision 3643)
+++ palm/trunk/SOURCE/biometeorology_mod.f90	(revision 3646)
@@ -27,4 +27,8 @@
 ! -----------------
 ! $Id$
+! Remove check for simulated_time > 0, it is not required since biometeorology
+! is only called from time_integration and not during time_integration_spinup
+! 
+! 3614 2018-12-10 07:05:46Z raasch
 ! unused variables removed
 ! 
@@ -101,5 +105,5 @@
        ONLY:  average_count_3d, biometeorology, dz, dz_stretch_factor,         &
               dz_stretch_level, humidity, initializing_actions, nz_do3d,       &
-              simulated_time, surface_pressure
+              surface_pressure
 
     USE date_and_time_mod,                                                                                                        &
@@ -1343,7 +1347,5 @@
 !
 !-- fill out the MRT 2D grid from appropriate source (RTM, RRTMG,...)
-    IF ( simulated_time > 0.0_wp ) THEN
-       CALL bio_calculate_mrt_grid ( av )
-    ENDIF
+    CALL bio_calculate_mrt_grid ( av )
 
     DO i = nxl, nxr
@@ -1355,8 +1357,6 @@
 !
 !--       Determine input only if 
-          IF ( simulated_time > 0.0_wp ) THEN
-             CALL bio_get_thermal_index_input_ij ( av, i, j, ta, vp,           &
-                ws, pair, tmrt_ij )
-          END IF
+          CALL bio_get_thermal_index_input_ij ( av, i, j, ta, vp,           &
+                                                ws, pair, tmrt_ij )
 !
 !--       Only proceed if input is available
Index: palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- palm/trunk/SOURCE/check_parameters.f90	(revision 3643)
+++ palm/trunk/SOURCE/check_parameters.f90	(revision 3646)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Formatting
+! 
+! 3637 2018-12-20 01:51:36Z knoop
 ! Implementation of the PALM module interface
 ! 
@@ -3315,6 +3318,6 @@
        ntdim_3d(1) = do3d_time_count(1) + CEILING(                                    &
                      ( end_time - MAX(                                                &
-                         MERGE(skip_time_data_output_av, skip_time_data_output_av     &
-                              + spinup_time, data_output_during_spinup ),             &
+                         MERGE(   skip_time_data_output_av, skip_time_data_output_av  &
+                                + spinup_time, data_output_during_spinup ),           &
                          simulated_time_at_begin )                                    &
                      ) / dt_data_output_av )
@@ -3323,6 +3326,6 @@
                         ( end_time - MAX(                                             &
                            MERGE(skip_time_do2d_xy, skip_time_do2d_xy + spinup_time,  &
-                               data_output_during_spinup ),                           &
-                                          simulated_time_at_begin )                   &
+                                 data_output_during_spinup ),                         &
+                           simulated_time_at_begin )                                  &
                         ) / dt_do2d_xy )
 
Index: palm/trunk/SOURCE/chemistry_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 3643)
+++ palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 3646)
@@ -27,4 +27,8 @@
 ! -----------------
 ! $Id$
+! Bugfix: use time_since_reference_point instead of simulated_time (relevant
+! when using wall/soil spinup)
+! 
+! 3643 2018-12-24 13:16:19Z knoop
 ! Bugfix: set found logical correct in chem_data_output_2d
 ! 
@@ -1923,6 +1927,6 @@
     USE statistics,                                                          &
          ONLY:  weight_pres
-    USE control_parameters,                                                 &
-         ONLY:  dt_3d, intermediate_timestep_count, simulated_time
+    USE control_parameters,                                                  &
+         ONLY:  dt_3d, intermediate_timestep_count, time_since_reference_point
 
     IMPLICIT NONE
@@ -2014,9 +2018,6 @@
 
        IF(maxval(rcntrl) > 0.0)   THEN    ! Only if rcntrl is set
-          IF( simulated_time <= 2*dt_3d)  THEN
+          IF( time_since_reference_point <= 2*dt_3d)  THEN
              rcntrl_local = 0
-             !
-             !--   todo: remove (kanani)
-             !                  WRITE(9,'(a,2f10.3)') 'USE Default rcntrl in the first steps ',simulated_time,dt_3d
           ELSE
              rcntrl_local = rcntrl
Index: palm/trunk/SOURCE/data_output_2d.f90
===================================================================
--- palm/trunk/SOURCE/data_output_2d.f90	(revision 3643)
+++ palm/trunk/SOURCE/data_output_2d.f90	(revision 3646)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Bugfix: use time_since_reference_point instead of simulated_time (relevant
+! when using wall/soil spinup)
+! 
+! 3637 2018-12-20 01:51:36Z knoop
 ! Implementation of the PALM module interface
 ! 
@@ -298,5 +302,5 @@
                ibc_uv_b, io_blocks, io_group, message_string,                  &
                ntdim_2d_xy, ntdim_2d_xz, ntdim_2d_yz,                          &
-               psolver, section, simulated_time,                               &
+               psolver, section,                                               &
                time_since_reference_point
 
@@ -510,5 +514,5 @@
             ntdim_2d_xy(av) )  THEN
           WRITE ( message_string, * ) 'Output of xy cross-sections is not ',   &
-                          'given at t=', simulated_time, '&because the',       & 
+                          'given at t=', time_since_reference_point, 's because the',       & 
                           ' maximum number of output time levels is exceeded.'
           CALL message( 'data_output_2d', 'PA0384', 0, 1, 0, 6, 0 )
@@ -519,5 +523,5 @@
             ntdim_2d_xz(av) )  THEN
           WRITE ( message_string, * ) 'Output of xz cross-sections is not ',   &
-                          'given at t=', simulated_time, '&because the',       & 
+                          'given at t=', time_since_reference_point, 's because the',       & 
                           ' maximum number of output time levels is exceeded.'
           CALL message( 'data_output_2d', 'PA0385', 0, 1, 0, 6, 0 )
@@ -528,5 +532,5 @@
             ntdim_2d_yz(av) )  THEN
           WRITE ( message_string, * ) 'Output of yz cross-sections is not ',   &
-                          'given at t=', simulated_time, '&because the',       & 
+                          'given at t=', time_since_reference_point, 's because the',       & 
                           ' maximum number of output time levels is exceeded.'
           CALL message( 'data_output_2d', 'PA0386', 0, 1, 0, 6, 0 )
@@ -697,5 +701,5 @@
              CASE ( 'pc_xy', 'pc_xz', 'pc_yz' )  ! particle concentration
                 IF ( av == 0 )  THEN
-                   IF ( simulated_time >= particle_advection_start )  THEN
+                   IF ( time_since_reference_point >= particle_advection_start )  THEN
                       tend = prt_count
 !                      CALL exchange_horiz( tend, nbgp )
@@ -722,5 +726,5 @@
              CASE ( 'pr_xy', 'pr_xz', 'pr_yz' )  ! mean particle radius (effective radius)
                 IF ( av == 0 )  THEN
-                   IF ( simulated_time >= particle_advection_start )  THEN
+                   IF ( time_since_reference_point >= particle_advection_start )  THEN
                       DO  i = nxl, nxr
                          DO  j = nys, nyn
@@ -844,5 +848,5 @@
              CASE ( 'ql_vp_xy', 'ql_vp_xz', 'ql_vp_yz' )
                 IF ( av == 0 )  THEN
-                   IF ( simulated_time >= particle_advection_start )  THEN
+                   IF ( time_since_reference_point >= particle_advection_start )  THEN
                       DO  i = nxl, nxr
                          DO  j = nys, nyn
@@ -1422,7 +1426,7 @@
 !--                In case of parallel output, this is only done by PE0
 !--                to increase the performance.
-                   IF ( simulated_time /= do2d_xy_last_time(av) )  THEN
+                   IF ( time_since_reference_point /= do2d_xy_last_time(av) )  THEN
                       do2d_xy_time_count(av) = do2d_xy_time_count(av) + 1
-                      do2d_xy_last_time(av)  = simulated_time
+                      do2d_xy_last_time(av)  = time_since_reference_point
                       IF ( myid == 0 )  THEN
                          IF ( .NOT. data_output_2d_on_each_pe  &
@@ -1611,7 +1615,7 @@
 !--                In case of parallel output, this is only done by PE0
 !--                to increase the performance.
-                   IF ( simulated_time /= do2d_xz_last_time(av) )  THEN
+                   IF ( time_since_reference_point /= do2d_xz_last_time(av) )  THEN
                       do2d_xz_time_count(av) = do2d_xz_time_count(av) + 1
-                      do2d_xz_last_time(av)  = simulated_time
+                      do2d_xz_last_time(av)  = time_since_reference_point
                       IF ( myid == 0 )  THEN
                          IF ( .NOT. data_output_2d_on_each_pe  &
@@ -1829,7 +1833,7 @@
 !--                In case of parallel output, this is only done by PE0
 !--                to increase the performance.
-                   IF ( simulated_time /= do2d_yz_last_time(av) )  THEN
+                   IF ( time_since_reference_point /= do2d_yz_last_time(av) )  THEN
                       do2d_yz_time_count(av) = do2d_yz_time_count(av) + 1
-                      do2d_yz_last_time(av)  = simulated_time
+                      do2d_yz_last_time(av)  = time_since_reference_point
                       IF ( myid == 0 )  THEN
                          IF ( .NOT. data_output_2d_on_each_pe  &
Index: palm/trunk/SOURCE/data_output_3d.f90
===================================================================
--- palm/trunk/SOURCE/data_output_3d.f90	(revision 3643)
+++ palm/trunk/SOURCE/data_output_3d.f90	(revision 3646)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Bugfix: use time_since_reference_point instead of simulated_time (relevant
+! when using wall/soil spinup)
+! 
+! 3637 2018-12-20 01:51:36Z knoop
 ! Implementation of the PALM module interface
 ! 
@@ -255,5 +259,5 @@
                io_blocks, io_group, land_surface, message_string,              &
                ntdim_3d, nz_do3d,  ocean_mode, plant_canopy,                   &
-               psolver, salsa, simulated_time, time_since_reference_point,     &
+               psolver, salsa, time_since_reference_point,                     &
                urban_surface, varnamelength
 
@@ -355,7 +359,7 @@
     IF ( netcdf_data_format > 4 )  THEN
        IF ( do3d_time_count(av) + 1 > ntdim_3d(av) )  THEN
-          WRITE ( message_string, * ) 'Output of 3d data is not given at t=',  &
-                                      simulated_time, '&because the maximum ', & 
-                                      'number of output time levels is ',      &
+          WRITE ( message_string, * ) 'Output of 3d data is not given at t=',               &
+                                      time_since_reference_point, 's because the maximum ', & 
+                                      'number of output time levels is ',                   &
                                       'exceeded.'
           CALL message( 'data_output_3d', 'PA0387', 0, 1, 0, 6, 0 )
@@ -447,5 +451,5 @@
           CASE ( 'pc' )  ! particle concentration (requires ghostpoint exchange)
              IF ( av == 0 )  THEN
-                IF ( simulated_time >= particle_advection_start )  THEN
+                IF ( time_since_reference_point >= particle_advection_start )  THEN
                    tend = prt_count
                 ELSE
@@ -470,5 +474,5 @@
           CASE ( 'pr' )  ! mean particle radius (effective radius)
              IF ( av == 0 )  THEN
-                IF ( simulated_time >= particle_advection_start )  THEN
+                IF ( time_since_reference_point >= particle_advection_start )  THEN
                    DO  i = nxl, nxr
                       DO  j = nys, nyn
@@ -585,5 +589,5 @@
           CASE ( 'ql_vp' )
              IF ( av == 0 )  THEN
-                IF ( simulated_time >= particle_advection_start )  THEN
+                IF ( time_since_reference_point >= particle_advection_start )  THEN
                    DO  i = nxl, nxr
                       DO  j = nys, nyn
Index: palm/trunk/SOURCE/parin.f90
===================================================================
--- palm/trunk/SOURCE/parin.f90	(revision 3643)
+++ palm/trunk/SOURCE/parin.f90	(revision 3646)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Bugfix: for restarts, reset data_output_during_spinup to FALSE to enable
+! correct calculation of ntdim in check_parameters
+! 
+! 3637 2018-12-20 01:51:36Z knoop
 ! Implementation of the PALM module interface
 ! 
@@ -893,5 +897,5 @@
              max_pr_user = max_pr_user_tmp
           ENDIF
-
+PRINT*, 'data_output_during_spinup 1: ', data_output_during_spinup
 !
 !--       Activate spinup
@@ -904,8 +908,14 @@
                 ENDIF
                 end_time = end_time + spinup_time
-                IF ( TRIM( initializing_actions ) /= 'read_restart_data' )     &
+                IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
                    spinup = .TRUE.
+                ELSEIF (        TRIM( initializing_actions ) == 'read_restart_data'      &
+                         .AND.  time_since_reference_point > 0.0_wp )  THEN
+                   data_output_during_spinup = .FALSE.  !< required for correct ntdim calculation
+                                                        !< in check_parameters for restart run
+                ENDIF
              ENDIF
           ENDIF
+PRINT*, 'data_output_during_spinup 2: ', data_output_during_spinup
 
 !
Index: palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 3643)
+++ palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 3646)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Remove unused variable simulated_time
+! 
+! 3636 2018-12-19 13:48:34Z raasch
 ! nopointer option removed
 ! 
@@ -342,5 +345,5 @@
                coupling_char, dt_3d, dz, humidity, message_string,             &
                neutral, passive_scalar, rans_mode, rans_tke_e,                 &
-               roughness_length, simulated_time, topography, volume_flow
+               roughness_length, topography, volume_flow
 
     USE chem_modules,                                                          &
Index: palm/trunk/SOURCE/surface_output_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_output_mod.f90	(revision 3643)
+++ palm/trunk/SOURCE/surface_output_mod.f90	(revision 3646)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Bugfix: use time_since_reference_point instead of simulated_time (relevant
+! when using wall/soil spinup)
+! 
+! 3614 2018-12-10 07:05:46Z raasch
 ! unused variables removed
 ! 
@@ -864,5 +868,5 @@
    
       USE control_parameters,                                                  &
-          ONLY:  io_blocks, io_group, simulated_time
+          ONLY:  io_blocks, io_group, time_since_reference_point
 
       USE pegrid,                                                              &
@@ -2234,5 +2238,5 @@
                WRITE ( 25+av )  LEN_TRIM( 'time' )
                WRITE ( 25+av )  'time'
-               WRITE ( 25+av )  simulated_time
+               WRITE ( 25+av )  time_since_reference_point
                WRITE ( 25+av )  LEN_TRIM( trimvar )
                WRITE ( 25+av )  TRIM( trimvar )
Index: palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90
===================================================================
--- palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90	(revision 3643)
+++ palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90	(revision 3646)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Bugfix: use time_since_reference_point instead of simulated_time (relevant
+! when using wall/soil spinup)
+! 
+! 3579 2018-11-29 15:32:39Z suehring
 ! - Bugfix in calculation of turbulence scaling parameters for turbulence 
 !   generator in case of topography
@@ -1054,5 +1058,6 @@
     USE control_parameters,                                                    &
         ONLY:  child_domain, dt_3d, intermediate_timestep_count,               &
-               nesting_offline, rans_mode, simulated_time, volume_flow_initial
+               nesting_offline, rans_mode, time_since_reference_point,         &
+               volume_flow_initial
 
     USE grid_variables,                                                        &
@@ -1087,5 +1092,5 @@
 !
 !-- Initial value of fu, fv, fw
-    IF ( simulated_time == 0.0_wp .AND. .NOT. velocity_seed_initialized )  THEN
+    IF ( time_since_reference_point == 0.0_wp .AND. .NOT. velocity_seed_initialized )  THEN
        CALL stg_generate_seed_yz( nuy, nuz, buy, buz, fu_yz, id_stg_left )
        CALL stg_generate_seed_yz( nvy, nvz, bvy, bvz, fv_yz, id_stg_left )
Index: palm/trunk/SOURCE/time_integration.f90
===================================================================
--- palm/trunk/SOURCE/time_integration.f90	(revision 3643)
+++ palm/trunk/SOURCE/time_integration.f90	(revision 3646)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Bugfix: use time_since_reference_point instead of simulated_time where
+! required (relevant when using wall/soil spinup)
+! 
+! 3634 2018-12-18 12:31:28Z knoop
 ! OpenACC port for SPEC
 ! 
@@ -915,5 +919,5 @@
 !--       to regard droplet interactions directly
           IF ( particle_advection  .AND.                         &
-               simulated_time >= particle_advection_start  .AND. &
+               time_since_reference_point >= particle_advection_start  .AND. &
                intermediate_timestep_count == 1 )  THEN
              CALL lpm
@@ -1424,26 +1428,26 @@
 
 
-       IF ( simulated_time >= skip_time_data_output_av )  THEN
+       IF ( time_since_reference_point >= skip_time_data_output_av )  THEN
           time_do_av         = time_do_av       + dt_3d
        ENDIF
-       IF ( simulated_time >= skip_time_do2d_xy )  THEN
+       IF ( time_since_reference_point >= skip_time_do2d_xy )  THEN
           time_do2d_xy       = time_do2d_xy     + dt_3d
        ENDIF
-       IF ( simulated_time >= skip_time_do2d_xz )  THEN
+       IF ( time_since_reference_point >= skip_time_do2d_xz )  THEN
           time_do2d_xz       = time_do2d_xz     + dt_3d
        ENDIF
-       IF ( simulated_time >= skip_time_do2d_yz )  THEN
+       IF ( time_since_reference_point >= skip_time_do2d_yz )  THEN
           time_do2d_yz       = time_do2d_yz     + dt_3d
        ENDIF
-       IF ( simulated_time >= skip_time_do3d    )  THEN
+       IF ( time_since_reference_point >= skip_time_do3d    )  THEN
           time_do3d          = time_do3d        + dt_3d
        ENDIF
        DO  mid = 1, masks
-          IF ( simulated_time >= skip_time_domask(mid) )  THEN
+          IF ( time_since_reference_point >= skip_time_domask(mid) )  THEN
              time_domask(mid)= time_domask(mid) + dt_3d
           ENDIF
        ENDDO
        time_dvrp          = time_dvrp        + dt_3d
-       IF ( simulated_time >= skip_time_dosp )  THEN
+       IF ( time_since_reference_point >= skip_time_dosp )  THEN
           time_dosp       = time_dosp        + dt_3d
        ENDIF
@@ -1452,5 +1456,5 @@
           time_dopts      = time_dopts       + dt_3d
        ENDIF
-       IF ( simulated_time >= skip_time_dopr )  THEN
+       IF ( time_since_reference_point >= skip_time_dopr )  THEN
           time_dopr       = time_dopr        + dt_3d
        ENDIF
@@ -1460,8 +1464,8 @@
 !--    Increment time-counter for surface output
        IF ( surface_data_output )  THEN
-          IF ( simulated_time >= skip_time_dosurf )  THEN
+          IF ( time_since_reference_point >= skip_time_dosurf )  THEN
              time_dosurf    = time_dosurf + dt_3d
           ENDIF
-          IF ( simulated_time >= skip_time_dosurf_av )  THEN
+          IF ( time_since_reference_point >= skip_time_dosurf_av )  THEN
              time_dosurf_av = time_dosurf_av + dt_3d
           ENDIF
@@ -1552,5 +1556,5 @@
        IF ( averaging_interval_pr /= 0.0_wp  .AND.  &
             ( dt_dopr - time_dopr ) <= averaging_interval_pr  .AND.  &
-            simulated_time >= skip_time_dopr )  THEN
+            time_since_reference_point >= skip_time_dopr )  THEN
           time_dopr_av = time_dopr_av + dt_3d
           IF ( time_dopr_av >= dt_averaging_input_pr )  THEN
@@ -1566,5 +1570,5 @@
        IF ( averaging_interval /= 0.0_wp  .AND.                                &
             ( dt_data_output_av - time_do_av ) <= averaging_interval  .AND. &
-            simulated_time >= skip_time_data_output_av )                    &
+            time_since_reference_point >= skip_time_data_output_av )                    &
        THEN
           time_do_sla = time_do_sla + dt_3d
@@ -1580,5 +1584,5 @@
           IF ( averaging_interval_surf /= 0.0_wp  .AND.                        & 
                ( dt_dosurf_av - time_dosurf_av ) <= averaging_interval_surf    &
-          .AND.  simulated_time >= skip_time_dosurf_av )  THEN
+          .AND.  time_since_reference_point >= skip_time_dosurf_av )  THEN
              IF ( time_dosurf_av >= dt_averaging_input )  THEN        
                 CALL surface_output_averaging
@@ -1592,5 +1596,5 @@
        IF ( averaging_interval_sp /= 0.0_wp  .AND.  &
             ( dt_dosp - time_dosp ) <= averaging_interval_sp  .AND.  &
-            simulated_time >= skip_time_dosp )  THEN
+            time_since_reference_point >= skip_time_dosp )  THEN
           time_dosp_av = time_dosp_av + dt_3d
           IF ( time_dosp_av >= dt_averaging_input_pr )  THEN
@@ -1706,5 +1710,5 @@
        IF ( particle_advection )  THEN
           IF ( time_dopts >= dt_dopts  .OR. &
-               ( simulated_time >= particle_advection_start  .AND. &
+               ( time_since_reference_point >= particle_advection_start  .AND. &
                  first_call_lpm ) )  THEN
              CALL data_output_ptseries
Index: palm/trunk/SOURCE/turbulence_closure_mod.f90
===================================================================
--- palm/trunk/SOURCE/turbulence_closure_mod.f90	(revision 3643)
+++ palm/trunk/SOURCE/turbulence_closure_mod.f90	(revision 3646)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Remove unused variable simulated_time
+! 
+! 3636 2018-12-19 13:48:34Z raasch
 ! nopointer option removed
 ! 
@@ -194,5 +197,5 @@
                les_dynamic, les_mw, ocean_mode, plant_canopy, prandtl_number,  &
                pt_reference, rans_mode, rans_tke_e, rans_tke_l,                &
-               simulated_time,timestep_scheme, turbulence_closure,             &
+               timestep_scheme, turbulence_closure,                            &
                turbulent_inflow, use_upstream_for_tke, vpt_reference,          &
                ws_scheme_sca, current_timestep_number
