Index: /palm/trunk/SOURCE/lagrangian_particle_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/lagrangian_particle_model_mod.f90	(revision 4882)
+++ /palm/trunk/SOURCE/lagrangian_particle_model_mod.f90	(revision 4883)
@@ -24,4 +24,7 @@
 ! -----------------
 ! $Id$
+! User switch for particle coupling added
+!
+! 4865 2021-02-03 11:51:40Z schwenkel
 ! Remove unnecessary interface decalrations and public statments for private routines
 !
@@ -251,5 +254,5 @@
 
     USE pmc_interface,                                                                             &
-        ONLY: nested_run
+        ONLY: nested_run, particle_coupling
 
     USE grid_variables,                                                                            &
@@ -2253,9 +2256,11 @@
 !
 !--          In case of nested runs do the transfer of particles after every full model time step
-             IF ( nested_run )   THEN
-                CALL particles_from_parent_to_child
-                CALL particles_from_child_to_parent
-                CALL pmcp_p_delete_particles_in_fine_grid_area
-
+!--          if requested ( particle_coupling = .TRUE. )
+             IF ( nested_run )   THEN   
+                IF ( particle_coupling )  THEN
+                   CALL particles_from_parent_to_child
+                   CALL particles_from_child_to_parent
+                   CALL pmcp_p_delete_particles_in_fine_grid_area
+                ENDIF
                 CALL lpm_sort_and_delete
 
Index: /palm/trunk/SOURCE/pmc_handle_communicator_mod.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_handle_communicator_mod.f90	(revision 4882)
+++ /palm/trunk/SOURCE/pmc_handle_communicator_mod.f90	(revision 4883)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! User switch for particle coupling added
+!
+! 4843 2021-01-15 15:22:11Z raasch
 ! local namelist parameter added to switch off the module although the respective module namelist
 ! appears in the namelist file
@@ -146,5 +149,6 @@
 !--------------------------------------------------------------------------------------------------!
  SUBROUTINE pmc_init_model( comm, nesting_datatransfer_mode, nesting_mode,                         &
-                            anterpolation_buffer_width, anterpolation_starting_height, pmc_status )
+                            anterpolation_buffer_width, anterpolation_starting_height,             &
+                            particle_coupling, pmc_status )
 
     USE control_parameters,                                                                        &
@@ -154,5 +158,5 @@
         ONLY:  myid
 
-      IMPLICIT NONE
+    IMPLICIT NONE
 
     CHARACTER(LEN=7), INTENT(INOUT) ::  nesting_datatransfer_mode  !<
@@ -164,4 +168,5 @@
 
     REAL(wp), INTENT(INOUT) ::  anterpolation_starting_height  !< steering parameter for canopy restricted anterpolation 
+    LOGICAL, INTENT(INOUT)  ::  particle_coupling              !< switch for particle coupling (default .TRUE.)
     
     INTEGER ::  childcount     !<
@@ -190,5 +195,5 @@
 
        CALL read_coupling_layout( nesting_datatransfer_mode, nesting_mode,                         &
-            anterpolation_buffer_width, anterpolation_starting_height,                             &
+            anterpolation_buffer_width, anterpolation_starting_height, particle_coupling,          &
             pmc_status )
 
@@ -264,4 +269,5 @@
     CALL MPI_BCAST( anterpolation_buffer_width, 1, MPI_INT, 0, MPI_COMM_WORLD, istat )
     CALL MPI_BCAST( anterpolation_starting_height, 1, MPI_REAL, 0, MPI_COMM_WORLD, istat )
+    CALL MPI_BCAST( particle_coupling, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, istat )
 !
 !-- Assign global MPI processes to individual models by setting the couple id
@@ -435,5 +441,5 @@
  SUBROUTINE read_coupling_layout( nesting_datatransfer_mode, nesting_mode,                         &
                                   anterpolation_buffer_width, anterpolation_starting_height,       &
-                                  pmc_status )
+                                  particle_coupling, pmc_status )
 
     IMPLICIT NONE
@@ -446,4 +452,5 @@
 
     REAL(wp), INTENT(INOUT) ::  anterpolation_starting_height   !< steering parameter for canopy restricted anterpolation
+    LOGICAL, INTENT(INOUT)  ::  particle_coupling               !< switch for particle coupling (default .TRUE.)
 
     INTEGER(iwp) ::  bad_llcorner  !<
@@ -462,5 +469,6 @@
                                    nesting_datatransfer_mode,                                      &
                                    nesting_mode,                                                   &
-                                   switch_off_module
+                                   switch_off_module,                                              &
+                                   particle_coupling
 
 
Index: /palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 4882)
+++ /palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 4883)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! User switch for particle coupling added. Some code reformatting according to follow PALM coding standard.
+! Some missing doxygen comments added.
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! Bugfix in setting up the nesting configuration for chemical and aerosol species in case of more
 ! than one child domain
@@ -456,5 +460,5 @@
 
     INTEGER(iwp), SAVE ::  comm_world_nesting  !< Global nesting communicator
-    INTEGER(iwp), SAVE ::  cpl_id  = 1         !<
+    INTEGER(iwp), SAVE ::  cpl_id  = 1         !< Model (domain) id (1 for root, 2,... for nested domains).
     INTEGER(iwp), SAVE ::  cpl_npe_total       !<
     INTEGER(iwp), SAVE ::  cpl_parent_id       !<
@@ -470,4 +474,5 @@
 
     LOGICAL, SAVE ::  nested_run = .FALSE.        !< general switch
+    LOGICAL, SAVE ::  particle_coupling = .TRUE.  !< switch for particle coupling (meaningful only when lpm is used) 
     LOGICAL, SAVE ::  rans_mode_parent = .FALSE.  !< mode of parent model (.F. - LES mode, .T. - RANS mode)
 !
@@ -561,8 +566,10 @@
 !
 !-- Work arrays for interpolation and user-defined type definitions for horizontal work-array exchange
-    INTEGER(iwp) ::  workarr_lr_exchange_type   !<
-    INTEGER(iwp) ::  workarr_sn_exchange_type   !<
-    INTEGER(iwp) ::  workarr_t_exchange_type_x  !<
-    INTEGER(iwp) ::  workarr_t_exchange_type_y  !<
+    INTEGER(iwp) ::  workarr_lr_exchange_type   !< type definition for work-array exchange on left and right boundaries
+    INTEGER(iwp) ::  workarr_sn_exchange_type   !< type definition for work-array exchange on south and north boundaries
+    INTEGER(iwp) ::  workarr_t_exchange_type_x  !< type definition for work-array exchange on top boundary between left-right
+                                                !< neighbouring subdomains
+    INTEGER(iwp) ::  workarr_t_exchange_type_y  !< type definition for work-array exchange on top boundary between south-north
+                                                !< neighbouring subdomains
 
     INTEGER(iwp), DIMENSION(3) ::  parent_grid_info_int  !< Array for communicating the parent-grid dimensions to its children.
@@ -572,7 +579,7 @@
                                                       !< children.
 
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  workarr_lr  !<
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  workarr_sn  !<
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  workarr_t   !<
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  workarr_lr  !< work array for interpolation on left and right boundaries
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  workarr_sn  !< work array for interpolation on south and north boundaries
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  workarr_t   !< work array for interpolation on top boundary
 
     TYPE parentgrid_def
@@ -599,15 +606,20 @@
 !-- Variables for particle coupling
     TYPE, PUBLIC :: childgrid_def
-       INTEGER(iwp) ::  nx  !<
-       INTEGER(iwp) ::  ny  !<
-       INTEGER(iwp) ::  nz  !<
-       REAL(wp)     ::  dx  !<
-       REAL(wp)     ::  dy  !<
-       REAL(wp)     ::  dz  !<
-       REAL(wp)     ::  lx_coord, lx_coord_b !<   ! split onto separate lines
-       REAL(wp)     ::  rx_coord, rx_coord_b !<
-       REAL(wp)     ::  sy_coord, sy_coord_b !<
-       REAL(wp)     ::  ny_coord, ny_coord_b !<
-       REAL(wp)     ::  uz_coord, uz_coord_b !<
+       INTEGER(iwp) ::  nx          !<
+       INTEGER(iwp) ::  ny          !<
+       INTEGER(iwp) ::  nz          !<
+       REAL(wp)     ::  dx          !<
+       REAL(wp)     ::  dy          !<
+       REAL(wp)     ::  dz          !<
+       REAL(wp)     ::  lx_coord    !< 
+       REAL(wp)     ::  rx_coord    !< 
+       REAL(wp)     ::  sy_coord    !< 
+       REAL(wp)     ::  ny_coord    !< 
+       REAL(wp)     ::  uz_coord    !< 
+       REAL(wp)     ::  lx_coord_b  !< 
+       REAL(wp)     ::  rx_coord_b  !< 
+       REAL(wp)     ::  sy_coord_b  !< 
+       REAL(wp)     ::  ny_coord_b  !< 
+       REAL(wp)     ::  uz_coord_b  !<        
     END TYPE childgrid_def
 
@@ -685,4 +697,5 @@
            nesting_mode,                                                                           &
            parent_to_child,                                                                        &
+           particle_coupling,                                                                      &
            rans_mode_parent
 
@@ -711,14 +724,15 @@
     IMPLICIT NONE
 
-    INTEGER(iwp), INTENT(OUT) ::  world_comm  !<
+    INTEGER(iwp), INTENT(OUT) ::  world_comm  !< global communicator
 
 #if defined( __parallel )
 
-    INTEGER(iwp) ::  pmc_status  !<
+    INTEGER(iwp) ::  pmc_status  !< status parameter indicating if the nesting_parameters namelist
+                                 !< was succesfully input or not  
 
 
     CALL pmc_init_model( world_comm, nesting_datatransfer_mode, nesting_mode,                      &
-                         anterpolation_buffer_width, anterpolation_starting_height, pmc_status )
-
+                         anterpolation_buffer_width, anterpolation_starting_height,                &
+                         particle_coupling, pmc_status )
     IF ( pmc_status == pmc_no_namelist_found )  THEN
 !
@@ -1745,22 +1759,22 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i       !< Child-grid index in the x-direction
-    INTEGER(iwp) ::  ii      !< Parent-grid index in the x-direction
-    INTEGER(iwp) ::  istart  !<
-    INTEGER(iwp) ::  ir      !<
-    INTEGER(iwp) ::  iw      !< Child-grid index limited to -1 <= iw <= nx+1 for wall_flags_total_0
-    INTEGER(iwp) ::  j       !< Child-grid index in the y-direction
-    INTEGER(iwp) ::  jj      !< Parent-grid index in the y-direction
-    INTEGER(iwp) ::  jstart  !<
-    INTEGER(iwp) ::  jr      !<
-    INTEGER(iwp) ::  jw      !< Child-grid index limited to -1 <= jw <= ny+1 for wall_flags_total_0
-    INTEGER(iwp) ::  k       !< Child-grid index in the z-direction
-    INTEGER(iwp) ::  kk      !< Parent-grid index in the z-direction
-    INTEGER(iwp) ::  kstart  !<
-    INTEGER(iwp) ::  kw      !< Child-grid index limited to kw <= nzt+1 for wall_flags_total_0
-
-    REAL(wp) ::  tolex  !< Tolerance for grid-line matching in x-direction
-    REAL(wp) ::  toley  !< Tolerance for grid-line matching in y-direction
-    REAL(wp) ::  tolez  !< Tolerance for grid-line matching in z-direction
+    INTEGER(iwp) ::  i       !< child-grid index in the x-direction
+    INTEGER(iwp) ::  ii      !< parent-grid index in the x-direction
+    INTEGER(iwp) ::  istart  !< starting index for the index-mapping search loop in the x-direction 
+    INTEGER(iwp) ::  ir      !< search-loop running index in the x-direction
+    INTEGER(iwp) ::  iw      !< child-grid index limited to -1 <= iw <= nx+1 for wall_flags_total_0
+    INTEGER(iwp) ::  j       !< child-grid index in the y-direction
+    INTEGER(iwp) ::  jj      !< parent-grid index in the y-direction
+    INTEGER(iwp) ::  jstart  !< starting index for the index-mapping search loop in the y-direction
+    INTEGER(iwp) ::  jr      !< search-loop running index in the y-direction
+    INTEGER(iwp) ::  jw      !< child-grid index limited to -1 <= jw <= ny+1 for wall_flags_total_0
+    INTEGER(iwp) ::  k       !< child-grid index in the z-direction
+    INTEGER(iwp) ::  kk      !< parent-grid index in the z-direction
+    INTEGER(iwp) ::  kstart  !< starting index for the index-mapping search loop in the z-direction
+    INTEGER(iwp) ::  kw      !< child-grid index limited to kw <= nzt+1 for wall_flags_total_0
+
+    REAL(wp) ::  tolex  !< tolerance for grid-line matching in x-direction
+    REAL(wp) ::  toley  !< tolerance for grid-line matching in y-direction
+    REAL(wp) ::  tolez  !< tolerance for grid-line matching in z-direction
 
 !
@@ -2638,6 +2652,6 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i  !<
-    INTEGER(iwp) ::  j  !<
+    INTEGER(iwp) ::  i  !< grid index in the x-direction
+    INTEGER(iwp) ::  j  !< grid index in the y-direction
 
 !
@@ -3713,9 +3727,9 @@
     IMPLICIT NONE
 
-    INTEGER(iwp), INTENT(IN) ::  direction  !< Transfer direction: parent_to_child or child_to_parent
+    INTEGER(iwp), INTENT(IN) ::  direction  !< transfer direction: parent_to_child or child_to_parent
 
 #if defined( __parallel )
 
-    REAL(wp), DIMENSION(1) ::  dtl  !< Time step size
+    REAL(wp), DIMENSION(1) ::  dtl  !< time step size
 
 
@@ -4126,8 +4140,8 @@
  
     IMPLICIT NONE
-    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) ::  n   !< Running index for number of chemical species
+    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) ::  n   !< running index for number of chemical species
 
 
@@ -4216,16 +4230,16 @@
     IMPLICIT NONE
 
-    CHARACTER(LEN=1), INTENT(IN) ::  edge  !< Edge symbol: 'l' or 'r'
-    CHARACTER(LEN=1), INTENT(IN) ::  var   !< Variable symbol: 'u', 'v', 'w' or 's'
-
-    INTEGER(iwp), INTENT(IN) ::  kct  !< The parent-grid index in z-direction just below the boundary value node
-
-    INTEGER(iwp), DIMENSION(jpsa:jpna), INTENT(IN) ::  jfl  !< Indicates start index of child cells belonging to certain
+    CHARACTER(LEN=1), INTENT(IN) ::  edge  !< edge symbol: 'l' or 'r'
+    CHARACTER(LEN=1), INTENT(IN) ::  var   !< variable symbol: 'u', 'v', 'w' or 's'
+
+    INTEGER(iwp), INTENT(IN) ::  kct  !< the parent-grid index in z-direction just below the boundary value node
+
+    INTEGER(iwp), DIMENSION(jpsa:jpna), INTENT(IN) ::  jfl  !< indicates start index of child cells belonging to certain
                                                             !< parent cell - y direction
-    INTEGER(iwp), DIMENSION(jpsa:jpna), INTENT(IN) ::  jfu  !< Indicates end index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(jpsa:jpna), INTENT(IN) ::  jfu  !< indicates end index of child cells belonging to certain
                                                             !< parent cell - y direction
-    INTEGER(iwp), DIMENSION(0:pg%nz+1), INTENT(IN) ::  kfl  !< Indicates start index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(0:pg%nz+1), INTENT(IN) ::  kfl  !< indicates start index of child cells belonging to certain
                                                             !< parent cell - z direction
-    INTEGER(iwp), DIMENSION(0:pg%nz+1), INTENT(IN) ::  kfu  !< Indicates end index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(0:pg%nz+1), INTENT(IN) ::  kfu  !< indicates end index of child cells belonging to certain
                                                             !< parent cell - z direction
 
@@ -4236,24 +4250,25 @@
 !
 !-- Local variables:
-    INTEGER(iwp) ::  icb    !< Fixed child-grid index in the x-direction pointing to the node just behind the
+    INTEGER(iwp) ::  icb    !< fixed child-grid index in the x-direction pointing to the node just behind the
                             !< boundary-value node
-    INTEGER(iwp) ::  icbc   !< Fixed child-grid index in the x-direction pointing to the boundary-value nodes
-    INTEGER(iwp) ::  icbgp  !< Index running over the redundant boundary ghost points in the x-direction
+    INTEGER(iwp) ::  icbc   !< fixed child-grid index in the x-direction pointing to the boundary-value nodes
+    INTEGER(iwp) ::  icbgp  !< index running over the redundant boundary ghost points in the x-direction
     INTEGER(iwp) ::  ierr   !< MPI error code
-    INTEGER(iwp) ::  ipbeg  !< Parent-grid index in the x-direction pointing to the starting point of workarr_lr
+    INTEGER(iwp) ::  ipbeg  !< parent-grid index in the x-direction pointing to the starting point of workarr_lr
                             !< in the parent-grid array
-    INTEGER(iwp) ::  ipw    !< Reduced parent-grid index in the x-direction for workarr_lr pointing to
+    INTEGER(iwp) ::  ipw    !< reduced parent-grid index in the x-direction for workarr_lr pointing to
                             !< the boundary ghost node
-    INTEGER(iwp) ::  ipwp   !< Reduced parent-grid index in the x-direction for workarr_lr pointing to
+    INTEGER(iwp) ::  ipwp   !< reduced parent-grid index in the x-direction for workarr_lr pointing to
                             !< the first prognostic node
-    INTEGER(iwp) ::  jc     !< Running child-grid index in the y-direction
-    INTEGER(iwp) ::  jp     !< Running parent-grid index in the y-direction
-    INTEGER(iwp) ::  kc     !< Running child-grid index in the z-direction
-    INTEGER(iwp) ::  kp     !< Running parent-grid index in the z-direction
-
-    REAL(wp) ::  cb          !< Interpolation coefficient for the boundary ghost node
-    REAL(wp) ::  cp          !< Interpolation coefficient for the first prognostic node
-    REAL(wp) ::  c_interp_1  !< Value interpolated to the flux point in x direction from the parent-grid data
-    REAL(wp) ::  c_interp_2  !< Auxiliary value interpolated  to the flux point in x direction from the parent-grid data
+    INTEGER(iwp) ::  jc     !< running child-grid index in the y-direction
+    INTEGER(iwp) ::  jp     !< running parent-grid index in the y-direction
+    INTEGER(iwp) ::  kc     !< running child-grid index in the z-direction
+    INTEGER(iwp) ::  kp     !< running parent-grid index in the z-direction
+
+    REAL(wp) ::  cb          !< interpolation coefficient for the boundary ghost node
+    REAL(wp) ::  cp          !< interpolation coefficient for the first prognostic node
+    REAL(wp) ::  c_interp_1  !< value interpolated to the flux point in x direction from the parent-grid data
+    REAL(wp) ::  c_interp_2  !< auxiliary value interpolated  to the flux point in x direction from the parent-grid data
+    
 !
 !-- Check which edge is to be handled
@@ -4453,16 +4468,16 @@
     IMPLICIT NONE
 
-    CHARACTER(LEN=1), INTENT(IN) ::  edge  !< Edge symbol: 's' or 'n'
-    CHARACTER(LEN=1), INTENT(IN) ::  var   !< Variable symbol: 'u', 'v', 'w' or 's'
-
-    INTEGER(iwp), INTENT(IN) ::  kct  !< The parent-grid index in z-direction just below the boundary value node
-
-    INTEGER(iwp), DIMENSION(ipla:ipra), INTENT(IN) ::  ifl  !< Indicates start index of child cells belonging to certain
+    CHARACTER(LEN=1), INTENT(IN) ::  edge  !< edge symbol: 's' or 'n'
+    CHARACTER(LEN=1), INTENT(IN) ::  var   !< variable symbol: 'u', 'v', 'w' or 's'
+
+    INTEGER(iwp), INTENT(IN) ::  kct  !< the parent-grid index in z-direction just below the boundary value node
+
+    INTEGER(iwp), DIMENSION(ipla:ipra), INTENT(IN) ::  ifl  !< indicates start index of child cells belonging to certain
                                                             !< parent cell - x direction
-    INTEGER(iwp), DIMENSION(ipla:ipra), INTENT(IN) ::  ifu  !< Indicates end index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(ipla:ipra), INTENT(IN) ::  ifu  !< indicates end index of child cells belonging to certain
                                                             !< parent cell - x direction
-    INTEGER(iwp), DIMENSION(0:pg%nz+1), INTENT(IN) ::  kfl  !< Indicates start index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(0:pg%nz+1), INTENT(IN) ::  kfl  !< indicates start index of child cells belonging to certain
                                                             !< parent cell - z direction
-    INTEGER(iwp), DIMENSION(0:pg%nz+1), INTENT(IN) ::  kfu  !< Indicates end index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(0:pg%nz+1), INTENT(IN) ::  kfu  !< indicates end index of child cells belonging to certain
                                                             !< parent cell - z direction
 
@@ -4472,25 +4487,24 @@
 !
 !-- Local variables:
-    INTEGER(iwp) ::  ic     !< Running child-grid index in the x-direction
+    INTEGER(iwp) ::  ic     !< running child-grid index in the x-direction
     INTEGER(iwp) ::  ierr   !< MPI error code
-    INTEGER(iwp) ::  ip     !< Running parent-grid index in the x-direction
-    INTEGER(iwp) ::  jcb    !< Fixed child-grid index in the y-direction pointing to the node just behind the
+    INTEGER(iwp) ::  ip     !< running parent-grid index in the x-direction
+    INTEGER(iwp) ::  jcb    !< fixed child-grid index in the y-direction pointing to the node just behind the
                             !< boundary-value node
-    INTEGER(iwp) ::  jcbc   !< Fixed child-grid index in the y-direction pointing to the boundary-value nodes
-    INTEGER(iwp) ::  jcbgp  !< Index running over the redundant boundary ghost points in y-direction
-    INTEGER(iwp) ::  jpbeg  !< Parent-grid index in the y-direction pointing to the starting point of workarr_sn
+    INTEGER(iwp) ::  jcbc   !< fixed child-grid index in the y-direction pointing to the boundary-value nodes
+    INTEGER(iwp) ::  jcbgp  !< index running over the redundant boundary ghost points in y-direction
+    INTEGER(iwp) ::  jpbeg  !< parent-grid index in the y-direction pointing to the starting point of workarr_sn
                             !< in the parent-grid array
-    INTEGER(iwp) ::  jpw    !< Reduced parent-grid index in the y-direction for workarr_sn pointing to
+    INTEGER(iwp) ::  jpw    !< reduced parent-grid index in the y-direction for workarr_sn pointing to
                             !< the boundary ghost node
-    INTEGER(iwp) ::  jpwp   !< Reduced parent-grid index in the y-direction for workarr_sn pointing to
+    INTEGER(iwp) ::  jpwp   !< reduced parent-grid index in the y-direction for workarr_sn pointing to
                             !< the first prognostic node
-    INTEGER(iwp) ::  kc     !< Running child-grid index in the z-direction
-    INTEGER(iwp) ::  kp     !< Running parent-grid index in the z-direction
-
-    REAL(wp) ::  cb          !< Interpolation coefficient for the boundary ghost node
-    REAL(wp) ::  cp          !< Interpolation coefficient for the first prognostic node
-    REAL(wp) ::  c_interp_1  !< Value interpolated to the flux point in x direction from the parent-grid data
-    REAL(wp) ::  c_interp_2  !< Auxiliary value interpolated  to the flux point in x direction from the parent-grid data
-
+    INTEGER(iwp) ::  kc     !< running child-grid index in the z-direction
+    INTEGER(iwp) ::  kp     !< running parent-grid index in the z-direction
+
+    REAL(wp) ::  cb          !< interpolation coefficient for the boundary ghost node
+    REAL(wp) ::  cp          !< interpolation coefficient for the first prognostic node
+    REAL(wp) ::  c_interp_1  !< value interpolated to the flux point in x direction from the parent-grid data
+    REAL(wp) ::  c_interp_2  !< auxiliary value interpolated  to the flux point in x direction from the parent-grid data
 
 !
@@ -4692,15 +4706,15 @@
     IMPLICIT NONE
 
-    CHARACTER(LEN=1), INTENT(IN) ::  var  !< Variable symbol: 'u', 'v', 'w' or 's'
-
-    INTEGER(iwp), INTENT(IN) ::  kct  !< The parent-grid index in z-direction just below the boundary value node
-
-    INTEGER(iwp), DIMENSION(ipla:ipra), INTENT(IN) ::  ifl  !< Indicates start index of child cells belonging to certain
+    CHARACTER(LEN=1), INTENT(IN) ::  var  !< variable symbol: 'u', 'v', 'w' or 's'
+
+    INTEGER(iwp), INTENT(IN) ::  kct  !< the parent-grid index in z-direction just below the boundary value node
+
+    INTEGER(iwp), DIMENSION(ipla:ipra), INTENT(IN) ::  ifl  !< indicates start index of child cells belonging to certain
                                                             !< parent cell - x direction
-    INTEGER(iwp), DIMENSION(ipla:ipra), INTENT(IN) ::  ifu  !< Indicates end index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(ipla:ipra), INTENT(IN) ::  ifu  !< indicates end index of child cells belonging to certain
                                                             !< parent cell - x direction
-    INTEGER(iwp), DIMENSION(jpsa:jpna), INTENT(IN) ::  jfl  !< Indicates start index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(jpsa:jpna), INTENT(IN) ::  jfl  !< indicates start index of child cells belonging to certain
                                                             !< parent cell - y direction
-    INTEGER(iwp), DIMENSION(jpsa:jpna), INTENT(IN) ::  jfu  !< Indicates end index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(jpsa:jpna), INTENT(IN) ::  jfu  !< indicates end index of child cells belonging to certain
                                                             !< parent cell - y direction
 
@@ -4709,29 +4723,28 @@
     REAL(wp), DIMENSION(0:pg%nz+1,jps:jpn,ipl:ipr), INTENT(IN) ::  parent_array  !< Parent-grid array
 
-
 !
 !-- Local variables:
-    INTEGER(iwp) ::  ic          !< Running child-grid index in the x-direction
+    INTEGER(iwp) ::  ic          !< running child-grid index in the x-direction
     INTEGER(iwp) ::  ierr        !< MPI error code
-    INTEGER(iwp) ::  iplc        !< Lower parent-grid index limit in the x-direction for copying parent-grid
+    INTEGER(iwp) ::  iplc        !< lower parent-grid index limit in the x-direction for copying parent-grid
                                  !< array data to workarr_t
-    INTEGER(iwp) ::  iprc        !< Upper parent-grid index limit in the x-direction for copying parent-grid
+    INTEGER(iwp) ::  iprc        !< upper parent-grid index limit in the x-direction for copying parent-grid
                                  !< array data to workarr_t
-    INTEGER(iwp) ::  jc          !< Running child-grid index in the y-direction
-    INTEGER(iwp) ::  jpsc        !< Lower parent-grid index limit in the y-direction for copying parent-grid
+    INTEGER(iwp) ::  jc          !< running child-grid index in the y-direction
+    INTEGER(iwp) ::  jpsc        !< lower parent-grid index limit in the y-direction for copying parent-grid
                                  !< array data to workarr_t
-    INTEGER(iwp) ::  jpnc        !< Upper parent-grid-index limit in the y-direction for copying parent-grid
+    INTEGER(iwp) ::  jpnc        !< upper parent-grid-index limit in the y-direction for copying parent-grid
                                  !< array data to workarr_t
-    INTEGER(iwp) ::  kc          !< Vertical child-grid index fixed to the boundary-value level
-    INTEGER(iwp) ::  ip          !< Running parent-grid index in the x-direction
-    INTEGER(iwp) ::  jp          !< Running parent-grid index in the y-direction
-    INTEGER(iwp) ::  kpw         !< Reduced parent-grid index in the z-direction for workarr_t pointing to
+    INTEGER(iwp) ::  kc          !< vertical child-grid index fixed to the boundary-value level
+    INTEGER(iwp) ::  ip          !< running parent-grid index in the x-direction
+    INTEGER(iwp) ::  jp          !< running parent-grid index in the y-direction
+    INTEGER(iwp) ::  kpw         !< reduced parent-grid index in the z-direction for workarr_t pointing to
                                  !< the boundary ghost node
 
-    REAL(wp) ::  c31         !< Interpolation coefficient for the 3rd-order WS scheme
-    REAL(wp) ::  c32         !< Interpolation coefficient for the 3rd-order WS scheme
-    REAL(wp) ::  c33         !< Interpolation coefficient for the 3rd-order WS scheme
-    REAL(wp) ::  c_interp_1  !< Value interpolated to the flux point in z direction from the parent-grid data
-    REAL(wp) ::  c_interp_2  !< Auxiliary value interpolated to the flux point in z direction from the parent-grid data
+    REAL(wp) ::  c31         !< interpolation coefficient for the 3rd-order WS scheme
+    REAL(wp) ::  c32         !< interpolation coefficient for the 3rd-order WS scheme
+    REAL(wp) ::  c33         !< interpolation coefficient for the 3rd-order WS scheme
+    REAL(wp) ::  c_interp_1  !< value interpolated to the flux point in z direction from the parent-grid data
+    REAL(wp) ::  c_interp_2  !< auxiliary value interpolated to the flux point in z direction from the parent-grid data
 
 
@@ -4964,43 +4977,43 @@
     IMPLICIT NONE
 
-    CHARACTER(LEN=*), INTENT(IN) ::  var  !< Variable symbol: 'u', 'v', 'w' or 's'
-
-    INTEGER(iwp), INTENT(IN) ::  kct  !< Top boundary index for anterpolation along z
+    CHARACTER(LEN=*), INTENT(IN) ::  var  !< variable symbol: 'u', 'v', 'w' or 's'
+
+    INTEGER(iwp), INTENT(IN) ::  kct  !< top boundary index for anterpolation along z
 
     INTEGER(iwp), DIMENSION(0:pg%nz+1,jpsa:jpna,ipla:ipra), INTENT(IN) ::  ijkfc  !< number of child grid points contributing
                                                                                   !< to a parent grid box
-    INTEGER(iwp), DIMENSION(ipla:ipra), INTENT(IN) ::  ifl  !< Indicates start index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(ipla:ipra), INTENT(IN) ::  ifl  !< indicates start index of child cells belonging to certain
                                                             !< parent cell - x direction
-    INTEGER(iwp), DIMENSION(ipla:ipra), INTENT(IN) ::  ifu  !< Indicates end index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(ipla:ipra), INTENT(IN) ::  ifu  !< indicates end index of child cells belonging to certain
                                                             !< parent cell - x direction
-    INTEGER(iwp), DIMENSION(jpsa:jpna), INTENT(IN) ::  jfl  !< Indicates start index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(jpsa:jpna), INTENT(IN) ::  jfl  !< indicates start index of child cells belonging to certain
                                                             !< parent cell - y direction
-    INTEGER(iwp), DIMENSION(jpsa:jpna), INTENT(IN) ::  jfu  !< Indicates end index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(jpsa:jpna), INTENT(IN) ::  jfu  !< indicates end index of child cells belonging to certain
                                                             !< parent cell - y direction
-    INTEGER(iwp), DIMENSION(0:pg%nz+1), INTENT(IN) ::  kfl  !< Indicates start index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(0:pg%nz+1), INTENT(IN) ::  kfl  !< indicates start index of child cells belonging to certain
                                                             !< parent cell - z direction
-    INTEGER(iwp), DIMENSION(0:pg%nz+1), INTENT(IN) ::  kfu  !< Indicates end index of child cells belonging to certain
+    INTEGER(iwp), DIMENSION(0:pg%nz+1), INTENT(IN) ::  kfu  !< indicates end index of child cells belonging to certain
                                                             !< parent cell - z direction
 
-    REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg), INTENT(IN) ::  child_array  !< Child-grid array
-
-    REAL(wp), DIMENSION(0:pg%nz+1,jps:jpn,ipl:ipr), INTENT(INOUT) ::  parent_array  !< Parent-grid array
+    REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg), INTENT(IN) ::  child_array  !< child-grid array
+
+    REAL(wp), DIMENSION(0:pg%nz+1,jps:jpn,ipl:ipr), INTENT(INOUT) ::  parent_array  !< parent-grid array
 
 !
 !-- Local variables:
-    INTEGER(iwp) ::  ic              !< Running index x-direction - child grid
-    INTEGER(iwp) ::  ip              !< Running index x-direction - parent grid
-    INTEGER(iwp) ::  ipl_anterp      !< Left boundary index for anterpolation along x
-    INTEGER(iwp) ::  ipr_anterp      !< Right boundary index for anterpolation along x
-    INTEGER(iwp) ::  jc              !< Running index y-direction - child grid
-    INTEGER(iwp) ::  jp              !< Running index y-direction - parent grid
-    INTEGER(iwp) ::  jpn_anterp      !< North boundary index for anterpolation along y
-    INTEGER(iwp) ::  jps_anterp      !< South boundary index for anterpolation along y
-    INTEGER(iwp) ::  kc              !< Running index z-direction - child grid
-    INTEGER(iwp) ::  kp              !< Running index z-direction - parent grid
-    INTEGER(iwp) ::  kpt_anterp      !< Top boundary index for anterpolation along z
+    INTEGER(iwp) ::  ic              !< running index x-direction - child grid
+    INTEGER(iwp) ::  ip              !< running index x-direction - parent grid
+    INTEGER(iwp) ::  ipl_anterp      !< left boundary index for anterpolation along x
+    INTEGER(iwp) ::  ipr_anterp      !< right boundary index for anterpolation along x
+    INTEGER(iwp) ::  jc              !< running index y-direction - child grid
+    INTEGER(iwp) ::  jp              !< running index y-direction - parent grid
+    INTEGER(iwp) ::  jpn_anterp      !< north boundary index for anterpolation along y
+    INTEGER(iwp) ::  jps_anterp      !< south boundary index for anterpolation along y
+    INTEGER(iwp) ::  kc              !< running index z-direction - child grid
+    INTEGER(iwp) ::  kp              !< running index z-direction - parent grid
+    INTEGER(iwp) ::  kpt_anterp      !< top boundary index for anterpolation along z
     INTEGER(iwp) ::  var_flag        !< bit number used to flag topography on respective grid
 
-    REAL(wp) ::  cellsum  !< Sum of respective child cells belonging to parent cell
+    REAL(wp) ::  cellsum  !< sum of respective child cells belonging to parent cell
 
 !
@@ -5092,12 +5105,12 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  ic  !< Index along x-direction
-    INTEGER(iwp) ::  jc  !< Index along y-direction
-    INTEGER(iwp) ::  kc  !< Index along z-direction
-    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) ::  m   !< Running index for surface type
-    INTEGER(iwp) ::  n   !< Running index for number of chemical species
+    INTEGER(iwp) ::  ic  !< index along x-direction
+    INTEGER(iwp) ::  jc  !< index along y-direction
+    INTEGER(iwp) ::  kc  !< index along z-direction
+    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) ::  m   !< running index for surface type
+    INTEGER(iwp) ::  n   !< running index for number of chemical species
 
 
@@ -5307,23 +5320,22 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i     !< Running index in the x-direction
+    INTEGER(iwp) ::  i     !< running index in the x-direction
     INTEGER(iwp) ::  ierr  !< MPI error code
-    INTEGER(iwp) ::  j     !< Running index in the y-direction
-    INTEGER(iwp) ::  k     !< Running index in the z-direction
-    INTEGER(iwp) ::  n     !< Running index over the boundary faces: l, r, s, n and t
-
-    REAL(wp) ::  dxdy                  !< Surface area of grid cell top face
-    REAL(wp) ::  innor                 !< Inner normal vector of the grid cell face
-    REAL(wp) ::  sub_sum               !< Intermediate sum for reducing the loss of signifigant digits in 2-D summations
-    REAL(wp) ::  u_corr_left           !< Correction added to the left boundary value of u
-    REAL(wp) ::  u_corr_right          !< Correction added to the right boundary value of u
-    REAL(wp) ::  v_corr_south          !< Correction added to the south boundary value of v
-    REAL(wp) ::  v_corr_north          !< Correction added to the north boundary value of v
-    REAL(wp) ::  volume_flux_integral  !< Surface integral of volume flux over the domain boundaries
-    REAL(wp) ::  volume_flux_local     !< Surface integral of volume flux over the subdomain boundary face
-    REAL(wp) ::  w_corr_top            !< Correction added to the top boundary value of w
-
-    REAL(wp), DIMENSION(5) ::  volume_flux  !< Surface integral of volume flux over each boundary face of the domain
-
+    INTEGER(iwp) ::  j     !< running index in the y-direction
+    INTEGER(iwp) ::  k     !< running index in the z-direction
+    INTEGER(iwp) ::  n     !< running index over the boundary faces: l, r, s, n and t
+
+    REAL(wp) ::  dxdy                  !< surface area of grid cell top face
+    REAL(wp) ::  innor                 !< inner normal vector of the grid cell face
+    REAL(wp) ::  sub_sum               !< intermediate sum for reducing the loss of signifigant digits in 2-D summations
+    REAL(wp) ::  u_corr_left           !< correction added to the left boundary value of u
+    REAL(wp) ::  u_corr_right          !< correction added to the right boundary value of u
+    REAL(wp) ::  v_corr_south          !< correction added to the south boundary value of v
+    REAL(wp) ::  v_corr_north          !< correction added to the north boundary value of v
+    REAL(wp) ::  volume_flux_integral  !< surface integral of volume flux over the domain boundaries
+    REAL(wp) ::  volume_flux_local     !< surface integral of volume flux over the subdomain boundary face
+    REAL(wp) ::  w_corr_top            !< correction added to the top boundary value of w
+
+    REAL(wp), DIMENSION(5) ::  volume_flux  !< surface integral of volume flux over each boundary face of the domain
 
 !
@@ -5534,15 +5546,15 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i     !< Running index in the x-direction
+    INTEGER(iwp) ::  i     !< running index in the x-direction
     INTEGER(iwp) ::  ierr  !< MPI error code
-    INTEGER(iwp) ::  j     !< Running index in the y-direction
-    INTEGER(iwp) ::  k     !< Running index in the z-direction
-
-    REAL(wp) ::  dxdy               !< Surface area of grid cell top face
-    REAL(wp) ::  sub_sum            !< Intermediate sum for reducing the loss of signifigant digits in 2-D summations
-    REAL(wp) ::  top_area           !< Top boundary face area
-    REAL(wp) ::  volume_flux        !< Surface integral of volume flux over the top boundary face
-    REAL(wp) ::  volume_flux_local  !< Surface integral of volume flux over the subdomain boundary face
-    REAL(wp) ::  w_corr_top         !< Correction added to the top boundary value of w
+    INTEGER(iwp) ::  j     !< running index in the y-direction
+    INTEGER(iwp) ::  k     !< running index in the z-direction
+
+    REAL(wp) ::  dxdy               !< surface area of grid cell top face
+    REAL(wp) ::  sub_sum            !< intermediate sum for reducing the loss of signifigant digits in 2-D summations
+    REAL(wp) ::  top_area           !< top boundary face area
+    REAL(wp) ::  volume_flux        !< surface integral of volume flux over the top boundary face
+    REAL(wp) ::  volume_flux_local  !< surface integral of volume flux over the subdomain boundary face
+    REAL(wp) ::  w_corr_top         !< correction added to the top boundary value of w
 
 
Index: /palm/trunk/SOURCE/pmc_particle_interface.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_particle_interface.f90	(revision 4882)
+++ /palm/trunk/SOURCE/pmc_particle_interface.f90	(revision 4883)
@@ -1,3 +1,2 @@
-MODULE pmc_particle_interface
 !--------------------------------------------------------------------------------------------------!
 ! This file is part of the PALM model system.
@@ -25,4 +24,7 @@
 ! -----------------
 ! $Id$
+! User switch for particle coupling added. Some code reformatting according to follow PALM coding standard.
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! File re-formatted to follow the PALM coding standard
 !
@@ -59,167 +61,161 @@
 ! Interface to palm lpm model to handel particle transfer between parent and child model.
 !--------------------------------------------------------------------------------------------------!
-#if defined( __parallel )
-
-   USE, INTRINSIC ::  ISO_C_BINDING
-
-   USE MPI
-
-   USE kinds
-
-   USE pegrid,                                                                                     &
-       ONLY: myidx,                                                                                &
-             myidy
-
-   USE indices,                                                                                    &
-       ONLY: nbgp,                                                                                 &
-             nx,                                                                                   &
-             nxl,                                                                                  &
-             nxr,                                                                                  &
-             nxlg,                                                                                 &
-             nxrg,                                                                                 &
-             ny,                                                                                   &
-             nys,                                                                                  &
-             nyn,                                                                                  &
-             nysg,                                                                                 &
-             nyng,                                                                                 &
-             nzb,                                                                                  &
-             nzt
-
-
-   USE grid_variables,                                                                             &
-       ONLY:  dx,                                                                                  &
-              dy
-
-   USE arrays_3d,                                                                                  &
-        ONLY: zw
-
-   USE control_parameters,                                                                         &
-       ONLY:  message_string
-
-   USE particle_attributes,                                                                        &
-       ONLY:  alloc_factor,                                                                        &
-              grid_particles,                                                                      &
-              ibc_par_lr,                                                                          &
-              ibc_par_ns,                                                                          &
-              ibc_par_t,                                                                           &
-              particles,                                                                           &
-              particle_type,                                                                       &
-              prt_count,                                                                           &
-              number_of_particles,                                                                 &
-              zero_particle
-
-
-
-
-
-!    USE lpm_pack_and_sort_mod
-
-#if defined( __parallel )
-   USE pmc_general,                                                                                &
-       ONLY: pedef
-
-   USE pmc_parent,                                                                                 &
-       ONLY: children,                                                                             &
-             pmc_s_fillbuffer,                                                                     &
-             pmc_s_getdata_from_buffer,                                                            &
-             pmc_s_get_child_npes
-
-   USE pmc_child,                                                                                  &
-       ONLY:  me,                                                                                  &
-              pmc_c_getbuffer,                                                                     &
-              pmc_c_putbuffer
-
-   USE pmc_interface,                                                                              &
-       ONLY:  coord_x,                                                                             &
-              coord_y,                                                                             &
-              cpl_id,                                                                              &
-              get_childid,                                                                         &
-              get_child_edges,                                                                     &
-              get_child_gridspacing,                                                               &
-              get_number_of_children,                                                              &
-              lower_left_coord_x,                                                                  &
-              lower_left_coord_y,                                                                  &
-              nr_part,                                                                             &
-              nr_partc,                                                                            &
-              parent_bound,                                                                        &
-              part_adr,                                                                            &
-              part_adrc,                                                                           &
-              pg,                                                                                  &
-              nested_run
-
-
-    USE pmc_handle_communicator,                                                                   &
-        ONLY:  pmc_parent_for_child
-
-   USE pmc_mpi_wrapper,                                                                            &
-       ONLY:   pmc_recv_from_child,                                                                &
-               pmc_send_to_parent
-
-#endif
-
-   IMPLICIT NONE
-
-
-   PRIVATE
-   SAVE
-
-   TYPE  coarse_particle_def
-      INTEGER(iwp) ::  nr_particle  !<
-
-      TYPE(particle_type),ALLOCATABLE,DIMENSION(:) ::  parent_particles  !<
-   END TYPE  coarse_particle_def
-
-   INTEGER(iwp),PARAMETER ::  max_nr_particle_in_rma_win = 100000  !<
-   INTEGER(iwp),PARAMETER ::  min_particles_per_column   = 100     !<
-
-
-   INTEGER(iwp) ::  nr_fine_in_coarse   !< Number of fine grid cells in coarse grid (one direction)
-   INTEGER(iwp) ::  particle_win_child  !<
-
-   INTEGER(iwp),ALLOCATABLE,DIMENSION(:) ::  particle_win_parent  !<
-
-   TYPE(C_PTR), ALLOCATABLE,DIMENSION(:) ::  buf_ptr  !<
-
-   TYPE(particle_type), DIMENSION(:),POINTER ::  particle_in_win  !<
-
-   TYPE(coarse_particle_def),ALLOCATABLE,DIMENSION(:,:) ::  coarse_particles  !<
-
-
-
-   INTERFACE pmcp_g_init
-      MODULE PROCEDURE pmcp_g_init
-   END  INTERFACE pmcp_g_init
-
-   INTERFACE pmcp_g_alloc_win
-      MODULE PROCEDURE pmcp_g_alloc_win
-   END  INTERFACE pmcp_g_alloc_win
-
-   INTERFACE pmcp_c_get_particle_from_parent
-      MODULE PROCEDURE pmcp_c_get_particle_from_parent
-   END  INTERFACE pmcp_c_get_particle_from_parent
-
-   INTERFACE pmcp_c_send_particle_to_parent
-      MODULE PROCEDURE pmcp_c_send_particle_to_parent
-   END  INTERFACE pmcp_c_send_particle_to_parent
-
-   INTERFACE pmcp_p_fill_particle_win
-      MODULE PROCEDURE pmcp_p_fill_particle_win
-   END  INTERFACE pmcp_p_fill_particle_win
-
-   INTERFACE pmcp_p_empty_particle_win
-      MODULE PROCEDURE pmcp_p_empty_particle_win
-   END  INTERFACE pmcp_p_empty_particle_win
-
-   INTERFACE pmcp_g_print_number_of_particles
-      MODULE PROCEDURE pmcp_g_print_number_of_particles
-   END  INTERFACE pmcp_g_print_number_of_particles
-
-   INTERFACE pmcp_p_delete_particles_in_fine_grid_area
-      MODULE PROCEDURE pmcp_p_delete_particles_in_fine_grid_area
-   END  INTERFACE pmcp_p_delete_particles_in_fine_grid_area
-
-   PUBLIC pmcp_g_init, pmcp_g_alloc_win, pmcp_c_get_particle_from_parent
-   PUBLIC pmcp_c_send_particle_to_parent, pmcp_p_fill_particle_win, pmcp_g_print_number_of_particles
-   PUBLIC pmcp_p_empty_particle_win, pmcp_p_delete_particles_in_fine_grid_area
+ MODULE pmc_particle_interface
+  
+#if defined( __parallel )
+
+    USE, INTRINSIC ::  ISO_C_BINDING
+
+    USE MPI
+
+    USE kinds
+
+    USE pegrid,                                                                                     &
+         ONLY: myidx,                                                                               &
+               myidy
+
+    USE indices,                                                                                    &
+         ONLY: nbgp,                                                                                &
+               nx,                                                                                  &
+               nxl,                                                                                 &
+               nxr,                                                                                 &
+               nxlg,                                                                                &
+               nxrg,                                                                                &
+               ny,                                                                                  &
+               nys,                                                                                 &
+               nyn,                                                                                 &
+               nysg,                                                                                &
+               nyng,                                                                                &
+               nzb,                                                                                 &
+               nzt
+
+    USE grid_variables,                                                                             &
+         ONLY:  dx,                                                                                 &
+                dy
+
+    USE arrays_3d,                                                                                  &
+         ONLY: zw
+
+    USE control_parameters,                                                                         &
+         ONLY:  message_string
+
+    USE particle_attributes,                                                                        &
+         ONLY:  alloc_factor,                                                                       &
+                grid_particles,                                                                     &
+                ibc_par_lr,                                                                         &
+                ibc_par_ns,                                                                         &
+                ibc_par_t,                                                                          &
+                particles,                                                                          &
+                particle_type,                                                                      &
+                prt_count,                                                                          &
+                number_of_particles,                                                                &
+                zero_particle
+
+!     USE lpm_pack_and_sort_mod
+
+#if defined( __parallel )
+    USE pmc_general,                                                                                &
+         ONLY: pedef
+
+    USE pmc_parent,                                                                                 &
+         ONLY: children,                                                                            &
+               pmc_s_fillbuffer,                                                                    &
+               pmc_s_getdata_from_buffer,                                                           &
+               pmc_s_get_child_npes
+
+    USE pmc_child,                                                                                  &
+         ONLY:  me,                                                                                 &
+                pmc_c_getbuffer,                                                                    &
+                pmc_c_putbuffer
+
+    USE pmc_interface,                                                                              &
+         ONLY:  coord_x,                                                                            &
+                coord_y,                                                                            &
+                cpl_id,                                                                             &
+                get_childid,                                                                        &
+                get_child_edges,                                                                    &
+                get_child_gridspacing,                                                              &
+                get_number_of_children,                                                             &
+                lower_left_coord_x,                                                                 &
+                lower_left_coord_y,                                                                 &
+                nested_run,                                                                         &
+                nr_part,                                                                            &
+                nr_partc,                                                                           &
+                parent_bound,                                                                       &
+                particle_coupling,                                                                  &
+                part_adr,                                                                           &
+                part_adrc,                                                                          &
+                pg
+
+    USE pmc_handle_communicator,                                                                    &
+         ONLY:  pmc_parent_for_child
+
+    USE pmc_mpi_wrapper,                                                                            &
+         ONLY:   pmc_recv_from_child,                                                               &
+                pmc_send_to_parent
+
+#endif
+
+    IMPLICIT NONE
+
+    PRIVATE
+    SAVE
+
+    TYPE  coarse_particle_def
+       INTEGER(iwp) ::  nr_particle  !<
+
+       TYPE(particle_type),ALLOCATABLE,DIMENSION(:) ::  parent_particles  !<
+    END TYPE  coarse_particle_def
+
+    INTEGER(iwp),PARAMETER ::  max_nr_particle_in_rma_win = 100000  !<
+    INTEGER(iwp),PARAMETER ::  min_particles_per_column   = 100     !<
+
+
+    INTEGER(iwp) ::  nr_fine_in_coarse   !< Number of fine grid cells in coarse grid (one direction)
+    INTEGER(iwp) ::  particle_win_child  !<
+
+    INTEGER(iwp),ALLOCATABLE,DIMENSION(:) ::  particle_win_parent  !<
+
+    TYPE(C_PTR), ALLOCATABLE,DIMENSION(:) ::  buf_ptr  !<
+
+    TYPE(particle_type), DIMENSION(:),POINTER ::  particle_in_win  !<
+
+    TYPE(coarse_particle_def),ALLOCATABLE,DIMENSION(:,:) ::  coarse_particles  !<
+
+    INTERFACE pmcp_g_init
+       MODULE PROCEDURE pmcp_g_init
+    END  INTERFACE pmcp_g_init
+   
+    INTERFACE pmcp_g_alloc_win
+       MODULE PROCEDURE pmcp_g_alloc_win
+    END  INTERFACE pmcp_g_alloc_win
+
+    INTERFACE pmcp_c_get_particle_from_parent
+       MODULE PROCEDURE pmcp_c_get_particle_from_parent
+    END  INTERFACE pmcp_c_get_particle_from_parent
+
+    INTERFACE pmcp_c_send_particle_to_parent
+       MODULE PROCEDURE pmcp_c_send_particle_to_parent
+    END  INTERFACE pmcp_c_send_particle_to_parent
+
+    INTERFACE pmcp_p_fill_particle_win
+       MODULE PROCEDURE pmcp_p_fill_particle_win
+    END  INTERFACE pmcp_p_fill_particle_win
+
+    INTERFACE pmcp_p_empty_particle_win
+       MODULE PROCEDURE pmcp_p_empty_particle_win
+    END  INTERFACE pmcp_p_empty_particle_win
+    
+    INTERFACE pmcp_g_print_number_of_particles
+       MODULE PROCEDURE pmcp_g_print_number_of_particles
+    END  INTERFACE pmcp_g_print_number_of_particles
+
+    INTERFACE pmcp_p_delete_particles_in_fine_grid_area
+       MODULE PROCEDURE pmcp_p_delete_particles_in_fine_grid_area
+    END  INTERFACE pmcp_p_delete_particles_in_fine_grid_area
+
+    PUBLIC pmcp_g_init, pmcp_g_alloc_win, pmcp_c_get_particle_from_parent
+    PUBLIC pmcp_c_send_particle_to_parent, pmcp_p_fill_particle_win, pmcp_g_print_number_of_particles
+    PUBLIC pmcp_p_empty_particle_win, pmcp_p_delete_particles_in_fine_grid_area
 
  CONTAINS
@@ -249,31 +245,33 @@
        part_adr = 0
     ENDIF
-
 !
 !-- Set the boundary conditions to nested for all non root (i.e child) models
     IF ( cpl_id > 1 )  THEN
-
-       IF ( ibc_par_t /= 3 )  THEN
-          ibc_par_t  = 3
-          message_string = 'In Child model:  ibc_par_t is automatically set to nested '
-          CALL message( 'pmcp_g_init ', 'PA0477', 0, 1, 0, 6, 0 )
+       IF ( particle_coupling )  THEN
+          IF ( ibc_par_t /= 3 )  THEN
+             ibc_par_t  = 3
+             message_string = 'In Child model:  ibc_par_t is automatically set to nested '
+             CALL message( 'pmcp_g_init ', 'PA0477', 0, 1, 0, 6, 0 )
+          ENDIF
+
+          IF ( ibc_par_lr /= 3 )  THEN
+             ibc_par_lr = 3
+             message_string = 'In Child model:  ibc_par_lr is automatically set to nested '
+             CALL message( 'pmcp_g_init ', 'PA0478', 0, 1, 0, 6, 0 )
+          ENDIF
+
+          IF ( ibc_par_ns /= 3 )  THEN
+             ibc_par_ns = 3
+             message_string = 'In Child model:  ibc_par_ns is automatically set to nested '
+             CALL message( 'pmcp_g_init ', 'PA0479', 0, 1, 0, 6, 0 )
+          ENDIF
        ENDIF
 
-       IF ( ibc_par_lr /= 3 )  THEN
-          ibc_par_lr = 3
-          message_string = 'In Child model:  ibc_par_lr is automatically set to nested '
-          CALL message( 'pmcp_g_init ', 'PA0478', 0, 1, 0, 6, 0 )
-       ENDIF
-
-       IF ( ibc_par_ns /= 3 )  THEN
-          ibc_par_ns = 3
-          message_string = 'In Child model:  ibc_par_ns is automatically set to nested '
-          CALL message( 'pmcp_g_init ', 'PA0479', 0, 1, 0, 6, 0 )
-       ENDIF
-
     ENDIF
 
 #endif
  END SUBROUTINE pmcp_g_init
+
+  
 !--------------------------------------------------------------------------------------------------!
 ! Description:
