Index: /palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 3983)
+++ /palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 3984)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Commenting improved, pmci_map_fine_to_coarse_grid renamed as pmci_map_child_grid_to_parent_grid,
+! set_child_edge_coords renamed as pmci_set_child_edge_coords, some variables renamed, etc. 
+! 
+! 3979 2019-05-15 13:54:29Z hellstea
 ! Bugfix in pmc_interp_1sto_sn. This bug had effect only in case of 1-d domain
 ! decomposition with npex = 1. 
@@ -524,12 +528,12 @@
 !
 !-- Constants
-    INTEGER(iwp), PARAMETER ::  child_to_parent = 2   !<
-    INTEGER(iwp), PARAMETER ::  parent_to_child = 1   !<
+    INTEGER(iwp), PARAMETER ::  child_to_parent = 2   !< Parameter for pmci_parent_datatrans indicating the direction of transfer
+    INTEGER(iwp), PARAMETER ::  parent_to_child = 1   !< Parameter for pmci_parent_datatrans indicating the direction of transfer
     INTEGER(iwp), PARAMETER ::  interpolation_scheme_lrsn  = 2  !< Interpolation scheme to be used on lateral boundaries
     INTEGER(iwp), PARAMETER ::  interpolation_scheme_t     = 3  !< Interpolation scheme to be used on top boundary
 !
 !-- Coupler setup
-    INTEGER(iwp), SAVE      ::  comm_world_nesting    !<
-    INTEGER(iwp), SAVE      ::  cpl_id  = 1           !<
+    INTEGER(iwp), SAVE      ::  comm_world_nesting    !< Global nesting communicator
+    INTEGER(iwp), SAVE      ::  cpl_id  = 1           !< 
     INTEGER(iwp), SAVE      ::  cpl_npe_total         !<
     INTEGER(iwp), SAVE      ::  cpl_parent_id         !<
@@ -547,8 +551,8 @@
 !
 !-- Geometry
-    REAL(wp), SAVE, DIMENSION(:), ALLOCATABLE, PUBLIC ::  coord_x            !<
-    REAL(wp), SAVE, DIMENSION(:), ALLOCATABLE, PUBLIC ::  coord_y            !<
-    REAL(wp), SAVE, PUBLIC                            ::  lower_left_coord_x !<
-    REAL(wp), SAVE, PUBLIC                            ::  lower_left_coord_y !<
+    REAL(wp), SAVE, DIMENSION(:), ALLOCATABLE, PUBLIC ::  coord_x            !< Array for the absolute x-coordinates
+    REAL(wp), SAVE, DIMENSION(:), ALLOCATABLE, PUBLIC ::  coord_y            !< Array for the absolute y-coordinates
+    REAL(wp), SAVE, PUBLIC                            ::  lower_left_coord_x !< x-coordinate of the lower left corner of the domain 
+    REAL(wp), SAVE, PUBLIC                            ::  lower_left_coord_y !< y-coordinate of the lower left corner of the domain 
 !
 !-- Children's parent-grid arrays
@@ -644,5 +648,4 @@
 
     REAL(wp), DIMENSION(7)              ::  parent_grid_info_real   !<
-    REAL(wp), DIMENSION(2)              ::  zmax_coarse             !<
 
     TYPE parentgrid_def
@@ -865,5 +868,5 @@
 !
 !-- Initialize the child (must be called before pmc_setup_parent)
-!  EXTEND THIS COMMENT EXPLAINEIN WHY IT MUST BE CALLED BEFORE    
+!-- Klaus, extend this comment to explain why it must be called before    
     CALL pmci_setup_child               ! CONTAIN THIS
 !
@@ -999,5 +1002,4 @@
              ENDIF
           ENDDO
-          zmax_coarse  = child_grid_info(1:2)
 !    
 !--       Get absolute coordinates from the child
@@ -1101,5 +1103,5 @@
           ENDIF          
 
-          CALL set_child_edge_coords
+          CALL pmci_set_child_edge_coords
 
           DEALLOCATE( child_coord_x )
@@ -1110,5 +1112,5 @@
           CALL pmc_send_to_child( child_id, rans_mode, 1, 0, 19, ierr )  
 !
-!--       Send coarse grid information to child
+!--       Send parent grid information to child
           CALL pmc_send_to_child( child_id, parent_grid_info_real,                                  &
                                   SIZE( parent_grid_info_real ), 0, 21,                             &
@@ -1290,8 +1292,8 @@
 
 
-     SUBROUTINE set_child_edge_coords
+     SUBROUTINE pmci_set_child_edge_coords
         IMPLICIT  NONE
 
-        INTEGER(iwp) ::  nbgp_lpm = 1  !<
+        INTEGER(iwp) ::  nbgp_lpm = 1  !< Number of ghost-point layers used for lpm (Klaus, is this correct?)
 
         
@@ -1313,8 +1315,8 @@
         childgrid(m)%ny_coord   = child_coord_y(ny_child) + dy_child
         childgrid(m)%ny_coord_b = child_coord_y(ny_child+nbgp_lpm) + dy_child
-        childgrid(m)%uz_coord   = zmax_coarse(2)
-        childgrid(m)%uz_coord_b = zmax_coarse(1)
-
-     END SUBROUTINE set_child_edge_coords
+        childgrid(m)%uz_coord   = child_grid_info(2)
+        childgrid(m)%uz_coord_b = child_grid_info(1)
+
+     END SUBROUTINE pmci_set_child_edge_coords
 
 #endif
@@ -1331,5 +1333,5 @@
     INTEGER(iwp) ::  lb                            !< Running index for aerosol size bins
     INTEGER(iwp) ::  lc                            !< Running index for aerosol mass bins
-    INTEGER(iwp) ::  lg                            !< Running index for salsa gases
+    INTEGER(iwp) ::  lg                            !< Running index for SALSA gases
     INTEGER(iwp) ::  n                             !< Running index for number of chemical species
     INTEGER(iwp), DIMENSION(3) ::  child_grid_dim  !< Array for sending the child-grid dimensions to parent 
@@ -1337,6 +1339,6 @@
     REAL(wp), DIMENSION(5) ::  child_grid_info     !< Array for sending the child-grid spacings etc to parent 
          
-    CHARACTER( LEN=da_namelen ) ::  myname         !< 
-    CHARACTER(LEN=5) ::  salsa_char                !<
+    CHARACTER( LEN=da_namelen ) ::  myname         !< Name of the variable to be coupled
+    CHARACTER(LEN=5) ::  salsa_char                !< Name extension for the variable name in case of SALSA variable
     
 !
@@ -1345,5 +1347,5 @@
     IF ( .NOT. pmc_is_rootmodel() )  THEN
 !
-!--    ADD A DESCRIPTION HERE WHAT PMC_CHILDINIT DOES       
+!--    KLaus, add a description here what pmc_childinit does       
        CALL pmc_childinit
 !
@@ -1355,7 +1357,7 @@
 !--    pmci_set_array_pointer (for parent arrays)
 !--    pmci_create_childs_parent_grid_arrays (for child's parent-grid arrays)
-       CALL pmc_set_dataarray_name( 'coarse', 'u'  ,'fine', 'u',  ierr )
-       CALL pmc_set_dataarray_name( 'coarse', 'v'  ,'fine', 'v',  ierr )
-       CALL pmc_set_dataarray_name( 'coarse', 'w'  ,'fine', 'w',  ierr )
+       CALL pmc_set_dataarray_name( 'parent', 'u', 'child', 'u', ierr )
+       CALL pmc_set_dataarray_name( 'parent', 'v', 'child', 'v', ierr )
+       CALL pmc_set_dataarray_name( 'parent', 'w', 'child', 'w', ierr )
 !
 !--    Set data array name for TKE. Please note, nesting of TKE is actually
@@ -1363,8 +1365,8 @@
 !--    design of model coupler, however, data array names must be already 
 !--    available at this point.
-       IF ( (        rans_mode_parent  .AND.         rans_mode )  .OR.         &
-            (  .NOT. rans_mode_parent  .AND.  .NOT.  rans_mode  .AND.          &
+       IF ( (        rans_mode_parent  .AND.         rans_mode )  .OR.                              &
+            (  .NOT. rans_mode_parent  .AND.  .NOT.  rans_mode  .AND.                               &
                .NOT. constant_diffusion ) )  THEN
-          CALL pmc_set_dataarray_name( 'coarse', 'e'  ,'fine', 'e',  ierr )
+          CALL pmc_set_dataarray_name( 'parent', 'e', 'child', 'e', ierr )
        ENDIF
 !
@@ -1373,23 +1375,23 @@
 !--    above.
        IF ( rans_mode_parent  .AND.  rans_mode  .AND.  rans_tke_e )  THEN
-          CALL pmc_set_dataarray_name( 'coarse', 'diss'  ,'fine', 'diss',  ierr )
+          CALL pmc_set_dataarray_name( 'parent', 'diss', 'child', 'diss', ierr )
        ENDIF
 
        IF ( .NOT. neutral )  THEN
-          CALL pmc_set_dataarray_name( 'coarse', 'pt' ,'fine', 'pt', ierr )
+          CALL pmc_set_dataarray_name( 'parent', 'pt' ,'child', 'pt', ierr )
        ENDIF
 
        IF ( humidity )  THEN
 
-          CALL pmc_set_dataarray_name( 'coarse', 'q'  ,'fine', 'q',  ierr )
+          CALL pmc_set_dataarray_name( 'parent', 'q', 'child', 'q', ierr )
 
           IF ( bulk_cloud_model  .AND.  microphysics_morrison )  THEN
-            CALL pmc_set_dataarray_name( 'coarse', 'qc'  ,'fine', 'qc',  ierr )  
-            CALL pmc_set_dataarray_name( 'coarse', 'nc'  ,'fine', 'nc',  ierr ) 
+            CALL pmc_set_dataarray_name( 'parent', 'qc', 'child', 'qc', ierr )  
+            CALL pmc_set_dataarray_name( 'parent', 'nc', 'child', 'nc', ierr ) 
           ENDIF
 
           IF ( bulk_cloud_model  .AND.  microphysics_seifert )  THEN
-             CALL pmc_set_dataarray_name( 'coarse', 'qr'  ,'fine', 'qr',  ierr )
-             CALL pmc_set_dataarray_name( 'coarse', 'nr'  ,'fine', 'nr',  ierr ) 
+             CALL pmc_set_dataarray_name( 'parent', 'qr', 'child', 'qr', ierr )
+             CALL pmc_set_dataarray_name( 'parent', 'nr', 'child', 'nr', ierr ) 
           ENDIF
      
@@ -1397,23 +1399,16 @@
 
        IF ( passive_scalar )  THEN
-          CALL pmc_set_dataarray_name( 'coarse', 's'  ,'fine', 's',  ierr )
+          CALL pmc_set_dataarray_name( 'parent', 's', 'child', 's', ierr )
        ENDIF
 
        IF ( particle_advection )  THEN
-          CALL pmc_set_dataarray_name( 'coarse', 'nr_part'  ,'fine',           &
-               'nr_part',  ierr )
-          CALL pmc_set_dataarray_name( 'coarse', 'part_adr'  ,'fine',          &
-               'part_adr',  ierr )
+          CALL pmc_set_dataarray_name( 'parent', 'nr_part', 'child', 'nr_part', ierr )
+          CALL pmc_set_dataarray_name( 'parent', 'part_adr', 'child', 'part_adr', ierr )
        ENDIF
        
        IF ( air_chemistry  .AND.  nest_chemistry )  THEN
           DO n = 1, nspec
-             CALL pmc_set_dataarray_name( 'coarse',                            &
-                                          'chem_' //                           &
-                                          TRIM( chem_species(n)%name ),        &
-                                         'fine',                               &
-                                          'chem_' //                           &
-                                          TRIM( chem_species(n)%name ),        &
-                                          ierr )
+             CALL pmc_set_dataarray_name( 'parent', 'chem_' // TRIM( chem_species(n)%name ),        &
+                                          'child',  'chem_' // TRIM( chem_species(n)%name ), ierr )
           ENDDO 
        ENDIF
@@ -1422,32 +1417,17 @@
           DO  lb = 1, nbins_aerosol
              WRITE(salsa_char,'(i0)') lb
-             CALL pmc_set_dataarray_name( 'coarse',                            &
-                                          'an_' //                             &
-                                          TRIM( salsa_char ),                  &
-                                          'fine',                              &
-                                          'an_' //                             &
-                                          TRIM( salsa_char ),                  &
-                                          ierr )
+             CALL pmc_set_dataarray_name( 'parent', 'an_' // TRIM( salsa_char ),                    &
+                                          'child',  'an_' // TRIM( salsa_char ), ierr )
           ENDDO
           DO  lc = 1, nbins_aerosol * ncomponents_mass
              WRITE(salsa_char,'(i0)') lc
-             CALL pmc_set_dataarray_name( 'coarse',                            &
-                                          'am_' //                             &
-                                          TRIM( salsa_char ),                  &
-                                          'fine',                              &
-                                          'am_' //                             &
-                                          TRIM( salsa_char ),                  &
-                                          ierr )
+             CALL pmc_set_dataarray_name( 'parent', 'am_' // TRIM( salsa_char ),                    &
+                                          'child',  'am_' // TRIM( salsa_char ), ierr )
           ENDDO
           IF ( .NOT. salsa_gases_from_chem )  THEN
              DO  lg = 1, ngases_salsa
                 WRITE(salsa_char,'(i0)') lg
-                CALL pmc_set_dataarray_name( 'coarse',                         &
-                                             'sg_' //                          &
-                                             TRIM( salsa_char ),               &
-                                             'fine',                           &
-                                             'sg_' //                          &
-                                             TRIM( salsa_char ),               &
-                                             ierr )
+                CALL pmc_set_dataarray_name( 'parent', 'sg_' // TRIM( salsa_char ),                 &
+                                             'child',  'sg_' // TRIM( salsa_char ), ierr )
              ENDDO
           ENDIF
@@ -1520,6 +1500,6 @@
        CALL MPI_BCAST( rans_mode_parent, 1, MPI_LOGICAL, 0, comm2d, ierr )       
 !
-!--    Find the index bounds for the nest domain in the coarse-grid index space
-       CALL pmci_map_fine_to_coarse_grid
+!--    Find the index bounds for the nest domain in the parent-grid index space
+       CALL pmci_map_child_grid_to_parent_grid
 !
 !--    TO_DO: Klaus give a comment what is happening here
@@ -1537,11 +1517,11 @@
        DO  WHILE ( pmc_c_getnextarray( myname ) )
 !
-!--       Note that cg%nz is not the original nz of parent, but the highest
+!--       Note that pg%nz is not the original nz of parent, but the highest
 !--       parent-grid level needed for nesting.
-!--       Please note, in case of chemical species an additional parameter
-!--       need to be passed, which is required to set the pointer correctly
-!--       to the chemical-species data structure. Hence, first check if current
-!--       variable is a chemical species. If so, pass index id of respective
-!--       species and increment this subsequently.
+!--       Note that in case of chemical species or SALSA variables an additional 
+!--       parameter needs to be passed. The parameter is required to set the pointer 
+!--       correctlyto the chemical-species or SALSA data structure. Hence, first check if 
+!--       the current variable is a chemical species or a SALSA variable. If so, pass 
+!--       index id of respective sub-variable (species or bin) and increment this subsequently.
           IF ( INDEX( TRIM( myname ), 'chem_' ) /= 0 )  THEN             
              CALL pmci_create_childs_parent_grid_arrays ( myname, ipl, ipr, jps, jpn, pg%nz, n )
@@ -1573,8 +1553,7 @@
 
 
-    SUBROUTINE pmci_map_fine_to_coarse_grid
-!
-!--    Determine index bounds of interpolation/anterpolation area in the coarse
-!--    grid index space
+    SUBROUTINE pmci_map_child_grid_to_parent_grid
+!
+!--    Determine index bounds of interpolation/anterpolation area in the parent-grid index space
        IMPLICIT NONE
 
@@ -1582,13 +1561,13 @@
 
        INTEGER(iwp), DIMENSION(4)          ::  parent_bound_global  !< Transfer array for global parent-grid index bounds
-       INTEGER(iwp), DIMENSION(2)          ::  size_of_array        !<
-
-       INTEGER(iwp) ::  i       !< 
-       INTEGER(iwp) ::  iauxl   !<
-       INTEGER(iwp) ::  iauxr   !<
-       INTEGER(iwp) ::  ijaux   !< 
-       INTEGER(iwp) ::  j       !<
-       INTEGER(iwp) ::  jauxs   !<
-       INTEGER(iwp) ::  jauxn   !< 
+       INTEGER(iwp), DIMENSION(2)          ::  size_of_array        !< For sending the dimensions of parent_bound_all to parent
+
+       INTEGER(iwp) ::  ip      !< Running parent-grid index in the x-direction 
+       INTEGER(iwp) ::  iauxl   !< Offset between the index bound ipl and the auxiliary index bound ipla
+       INTEGER(iwp) ::  iauxr   !< Offset between the index bound ipr and the auxiliary index bound ipra
+       INTEGER(iwp) ::  ijaux   !< Temporary variable for receiving the index bound from the neighbouring subdomain
+       INTEGER(iwp) ::  jp      !< Running parent-grid index in the y-direction 
+       INTEGER(iwp) ::  jauxs   !< Offset between the index bound jps and the auxiliary index bound jpsa
+       INTEGER(iwp) ::  jauxn   !< Offset between the index bound jpn and the auxiliary index bound jpna
 
        REAL(wp) ::  xexl        !< Parent-grid array exceedance behind the left edge of the child PE subdomain
@@ -1596,22 +1575,28 @@
        REAL(wp) ::  yexs        !< Parent-grid array exceedance behind the south edge of the child PE subdomain
        REAL(wp) ::  yexn        !< Parent-grid array exceedance behind the north edge of the child PE subdomain
-       REAL(wp) ::  xcs         !< RENAME 
-       REAL(wp) ::  xce         !< RENAME 
-       REAL(wp) ::  ycs         !< RENAME 
-       REAL(wp) ::  yce         !< RENAME 
-
-!
-!--    Determine the anterpolation index limits. If at least half of the 
-!--    parent-grid cell is within the current child sub-domain, then it 
-!--    is included in the current sub-domain's anterpolation domain. 
-!--    Else the parent-grid cell is included in the neighbouring subdomain's 
-!--    anterpolation domain, or not included at all if we are at the outer 
-!--    edge of the child domain. This may occur especially when a large grid-spacing
-!--    ratio is used.       
-!
-!--    Left
-!--    EXPLAIN THE EXTENSION HERE AND IN THE OTHER OCCASIONS (r, s, n)       
+       REAL(wp) ::  xpl         !< Requested left-edge x-coordinate of the parent-grid array domain (at the internal boundaries
+                                !< the real edge may differ from this in some cases as explained in the comment block below)  
+       REAL(wp) ::  xpr         !< Requested right-edge x-coordinate of the parent-grid array domain (at the internal boundaries
+                                !< the real edge may differ from this in some cases as explained in the comment block below)
+       REAL(wp) ::  yps         !< Requested south-edge y-coordinate of the parent-grid array domain (at the internal boundaries
+                                !< the real edge may differ from this in some cases as explained in the comment block below)
+       REAL(wp) ::  ypn         !< Requested south-edge y-coordinate of the parent-grid array domain (at the internal boundaries
+                                !< the real edge may differ from this in some cases as explained in the comment block below)
+
+!
+!--    Determine the index limits for the child's parent-grid arrays (such as uc for example).
+!--    Note that at the outer edges of the child domain (nest boundaries) these arrays exceed
+!--    the boundary by two parent-grid cells. At the internal boundaries, there are no 
+!--    exceedances and thus no overlaps with the neighbouring subdomain. If at least half 
+!--    of the parent-grid cell is within the current child sub-domain, then it is included 
+!--    in the current sub-domain's parent-grid array. Else the parent-grid cell is 
+!--    included in the neighbouring subdomain's parent-grid array, or not included at all if 
+!--    we are at the outer edge of the child domain. This may occur especially when a large 
+!--    grid-spacing ratio is used.       
+!
+!--    Left boundary.
+!--    Extension by two parent-grid cells behind the boundary, see the comment block above.    
        IF ( bc_dirichlet_l )  THEN
-          xexl  = 2 * pg%dx
+          xexl  = 2.0_wp * pg%dx
           iauxl = 0
        ELSE
@@ -1619,15 +1604,16 @@
           iauxl = 1
        ENDIF
-       xcs     = coord_x(nxl) - xexl
-       DO  i = 0, pg%nx
-          IF ( pg%coord_x(i) + 0.5_wp * pg%dx >= xcs )  THEN   ! Consider changing >= to ==
-             ipl = MAX( 0, i )
+       xpl     = coord_x(nxl) - xexl
+       DO  ip = 0, pg%nx
+          IF ( pg%coord_x(ip) + 0.5_wp * pg%dx >= xpl )  THEN
+             ipl = MAX( 0, ip )
              EXIT
           ENDIF
        ENDDO
 !
-!--    Right
+!--    Right boundary.
+!--    Extension by two parent-grid cells behind the boundary, see the comment block above.       
        IF ( bc_dirichlet_r )  THEN
-          xexr  = 2 * pg%dx
+          xexr  = 2.0_wp * pg%dx
           iauxr = 0  
        ELSE
@@ -1635,15 +1621,16 @@
           iauxr = 1  
        ENDIF
-       xce  = coord_x(nxr+1) + xexr
-       DO  i = pg%nx, 0 , -1
-          IF ( pg%coord_x(i) + 0.5_wp * pg%dx <= xce )  THEN
-             ipr = MIN( pg%nx, MAX( ipl, i ) )
+       xpr  = coord_x(nxr+1) + xexr
+       DO  ip = pg%nx, 0 , -1
+          IF ( pg%coord_x(ip) + 0.5_wp * pg%dx <= xpr )  THEN
+             ipr = MIN( pg%nx, MAX( ipl, ip ) )
              EXIT
           ENDIF
        ENDDO
 !
-!--    South
+!--    South boundary.
+!--    Extension by two parent-grid cells behind the boundary, see the comment block above.   
        IF ( bc_dirichlet_s )  THEN
-          yexs  = 2 * pg%dy
+          yexs  = 2.0_wp * pg%dy
           jauxs = 0  
        ELSE
@@ -1651,15 +1638,16 @@
           jauxs = 1  
        ENDIF
-       ycs  = coord_y(nys) - yexs
-       DO  j = 0, pg%ny
-          IF ( pg%coord_y(j) + 0.5_wp * pg%dy >= ycs )  THEN
-             jps = MAX( 0, j )
+       yps  = coord_y(nys) - yexs
+       DO  jp = 0, pg%ny
+          IF ( pg%coord_y(jp) + 0.5_wp * pg%dy >= yps )  THEN
+             jps = MAX( 0, jp )
              EXIT
           ENDIF
        ENDDO
 !
-!--    North
+!--    North boundary.
+!--    Extension by two parent-grid cells behind the boundary, see the comment block above.  
        IF  ( bc_dirichlet_n )  THEN
-          yexn  = 2 * pg%dy
+          yexn  = 2.0_wp * pg%dy
           jauxn = 0
        ELSE
@@ -1667,8 +1655,8 @@
           jauxn = 1
        ENDIF
-       yce  = coord_y(nyn+1) + yexn
-       DO  j = pg%ny, 0 , -1
-          IF ( pg%coord_y(j) + 0.5_wp * pg%dy <= yce )  THEN
-             jpn = MIN( pg%ny, MAX( jps, j ) )
+       ypn  = coord_y(nyn+1) + yexn
+       DO  jp = pg%ny, 0 , -1
+          IF ( pg%coord_y(jp) + 0.5_wp * pg%dy <= ypn )  THEN
+             jpn = MIN( pg%ny, MAX( jps, jp ) )
              EXIT
           ENDIF
@@ -1678,26 +1666,31 @@
 !--    This is a safety measure mainly for cases with high grid-spacing 
 !--    ratio and narrow child subdomains.
-       IF ( nxl == 0 )  THEN
-          CALL MPI_SEND( ipr, 1, MPI_INTEGER, pright, 717, comm2d, ierr )
-       ELSE IF ( nxr == nx )  THEN
-          CALL MPI_RECV( ijaux, 1, MPI_INTEGER, pleft, 717, comm2d, status, ierr )
-          ipl = ijaux + 1
-       ELSE
-          CALL MPI_SEND( ipr, 1, MPI_INTEGER, pright, 717, comm2d, ierr )
-          CALL MPI_RECV( ijaux, 1, MPI_INTEGER, pleft, 717, comm2d, status, ierr ) 
-          ipl = ijaux + 1
-       ENDIF
-       IF ( nys == 0 )  THEN
-          CALL MPI_SEND( jpn, 1, MPI_INTEGER, pnorth, 719, comm2d, ierr )
-       ELSE IF ( nyn == ny )  THEN
-          CALL MPI_RECV( ijaux, 1, MPI_INTEGER, psouth, 719, comm2d, status, ierr )
-          jps = ijaux + 1
-       ELSE
-          CALL MPI_SEND( jpn, 1, MPI_INTEGER, pnorth, 719, comm2d, ierr )
-          CALL MPI_RECV( ijaux, 1, MPI_INTEGER, psouth, 719, comm2d, status, ierr ) 
-          jps = ijaux + 1
-       ENDIF
-
-       WRITE(9,"('Pmci_map_fine_to_coarse_grid. Parent-grid array bounds: ',4(i4,2x))")             &
+       IF ( pdims(1) > 1 )  THEN
+          IF ( nxl == 0 )  THEN
+             CALL MPI_SEND( ipr, 1, MPI_INTEGER, pright, 717, comm2d, ierr )
+          ELSE IF ( nxr == nx )  THEN
+             CALL MPI_RECV( ijaux, 1, MPI_INTEGER, pleft, 717, comm2d, status, ierr )
+             ipl = ijaux + 1
+          ELSE
+             CALL MPI_SEND( ipr, 1, MPI_INTEGER, pright, 717, comm2d, ierr )
+             CALL MPI_RECV( ijaux, 1, MPI_INTEGER, pleft, 717, comm2d, status, ierr ) 
+             ipl = ijaux + 1
+          ENDIF
+       ENDIF
+
+       IF ( pdims(2) > 1 )  THEN
+          IF ( nys == 0 )  THEN
+             CALL MPI_SEND( jpn, 1, MPI_INTEGER, pnorth, 719, comm2d, ierr )
+          ELSE IF ( nyn == ny )  THEN
+             CALL MPI_RECV( ijaux, 1, MPI_INTEGER, psouth, 719, comm2d, status, ierr )
+             jps = ijaux + 1
+          ELSE
+             CALL MPI_SEND( jpn, 1, MPI_INTEGER, pnorth, 719, comm2d, ierr )
+             CALL MPI_RECV( ijaux, 1, MPI_INTEGER, psouth, 719, comm2d, status, ierr ) 
+             jps = ijaux + 1
+          ENDIF
+       ENDIF
+          
+       WRITE(9,"('pmci_map_child_grid_to_parent_grid. Parent-grid array bounds: ',4(i4,2x))")             &
             ipl, ipr, jps, jpn
        FLUSH(9)
@@ -1709,5 +1702,6 @@
        parent_bound(5) = myid
 !
-!--    The following index bounds are used for allocating index mapping and some other auxiliary arrays
+!--    The following auxiliary index bounds are used for allocating index mapping and 
+!--    some other auxiliary arrays.
        ipla = ipl - iauxl
        ipra = ipr + iauxr
@@ -1715,7 +1709,10 @@
        jpna = jpn + jauxn
 !
+!--    The index-bounds parent_bound of all subdomains of the current child domain
+!--    must be sent to the parent in order for the parent to create the index list.
+!--    For this reason, the parent_bound arrays are packed together in single
+!--    array parent_bound_all using MPI_GATHER.       
 !--    Note that MPI_Gather receives data from all processes in the rank order
-!--    This fact is exploited in creating the index list in pmci_create_index_list
-!    IMPROVE THIS COMMENT. EXPLAIN WHERE THIS INFORMATION IS NEEDED.
+!--    This fact is exploited in creating the index list in pmci_create_index_list.
        CALL MPI_GATHER( parent_bound, 5, MPI_INTEGER, parent_bound_all, 5,                          &
                         MPI_INTEGER, 0, comm2d, ierr )
@@ -1734,5 +1731,5 @@
        ENDIF
 !
-!--    Broadcat the global parent-grid index bounds to all current child processes
+!--    Broadcast the global parent-grid index bounds to all current child processes
        CALL MPI_BCAST( parent_bound_global, 4, MPI_INTEGER, 0, comm2d, ierr )
        iplg = parent_bound_global(1)
@@ -1740,9 +1737,9 @@
        jpsg = parent_bound_global(3)
        jpng = parent_bound_global(4)
-       WRITE( 9, "('Pmci_map_fine_to_coarse_grid. Global parent-grid index bounds iplg, iprg, jpsg, jpng: ',4(i4,2x))" ) &
+       WRITE( 9, "('pmci_map_child_grid_to_parent_grid. Global parent-grid index bounds iplg, iprg, jpsg, jpng: ',4(i4,2x))" ) &
             iplg, iprg, jpsg, jpng
        FLUSH( 9 )
        
-    END SUBROUTINE pmci_map_fine_to_coarse_grid
+    END SUBROUTINE pmci_map_child_grid_to_parent_grid
 
      
@@ -1786,5 +1783,5 @@
 !
 !--    First determine kcto and kctw which refer to the uppermost 
-!--    coarse-grid levels below the child top-boundary level.
+!--    parent-grid levels below the child top-boundary level.
        kk = 0
        DO WHILE ( pg%zu(kk) <= zu(nzt) )
@@ -1992,5 +1989,5 @@
        WRITE( 9, * )
 !
-!--    Precomputation of number of fine-grid nodes inside parent-grid cells.
+!--    Precomputation of number of child-grid nodes inside parent-grid cells.
 !--    Note that ii, jj, and kk are parent-grid indices. 
 !--    This information is needed in the anterpolation. 
@@ -2076,10 +2073,10 @@
 !--          Error
              WRITE( message_string, * ) 'child domain too narrow for anterpolation in x-direction'
-             CALL message( 'pmci_map_fine_to_coarse_grid', 'PA0652', 3, 2, 0, 6, 0 )
+             CALL message( 'pmci_check_child_domain_size', 'PA0652', 3, 2, 0, 6, 0 )
           ELSE IF ( iprg - iplg + 1 < 11 )  THEN
 !                
 !--          Warning
              WRITE( message_string, * ) 'anterpolation_buffer_width value too high, reset to 0'
-             CALL message( 'pmci_map_fine_to_coarse_grid', 'PA0653', 0, 1, 0, 6, 0 )
+             CALL message( 'pmci_check_child_domain_size', 'PA0653', 0, 1, 0, 6, 0 )
              anterpolation_buffer_width = 0
           ELSE
@@ -2087,5 +2084,5 @@
 !--          Informative message
              WRITE( message_string, * ) 'anterpolation_buffer_width value too high, reset to default value 2'
-             CALL message( 'pmci_map_fine_to_coarse_grid', 'PA0654', 0, 0, 0, 6, 0 )
+             CALL message( 'pmci_check_child_domain_size', 'PA0654', 0, 0, 0, 6, 0 )
              anterpolation_buffer_width = 2
           ENDIF
@@ -2098,10 +2095,10 @@
 !--          Error
              WRITE( message_string, * ) 'child domain too narrow for anterpolation in y-direction'
-             CALL message( 'pmci_map_fine_to_coarse_grid', 'PA0652', 3, 2, 0, 6, 0 )
+             CALL message( 'pmci_check_child_domain_size', 'PA0652', 3, 2, 0, 6, 0 )
           ELSE IF ( jpng - jpsg + 1 < 11 )  THEN
 !                
 !--          Warning
              WRITE( message_string, * ) 'anterpolation_buffer_width value too high, reset to 0'
-             CALL message( 'pmci_map_fine_to_coarse_grid', 'PA0653', 0, 1, 0, 6, 0 )
+             CALL message( 'pmci_check_child_domain_size', 'PA0653', 0, 1, 0, 6, 0 )
              anterpolation_buffer_width = 0
           ELSE
@@ -2109,5 +2106,5 @@
 !--          Informative message
              WRITE( message_string, * ) 'anterpolation_buffer_width value too high, reset to default value 2'
-             CALL message( 'pmci_map_fine_to_coarse_grid', 'PA0654', 0, 0, 0, 6, 0 )
+             CALL message( 'pmci_check_child_domain_size', 'PA0654', 0, 0, 0, 6, 0 )
              anterpolation_buffer_width = 2
           ENDIF
@@ -2120,10 +2117,10 @@
 !--          Error
              WRITE( message_string, * ) 'child domain too shallow for anterpolation in z-direction'
-             CALL message( 'pmci_map_fine_to_coarse_grid', 'PA0652', 3, 2, 0, 6, 0 )
+             CALL message( 'pmci_check_child_domain_size', 'PA0652', 3, 2, 0, 6, 0 )
           ELSE IF ( kctw - 3 < 1 )  THEN
 !                
 !--          Warning
              WRITE( message_string, * ) 'anterpolation_buffer_width value too high, reset to 0'
-             CALL message( 'pmci_map_fine_to_coarse_grid', 'PA0653', 0, 1, 0, 6, 0 )
+             CALL message( 'pmci_check_child_domain_size', 'PA0653', 0, 1, 0, 6, 0 )
              anterpolation_buffer_width = 0
           ELSE
@@ -2131,5 +2128,5 @@
 !--          Informative message
              WRITE( message_string, * ) 'anterpolation_buffer_width value too high, reset to default value 2'
-             CALL message( 'pmci_map_fine_to_coarse_grid', 'PA0654', 0, 0, 0, 6, 0 )
+             CALL message( 'pmci_check_child_domain_size', 'PA0654', 0, 0, 0, 6, 0 )
              anterpolation_buffer_width = 2  
           ENDIF
