Index: /palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- /palm/trunk/SOURCE/init_3d_model.f90	(revision 1877)
+++ /palm/trunk/SOURCE/init_3d_model.f90	(revision 1878)
@@ -19,5 +19,5 @@
 ! Current revisions:
 ! ------------------
-!
+! The zeroth element of weight_pres removed as unnecessary
 !
 ! Former revisions:
@@ -690,9 +690,6 @@
 !-- is done). Further below the values needed within the timestep scheme
 !-- will be set.
-!-- TO_DO: zeroth element added to weight_pres because in case of nesting
-!--        pres may need to be called  outside the RK-substeps. Antti will
-!--        check if this is really required.
     ALLOCATE( weight_substep(1:intermediate_timestep_count_max),               &
-              weight_pres(0:intermediate_timestep_count_max) )
+              weight_pres(1:intermediate_timestep_count_max) )
     weight_substep = 1.0_wp
     weight_pres    = 1.0_wp
@@ -1683,7 +1680,4 @@
 !-- Setting weighting factors for calculation of perturbation pressure 
 !-- and turbulent quantities from the RK substeps
-!-- TO_DO: zeroth element is added to weight_pres because in nesting pres
-!--        may need to be called outside the RK-substeps
-    weight_pres(0) = 1.0_wp
     IF ( TRIM(timestep_scheme) == 'runge-kutta-3' )  THEN      ! for RK3-method
 
Index: /palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 1877)
+++ /palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 1878)
@@ -20,6 +20,6 @@
 ! Current revisions:
 ! ------------------
-! 
-! 
+! Synchronization rewritten, logc-array index order changed for cache optimization 
+!
 ! Former revisions:
 ! -----------------
@@ -338,6 +338,6 @@
     END INTERFACE
 
-    INTERFACE pmci_client_synchronize
-       MODULE PROCEDURE pmci_client_synchronize
+    INTERFACE pmci_synchronize
+       MODULE PROCEDURE pmci_synchronize
     END INTERFACE
 
@@ -360,8 +360,4 @@
     INTERFACE pmci_server_initialize
        MODULE PROCEDURE pmci_server_initialize
-    END INTERFACE
-
-    INTERFACE pmci_server_synchronize
-       MODULE PROCEDURE pmci_server_synchronize
     END INTERFACE
 
@@ -376,5 +372,4 @@
            server_to_client
     PUBLIC pmci_client_initialize
-    PUBLIC pmci_client_synchronize
     PUBLIC pmci_datatrans
     PUBLIC pmci_ensure_nest_mass_conservation
@@ -382,5 +377,5 @@
     PUBLIC pmci_modelconfiguration
     PUBLIC pmci_server_initialize
-    PUBLIC pmci_server_synchronize
+    PUBLIC pmci_synchronize
     PUBLIC pmci_set_swaplevel
 
@@ -1253,8 +1248,8 @@
        IF ( nest_bound_l )  THEN
 
-          ALLOCATE( logc_u_l(nzb:nzt_topo_nestbc_l,nys:nyn,1:2) )
-          ALLOCATE( logc_v_l(nzb:nzt_topo_nestbc_l,nys:nyn,1:2) )
-          ALLOCATE( logc_ratio_u_l(nzb:nzt_topo_nestbc_l,nys:nyn,1:2,0:ncorr-1) )
-          ALLOCATE( logc_ratio_v_l(nzb:nzt_topo_nestbc_l,nys:nyn,1:2,0:ncorr-1) )
+          ALLOCATE( logc_u_l(1:2,nzb:nzt_topo_nestbc_l,nys:nyn) )
+          ALLOCATE( logc_v_l(1:2,nzb:nzt_topo_nestbc_l,nys:nyn) )
+          ALLOCATE( logc_ratio_u_l(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_l,nys:nyn) )
+          ALLOCATE( logc_ratio_v_l(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_l,nys:nyn) )
           logc_u_l       = 0
           logc_v_l       = 0
@@ -1273,6 +1268,6 @@
              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
                                 inc, wall_index, z0(j,i), kb, direction, ncorr )
-             logc_u_l(k,j,1) = lc
-             logc_ratio_u_l(k,j,1,0:ncorr-1) = lcr(0:ncorr-1)
+             logc_u_l(1,k,j) = lc
+             logc_ratio_u_l(1,0:ncorr-1,k,j) = lcr(0:ncorr-1)
              lcr(0:ncorr-1) = 1.0_wp
 !
@@ -1284,6 +1279,6 @@
              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
                                 inc, wall_index, z0(j,i), kb, direction, ncorr )
-             logc_v_l(k,j,1) = lc
-             logc_ratio_v_l(k,j,1,0:ncorr-1) = lcr(0:ncorr-1)
+             logc_v_l(1,k,j) = lc
+             logc_ratio_v_l(1,0:ncorr-1,k,j) = lcr(0:ncorr-1)
              lcr(0:ncorr-1) = 1.0_wp
 
@@ -1296,8 +1291,8 @@
        IF ( nest_bound_r )  THEN
 
-          ALLOCATE( logc_u_r(nzb:nzt_topo_nestbc_r,nys:nyn,1:2) )
-          ALLOCATE( logc_v_r(nzb:nzt_topo_nestbc_r,nys:nyn,1:2) )
-          ALLOCATE( logc_ratio_u_r(nzb:nzt_topo_nestbc_r,nys:nyn,1:2,0:ncorr-1) )
-          ALLOCATE( logc_ratio_v_r(nzb:nzt_topo_nestbc_r,nys:nyn,1:2,0:ncorr-1) )
+          ALLOCATE( logc_u_r(1:2,nzb:nzt_topo_nestbc_r,nys:nyn) )
+          ALLOCATE( logc_v_r(1:2,nzb:nzt_topo_nestbc_r,nys:nyn) )
+          ALLOCATE( logc_ratio_u_r(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_r,nys:nyn) )
+          ALLOCATE( logc_ratio_v_r(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_r,nys:nyn) )
           logc_u_r       = 0
           logc_v_r       = 0
@@ -1315,6 +1310,6 @@
              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
                                 inc, wall_index, z0(j,i), kb, direction, ncorr )
-             logc_u_r(k,j,1) = lc
-             logc_ratio_u_r(k,j,1,0:ncorr-1) = lcr(0:ncorr-1)
+             logc_u_r(1,k,j) = lc
+             logc_ratio_u_r(1,0:ncorr-1,k,j) = lcr(0:ncorr-1)
              lcr(0:ncorr-1) = 1.0_wp
 !
@@ -1326,6 +1321,6 @@
              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
                                 inc, wall_index, z0(j,i), kb, direction, ncorr )
-             logc_v_r(k,j,1) = lc
-             logc_ratio_v_r(k,j,1,0:ncorr-1) = lcr(0:ncorr-1)
+             logc_v_r(1,k,j) = lc
+             logc_ratio_v_r(1,0:ncorr-1,k,j) = lcr(0:ncorr-1)
              lcr(0:ncorr-1) = 1.0_wp
 
@@ -1338,8 +1333,8 @@
        IF ( nest_bound_s )  THEN
 
-          ALLOCATE( logc_u_s(nzb:nzt_topo_nestbc_s,nxl:nxr,1:2) )
-          ALLOCATE( logc_v_s(nzb:nzt_topo_nestbc_s,nxl:nxr,1:2) )
-          ALLOCATE( logc_ratio_u_s(nzb:nzt_topo_nestbc_s,nxl:nxr,1:2,0:ncorr-1) )
-          ALLOCATE( logc_ratio_v_s(nzb:nzt_topo_nestbc_s,nxl:nxr,1:2,0:ncorr-1) )
+          ALLOCATE( logc_u_s(1:2,nzb:nzt_topo_nestbc_s,nxl:nxr) )
+          ALLOCATE( logc_v_s(1:2,nzb:nzt_topo_nestbc_s,nxl:nxr) )
+          ALLOCATE( logc_ratio_u_s(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_s,nxl:nxr) )
+          ALLOCATE( logc_ratio_v_s(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_s,nxl:nxr) )
           logc_u_s       = 0
           logc_v_s       = 0
@@ -1358,6 +1353,6 @@
              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
                                 inc, wall_index, z0(j,i), kb, direction, ncorr )
-             logc_u_s(k,i,1) = lc
-             logc_ratio_u_s(k,i,1,0:ncorr-1) = lcr(0:ncorr-1)
+             logc_u_s(1,k,i) = lc
+             logc_ratio_u_s(1,0:ncorr-1,k,i) = lcr(0:ncorr-1)
              lcr(0:ncorr-1) = 1.0_wp
 !
@@ -1369,6 +1364,6 @@
              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
                                 inc, wall_index, z0(j,i), kb, direction, ncorr )
-             logc_v_s(k,i,1) = lc
-             logc_ratio_v_s(k,i,1,0:ncorr-1) = lcr(0:ncorr-1)
+             logc_v_s(1,k,i) = lc
+             logc_ratio_v_s(1,0:ncorr-1,k,i) = lcr(0:ncorr-1)
              lcr(0:ncorr-1) = 1.0_wp
 
@@ -1381,8 +1376,8 @@
        IF ( nest_bound_n )  THEN
 
-          ALLOCATE( logc_u_n(nzb:nzt_topo_nestbc_n,nxl:nxr,1:2) )
-          ALLOCATE( logc_v_n(nzb:nzt_topo_nestbc_n,nxl:nxr,1:2) )
-          ALLOCATE( logc_ratio_u_n(nzb:nzt_topo_nestbc_n,nxl:nxr,1:2,0:ncorr-1) )
-          ALLOCATE( logc_ratio_v_n(nzb:nzt_topo_nestbc_n,nxl:nxr,1:2,0:ncorr-1) )
+          ALLOCATE( logc_u_n(1:2,nzb:nzt_topo_nestbc_n,nxl:nxr) )
+          ALLOCATE( logc_v_n(1:2,nzb:nzt_topo_nestbc_n,nxl:nxr) )
+          ALLOCATE( logc_ratio_u_n(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_n,nxl:nxr) )
+          ALLOCATE( logc_ratio_v_n(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_n,nxl:nxr) )
           logc_u_n       = 0
           logc_v_n       = 0
@@ -1401,6 +1396,6 @@
              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
                                 inc, wall_index, z0(j,i), kb, direction, ncorr )
-             logc_u_n(k,i,1) = lc
-             logc_ratio_u_n(k,i,1,0:ncorr-1) = lcr(0:ncorr-1)
+             logc_u_n(1,k,i) = lc
+             logc_ratio_u_n(1,0:ncorr-1,k,i) = lcr(0:ncorr-1)
              lcr(0:ncorr-1) = 1.0_wp
 !
@@ -1412,6 +1407,6 @@
              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
                                 inc, wall_index, z0(j,i), kb, direction, ncorr )
-             logc_v_n(k,i,1) = lc
-             logc_ratio_v_n(k,i,1,0:ncorr-1) = lcr(0:ncorr-1)
+             logc_v_n(1,k,i) = lc
+             logc_ratio_v_n(1,0:ncorr-1,k,i) = lcr(0:ncorr-1)
              lcr(0:ncorr-1) = 1.0_wp
 
@@ -1429,7 +1424,8 @@
           IF ( nest_bound_l )  THEN
 
-             ALLOCATE( logc_w_l(nzb:nzt_topo_nestbc_l,nys:nyn,1:2) )
-             ALLOCATE( logc_ratio_w_l(nzb:nzt_topo_nestbc_l,nys:nyn,1:2,       &
-                                      0:ncorr-1) )
+             ALLOCATE( logc_w_l(1:2,nzb:nzt_topo_nestbc_l,nys:nyn) )
+             ALLOCATE( logc_ratio_w_l(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_l,     &
+                                      nys:nyn) )
+
              logc_w_l       = 0
              logc_ratio_w_l = 1.0_wp
@@ -1450,6 +1446,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_u_l(k,j,2) = inc * lc
-                      logc_ratio_u_l(k,j,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_u_l(2,k,j) = inc * lc
+                      logc_ratio_u_l(2,0:ncorr-1,k,j) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1467,6 +1463,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_u_l(k,j,2) = inc * lc
-                      logc_ratio_u_l(k,j,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_u_l(2,k,j) = inc * lc
+                      logc_ratio_u_l(2,0:ncorr-1,k,j) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1484,6 +1480,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_w_l(k,j,2) = inc * lc
-                      logc_ratio_w_l(k,j,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_w_l(2,k,j) = inc * lc
+                      logc_ratio_w_l(2,0:ncorr-1,k,j) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1501,6 +1497,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_w_l(k,j,2) = inc * lc
-                      logc_ratio_w_l(k,j,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_w_l(2,k,j) = inc * lc
+                      logc_ratio_w_l(2,0:ncorr-1,k,j) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1515,7 +1511,7 @@
           IF ( nest_bound_r )  THEN
 
-             ALLOCATE( logc_w_r(nzb:nzt_topo_nestbc_r,nys:nyn,1:2) )
-             ALLOCATE( logc_ratio_w_r(nzb:nzt_topo_nestbc_r,nys:nyn,1:2,       &
-                                      0:ncorr-1) )
+             ALLOCATE( logc_w_r(1:2,nzb:nzt_topo_nestbc_r,nys:nyn) )
+             ALLOCATE( logc_ratio_w_r(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_r,     &
+                                      nys:nyn) )
              logc_w_r       = 0
              logc_ratio_w_r = 1.0_wp
@@ -1536,6 +1532,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_u_r(k,j,2) = inc * lc
-                      logc_ratio_u_r(k,j,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_u_r(2,k,j) = inc * lc
+                      logc_ratio_u_r(2,0:ncorr-1,k,j) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1552,6 +1548,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_u_r(k,j,2) = inc * lc
-                      logc_ratio_u_r(k,j,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_u_r(2,k,j) = inc * lc
+                      logc_ratio_u_r(2,0:ncorr-1,k,j) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1568,6 +1564,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_w_r(k,j,2) = inc * lc
-                      logc_ratio_w_r(k,j,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_w_r(2,k,j) = inc * lc
+                      logc_ratio_w_r(2,0:ncorr-1,k,j) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1585,6 +1581,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_w_r(k,j,2) = inc * lc
-                      logc_ratio_w_r(k,j,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_w_r(2,k,j) = inc * lc
+                      logc_ratio_w_r(2,0:ncorr-1,k,j) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1599,7 +1595,7 @@
           IF ( nest_bound_s )  THEN
 
-             ALLOCATE( logc_w_s(nzb:nzt_topo_nestbc_s, nxl:nxr, 1:2) )
-             ALLOCATE( logc_ratio_w_s(nzb:nzt_topo_nestbc_s,nxl:nxr,1:2,       &
-                                      0:ncorr-1) )
+             ALLOCATE( logc_w_s(1:2,nzb:nzt_topo_nestbc_s,nxl:nxr) )
+             ALLOCATE( logc_ratio_w_s(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_s,     &
+                                      nxl:nxr) )
              logc_w_s       = 0
              logc_ratio_w_s = 1.0_wp
@@ -1620,6 +1616,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_v_s(k,i,2) = inc * lc
-                      logc_ratio_v_s(k,i,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_v_s(2,k,i) = inc * lc
+                      logc_ratio_v_s(2,0:ncorr-1,k,i) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1637,6 +1633,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_v_s(k,i,2) = inc * lc
-                      logc_ratio_v_s(k,i,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_v_s(2,k,i) = inc * lc
+                      logc_ratio_v_s(2,0:ncorr-1,k,i) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1654,6 +1650,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_w_s(k,i,2) = inc * lc
-                      logc_ratio_w_s(k,i,2,0:ncorr - 1) = lcr(0:ncorr-1)
+                      logc_w_s(2,k,i) = inc * lc
+                      logc_ratio_w_s(2,0:ncorr-1,k,i) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1671,6 +1667,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_w_s(k,i,2) = inc * lc
-                      logc_ratio_w_s(k,i,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_w_s(2,k,i) = inc * lc
+                      logc_ratio_w_s(2,0:ncorr-1,k,i) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1685,7 +1681,7 @@
           IF ( nest_bound_n )  THEN
 
-             ALLOCATE( logc_w_n(nzb:nzt_topo_nestbc_n, nxl:nxr, 1:2) )
-             ALLOCATE( logc_ratio_w_n(nzb:nzt_topo_nestbc_n,nxl:nxr,1:2,       &
-                                      0:ncorr-1) )
+             ALLOCATE( logc_w_n(1:2,nzb:nzt_topo_nestbc_n, nxl:nxr) )
+             ALLOCATE( logc_ratio_w_n(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_n,     &
+                                      nxl:nxr) )
              logc_w_n       = 0
              logc_ratio_w_n = 1.0_wp
@@ -1706,6 +1702,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_v_n(k,i,2) = inc * lc
-                      logc_ratio_v_n(k,i,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_v_n(2,k,i) = inc * lc
+                      logc_ratio_v_n(2,0:ncorr-1,k,i) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1722,6 +1718,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_v_n(k,i,2) = inc * lc
-                      logc_ratio_v_n(k,i,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_v_n(2,k,i) = inc * lc
+                      logc_ratio_v_n(2,0:ncorr-1,k,i) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1738,6 +1734,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_w_n(k,i,2) = inc * lc
-                      logc_ratio_w_n(k,i,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_w_n(2,k,i) = inc * lc
+                      logc_ratio_w_n(2,0:ncorr-1,k,i) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -1754,6 +1750,6 @@
 !--                   The direction of the wall-normal index is stored as the
 !--                   sign of the logc-element.
-                      logc_w_n(k,i,2) = inc * lc
-                      logc_ratio_w_n(k,i,2,0:ncorr-1) = lcr(0:ncorr-1)
+                      logc_w_n(2,k,i) = inc * lc
+                      logc_ratio_w_n(2,0:ncorr-1,k,i) = lcr(0:ncorr-1)
                       lcr(0:ncorr-1) = 1.0_wp
                    ENDIF
@@ -2975,95 +2971,24 @@
 
 
-!-- TO_DO: the timestep sycnchronization could be done easier using
-!--        an MPI_ALLREDUCE with MIN over MPI_COMM_WORLD
- SUBROUTINE pmci_server_synchronize
+
+ SUBROUTINE pmci_synchronize
 
 #if defined( __parallel )
 !
-!-- Unify the time steps for each model and synchronize. This is based on the
-!-- assumption that the native time step (original dt_3d) of any server is
-!-- always larger than the smallest native time step of it s clients.
-    IMPLICIT NONE
-
-    INTEGER(iwp) ::  client_id   !:
-    INTEGER(iwp) ::  ierr        !:
-    INTEGER(iwp) ::  m           !:
-
-    REAL(wp), DIMENSION(1) ::  dtc         !:
-    REAL(wp), DIMENSION(1) ::  dtl         !:
-
-
-    CALL cpu_log( log_point_s(70), 'pmc sync', 'start' )
-
-!
-!-- First find the smallest native time step of all the clients of the current
-!-- server.
-    dtl(1) = 999999.9_wp
-    DO  m = 1, SIZE( PMC_Server_for_Client )-1
-       client_id = PMC_Server_for_Client(m)
-       IF ( myid == 0 )  THEN
-          CALL pmc_recv_from_client( client_id, dtc, SIZE( dtc ), 0, 101, ierr )
-          dtl(1) = MIN( dtl(1), dtc(1) )
-          dt_3d   = dtl(1)
-       ENDIF
-    ENDDO
-
-!
-!-- Broadcast the unified time step to all server processes
-    CALL MPI_BCAST( dt_3d, 1, MPI_REAL, 0, comm2d, ierr )
-
-!
-!-- Send the new time step to all the clients of the current server
-    DO  m = 1, SIZE( PMC_Server_for_Client ) - 1
-       client_id = PMC_Server_for_Client(m)
-       IF ( myid == 0 )  THEN
-          CALL pmc_send_to_client( client_id, dtl, SIZE( dtl ), 0, 102, ierr )
-       ENDIF
-    ENDDO
-
-    CALL cpu_log( log_point_s(70), 'pmc sync', 'stop' )
-
-#endif
- END SUBROUTINE pmci_server_synchronize
-
-
-
- SUBROUTINE pmci_client_synchronize
-
-#if defined( __parallel )
-!
-!-- Unify the time steps for each model and synchronize. This is based on the
-!-- assumption that the native time step (original dt_3d) of any server is
-!-- always larger than the smallest native time step of it s clients.
-
-    IMPLICIT NONE
-
-    INTEGER(iwp) ::  ierr   !:
-
-    REAL(wp), DIMENSION(1) ::  dtl    !:
-    REAL(wp), DIMENSION(1) ::  dts    !:
-    
-
-    dtl(1) = dt_3d
-    IF ( cpl_id > 1 )  THEN
-
-       CALL cpu_log( log_point_s(70), 'pmc sync', 'start' )
-
-       IF ( myid==0 )  THEN
-          CALL pmc_send_to_server( dtl, SIZE( dtl ), 0, 101, ierr )
-          CALL pmc_recv_from_server( dts, SIZE( dts ), 0, 102, ierr )
-          dt_3d = dts(1)
-       ENDIF
-
-!
-!--    Broadcast the unified time step to all server processes
-       CALL MPI_BCAST( dt_3d, 1, MPI_REAL, 0, comm2d, ierr )
-
-       CALL cpu_log( log_point_s(70), 'pmc sync', 'stop' )
-
-    ENDIF
-
-#endif
- END SUBROUTINE pmci_client_synchronize
+!-- Unify the time steps for each model and synchronize using 
+!-- MPI_ALLREDUCE with the MPI_MIN operator over all processes using 
+!-- the global communicator MPI_COMM_WORLD.
+   IMPLICIT NONE
+
+   INTEGER(iwp)           :: ierr  !:
+   REAL(wp), DIMENSION(1) :: dtl   !:
+   REAL(wp), DIMENSION(1) :: dtg   !:
+
+   
+   dtl(1) = dt_3d 
+   CALL MPI_ALLREDUCE( dtl, dtg, 1, MPI_REAL, MPI_MIN, MPI_COMM_WORLD, ierr )
+   dt_3d  = dtg(1)
+
+ END SUBROUTINE pmci_synchronize
                 
 
@@ -3506,5 +3431,5 @@
       REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr),                          &
                                       INTENT(IN)    ::  fc      !:
-      REAL(wp), DIMENSION(nzb:nzt_topo_nestbc,nys:nyn,1:2,0:ncorr-1),          &
+      REAL(wp), DIMENSION(1:2,0:ncorr-1,nzb:nzt_topo_nestbc,nys:nyn),          &
                                       INTENT(IN)    ::  logc_ratio   !:
       REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN)    ::  r1x     !:
@@ -3519,5 +3444,5 @@
       INTEGER(iwp), DIMENSION(nysg:nyng,nxlg:nxrg), INTENT(IN) ::  kb     !:
       INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN)           ::  kc     !:
-      INTEGER(iwp), DIMENSION(nzb:nzt_topo_nestbc,nys:nyn,1:2),                &
+      INTEGER(iwp), DIMENSION(1:2,nzb:nzt_topo_nestbc,nys:nyn),                &
                                           INTENT(IN)           ::  logc   !:
       INTEGER(iwp) ::  nzt_topo_nestbc   !:
@@ -3589,6 +3514,6 @@
 !
 !--   Generalized log-law-correction algorithm.
-!--   Doubly two-dimensional index arrays logc(:,:,1:2) and log-ratio arrays 
-!--   logc_ratio(:,:,1:2,0:ncorr-1) have been precomputed in subroutine
+!--   Doubly two-dimensional index arrays logc(1:2,:,:) and log-ratio arrays 
+!--   logc_ratio(1:2,0:ncorr-1,:,:) have been precomputed in subroutine
 !--   pmci_init_loglaw_correction.
 !
@@ -3597,9 +3522,9 @@
          DO  j = nys, nyn
             k = kb(j,i)+1
-            IF ( ( logc(k,j,1) /= 0 )  .AND.  ( logc(k,j,2) == 0 ) )  THEN
-               k1 = logc(k,j,1)
-               DO  kcorr=0,ncorr - 1
+            IF ( ( logc(1,k,j) /= 0 )  .AND.  ( logc(2,k,j) == 0 ) )  THEN
+               k1 = logc(1,k,j)
+               DO  kcorr = 0, ncorr - 1
                   kco = k + kcorr
-                  f(kco,j,i) = logc_ratio(k,j,1,kcorr) * f(k1,j,i)
+                  f(kco,j,i) = logc_ratio(1,kcorr,k,j) * f(k1,j,i)
                ENDDO
             ENDIF
@@ -3619,14 +3544,14 @@
             DO  j = nys, nyn
                DO  k = kb(j,i)+1, nzt_topo_nestbc
-                  IF ( ( logc(k,j,2) /= 0 )  .AND.  ( logc(k,j,1) == 0 ) )  THEN
+                  IF ( ( logc(2,k,j) /= 0 )  .AND.  ( logc(1,k,j) == 0 ) )  THEN
 
 !
 !--                  Direction of the wall-normal index is carried in as the
 !--                  sign of logc
-                     jinc = SIGN( 1, logc(k,j,2) )
-                     j1   = ABS( logc(k,j,2) )
+                     jinc = SIGN( 1, logc(2,k,j) )
+                     j1   = ABS( logc(2,k,j) )
                      DO  jcorr = 0, ncorr-1
                         jco = j + jinc * jcorr
-                        f(k,jco,i) = logc_ratio(k,j,2,jcorr) * f(k,j1,i)
+                        f(k,jco,i) = logc_ratio(2,jcorr,k,j) * f(k,j1,i)
                      ENDDO
                   ENDIF
@@ -3640,15 +3565,15 @@
             DO  j = nys, nyn
                k = kb(j,i) + 1
-               IF ( ( logc(k,j,2) /= 0 )  .AND.  ( logc(k,j,1) /= 0 ) )  THEN
-                  k1   = logc(k,j,1)                 
-                  jinc = SIGN( 1, logc(k,j,2) )
-                  j1   = ABS( logc(k,j,2) )                 
+               IF ( ( logc(2,k,j) /= 0 )  .AND.  ( logc(1,k,j) /= 0 ) )  THEN
+                  k1   = logc(1,k,j)                 
+                  jinc = SIGN( 1, logc(2,k,j) )
+                  j1   = ABS( logc(2,k,j) )                 
                   DO  jcorr = 0, ncorr-1
                      jco = j + jinc * jcorr
                      DO  kcorr = 0, ncorr-1
                         kco = k + kcorr
-                        f(kco,jco,i) = 0.5_wp * ( logc_ratio(k,j,1,kcorr) *    &
+                        f(kco,jco,i) = 0.5_wp * ( logc_ratio(1,kcorr,k,j) *    &
                                                   f(k1,j,i)                    &
-                                                + logc_ratio(k,j,2,jcorr) *    &
+                                                + logc_ratio(2,jcorr,k,j) *    &
                                                   f(k,j1,i) )
                      ENDDO
@@ -3709,5 +3634,5 @@
       REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr),                          &
                                       INTENT(IN)    ::  fc            !:
-      REAL(wp), DIMENSION(nzb:nzt_topo_nestbc,nxl:nxr,1:2,0:ncorr-1),          &
+      REAL(wp), DIMENSION(1:2,0:ncorr-1,nzb:nzt_topo_nestbc,nxl:nxr),          &
                                       INTENT(IN)    ::  logc_ratio    !:
       REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN)    ::  r1x           !:
@@ -3722,5 +3647,5 @@
       INTEGER(iwp), DIMENSION(nysg:nyng,nxlg:nxrg), INTENT(IN) ::  kb    !:
       INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN)           ::  kc    !:
-      INTEGER(iwp), DIMENSION(nzb:nzt_topo_nestbc,nxl:nxr,1:2),                &
+      INTEGER(iwp), DIMENSION(1:2,nzb:nzt_topo_nestbc,nxl:nxr),                &
                                           INTENT(IN)           ::  logc  !:
       INTEGER(iwp) ::  nzt_topo_nestbc   !:
@@ -3789,6 +3714,6 @@
 !
 !--   Generalized log-law-correction algorithm.
-!--   Multiply two-dimensional index arrays logc(:,:,1:2) and log-ratio arrays 
-!--   logc_ratio(:,:,1:2,0:ncorr-1) have been precomputed in subroutine
+!--   Multiply two-dimensional index arrays logc(1:2,:,:) and log-ratio arrays 
+!--   logc_ratio(1:2,0:ncorr-1,:,:) have been precomputed in subroutine
 !--   pmci_init_loglaw_correction.
 !
@@ -3797,9 +3722,9 @@
          DO  i = nxl, nxr
             k = kb(j,i) + 1
-            IF ( ( logc(k,i,1) /= 0 )  .AND.  ( logc(k,i,2) == 0 ) )  THEN
-               k1 = logc(k,i,1)
+            IF ( ( logc(1,k,i) /= 0 )  .AND.  ( logc(2,k,i) == 0 ) )  THEN
+               k1 = logc(1,k,i)
                DO  kcorr = 0, ncorr-1
                   kco = k + kcorr
-                  f(kco,j,i) = logc_ratio(k,i,1,kcorr) * f(k1,j,i)
+                  f(kco,j,i) = logc_ratio(1,kcorr,k,i) * f(k1,j,i)
                ENDDO
             ENDIF
@@ -3820,14 +3745,14 @@
 !
 !--               Solid surface only on left/right side of the node           
-                  IF ( ( logc(k,i,2) /= 0 )  .AND.  ( logc(k,i,1) == 0 ) )  THEN
+                  IF ( ( logc(2,k,i) /= 0 )  .AND.  ( logc(1,k,i) == 0 ) )  THEN
 
 !
 !--                  Direction of the wall-normal index is carried in as the
 !--                  sign of logc
-                     iinc = SIGN( 1, logc(k,i,2) )
-                     i1  = ABS( logc(k,i,2) )
+                     iinc = SIGN( 1, logc(2,k,i) )
+                     i1  = ABS( logc(2,k,i) )
                      DO  icorr = 0, ncorr-1
                         ico = i + iinc * icorr
-                        f(k,j,ico) = logc_ratio(k,i,2,icorr) * f(k,j,i1)
+                        f(k,j,ico) = logc_ratio(2,icorr,k,i) * f(k,j,i1)
                      ENDDO
                   ENDIF
@@ -3841,15 +3766,15 @@
             DO  i = nxl, nxr
                k = kb(j,i) + 1
-               IF ( ( logc(k,i,2) /= 0 )  .AND.  ( logc(k,i,1) /= 0 ) )  THEN
-                  k1   = logc(k,i,1)         
-                  iinc = SIGN( 1, logc(k,i,2) )
-                  i1   = ABS( logc(k,i,2) )
+               IF ( ( logc(2,k,i) /= 0 )  .AND.  ( logc(1,k,i) /= 0 ) )  THEN
+                  k1   = logc(1,k,i)         
+                  iinc = SIGN( 1, logc(2,k,i) )
+                  i1   = ABS( logc(2,k,i) )
                   DO  icorr = 0, ncorr-1
                      ico = i + iinc * icorr
                      DO  kcorr = 0, ncorr-1
                         kco = k + kcorr
-                        f(kco,i,ico) = 0.5_wp * ( logc_ratio(k,i,1,kcorr) *    &
+                        f(kco,i,ico) = 0.5_wp * ( logc_ratio(1,kcorr,k,i) *    &
                                                   f(k1,j,i)  &
-                                                + logc_ratio(k,i,2,icorr) *    &
+                                                + logc_ratio(2,icorr,k,i) *    &
                                                   f(k,j,i1) )
                      ENDDO
Index: /palm/trunk/SOURCE/time_integration.f90
===================================================================
--- /palm/trunk/SOURCE/time_integration.f90	(revision 1877)
+++ /palm/trunk/SOURCE/time_integration.f90	(revision 1878)
@@ -19,5 +19,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! Synchronization for nested runs rewritten
 ! 
 ! Former revisions:
@@ -282,7 +282,6 @@
     USE pmc_interface,                                                         &
         ONLY:  client_to_server, nested_run, nesting_mode,                     &
-               pmci_client_synchronize, pmci_datatrans,                        &
-               pmci_ensure_nest_mass_conservation,                             &
-               pmci_server_synchronize, server_to_client
+               pmci_datatrans, pmci_ensure_nest_mass_conservation,             &
+               pmci_synchronize, server_to_client
 
     USE production_e_mod,                                                      &
@@ -325,8 +324,9 @@
 !
 !-- Synchronize the timestep in case of nested run.
-!-- The server side must be called first
     IF ( nested_run )  THEN
-       CALL pmci_server_synchronize
-       CALL pmci_client_synchronize
+!
+!--    Synchronization by unifying the time step.
+!--    Global minimum of all time-steps is used for all.
+       CALL pmci_synchronize
     ENDIF
 
@@ -368,14 +368,13 @@
        IF ( simulated_time /= 0.0_wp )  THEN
           CALL timestep
-
+!
+!--       Synchronize the timestep in case of nested run.
           IF ( nested_run )  THEN
 !
-!--          TO_DO: try to give more detailed and meaningful comments here
-!--          Server side must be called first
-             CALL pmci_server_synchronize
-             CALL pmci_client_synchronize
-          ENDIF
-       ENDIF
-
+!--          Synchronize by unifying the time step.
+!--          Global minimum of all time-steps is used for all.      
+             CALL pmci_synchronize
+          ENDIF
+       ENDIF
 
 !
