Index: /palm/trunk/SOURCE/pmc_handle_communicator_mod.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_handle_communicator_mod.f90	(revision 3887)
+++ /palm/trunk/SOURCE/pmc_handle_communicator_mod.f90	(revision 3888)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Missing MPI_BCAST of anterpolation_buffer_width added.
+! 
+! 3885 2019-04-11 11:29:34Z kanani
 ! Changes related to global restructuring of location messages and introduction 
 ! of additional debug messages
@@ -308,4 +311,6 @@
     CALL MPI_BCAST( nesting_datatransfer_mode, LEN(nesting_datatransfer_mode),  &
                     MPI_CHARACTER, 0, MPI_COMM_WORLD, istat )
+    CALL MPI_BCAST( anterpolation_buffer_width, 1, MPI_INT, 0, MPI_COMM_WORLD,  &
+                    istat )
 !
 !-- Assign global MPI processes to individual models by setting the couple id
Index: /palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 3887)
+++ /palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 3888)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Variables renamed, commenting improved etc.
+! 
+! 3885 2019-04-11 11:29:34Z kanani
 ! Changes related to global restructuring of location messages and introduction 
 ! of additional debug messages
@@ -1114,6 +1117,6 @@
        CALL MPI_BCAST( childgrid(m), STORAGE_SIZE(childgrid(1))/8, MPI_BYTE, 0, comm2d, ierr )
 !
-!--    TO_DO: Klaus: please give a comment what is done here
-!  DO IT YOURSELF       
+!--    Set up the index-list which is an integer array that maps the child index space on 
+!--    the parent index- and subdomain spaces.
        CALL pmci_create_index_list
 !
@@ -1166,84 +1169,82 @@
        IMPLICIT NONE
 
-       INTEGER(iwp) ::  i                  !<
-       INTEGER(iwp) ::  ic                 !<
-       INTEGER(iwp) ::  ierr               !<
-       INTEGER(iwp) ::  j                  !<
-       INTEGER(iwp) ::  k                  !<
-       INTEGER(iwp) ::  npx                !<
-       INTEGER(iwp) ::  npy                !<
-       INTEGER(iwp) ::  nrx                !<
-       INTEGER(iwp) ::  nry                !<
-       INTEGER(iwp) ::  px                 !<
-       INTEGER(iwp) ::  py                 !<
-       INTEGER(iwp) ::  parent_pe          !<
-
-       INTEGER(iwp), DIMENSION(2) ::  scoord             !<
-       INTEGER(iwp), DIMENSION(2) ::  size_of_array      !<
-
-       INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE  ::  coarse_bound_all   !<
-       INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE  ::  index_list         !<
-
+       INTEGER(iwp) ::  ilist              !< Index-list index running over the child's parent-grid jc,ic-space
+       INTEGER(iwp) ::  index_list_size    !< Dimension 2 of the array index_list
+       INTEGER(iwp) ::  ierr               !< MPI error code
+       INTEGER(iwp) ::  ip                 !< Running parent-grid index on the child domain in the x-direction 
+       INTEGER(iwp) ::  jp                 !< Running parent-grid index on the child domain in the y-direction
+       INTEGER(iwp) ::  n                  !< Running index over child subdomains
+       INTEGER(iwp) ::  nrx                !< Parent subdomain dimension in the x-direction
+       INTEGER(iwp) ::  nry                !< Parent subdomain dimension in the y-direction
+       INTEGER(iwp) ::  pex                !< Two-dimensional subdomain (pe) index in the x-direction
+       INTEGER(iwp) ::  pey                !< Two-dimensional subdomain (pe) index in the y-direction
+       INTEGER(iwp) ::  parent_pe          !< Parent subdomain index (one-dimensional)
+
+       INTEGER(iwp), DIMENSION(2) ::  pe_indices_2d                                  !< Array for two-dimensional subdomain (pe)
+                                                                                     !< indices needed for MPI_CART_RANK
+       INTEGER(iwp), DIMENSION(2) ::  size_of_childs_parent_grid_bounds_all          !< Dimensions of childs_parent_grid_bounds_all
+       INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE  ::  childs_parent_grid_bounds_all  !< Array that contains the child's
+                                                                                     !< parent-grid index bounds for all its
+                                                                                     !< subdomains (pes)
+       INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE  ::  index_list                     !< Array that maps the child index space on 
+                                                                                     !< the parent index- and subdomain spaces
        
        IF ( myid == 0 )  THEN
-!          
-!--       TO_DO: Klaus: give more specific comment what size_of_array stands for
-          CALL pmc_recv_from_child( child_id, size_of_array, 2, 0, 40, ierr )
-          ALLOCATE( coarse_bound_all(size_of_array(1),size_of_array(2)) )
-          CALL pmc_recv_from_child( child_id, coarse_bound_all,                &
-                                    SIZE( coarse_bound_all ), 0, 41, ierr )
-!
-!--       Compute size of index_list.
-          ic = 0         
-          DO  k = 1, size_of_array(2)           ! Replace k by some other letter
-             ic = ic + ( coarse_bound_all(4,k) - coarse_bound_all(3,k) + 1 ) * &
-                       ( coarse_bound_all(2,k) - coarse_bound_all(1,k) + 1 )
+          
+          CALL pmc_recv_from_child( child_id, size_of_childs_parent_grid_bounds_all,                &
+                                    2, 0, 40, ierr )
+          ALLOCATE( childs_parent_grid_bounds_all(size_of_childs_parent_grid_bounds_all(1),         &
+                                                  size_of_childs_parent_grid_bounds_all(2)) )
+          CALL pmc_recv_from_child( child_id, childs_parent_grid_bounds_all,                        &
+                                    SIZE( childs_parent_grid_bounds_all ), 0, 41, ierr )
+!
+!--       Compute size (dimension) of the index_list.
+          index_list_size = 0         
+          DO  n = 1, size_of_childs_parent_grid_bounds_all(2)
+             index_list_size = index_list_size +                                                    &
+                  ( childs_parent_grid_bounds_all(4,n) - childs_parent_grid_bounds_all(3,n) + 1 ) * &
+                  ( childs_parent_grid_bounds_all(2,n) - childs_parent_grid_bounds_all(1,n) + 1 )
           ENDDO
 
-          ALLOCATE( index_list(6,ic) )
-
-          CALL MPI_COMM_SIZE( comm1dx, npx, ierr )
-          CALL MPI_COMM_SIZE( comm1dy, npy, ierr )
-!
-!--       Nrx is the same for all PEs and so is nry, thus there is no need to compute
-!--       them separately for each PE.
+          ALLOCATE( index_list(6,index_list_size) )
+
           nrx = nxr - nxl + 1
           nry = nyn - nys + 1
-          ic  = 0
+          ilist = 0
 !
 !--       Loop over all children PEs
-          DO  k = 1, size_of_array(2)           ! Replace k by some other letter
-!
-!--          Area along y required by actual child PE
-             DO  j = coarse_bound_all(3,k), coarse_bound_all(4,k)  !: j = jps, jpn of PE# k 
-!
-!--             Area along x required by actual child PE
-                DO  i = coarse_bound_all(1,k), coarse_bound_all(2,k)  !: i = ipl, ipr of PE# k 
-
-                   px = i / nrx
-                   py = j / nry
-                   scoord(1) = px
-                   scoord(2) = py
-                   CALL MPI_CART_RANK( comm2d, scoord, parent_pe, ierr )
+          DO  n = 1, size_of_childs_parent_grid_bounds_all(2)           ! 
+!
+!--          Subspace along y required by actual child PE
+             DO  jp = childs_parent_grid_bounds_all(3,n), childs_parent_grid_bounds_all(4,n)  ! jp = jps, jpn of child PE# n 
+!
+!--             Subspace along x required by actual child PE
+                DO  ip = childs_parent_grid_bounds_all(1,n), childs_parent_grid_bounds_all(2,n)  ! ip = ipl, ipr of child PE# n 
+
+                   pex = ip / nrx
+                   pey = jp / nry
+                   pe_indices_2d(1) = pex
+                   pe_indices_2d(2) = pey
+                   CALL MPI_CART_RANK( comm2d, pe_indices_2d, parent_pe, ierr )
                   
-                   ic = ic + 1
-!
-!--                First index in parent array
-                   index_list(1,ic) = i - ( px * nrx ) + 1 + nbgp
-!
-!--                Second index in parent array
-                   index_list(2,ic) = j - ( py * nry ) + 1 + nbgp
-!
-!--                x index of child coarse grid
-                   index_list(3,ic) = i - coarse_bound_all(1,k) + 1
-!
-!--                y index of child coarse grid
-                   index_list(4,ic) = j - coarse_bound_all(3,k) + 1
+                   ilist = ilist + 1
+!
+!--                First index in parent array   ! TO_DO: IMPROVE THIS COMMENT
+                   index_list(1,ilist) = ip - ( pex * nrx ) + 1 + nbgp
+!
+!--                Second index in parent array   ! TO_DO: IMPROVE THIS COMMENT
+                   index_list(2,ilist) = jp - ( pey * nry ) + 1 + nbgp
+!
+!--                x index of child's parent grid
+                   index_list(3,ilist) = ip - childs_parent_grid_bounds_all(1,n) + 1
+!
+!--                y index of child's parent grid
+                   index_list(4,ilist) = jp - childs_parent_grid_bounds_all(3,n) + 1
 !
 !--                PE number of child
-                   index_list(5,ic) = k - 1
+                   index_list(5,ilist) = n - 1
 !
 !--                PE number of parent
-                   index_list(6,ic) = parent_pe
+                   index_list(6,ilist) = parent_pe
 
                 ENDDO
@@ -1252,5 +1253,5 @@
 !
 !--       TO_DO: Klaus: comment what is done here
-          CALL pmc_s_set_2d_index_list( child_id, index_list(:,1:ic) )
+          CALL pmc_s_set_2d_index_list( child_id, index_list(:,1:ilist) )
 
        ELSE
