Index: palm/trunk/SOURCE/exchange_horiz.f90
===================================================================
--- palm/trunk/SOURCE/exchange_horiz.f90	(revision 2298)
+++ palm/trunk/SOURCE/exchange_horiz.f90	(revision 2696)
@@ -1,5 +1,5 @@
 !> @file exchange_horiz.f90
 !------------------------------------------------------------------------------!
-! This file is part of PALM.
+! This file is part of the PALM model system.
 !
 ! PALM is free software: you can redistribute it and/or modify it under the
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! 3D-Integer exchange on multigrid level (MS)
+! 
+! 2298 2017-06-29 09:28:18Z raasch
 ! sendrecv_in_background related parts removed
 ! 
@@ -266,8 +269,8 @@
 !> @todo Missing subroutine description.
 !------------------------------------------------------------------------------!
- SUBROUTINE exchange_horiz_int( ar, nbgp_local)
+ SUBROUTINE exchange_horiz_int( ar, nys_l, nyn_l, nxl_l, nxr_l, nzt_l, nbgp_local)
 
     USE control_parameters,                                                    &
-        ONLY:  bc_lr, bc_lr_cyc, bc_ns, bc_ns_cyc
+        ONLY:  bc_lr, bc_lr_cyc, bc_ns, bc_ns_cyc, grid_level
                        
     USE indices,                                                               &
@@ -280,9 +283,13 @@
     IMPLICIT NONE
 
-
+    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) ::  nzt_l       !< local index bound at current grid level, top
     INTEGER(iwp) ::  nbgp_local  !< number of ghost points
     
-    INTEGER(iwp), DIMENSION(nzb:nzt+1,nys-nbgp_local:nyn+nbgp_local,           &
-                        nxl-nbgp_local:nxr+nbgp_local) ::  ar  !< treated array
+    INTEGER(iwp), DIMENSION(nzb:nzt_l+1,nys_l-nbgp_local:nyn_l+nbgp_local,     &
+                            nxl_l-nbgp_local:nxr_l+nbgp_local) ::  ar  !< treated array
 
 
@@ -293,19 +300,21 @@
 !--    within the PE memory
        IF ( bc_lr_cyc )  THEN
-          ar(:,:,nxl-nbgp_local:nxl-1) = ar(:,:,nxr-nbgp_local+1:nxr)
-          ar(:,:,nxr+1:nxr+nbgp_local) = ar(:,:,nxl:nxl+nbgp_local-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
     ELSE
 !
 !--    Send left boundary, receive right one (synchronous)
-       CALL MPI_SENDRECV(                                                      &
-           ar(nzb,nys-nbgp_local,nxl),   1, type_yz_int, pleft,  0,            &
-           ar(nzb,nys-nbgp_local,nxr+1), 1, type_yz_int, pright, 0,            &
+       CALL MPI_SENDRECV(                                                          &
+           ar(nzb,nys_l-nbgp_local,nxl_l),   1, type_yz_int(grid_level), pleft,  0,&
+           ar(nzb,nys_l-nbgp_local,nxr_l+1), 1, type_yz_int(grid_level), pright, 0,&
            comm2d, status, ierr )
 !
 !--    Send right boundary, receive left one (synchronous)
-       CALL MPI_SENDRECV(                                                      &
-           ar(nzb,nys-nbgp_local,nxr+1-nbgp_local), 1, type_yz_int, pright, 1, &
-           ar(nzb,nys-nbgp_local,nxl-nbgp_local),   1, type_yz_int, pleft,  1, &
+       CALL MPI_SENDRECV(                                                          &
+           ar(nzb,nys_l-nbgp_local,nxr_l+1-nbgp_local), 1, type_yz_int(grid_level),&
+           pright, 1,                                                              &
+           ar(nzb,nys_l-nbgp_local,nxl_l-nbgp_local),   1, type_yz_int(grid_level),&
+           pleft,  1,                                                              &
            comm2d, status, ierr )
     ENDIF
@@ -317,6 +326,6 @@
 !--    within the PE memory
        IF ( bc_ns_cyc )  THEN
-          ar(:,nys-nbgp_local:nys-1,:) = ar(:,nyn-nbgp_local+1:nyn,:)
-          ar(:,nyn+1:nyn+nbgp_local,:) = ar(:,nys:nys+nbgp_local-1,:)
+          ar(:,nys_l-nbgp_local:nys_l-1,:) = ar(:,nyn_l-nbgp_local+1:nyn_l,:)
+          ar(:,nyn_l+1:nyn_l+nbgp_local,:) = ar(:,nys_l:nys_l+nbgp_local-1,:)
        ENDIF
 
@@ -325,14 +334,14 @@
 !
 !--    Send front boundary, receive rear one (synchronous)
-       CALL MPI_SENDRECV(                                                      &
-           ar(nzb,nys,nxl-nbgp_local),   1, type_xz_int, psouth, 0,            &
-           ar(nzb,nyn+1,nxl-nbgp_local), 1, type_xz_int, pnorth, 0,            &
+       CALL MPI_SENDRECV(                                                          &
+           ar(nzb,nys_l,nxl_l-nbgp_local),   1, type_xz_int(grid_level), psouth, 0,&
+           ar(nzb,nyn_l+1,nxl_l-nbgp_local), 1, type_xz_int(grid_level), pnorth, 0,&
            comm2d, status, ierr )
 !
 !--    Send rear boundary, receive front one (synchronous)
-       CALL MPI_SENDRECV( ar(nzb,nyn-nbgp_local+1,nxl-nbgp_local), 1,          &
-                          type_xz_int, pnorth, 1,                              &
-                          ar(nzb,nys-nbgp_local,nxl-nbgp_local),   1,          &
-                          type_xz_int, psouth, 1,                              &
+       CALL MPI_SENDRECV( ar(nzb,nyn_l-nbgp_local+1,nxl_l-nbgp_local), 1,          &
+                          type_xz_int(grid_level), pnorth, 1,                      &
+                          ar(nzb,nys_l-nbgp_local,nxl_l-nbgp_local),   1,          &
+                          type_xz_int(grid_level), psouth, 1,                      &
                           comm2d, status, ierr )
 
@@ -342,11 +351,11 @@
 
     IF ( bc_lr == 'cyclic' )  THEN
-       ar(:,:,nxl-nbgp_local:nxl-1) = ar(:,:,nxr-nbgp_local+1:nxr)
-       ar(:,:,nxr+1:nxr+nbgp_local) = ar(:,:,nxl:nxl+nbgp_local-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 == 'cyclic' )  THEN
-       ar(:,nys-nbgp_local:nys-1,:) = ar(:,nyn-nbgp_local+1:nyn,:)
-       ar(:,nyn+1:nyn+nbgp_local,:) = ar(:,nys:nys+nbgp_local-1,:)
+       ar(:,nys_l-nbgp_local:nys_l-1,:) = ar(:,nyn_l-nbgp_local+1:nyn_l,:)
+       ar(:,nyn_l+1:nyn_l+nbgp_local,:) = ar(:,nys_l:nys_l+nbgp_local-1,:)
     ENDIF
 
