Index: palm/trunk/SOURCE/exchange_horiz_2d.f90
===================================================================
--- palm/trunk/SOURCE/exchange_horiz_2d.f90	(revision 1967)
+++ palm/trunk/SOURCE/exchange_horiz_2d.f90	(revision 1968)
@@ -19,5 +19,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! 2D-INTEGER exchange adopted for different multigrid level
 ! 
 ! Former revisions:
@@ -203,17 +203,14 @@
 !------------------------------------------------------------------------------!
  
- SUBROUTINE exchange_horiz_2d_int( ar )
+ SUBROUTINE exchange_horiz_2d_int( ar, nys_l, nyn_l, nxl_l, nxr_l, nbgp_local )
 
 
     USE control_parameters,                                                    &
-        ONLY:  bc_lr_cyc, bc_ns_cyc, nest_bound_l, nest_bound_n, nest_bound_r, &
-               nest_bound_s
+        ONLY:  bc_lr_cyc, bc_ns_cyc, grid_level, nest_bound_l, nest_bound_n,   &
+               nest_bound_r, nest_bound_s
         
     USE cpulog,                                                                &
         ONLY:  cpu_log, log_point_s
-        
-    USE indices,                                                               &
-        ONLY:  nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg
-        
+               
     USE kinds
     
@@ -222,6 +219,13 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i
-    INTEGER(iwp) ::  ar(nysg:nyng,nxlg:nxrg)  !<
+    INTEGER(iwp) ::  i           !< dummy index to zero-gradient conditions at in/outflow boundaries
+    INTEGER(iwp) ::  nxl_l       !< local index bound at current grid level, left side
+    INTEGER(iwp) ::  nxr_l       !< local index bound at current grid level, right side
+    INTEGER(iwp) ::  nyn_l       !< local index bound at current grid level, north side
+    INTEGER(iwp) ::  nys_l       !< local index bound at current grid level, south side
+    INTEGER(iwp) ::  nbgp_local  !< number of ghost layers to be exchanged
+
+    INTEGER(iwp), DIMENSION(nys_l-nbgp_local:nyn_l+nbgp_local,                 &
+                            nxl_l-nbgp_local:nxr_l+nbgp_local) ::  ar  !< treated array
 
     CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'start' )
@@ -236,19 +240,22 @@
 !--    One-dimensional decomposition along y, boundary values can be exchanged
 !--    within the PE memory
-       ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr)
-       ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1)
-
+       ar(:,nxl_l-nbgp_local:nxl_l-1) = ar(:,nxr_l-nbgp_local+1:nxr_l)
+       ar(:,nxr_l+1:nxr_l+nbgp_local) = ar(:,nxl_l:nxl_l+nbgp_local-1)
 
     ELSE
 !
 !--    Send left boundary, receive right one
-       CALL MPI_SENDRECV( ar(nysg,nxl), 1, type_y_int, pleft,  0,             &
-                          ar(nysg,nxr+1), 1, type_y_int, pright, 0,           &
+       CALL MPI_SENDRECV( ar(nys_l-nbgp_local,nxl_l),   1,                     &
+                          type_y_int(grid_level), pleft,  0,                   &
+                          ar(nys_l-nbgp_local,nxr_l+1), 1,                     &
+                          type_y_int(grid_level), pright, 0,                   &
                           comm2d, status, ierr )
 !
 !--    Send right boundary, receive left one
-       CALL MPI_SENDRECV( ar(nysg,nxr+1-nbgp), 1, type_y_int, pright,  1,     &
-                          ar(nysg,nxlg), 1, type_y_int, pleft,   1,           &
-                          comm2d, status, ierr )
+       CALL MPI_SENDRECV( ar(nys_l-nbgp_local,nxr_l+1-nbgp_local), 1,          &
+                          type_y_int(grid_level), pright, 1,                   &
+                          ar(nys_l-nbgp_local,nxl_l-nbgp_local),   1,          & 
+                          type_y_int(grid_level), pleft,  1,                   &
+                          comm2d, status, ierr )                         
 
     ENDIF
@@ -258,6 +265,6 @@
 !--    One-dimensional decomposition along x, boundary values can be exchanged
 !--    within the PE memory
-       ar(nysg:nys-1,:) = ar(nyn+1-nbgp:nyn,:)
-       ar(nyn+1:nyng,:) = ar(nys:nys-1+nbgp,:)
+       ar(nys_l-nbgp_local:nys_l-1,:) = ar(nyn_l+1-nbgp_local:nyn_l,:)
+       ar(nyn_l+1:nyn_l+nbgp_local,:) = ar(nys_l:nys_l-1+nbgp_local,:)
 
 
@@ -265,12 +272,16 @@
 !
 !--    Send front boundary, receive rear one
-       CALL MPI_SENDRECV( ar(nys,nxlg), 1, type_x_int, psouth, 0,             &
-                          ar(nyn+1,nxlg), 1, type_x_int, pnorth, 0,           &
+       CALL MPI_SENDRECV( ar(nys_l,nxl_l-nbgp_local),   1,                    &
+                          type_x_int(grid_level), psouth, 0,                  &
+                          ar(nyn_l+1,nxl_l-nbgp_local), 1,                    &
+                          type_x_int(grid_level), pnorth, 0,                  &
                           comm2d, status, ierr )                          
 
 !
 !--    Send rear boundary, receive front one
-       CALL MPI_SENDRECV( ar(nyn+1-nbgp,nxlg), 1, type_x_int, pnorth, 1,      &
-                          ar(nysg,nxlg), 1, type_x_int, psouth, 1,            &
+       CALL MPI_SENDRECV( ar(nyn_l+1-nbgp_local,nxl_l-nbgp_local), 1,         &
+                          type_x_int(grid_level), pnorth, 1,                  &
+                          ar(nys_l-nbgp_local,nxl_l-nbgp_local),   1,         &
+                          type_x_int(grid_level), psouth, 1,                  &
                           comm2d, status, ierr )
 
@@ -282,11 +293,11 @@
 !-- Lateral boundary conditions in the non-parallel case
     IF ( bc_lr_cyc )  THEN
-       ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr)
-       ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1)
+       ar(:,nxl_l-nbgp_local:nxl_l-1) = ar(:,nxr_l-nbgp_local+1:nxr_l)
+       ar(:,nxr_l+1:nxr_l+nbgp_local) = ar(:,nxl_l:nxl_l+nbgp_local-1)
     ENDIF
 
     IF ( bc_ns_cyc )  THEN
-       ar(nysg:nys-1,:) = ar(nyn+1-nbgp:nyn,:)
-       ar(nyn+1:nyng,:) = ar(nys:nys-1+nbgp,:)
+       ar(nys_l-nbgp_local:nys_l-1,:) = ar(nyn_l+1-nbgp_local:nyn_l,:)
+       ar(nyn_l+1:nyn_l+nbgp_local,:) = ar(nys_l:nys_l-1+nbgp_local,:)
     ENDIF
 
@@ -295,21 +306,21 @@
 !-- Neumann-conditions at inflow/outflow/nested boundaries
     IF ( nest_bound_l )  THEN
-       DO  i = nbgp, 1, -1
-         ar(:,nxl-i) = ar(:,nxl)
+       DO  i = nbgp_local, 1, -1
+         ar(:,nxl_l-i) = ar(:,nxl_l)
        ENDDO
     ENDIF
     IF ( nest_bound_r )  THEN
-       DO  i = 1, nbgp
-          ar(:,nxr+i) = ar(:,nxr)
+       DO  i = 1, nbgp_local
+          ar(:,nxr_l+i) = ar(:,nxr_l)
        ENDDO
     ENDIF
     IF ( nest_bound_s )  THEN
-       DO  i = nbgp, 1, -1
-         ar(nys-i,:) = ar(nys,:)
+       DO  i = nbgp_local, 1, -1
+         ar(nys_l-i,:) = ar(nys_l,:)
        ENDDO
     ENDIF
     IF ( nest_bound_n )  THEN
-       DO  i = 1, nbgp
-         ar(nyn+i,:) = ar(nyn,:)
+       DO  i = 1, nbgp_local
+         ar(nyn_l+i,:) = ar(nyn_l,:)
        ENDDO
     ENDIF
Index: palm/trunk/SOURCE/init_grid.f90
===================================================================
--- palm/trunk/SOURCE/init_grid.f90	(revision 1967)
+++ palm/trunk/SOURCE/init_grid.f90	(revision 1968)
@@ -19,5 +19,12 @@
 ! Current revisions:
 ! -----------------
-! 
+! Changed: PE-wise reading of topography file in order to avoid global definition
+! of arrays nzb_local and nzb_tmp. Thereby, topography definition for single
+! buildings and street canyons has changed, as well as flag setting for 
+! multigrid scheme.
+!
+! Bugfix in checking l_grid anisotropy. 
+! Simplify initial computation of lwall and vertical_influence, i.e. remove 
+! nzb_s_inner as it is still zero at this point.
 ! 
 ! Former revisions:
@@ -188,6 +195,6 @@
                canyon_width_x, canyon_width_y, constant_flux_layer,            &
                coupling_char, dp_level_ind_b, dz, dz_max, dz_stretch_factor,   &
-               dz_stretch_level, dz_stretch_level_index, ibc_uv_b, io_blocks,  &
-               io_group, inflow_l, inflow_n, inflow_r, inflow_s,               &
+               dz_stretch_level, dz_stretch_level_index, grid_level, ibc_uv_b, &
+               io_blocks, io_group, inflow_l, inflow_n, inflow_r, inflow_s,    &
                masking_method, maximum_grid_level, message_string,             &
                momentum_advec, nest_domain, ocean, outflow_l, outflow_n,       &
@@ -219,58 +226,60 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  bh       !< temporary vertical index of building height
-    INTEGER(iwp) ::  blx      !< grid point number of building size along x
-    INTEGER(iwp) ::  bly      !< grid point number of building size along y
-    INTEGER(iwp) ::  bxl      !< index for left building wall
-    INTEGER(iwp) ::  bxr      !< index for right building wall
-    INTEGER(iwp) ::  byn      !< index for north building wall
-    INTEGER(iwp) ::  bys      !< index for south building wall
-    INTEGER(iwp) ::  ch       !< temporary vertical index for canyon height
-    INTEGER(iwp) ::  cwx      !< grid point number of canyon size along x
-    INTEGER(iwp) ::  cwy      !< grid point number of canyon size along y
-    INTEGER(iwp) ::  cxl      !< index for left canyon wall
-    INTEGER(iwp) ::  cxr      !< index for right canyon wall
-    INTEGER(iwp) ::  cyn      !< index for north canyon wall
-    INTEGER(iwp) ::  cys      !< index for south canyon wall
-    INTEGER(iwp) ::  gls      !< number of lateral ghost points at total model domain boundaries required for multigrid solver
-    INTEGER(iwp) ::  i        !< index variable along x
-    INTEGER(iwp) ::  ii       !< loop variable for reading topography file
-    INTEGER(iwp) ::  inc      !< incremental parameter for coarsening grid level
-    INTEGER(iwp) ::  j        !< index variable along y
-    INTEGER(iwp) ::  k        !< index variable along z
-    INTEGER(iwp) ::  l        !< loop variable 
-    INTEGER(iwp) ::  nxl_l    !< index of left PE boundary for multigrid level
-    INTEGER(iwp) ::  nxr_l    !< index of right PE boundary for multigrid level
-    INTEGER(iwp) ::  nyn_l    !< index of north PE boundary for multigrid level
-    INTEGER(iwp) ::  nys_l    !< index of south PE boundary for multigrid level
-    INTEGER(iwp) ::  nzb_si   !< dummy index for local nzb_s_inner
-    INTEGER(iwp) ::  nzt_l    !< index of top PE boundary for multigrid level
-    INTEGER(iwp) ::  num_hole !< number of holes (in topography) resolved by only one grid point 
-    INTEGER(iwp) ::  num_wall !< number of surrounding vertical walls for a single grid point
-    INTEGER(iwp) ::  vi       !< dummy for vertical influence
+    INTEGER(iwp) ::  bh            !< temporary vertical index of building height
+    INTEGER(iwp) ::  blx           !< grid point number of building size along x
+    INTEGER(iwp) ::  bly           !< grid point number of building size along y
+    INTEGER(iwp) ::  bxl           !< index for left building wall
+    INTEGER(iwp) ::  bxr           !< index for right building wall
+    INTEGER(iwp) ::  byn           !< index for north building wall
+    INTEGER(iwp) ::  bys           !< index for south building wall
+    INTEGER(iwp) ::  ch            !< temporary vertical index for canyon height
+    INTEGER(iwp) ::  cwx           !< grid point number of canyon size along x
+    INTEGER(iwp) ::  cwy           !< grid point number of canyon size along y
+    INTEGER(iwp) ::  cxl           !< index for left canyon wall
+    INTEGER(iwp) ::  cxr           !< index for right canyon wall
+    INTEGER(iwp) ::  cyn           !< index for north canyon wall
+    INTEGER(iwp) ::  cys           !< index for south canyon wall
+    INTEGER(iwp) ::  i             !< index variable along x
+    INTEGER(iwp) ::  ii            !< loop variable for reading topography file
+    INTEGER(iwp) ::  inc           !< incremental parameter for coarsening grid level
+    INTEGER(iwp) ::  j             !< index variable along y
+    INTEGER(iwp) ::  k             !< index variable along z
+    INTEGER(iwp) ::  l             !< loop variable 
+    INTEGER(iwp) ::  nxl_l         !< index of left PE boundary for multigrid level
+    INTEGER(iwp) ::  nxr_l         !< index of right PE boundary for multigrid level
+    INTEGER(iwp) ::  nyn_l         !< index of north PE boundary for multigrid level
+    INTEGER(iwp) ::  nys_l         !< index of south PE boundary for multigrid level
+    INTEGER(iwp) ::  nzb_local_max !< vertical grid index of maximum topography height
+    INTEGER(iwp) ::  nzb_local_min !< vertical grid index of minimum topography height
+    INTEGER(iwp) ::  nzb_si        !< dummy index for local nzb_s_inner
+    INTEGER(iwp) ::  nzt_l         !< index of top PE boundary for multigrid level
+    INTEGER(iwp) ::  num_hole      !< number of holes (in topography) resolved by only one grid point 
+    INTEGER(iwp) ::  num_hole_l    !< number of holes (in topography) resolved by only one grid point on local PE     
+    INTEGER(iwp) ::  num_wall      !< number of surrounding vertical walls for a single grid point
+    INTEGER(iwp) ::  skip_n_rows   !< counting variable to skip rows while reading topography file    
+    INTEGER(iwp) ::  vi            !< dummy for vertical influence
 
     INTEGER(iwp), DIMENSION(:), ALLOCATABLE   ::                               &
                      vertical_influence  !< number of vertical grid points above obstacle where adjustment of near-wall mixing length is required
                                          
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  corner_nl  !< index of north-left corner location to limit near-wall mixing length
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  corner_nr  !< north-right
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  corner_sl  !< south-left
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  corner_sr  !< south-right
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  wall_l     !< distance to adjacent left-facing 
-                                                             !< wall
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  wall_n     !< north-facing
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  wall_r     !< right-facing
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  wall_s     !< right-facing
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_local  !< index for topography
-                                                             !< top at cell-center
-    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_tmp    !< dummy to calculate topography indices on u- and v-grid
-
-    LOGICAL  ::  hole = .FALSE.  !< flag to check if any holes resolved by only 1 grid point were filled
-
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  corner_nl      !< index of north-left corner location to limit near-wall mixing length
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  corner_nr      !< north-right
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  corner_sl      !< south-left
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  corner_sr      !< south-right
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_local      !< index for topography top at cell-center
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_tmp        !< dummy to calculate topography indices on u- and v-grid
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  wall_l         !< distance to adjacent left-facing wall
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  wall_n         !< north-facing
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  wall_r         !< right-facing
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  wall_s         !< right-facing
+
+    REAL(wp) ::  dum           !< dummy variable to skip columns while reading topography file    
     REAL(wp) ::  dx_l          !< grid spacing along x on different multigrid level
     REAL(wp) ::  dy_l          !< grid spacing along y on different multigrid level
     REAL(wp) ::  dz_stretched  !< stretched vertical grid spacing
 
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  topo_height  !< input variable for topography height
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  topo_height   !< input variable for topography height
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  zu_s_inner_l  !< dummy array on global scale to write topography output array
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  zw_w_inner_l  !< dummy array on global scale to write topography output array
 
     
@@ -472,15 +481,10 @@
 !-- Allocate outer and inner index arrays for topography and set
 !-- defaults.
-!-- nzb_local has to contain additional layers of ghost points for calculating
-!-- the flag arrays needed for the multigrid method
-    gls = 2**( maximum_grid_level )
-    IF ( gls < nbgp )  gls = nbgp
 
     ALLOCATE( corner_nl(nys:nyn,nxl:nxr), corner_nr(nys:nyn,nxl:nxr),       &
               corner_sl(nys:nyn,nxl:nxr), corner_sr(nys:nyn,nxl:nxr),       &
-              nzb_local(-gls:ny+gls,-gls:nx+gls),                                   &
-              nzb_tmp(-nbgp:ny+nbgp,-nbgp:nx+nbgp),                         &
               wall_l(nys:nyn,nxl:nxr), wall_n(nys:nyn,nxl:nxr),             &
-              wall_r(nys:nyn,nxl:nxr), wall_s(nys:nyn,nxl:nxr) )
+              wall_r(nys:nyn,nxl:nxr), wall_s(nys:nyn,nxl:nxr) )                     
+     
     ALLOCATE( fwxm(nysg:nyng,nxlg:nxrg), fwxp(nysg:nyng,nxlg:nxrg),         &
               fwym(nysg:nyng,nxlg:nxrg), fwyp(nysg:nyng,nxlg:nxrg),         &
@@ -499,4 +503,6 @@
               nzb_diff_u(nysg:nyng,nxlg:nxrg),                              &
               nzb_diff_v(nysg:nyng,nxlg:nxrg),                              &
+              nzb_local(nysg:nyng,nxlg:nxrg),                               &
+              nzb_tmp(nysg:nyng,nxlg:nxrg),                                 &
               rflags_s_inner(nzb:nzt+2,nysg:nyng,nxlg:nxrg),                &
               rflags_invers(nysg:nyng,nxlg:nxrg,nzb:nzt+2),                 &
@@ -559,5 +565,5 @@
     ENDDO
 
-    DO  k = 1, MAXVAL( nzb_s_inner )
+    DO  k = 1, nzt
        IF ( l_grid(k) > 1.5_wp * dx * wall_adjustment_factor .OR.  &
             l_grid(k) > 1.5_wp * dy * wall_adjustment_factor )  THEN
@@ -573,11 +579,6 @@
     vertical_influence(0) = vertical_influence(1)
 
-    DO  i = nxlg, nxrg
-       DO  j = nysg, nyng
-          DO  k = nzb_s_inner(j,i) + 1, &
-                  nzb_s_inner(j,i) + vertical_influence(nzb_s_inner(j,i))
-             l_wall(k,j,i) = zu(k) - zw(nzb_s_inner(j,i))
-          ENDDO
-       ENDDO
+    DO  k = nzb + 1, nzb + vertical_influence(nzb)
+       l_wall(k,:,:) = zu(k) - zw(nzb)
     ENDDO
 
@@ -629,7 +630,9 @@
 
 !
-!--       Define the building.
+!--       Define the building. 
           nzb_local = 0
-          nzb_local(bys:byn,bxl:bxr) = bh
+          IF ( bxl <= nxr  .AND.  bxr >= nxl  .AND.                            &
+               bys <= nyn  .AND.  byn >= nys )                                 &        
+             nzb_local(MAX(nys,bys):MIN(nyn,byn),MAX(nxl,bxl):MIN(nxr,bxr)) = bh
 
        CASE ( 'single_street_canyon' )
@@ -700,12 +703,14 @@
           nzb_local = ch
           IF ( canyon_width_x /= 9999999.9_wp )  THEN
-             nzb_local(:,cxl+1:cxr-1) = 0
+             IF ( cxl <= nxr  .AND.  cxr >= nxl )                              &
+                nzb_local(:,MAX(nxl,cxl+1):MIN(nxr,cxr-1)) = 0
           ELSEIF ( canyon_width_y /= 9999999.9_wp )  THEN
-             nzb_local(cys+1:cyn-1,:) = 0
+             IF ( cys <= nyn  .AND.  cyn >= nys )                              &          
+                nzb_local(MAX(nys,cys+1):MIN(nyn,cyn-1),:) = 0
           ENDIF
 
        CASE ( 'read_from_file' )
 
-          ALLOCATE ( topo_height(0:ny,0:nx) )
+          ALLOCATE ( topo_height(nys:nyn,nxl:nxr) )
 
           DO  ii = 0, io_blocks-1
@@ -717,6 +722,19 @@
                 OPEN( 90, FILE='TOPOGRAPHY_DATA'//TRIM( coupling_char ),       &
                           STATUS='OLD', FORM='FORMATTED', ERR=10 )
-                DO  j = ny, 0, -1
-                   READ( 90, *, ERR=11, END=11 )  ( topo_height(j,i), i = 0,nx )
+!
+!--             Read topography PE-wise. Rows are read from nyn to nys, columns
+!--             are read from nxl to nxr. At first, ny-nyn rows need to be skipped.
+                skip_n_rows = 0
+                DO WHILE ( skip_n_rows < ny - nyn )
+                   READ( 90, * )  
+                   skip_n_rows = skip_n_rows + 1
+                ENDDO
+!
+!--             Read data from nyn to nys and nxl to nxr. Therefore, skip 
+!--             column until nxl-1 is reached
+                DO  j = nyn, nys, -1
+                   READ( 90, *, ERR=11, END=11 )                               &
+                                              ( dum, i = 0, nxl-1 ),           &
+                                              ( topo_height(j,i), i = nxl, nxr )
                 ENDDO
 
@@ -741,6 +759,7 @@
 !
 !--       Calculate the index height of the topography
-          DO  i = 0, nx
-             DO  j = 0, ny
+          nzb_local = 0
+          DO  i = nxl, nxr
+             DO  j = nys, nyn
                 nzb_local(j,i) = MINLOC( ABS( zw - topo_height(j,i) ), 1 ) - 1
                 IF ( ABS( zw(nzb_local(j,i)  ) - topo_height(j,i) ) == &
@@ -759,23 +778,19 @@
 !--       Before checking for holes, set lateral boundary conditions for 
 !--       topography. After hole-filling, boundary conditions must be set again!
-          IF ( bc_ns_cyc )  THEN
-             nzb_local(-1,:)   = nzb_local(ny,:)
-             nzb_local(ny+1,:) = nzb_local(0,:)
-          ELSE
-             nzb_local(-1,:)   = nzb_local(0,:)
-             nzb_local(ny+1,:) = nzb_local(ny,:)
-          ENDIF
-
-          IF ( bc_lr_cyc )  THEN
-             nzb_local(:,-1)   = nzb_local(:,nx)
-             nzb_local(:,nx+1) = nzb_local(:,0)
-          ELSE
-             nzb_local(:,-1)   = nzb_local(:,0)
-             nzb_local(:,nx+1) = nzb_local(:,nx)
-          ENDIF
-
-          num_hole = 0
-          DO i = 0, nx
-             DO j = 0, ny
+          CALL exchange_horiz_2d_int( nzb_local, nys, nyn, nxl, nxr, nbgp )
+          
+          IF ( .NOT. bc_ns_cyc )  THEN
+             IF ( nys == 0  )  nzb_local(-1,:)   = nzb_local(0,:)
+             IF ( nyn == ny )  nzb_local(ny+1,:) = nzb_local(ny,:)
+          ENDIF
+
+          IF ( .NOT. bc_lr_cyc )  THEN
+             IF ( nxl == 0  )  nzb_local(:,-1)   = nzb_local(:,0)
+             IF ( nxr == nx )  nzb_local(:,nx+1) = nzb_local(:,nx)          
+          ENDIF
+
+          num_hole_l = 0
+          DO i = nxl, nxr
+             DO j = nys, nyn
 
                 num_wall = 0
@@ -791,14 +806,21 @@
 
                 IF ( num_wall == 4 )  THEN
-                   hole           = .TRUE.
                    nzb_local(j,i) = MIN( nzb_local(j-1,i), nzb_local(j+1,i),   &
                                          nzb_local(j,i-1), nzb_local(j,i+1) )
-                   num_hole       = num_hole + 1
+                   num_hole_l     = num_hole_l + 1
                 ENDIF
              ENDDO
           ENDDO
 !
+!--       Count the total number of holes, required for informative message.
+#if defined( __parallel )
+          CALL MPI_ALLREDUCE( num_hole_l, num_hole, 1, MPI_INTEGER, MPI_SUM,   &
+                              comm2d, ierr )
+#else
+          num_hole = num_hole_l
+#endif    
+!
 !--       Create an informative message if any hole was removed.
-          IF ( hole )  THEN
+          IF ( num_hole > 0 )  THEN
              WRITE( message_string, * ) num_hole, 'hole(s) resolved by only '//&
                                                   'one grid point were filled'
@@ -806,28 +828,16 @@
           ENDIF
 !
-!--       Add cyclic or Neumann boundary conditions (additional layers are for
-!--       calculating flag arrays needed for the multigrid sover)
-          IF ( bc_ns_cyc )  THEN
-             nzb_local(-gls:-1,0:nx)     = nzb_local(ny-gls+1:ny,0:nx)
-             nzb_local(ny+1:ny+gls,0:nx) = nzb_local(0:gls-1,0:nx)
-          ELSE
-             DO  j = -gls, -1
-                nzb_local(j,0:nx)  = nzb_local(0,0:nx)
-             ENDDO
-             DO  j = ny+1, ny+gls
-                 nzb_local(j,0:nx) = nzb_local(ny,0:nx)
-             ENDDO
-          ENDIF
-
-          IF ( bc_lr_cyc )  THEN
-             nzb_local(:,-gls:-1)     = nzb_local(:,nx-gls+1:nx)
-             nzb_local(:,nx+1:nx+gls) = nzb_local(:,0:gls-1)
-          ELSE
-             DO  i = -gls, -1
-                nzb_local(:,i) = nzb_local(:,0)
-             ENDDO
-             DO  i = nx+1, nx+gls
-                nzb_local(:,i) = nzb_local(:,nx)
-             ENDDO
+!--       Exchange ghost-points, as well as add cyclic or Neumann boundary 
+!--       conditions.
+          CALL exchange_horiz_2d_int( nzb_local, nys, nyn, nxl, nxr, nbgp )
+          
+          IF ( .NOT. bc_ns_cyc )  THEN
+             IF ( nys == 0  )  nzb_local(-1,:)   = nzb_local(0,:)
+             IF ( nyn == ny )  nzb_local(ny+1,:) = nzb_local(ny,:)
+          ENDIF
+
+          IF ( .NOT. bc_lr_cyc )  THEN
+             IF ( nxl == 0  )  nzb_local(:,-1)   = nzb_local(:,0)
+             IF ( nxr == nx )  nzb_local(:,nx+1) = nzb_local(:,nx)          
           ENDIF
 
@@ -838,5 +848,5 @@
 !--       case in the user interface. There, the subroutine user_init_grid 
 !--       checks which of these two conditions applies.
-          CALL user_init_grid( gls, nzb_local )
+          CALL user_init_grid( nzb_local )
 
     END SELECT
@@ -845,6 +855,11 @@
 !-- steering the degradation of order of the applied advection scheme.
 !-- In case of non-cyclic lateral boundaries, the order of the advection
-!-- scheme have to be reduced up to nzt (required at the lateral boundaries).
+!-- scheme has to be reduced up to nzt (required at the lateral boundaries).
+#if defined( __parallel )
+    CALL MPI_ALLREDUCE( MAXVAL( nzb_local ) + 1, nzb_max, 1, MPI_INTEGER,      &
+                        MPI_MAX, comm2d, ierr )
+#else
     nzb_max = MAXVAL( nzb_local ) + 1
+#endif
     IF ( inflow_l .OR. outflow_l .OR. inflow_r .OR. outflow_r .OR.             &
          inflow_n .OR. outflow_n .OR. inflow_s .OR. outflow_s .OR.             &
@@ -859,30 +874,21 @@
 !-- zu_s_inner and zw_w_inner
     IF ( TRIM( topography ) /= 'flat' )  THEN
-
+#if defined( __parallel )
+       CALL MPI_ALLREDUCE( MAXVAL( nzb_local ), nzb_local_max, 1, MPI_INTEGER, &
+                           MPI_MAX, comm2d, ierr )
+       CALL MPI_ALLREDUCE( MAXVAL( nzb_local ), nzb_local_min, 1, MPI_INTEGER, &
+                           MPI_MIN, comm2d, ierr )                           
+#else
+       nzb_local_max = MAXVAL( nzb_local )
+       nzb_local_min = MINVAL( nzb_local )
+#endif
 !
 !--    Consistency checks
-       IF ( MINVAL( nzb_local ) < 0  .OR.  MAXVAL( nzb_local ) > nz + 1 )  THEN
+       IF ( nzb_local_min < 0  .OR.  nzb_local_max  > nz + 1 )  THEN
           WRITE( message_string, * ) 'nzb_local values are outside the',       &
                                 'model domain',                                &
-                                '&MINVAL( nzb_local ) = ', MINVAL(nzb_local),  &
-                                '&MAXVAL( nzb_local ) = ', MAXVAL(nzb_local)
+                                '&MINVAL( nzb_local ) = ', nzb_local_min,      &
+                                '&MAXVAL( nzb_local ) = ', nzb_local_max
           CALL message( 'init_grid', 'PA0210', 1, 2, 0, 6, 0 )
-       ENDIF
-
-       IF ( bc_lr_cyc )  THEN
-          IF ( ANY( nzb_local(:,-1) /= nzb_local(:,nx)   )  .OR.               &
-               ANY( nzb_local(:,0)  /= nzb_local(:,nx+1) ) )  THEN
-             message_string = 'nzb_local does not fulfill cyclic' //           &
-                              ' boundary condition in x-direction'
-             CALL message( 'init_grid', 'PA0211', 1, 2, 0, 6, 0 )
-          ENDIF
-       ENDIF
-       IF ( bc_ns_cyc )  THEN
-          IF ( ANY( nzb_local(-1,:) /= nzb_local(ny,:)   )  .OR.               &
-               ANY( nzb_local(0,:)  /= nzb_local(ny+1,:) ) )  THEN
-             message_string = 'nzb_local does not fulfill cyclic' //           &
-                              ' boundary condition in y-direction'
-             CALL message( 'init_grid', 'PA0212', 1, 2, 0, 6, 0 )
-          ENDIF
        ENDIF
 
@@ -896,27 +902,29 @@
 !--       Therefore, the extent of topography in nzb_local is now reduced by 
 !--       1dx at the E topography walls and by 1dy at the N topography walls 
-!--       to form the basis for nzb_s_inner.
-          DO  j = -gls, ny + gls
-             DO  i = -gls, nx
+!--       to form the basis for nzb_s_inner. 
+!--       Note, the reverse memory access (i-j instead of j-i) is absolutely
+!--       required at this point.
+          DO  j = nys+1, nyn+1
+             DO  i = nxl-1, nxr
                 nzb_local(j,i) = MIN( nzb_local(j,i), nzb_local(j,i+1) )
              ENDDO
           ENDDO
-!--       apply cyclic boundary conditions in x-direction 
-!(ist das erforderlich? Ursache von Seung Bus Fehler?)
-          nzb_local(:,nx+1:nx+gls) = nzb_local(:,0:gls-1)
-          DO  i = -gls, nx + gls
-             DO  j = -gls, ny
+!
+!--       Exchange ghost points
+          CALL exchange_horiz_2d_int( nzb_local, nys, nyn, nxl, nxr, nbgp )
+
+          DO  i = nxl, nxr+1
+             DO  j = nys-1, nyn
                 nzb_local(j,i) = MIN( nzb_local(j,i), nzb_local(j+1,i) )
              ENDDO
           ENDDO
-!--       apply cyclic boundary conditions in y-direction
-!(ist das erforderlich? Ursache von Seung Bus Fehler?)
-          nzb_local(ny+1:ny+gls,:) = nzb_local(0:gls-1,:)
+!
+!--       Exchange ghost points          
+          CALL exchange_horiz_2d_int( nzb_local, nys, nyn, nxl, nxr, nbgp )
        ENDIF
-
 !
 !--    Initialize index arrays nzb_s_inner and nzb_w_inner
-       nzb_s_inner = nzb_local(nysg:nyng,nxlg:nxrg)
-       nzb_w_inner = nzb_local(nysg:nyng,nxlg:nxrg)
+       nzb_s_inner = nzb_local
+       nzb_w_inner = nzb_local
 
 !
@@ -937,11 +945,14 @@
 !--    nzb_s_outer: 
 !--    extend nzb_local east-/westwards first, then north-/southwards
-       nzb_tmp = nzb_local(-nbgp:ny+nbgp,-nbgp:nx+nbgp)
-       DO  j = -1, ny + 1
-          DO  i = 0, nx
+       nzb_tmp = nzb_local
+       DO  j = nys, nyn
+          DO  i = nxl, nxr
              nzb_tmp(j,i) = MAX( nzb_local(j,i-1), nzb_local(j,i),             &
                                  nzb_local(j,i+1) )
           ENDDO
        ENDDO
+       
+       CALL exchange_horiz_2d_int( nzb_tmp, nys, nyn, nxl, nxr, nbgp )
+       
        DO  i = nxl, nxr
           DO  j = nys, nyn
@@ -969,12 +980,14 @@
 !--    nzb_u_inner: 
 !--    extend nzb_local rightwards only
-       nzb_tmp = nzb_local(-nbgp:ny+nbgp,-nbgp:nx+nbgp)
-       DO  j = -1, ny + 1
-          DO  i = 0, nx + 1
+       nzb_tmp = nzb_local
+       DO  j = nys, nyn
+          DO  i = nxl, nxr
              nzb_tmp(j,i) = MAX( nzb_local(j,i-1), nzb_local(j,i) )
           ENDDO
        ENDDO
-       nzb_u_inner = nzb_tmp(nysg:nyng,nxlg:nxrg)
-
+       
+       CALL exchange_horiz_2d_int( nzb_tmp, nys, nyn, nxl, nxr, nbgp )
+       
+       nzb_u_inner = nzb_tmp
 !
 !--    nzb_u_outer: 
@@ -1001,11 +1014,13 @@
 !--    nzb_v_inner:
 !--    extend nzb_local northwards only
-       nzb_tmp = nzb_local(-nbgp:ny+nbgp,-nbgp:nx+nbgp)
-       DO  i = -1, nx + 1
-          DO  j = 0, ny + 1
+       nzb_tmp = nzb_local
+       DO  i = nxl, nxr
+          DO  j = nys, nyn
              nzb_tmp(j,i) = MAX( nzb_local(j-1,i), nzb_local(j,i) )
           ENDDO
        ENDDO
-       nzb_v_inner = nzb_tmp(nysg:nyng,nxlg:nxrg)
+       
+       CALL exchange_horiz_2d_int( nzb_tmp, nys, nyn, nxl, nxr, nbgp )      
+       nzb_v_inner = nzb_tmp
 
 !
@@ -1035,25 +1050,58 @@
 !--    Since nzb_s_inner and nzb_w_inner are derived directly from nzb_local
 !--    they do not require exchange and are not included here.
-       CALL exchange_horiz_2d_int( nzb_u_inner )
-       CALL exchange_horiz_2d_int( nzb_u_outer )
-       CALL exchange_horiz_2d_int( nzb_v_inner )
-       CALL exchange_horiz_2d_int( nzb_v_outer )
-       CALL exchange_horiz_2d_int( nzb_w_outer )
-       CALL exchange_horiz_2d_int( nzb_s_outer )
+       CALL exchange_horiz_2d_int( nzb_u_inner, nys, nyn, nxl, nxr, nbgp )
+       CALL exchange_horiz_2d_int( nzb_u_outer, nys, nyn, nxl, nxr, nbgp )
+       CALL exchange_horiz_2d_int( nzb_v_inner, nys, nyn, nxl, nxr, nbgp )
+       CALL exchange_horiz_2d_int( nzb_v_outer, nys, nyn, nxl, nxr, nbgp )
+       CALL exchange_horiz_2d_int( nzb_w_outer, nys, nyn, nxl, nxr, nbgp )
+       CALL exchange_horiz_2d_int( nzb_s_outer, nys, nyn, nxl, nxr, nbgp )
 
 !
 !--    Allocate and set the arrays containing the topography height
-       IF ( myid == 0 )  THEN
-
-          ALLOCATE( zu_s_inner(0:nx+1,0:ny+1), zw_w_inner(0:nx+1,0:ny+1) )
-
-          DO  i = 0, nx + 1
-             DO  j = 0, ny + 1
-                zu_s_inner(i,j) = zu(nzb_local(j,i))
-                zw_w_inner(i,j) = zw(nzb_local(j,i))
-             ENDDO
+       ALLOCATE( zu_s_inner(0:nx+1,0:ny+1), zw_w_inner(0:nx+1,0:ny+1),         &
+                 zu_s_inner_l(0:nx+1,0:ny+1), zw_w_inner_l(0:nx+1,0:ny+1) )
+                 
+       zu_s_inner   = 0.0_wp
+       zw_w_inner   = 0.0_wp
+       zu_s_inner_l = 0.0_wp
+       zw_w_inner_l = 0.0_wp
+       
+       DO  i = nxl, nxr
+          DO  j = nys, nyn
+             zu_s_inner_l(i,j) = zu(nzb_local(j,i))
+             zw_w_inner_l(i,j) = zw(nzb_local(j,i))
           ENDDO
-          
-       ENDIF
+       ENDDO
+       
+#if defined( __parallel )
+       CALL MPI_REDUCE( zu_s_inner_l, zu_s_inner, (nx+2)*(ny+2),         &
+                           MPI_REAL, MPI_SUM, 0, comm2d, ierr )       
+       CALL MPI_REDUCE( zw_w_inner_l, zw_w_inner, (nx+2)*(ny+2),         &
+                           MPI_REAL, MPI_SUM, 0, comm2d, ierr )  
+#else
+       zu_s_inner = zu_s_inner_l
+       zw_w_inner = zw_w_inner_l
+#endif
+
+      DEALLOCATE( zu_s_inner_l, zw_w_inner_l )
+      IF ( myid /= 0 )  DEALLOCATE( zu_s_inner, zw_w_inner )
+!
+!--   Set south and left ghost points, required for netcdf output
+      IF ( myid == 0 )  THEN
+         IF( bc_lr_cyc )  THEN
+            zu_s_inner(nx+1,:) = zu_s_inner(0,:)
+            zw_w_inner(nx+1,:) = zw_w_inner(0,:)
+         ELSE
+            zu_s_inner(nx+1,:) = zu_s_inner(nx,:)
+            zw_w_inner(nx+1,:) = zw_w_inner(nx,:)
+         ENDIF
+         IF( bc_ns_cyc )  THEN
+            zu_s_inner(:,ny+1) = zu_s_inner(:,0)
+            zw_w_inner(:,ny+1) = zw_w_inner(:,0)
+         ELSE
+            zu_s_inner(:,ny+1) = zu_s_inner(:,ny)
+            zw_w_inner(:,ny+1) = zw_w_inner(:,ny)
+         ENDIF
+      ENDIF
 !
 !--    Set flag arrays to be used for masking of grid points
@@ -1068,4 +1116,8 @@
 
     ENDIF
+!
+!-- Deallocate temporary array, as it might be reused for different
+!-- grid-levels further below.
+    DEALLOCATE( nzb_tmp )
 
 !
@@ -1190,5 +1242,4 @@
        ENDDO
     ENDDO
-
 !
 !-- Calculate wall flag arrays for the multigrid method.
@@ -1196,9 +1247,12 @@
 !-- version.
     IF ( psolver == 'multigrid_noopt' )  THEN
-!
-!--    Gridpoint increment of the current level
+
+!
+!--    Gridpoint increment of the current level. 
        inc = 1
-
        DO  l = maximum_grid_level, 1 , -1
+!
+!--       Set grid_level as it is required for exchange_horiz_2d_int
+          grid_level = l
 
           nxl_l = nxl_mg(l)
@@ -1207,5 +1261,4 @@
           nyn_l = nyn_mg(l)
           nzt_l = nzt_mg(l)
-
 !
 !--       Assign the flag level to be calculated
@@ -1251,12 +1304,52 @@
           IF ( .NOT. masking_method )  THEN
 
+!
+!--          Allocate temporary array for topography heights on coarser grid
+!--          level. Please note, 2 ghoist points are required, in order to
+!--          calculate flags() on the interior ghost point. 
+             ALLOCATE( nzb_tmp(nys_l-2:nyn_l+2,nxl_l-2:nxr_l+2) )
+             nzb_tmp = 0
+             
+             DO  i = nxl_l, nxr_l
+                DO  j = nys_l, nyn_l
+                   nzb_tmp(j,i) = nzb_local(j*inc,i*inc)
+                ENDDO
+             ENDDO
+!
+!--          Exchange ghost points on respective multigrid level. 2 ghost points
+!--          are required, in order to calculate flags on 
+!--          nys_l-1 / nyn_l+1 / nxl_l-1 / nxr_l+1. The alternative would be to 
+!--          exchange 3D-INTEGER array flags on the respective multigrid level.
+             CALL exchange_horiz_2d_int( nzb_tmp, nys_l, nyn_l, nxl_l, nxr_l, 2 )
+!
+!--          Set non-cyclic boundary conditions on respective multigrid level
+             IF ( .NOT. bc_ns_cyc )  THEN
+                IF ( nys == 0  )  THEN
+                   nzb_tmp(-2,:) = nzb_tmp(0,:)
+                   nzb_tmp(-1,:) = nzb_tmp(0,:)
+                ENDIF
+                IF ( nyn == ny )  THEN
+                   nzb_tmp(ny+2,:) = nzb_tmp(ny,:)
+                   nzb_tmp(ny+1,:) = nzb_tmp(ny,:)
+                ENDIF
+             ENDIF
+             IF ( .NOT. bc_lr_cyc )  THEN
+                IF ( nxl == 0  )  THEN
+                   nzb_tmp(:,-2) = nzb_tmp(:,0)
+                   nzb_tmp(:,-1) = nzb_tmp(:,0)
+                ENDIF
+                IF ( nxr == nx )  THEN
+                   nzb_tmp(:,nx+1) = nzb_tmp(:,nx)    
+                   nzb_tmp(:,nx+2) = nzb_tmp(:,nx)      
+                ENDIF        
+             ENDIF
+                       
              DO  i = nxl_l-1, nxr_l+1
                 DO  j = nys_l-1, nyn_l+1
-                   DO  k = nzb, nzt_l+1
-                         
+                   DO  k = nzb, nzt_l+1     
 !
 !--                   Inside/outside building (inside building does not need
 !--                   further tests for walls)
-                      IF ( k*inc <= nzb_local(j*inc,i*inc) )  THEN
+                      IF ( k*inc <= nzb_tmp(j,i) )  THEN
 
                          flags(k,j,i) = IBSET( flags(k,j,i), 6 )
@@ -1265,25 +1358,25 @@
 !
 !--                      Bottom wall
-                         IF ( (k-1)*inc <= nzb_local(j*inc,i*inc) )  THEN
+                         IF ( (k-1)*inc <= nzb_tmp(j,i) )  THEN
                             flags(k,j,i) = IBSET( flags(k,j,i), 0 )
                          ENDIF
 !
 !--                      South wall
-                         IF ( k*inc <= nzb_local((j-1)*inc,i*inc) )  THEN
+                         IF ( k*inc <= nzb_tmp(j-1,i) )  THEN
                             flags(k,j,i) = IBSET( flags(k,j,i), 2 )
                          ENDIF
 !
 !--                      North wall
-                         IF ( k*inc <= nzb_local((j+1)*inc,i*inc) )  THEN
+                         IF ( k*inc <= nzb_tmp(j+1,i) )  THEN
                             flags(k,j,i) = IBSET( flags(k,j,i), 3 )
                          ENDIF
 !
 !--                      Left wall
-                         IF ( k*inc <= nzb_local(j*inc,(i-1)*inc) )  THEN
+                         IF ( k*inc <= nzb_tmp(j,i-1) )  THEN
                             flags(k,j,i) = IBSET( flags(k,j,i), 4 )
                          ENDIF
 !
 !--                      Right wall
-                         IF ( k*inc <= nzb_local(j*inc,(i+1)*inc) )  THEN
+                         IF ( k*inc <= nzb_tmp(j,i+1) )  THEN
                             flags(k,j,i) = IBSET( flags(k,j,i), 5 )
                          ENDIF
@@ -1295,4 +1388,6 @@
              ENDDO
 
+             DEALLOCATE( nzb_tmp )
+
           ENDIF
 
@@ -1300,5 +1395,8 @@
 
        ENDDO
-
+!
+!--    Reset grid_level to "normal" grid
+       grid_level = 0
+       
     ENDIF
 !
@@ -1464,5 +1562,5 @@
 
     DEALLOCATE( corner_nl, corner_nr, corner_sl, corner_sr, nzb_local, &
-                nzb_tmp, vertical_influence, wall_l, wall_n, wall_r, wall_s )
+                vertical_influence, wall_l, wall_n, wall_r, wall_s )
 
 
Index: palm/trunk/SOURCE/init_pegrid.f90
===================================================================
--- palm/trunk/SOURCE/init_pegrid.f90	(revision 1967)
+++ palm/trunk/SOURCE/init_pegrid.f90	(revision 1968)
@@ -19,5 +19,6 @@
 ! Current revisions:
 ! ------------------
-! 
+! Extent MPI-datatypes for exchange of 2D-INTEGER arrays on coarser multigrid
+! level  
 ! 
 ! Former revisions:
@@ -27,5 +28,5 @@
 ! 1964 2016-07-14 15:35:18Z hellstea
 ! Bugfix: erroneous setting of nest_bound_l/r/s/n = .TRUE. for vertical nesting mode removed.
-! 
+!
 ! 1923 2016-05-31 16:37:07Z boeske
 ! Initial version of purely vertical nesting introduced. 
@@ -1011,17 +1012,22 @@
 !-- Define new MPI derived datatypes for the exchange of ghost points in
 !-- x- and y-direction for 2D-arrays (line)
-    CALL MPI_TYPE_VECTOR( nxr-nxl+1+2*nbgp, nbgp, ngp_y, MPI_REAL, type_x, &
+    CALL MPI_TYPE_VECTOR( nxr-nxl+1+2*nbgp, nbgp, ngp_y, MPI_REAL, type_x,     &
                           ierr )
     CALL MPI_TYPE_COMMIT( type_x, ierr )
-    CALL MPI_TYPE_VECTOR( nxr-nxl+1+2*nbgp, nbgp, ngp_y, MPI_INTEGER, &
-                          type_x_int, ierr )
-    CALL MPI_TYPE_COMMIT( type_x_int, ierr )
 
     CALL MPI_TYPE_VECTOR( nbgp, ngp_y, ngp_y, MPI_REAL, type_y, ierr )
     CALL MPI_TYPE_COMMIT( type_y, ierr )
-    CALL MPI_TYPE_VECTOR( nbgp, ngp_y, ngp_y, MPI_INTEGER, type_y_int, ierr )
-    CALL MPI_TYPE_COMMIT( type_y_int, ierr )
-
-
+!
+!-- Define new MPI derived datatypes for the exchange of ghost points in
+!-- x- and y-direction for 2D-INTEGER arrays (line) - on normal grid
+    ALLOCATE( type_x_int(0:maximum_grid_level),                                &
+              type_y_int(0:maximum_grid_level) )
+
+    CALL MPI_TYPE_VECTOR( nxr-nxl+1+2*nbgp, nbgp, ngp_y, MPI_INTEGER,          &
+                          type_x_int(0), ierr )
+    CALL MPI_TYPE_COMMIT( type_x_int(0), ierr )
+
+    CALL MPI_TYPE_VECTOR( nbgp, ngp_y, ngp_y, MPI_INTEGER, type_y_int(0), ierr )
+    CALL MPI_TYPE_COMMIT( type_y_int(0), ierr )
 !
 !-- Calculate gridpoint numbers for the exchange of ghost points along x
@@ -1064,5 +1070,6 @@
 !--    Definition of MPI-datatyoe as above, but only 1 ghost level is used
        DO  i = maximum_grid_level, 1 , -1
-
+!
+!--       For 3D-exchange
           ngp_xz(i) = (nzt_l - nzb_l + 2) * (nxr_l - nxl_l + 3)
           ngp_yz(i) = (nzt_l - nzb_l + 2) * (nyn_l - nys_l + 3)
@@ -1075,4 +1082,18 @@
                                 ierr )
           CALL MPI_TYPE_COMMIT( type_yz(i), ierr )
+
+
+!--       For 2D-exchange of INTEGER arrays on coarser grid level, where 2 ghost
+!--       points need to be exchanged.
+          CALL MPI_TYPE_VECTOR( nxr_l-nxl_l+5, 2, nyn_l-nys_l+5, MPI_INTEGER,          &
+                                type_x_int(i), ierr )
+          CALL MPI_TYPE_COMMIT( type_x_int(i), ierr )
+
+
+          CALL MPI_TYPE_VECTOR( 2, nyn_l-nys_l+5, nyn_l-nys_l+5, MPI_INTEGER,          &
+                                type_y_int(i), ierr )
+          CALL MPI_TYPE_COMMIT( type_y_int(i), ierr )
+
+
 
           nxl_l = nxl_l / 2
@@ -1141,4 +1162,5 @@
        ENDIF
     ENDIF
+
        
 !
Index: palm/trunk/SOURCE/modules.f90
===================================================================
--- palm/trunk/SOURCE/modules.f90	(revision 1967)
+++ palm/trunk/SOURCE/modules.f90	(revision 1968)
@@ -19,5 +19,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! Changed dimension for MPI-datatypes type_x_int and type_y_int
 ! 
 ! Former revisions:
@@ -34,5 +34,5 @@
 ! -gamma_x, gamma_y, gamma_z, var_x, var_y, var_z
 !
-! Change default values (in order to unify gradient calculation): 
+! Change initial values (in order to unify gradient calculation): 
 ! pt_vertical_gradient_level, sa_vertical_gradient_level
 !
@@ -1156,6 +1156,6 @@
                               sendrecvcount_zx, sendrecvcount_zyd,                  &
                               sendrecvcount_yxd, target_id, tasks_per_node = -9999, &
-                              threads_per_task = 1, type_x, type_x_int, type_xy,    &
-                              type_y, type_y_int
+                              threads_per_task = 1, type_x, type_xy,    &
+                              type_y
 
     INTEGER(iwp)          ::  pdims(2) = 1, req(100)
@@ -1177,5 +1177,6 @@
 
     INTEGER(iwp) :: ngp_yz_int, type_xz_int, type_yz_int
-    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  ngp_xz, ngp_yz, type_xz, type_yz
+    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  ngp_xz, ngp_yz, type_x_int,    &
+                                                type_xz, type_y_int, type_yz
 
     LOGICAL ::  left_border_pe  = .FALSE., north_border_pe = .FALSE., &
Index: palm/trunk/SOURCE/user_init_grid.f90
===================================================================
--- palm/trunk/SOURCE/user_init_grid.f90	(revision 1967)
+++ palm/trunk/SOURCE/user_init_grid.f90	(revision 1968)
@@ -19,5 +19,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Change dimensions for nzb_local, which do not longer need to be set on 
+! multigrid ghost points. 
 ! 
 ! Former revisions:
@@ -46,8 +47,6 @@
 ! ------------
 !> Execution of user-defined grid initializing actions
-!> First argument gls contains the number of ghost layers, which is > 1 if the
-!> multigrid method for the pressure solver is used
 !------------------------------------------------------------------------------!
- SUBROUTINE user_init_grid( gls, nzb_local )
+ SUBROUTINE user_init_grid( nzb_local )
  
 
@@ -62,9 +61,5 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  gls   !< 
-
-    INTEGER(iwp),                                                              &
-       DIMENSION(-gls:ny+gls,-gls:nx+gls) ::                                   &
-          nzb_local   !< 
+    INTEGER(iwp), DIMENSION(nysg:nyng,nxlg:nxrg) ::  nzb_local   !< 
 
 !
