Index: palm/trunk/SOURCE/init_pegrid.f90
===================================================================
--- palm/trunk/SOURCE/init_pegrid.f90	(revision 2600)
+++ palm/trunk/SOURCE/init_pegrid.f90	(revision 2696)
@@ -1,5 +1,5 @@
 !> @file init_pegrid.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,8 @@
 ! -----------------
 ! $Id$
+! 3D-Integer exchange on multigrid level (MS)
+! Forcing implemented (MS)
+! 
+! 2600 2017-11-01 14:11:20Z raasch
 ! calculation of block-I/O quantitites removed (is now done in parin)
 ! 
@@ -204,4 +208,6 @@
 !> user)and computation of the grid point number and array bounds of the local
 !> domains.
+!> @todo: remove MPI-data types for 2D exchange on coarse multigrid level (not
+!>        used any more) 
 !------------------------------------------------------------------------------!
  SUBROUTINE init_pegrid
@@ -210,5 +216,6 @@
     USE control_parameters,                                                    &
         ONLY:  bc_lr, bc_ns, coupling_mode, coupling_mode_remote,              &
-               coupling_topology, gathered_size, grid_level,                   &
+               coupling_topology, force_bound_l, force_bound_n, force_bound_r, &
+               force_bound_s, gathered_size, grid_level,                       &
                grid_level_count, inflow_l, inflow_n, inflow_r, inflow_s,       &
                maximum_grid_level, message_string,                             &
@@ -352,5 +359,4 @@
     CALL MPI_CART_SHIFT( comm2d, 0, 1, pleft, pright, ierr )
     CALL MPI_CART_SHIFT( comm2d, 1, 1, psouth, pnorth, ierr )
-
 !
 !-- In case of cyclic boundary conditions, a y-shift at the boundaries in
@@ -405,5 +411,4 @@
        ENDIF
     ENDIF
-
 !
 !-- Vertical nesting: store four lists that identify partner ranks to exchange 
@@ -700,5 +705,4 @@
 #endif
 
-
 ! 
 !-- Determine the number of ghost point layers
@@ -823,5 +827,4 @@
 !-- Create custom MPI vector datatypes for contiguous data transfer
     IF ( vnested )  CALL vnest_init_pegrid_domain
-
 
 #else
@@ -1096,6 +1099,12 @@
 !-- Do these calculations for the model grid and (if necessary) also
 !-- for the coarser grid levels used in the multigrid method
-    ALLOCATE ( ngp_xz(0:maximum_grid_level), ngp_yz(0:maximum_grid_level),     &
-               type_xz(0:maximum_grid_level), type_yz(0:maximum_grid_level) )
+    ALLOCATE ( ngp_xz(0:maximum_grid_level),                                   &
+               ngp_xz_int(0:maximum_grid_level),                               &
+               ngp_yz(0:maximum_grid_level),                                   &
+               ngp_yz_int(0:maximum_grid_level),                               &
+               type_xz(0:maximum_grid_level),                                  &
+               type_xz_int(0:maximum_grid_level),                              &
+               type_yz(0:maximum_grid_level),                                  &
+               type_yz_int(0:maximum_grid_level) )
 
     nxl_l = nxl; nxr_l = nxr; nys_l = nys; nyn_l = nyn; nzb_l = nzb; nzt_l = nzt
@@ -1125,4 +1134,16 @@
 
 !
+!-- Define data types for exchange of 3D Integer arrays.
+    ngp_yz_int(0) = (nzt - nzb + 2) * (nyn - nys + 1 + 2 * nbgp)
+
+    CALL MPI_TYPE_VECTOR( nxr-nxl+1+2*nbgp, nbgp*(nzt-nzb+2), ngp_yz_int(0),   &
+                          MPI_INTEGER, type_xz_int(0), ierr )
+    CALL MPI_TYPE_COMMIT( type_xz_int(0), ierr )
+
+    CALL MPI_TYPE_VECTOR( nbgp, ngp_yz_int(0), ngp_yz_int(0), MPI_INTEGER,     &
+                          type_yz_int(0), ierr )
+    CALL MPI_TYPE_COMMIT( type_yz_int(0), ierr )
+
+!
 !-- Definition of MPI-datatypes for multigrid method (coarser level grids)
     IF ( psolver(1:9) == 'multigrid' )  THEN
@@ -1131,15 +1152,33 @@
        DO  i = maximum_grid_level, 1 , -1
 !
-!--       For 3D-exchange
+!--       For 3D-exchange on different multigrid level, one ghost point for 
+!--       REAL arrays, two ghost points for INTEGER arrays
           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)
 
-          CALL MPI_TYPE_VECTOR( nxr_l-nxl_l+3, nzt_l-nzb_l+2, ngp_yz(i), &
+          ngp_xz_int(i) = (nzt_l - nzb_l + 2) * (nxr_l - nxl_l + 3)
+          ngp_yz_int(i) = (nzt_l - nzb_l + 2) * (nyn_l - nys_l + 3)
+!
+!--       MPI data type for REAL arrays, for xz-layers
+          CALL MPI_TYPE_VECTOR( nxr_l-nxl_l+3, nzt_l-nzb_l+2, ngp_yz(i),       &
                                 MPI_REAL, type_xz(i), ierr )
           CALL MPI_TYPE_COMMIT( type_xz(i), ierr )
 
+!
+!--       MPI data type for INTEGER arrays, for xz-layers
+          CALL MPI_TYPE_VECTOR( nxr_l-nxl_l+3, nzt_l-nzb_l+2, ngp_yz_int(i),   &
+                                MPI_INTEGER, type_xz_int(i), ierr )
+          CALL MPI_TYPE_COMMIT( type_xz_int(i), ierr )
+
+!
+!--       MPI data type for REAL arrays, for yz-layers
           CALL MPI_TYPE_VECTOR( 1, ngp_yz(i), ngp_yz(i), MPI_REAL, type_yz(i), &
                                 ierr )
           CALL MPI_TYPE_COMMIT( type_yz(i), ierr )
+!
+!--       MPI data type for INTEGER arrays, for yz-layers
+          CALL MPI_TYPE_VECTOR( 1, ngp_yz_int(i), ngp_yz_int(i), MPI_INTEGER,  &
+                                type_yz_int(i), ierr )
+          CALL MPI_TYPE_COMMIT( type_yz_int(i), ierr )
 
 
@@ -1155,6 +1194,4 @@
           CALL MPI_TYPE_COMMIT( type_y_int(i), ierr )
 
-
-
           nxl_l = nxl_l / 2
           nxr_l = nxr_l / 2
@@ -1166,15 +1203,4 @@
 
     ENDIF
-!
-!-- Define data types for exchange of 3D Integer arrays.
-    ngp_yz_int = (nzt - nzb + 2) * (nyn - nys + 1 + 2 * nbgp)
-
-    CALL MPI_TYPE_VECTOR( nxr-nxl+1+2*nbgp, nbgp*(nzt-nzb+2), ngp_yz_int, &
-                          MPI_INTEGER, type_xz_int, ierr )
-    CALL MPI_TYPE_COMMIT( type_xz_int, ierr )
-
-    CALL MPI_TYPE_VECTOR( nbgp, ngp_yz_int, ngp_yz_int, MPI_INTEGER, type_yz_int, &
-                          ierr )
-    CALL MPI_TYPE_COMMIT( type_yz_int, ierr )
 
 #endif
@@ -1190,4 +1216,6 @@
        ELSEIF ( bc_lr == 'nested' )  THEN
           nest_bound_l = .TRUE.
+       ELSEIF ( bc_lr == 'forcing' )  THEN
+          force_bound_l = .TRUE.
        ENDIF
     ENDIF
@@ -1200,4 +1228,6 @@
        ELSEIF ( bc_lr == 'nested' )  THEN
           nest_bound_r = .TRUE.
+       ELSEIF ( bc_lr == 'forcing' )  THEN
+          force_bound_r = .TRUE.
        ENDIF
     ENDIF
@@ -1210,4 +1240,6 @@
        ELSEIF ( bc_ns == 'nested' )  THEN
           nest_bound_s = .TRUE.
+       ELSEIF ( bc_ns == 'forcing' )  THEN
+          force_bound_s = .TRUE.
        ENDIF
     ENDIF
@@ -1220,4 +1252,6 @@
        ELSEIF ( bc_ns == 'nested' )  THEN
           nest_bound_n = .TRUE.
+       ELSEIF ( bc_ns == 'forcing' )  THEN
+          force_bound_n = .TRUE.
        ENDIF
     ENDIF
@@ -1295,10 +1329,10 @@
 !-- At the inflow or outflow, u or v, respectively, have to be calculated for
 !-- one more grid point.
-    IF ( inflow_l .OR. outflow_l .OR. nest_bound_l )  THEN
+    IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  THEN
        nxlu = nxl + 1
     ELSE
        nxlu = nxl
     ENDIF
-    IF ( inflow_s .OR. outflow_s .OR. nest_bound_s )  THEN
+    IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  THEN
        nysv = nys + 1
     ELSE
