Index: palm/trunk/SOURCE/time_integration.f90
===================================================================
--- palm/trunk/SOURCE/time_integration.f90	(revision 1917)
+++ palm/trunk/SOURCE/time_integration.f90	(revision 1918)
@@ -19,5 +19,7 @@
 ! Current revisions:
 ! ------------------
-! 
+! determination of time step moved to the end of the time step loop,
+! the first time step is now always calculated before the time step loop (i.e.
+! also in case of restart runs)
 ! 
 ! Former revisions:
@@ -260,8 +262,10 @@
     USE indices,                                                               &
         ONLY:  i_left, i_right, j_north, j_south, nbgp, nx, nxl, nxlg, nxr,    &
-               nxrg, nyn, nys, nzb, nzt, nzb_u_inner, nzb_v_inner 
+               nxrg, nyn, nyng, nys, nysg, nzb, nzt, nzb_u_inner, nzb_v_inner
 
     USE interaction_droplets_ptq_mod,                                          &
         ONLY:  interaction_droplets_ptq
+
+    USE interfaces
 
     USE kinds
@@ -311,5 +315,6 @@
 
     USE statistics,                                                            &
-        ONLY:  flow_statistics_called, hom, pr_palm, sums_ls_l
+        ONLY:  flow_statistics_called, hom, pr_palm, sums_ls_l, u_max,         &
+               u_max_ijk, v_max, v_max_ijk, w_max, w_max_ijk
 
     USE surface_layer_fluxes_mod,                                              &
@@ -326,8 +331,10 @@
     CHARACTER (LEN=9) ::  time_to_string          !< 
 
-!
-!-- At the beginning of a simulation determine the time step as well as
-!-- determine and print out the run control parameters
-    IF ( simulated_time == 0.0_wp )  CALL timestep
+    REAL(wp) ::  dt_3d_old  !< temporary storage of timestep to be used for
+                            !< steering of run control output interval
+
+!
+!-- At beginning determine the first time step
+    CALL timestep
 
 !
@@ -340,4 +347,9 @@
     ENDIF
 
+!
+!-- Determine and print out the run control quantities before the first time
+!-- step of this run. For the initial run, some statistics (e.g. divergence)
+!-- need to be determined first.
+    IF ( simulated_time == 0.0_wp )  CALL flow_statistics
     CALL run_control
 
@@ -349,9 +361,10 @@
 !--    In case of model termination initiated by the local model the coupler 
 !--    must not be called because this would again cause an MPI hang. 
-       DO WHILE ( time_coupling >= dt_coupling .AND. terminate_coupled == 0 )
+       DO WHILE ( time_coupling >= dt_coupling  .AND.  terminate_coupled == 0 )
           CALL surface_coupler
           time_coupling = time_coupling - dt_coupling
        ENDDO
-       IF (time_coupling == 0.0_wp .AND. time_since_reference_point < dt_coupling)&
+       IF (time_coupling == 0.0_wp  .AND.                                      &
+           time_since_reference_point < dt_coupling )                          &
        THEN
           time_coupling = time_since_reference_point
@@ -372,18 +385,4 @@
 
        CALL cpu_log( log_point_s(10), 'timesteps', 'start' )
-
-!
-!--    Determine size of next time step
-       IF ( simulated_time /= 0.0_wp )  THEN
-          CALL timestep
-!
-!--       Synchronize the timestep in case of nested run.
-          IF ( nested_run )  THEN
-!
-!--          Synchronize by unifying the time step.
-!--          Global minimum of all time-steps is used for all.      
-             CALL pmci_synchronize
-          ENDIF
-       ENDIF
 
 !
@@ -1026,17 +1025,4 @@
 
 !
-!--    Computation and output of run control parameters.
-!--    This is also done whenever perturbations have been imposed
-       IF ( time_run_control >= dt_run_control  .OR.                     &
-            timestep_scheme(1:5) /= 'runge'  .OR.  disturbance_created ) &
-       THEN
-          CALL run_control
-          IF ( time_run_control >= dt_run_control )  THEN
-             time_run_control = MOD( time_run_control, &
-                                     MAX( dt_run_control, dt_3d ) )
-          ENDIF
-       ENDIF
-
-!
 !--    Profile output (ASCII) on file
        IF ( time_dopr_listing >= dt_dopr_listing )  THEN
@@ -1149,4 +1135,46 @@
 
 !
+!--    Determine size of next time step. Save timestep dt_3d because it is
+!--    newly calculated in routine timestep, but required further below for
+!--    steering the run control output interval
+       dt_3d_old = dt_3d
+       CALL timestep
+
+!
+!--    Computation and output of run control parameters.
+!--    This is also done whenever perturbations have been imposed
+       IF ( time_run_control >= dt_run_control  .OR.                     &
+            timestep_scheme(1:5) /= 'runge'  .OR.  disturbance_created ) &
+       THEN
+!          IF ( current_timestep_number == 1 )  THEN
+!             IF ( nxl < 7 .AND.  nxr > 7 .AND. nys < 7 .AND. nyn > 7 )  THEN
+!                u(10,7,7) = 0.55
+!             ENDIF
+!             PRINT*, 'calculating minmax'
+!             CALL global_min_max( nzb, nzt+1, nysg, nyng, nxlg, nxrg, u,       &
+!                                  'abs', 0.0_wp, u_max, u_max_ijk )
+!             CALL global_min_max( nzb, nzt+1, nysg, nyng, nxlg, nxrg, v,       &
+!                                  'abs', 0.0_wp, v_max, v_max_ijk )
+!             CALL global_min_max( nzb, nzt+1, nysg, nyng, nxlg, nxrg, w,       &
+!                                  'abs', 0.0_wp, w_max, w_max_ijk )
+!             PRINT*, 'calculated u_max = ', u_max, '  myid = ', myid
+!          ENDIF
+          CALL run_control
+          IF ( time_run_control >= dt_run_control )  THEN
+             time_run_control = MOD( time_run_control, &
+                                     MAX( dt_run_control, dt_3d_old ) )
+          ENDIF
+       ENDIF
+
+!
+!--    Synchronize the timestep in case of nested run.
+       IF ( nested_run )  THEN
+!
+!--       Synchronize by unifying the time step.
+!--       Global minimum of all time-steps is used for all.
+          CALL pmci_synchronize
+       ENDIF
+
+!
 !--    Output elapsed simulated time in form of a progress bar on stdout
        IF ( myid == 0 )  CALL output_progress_bar
