Index: palm/trunk/SOURCE/pmc_general_mod.f90
===================================================================
--- palm/trunk/SOURCE/pmc_general_mod.f90	(revision 4829)
+++ palm/trunk/SOURCE/pmc_general_mod.f90	(revision 4830)
@@ -1,4 +1,3 @@
- MODULE pmc_general
-
+!> @file pmc_general_mod.f90
 !--------------------------------------------------------------------------------------------------!
 ! This file is part of the PALM model system.
@@ -18,5 +17,4 @@
 !--------------------------------------------------------------------------------------------------!
 !
-!
 ! Current revisions:
 ! -----------------
@@ -26,4 +24,7 @@
 ! -----------------
 ! $Id$
+! Reformatted to follow PALM coding standard
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! Interface pmc_sort removed. Subroutine description added.
 !
@@ -48,9 +49,13 @@
 ! Initial revision by K. Ketelsen
 !
+! Authors:
+! --------
+!> @author Klaus Ketelsen (no affiliation)
+!
 ! Description:
 ! ------------
-!
-! Structure definition and utilities of Palm Model Coupler
+!> Structure definition and utilities of Palm Model Coupler
 !--------------------------------------------------------------------------------------------------!
+ MODULE pmc_general
 
 #if defined( __parallel )
@@ -61,27 +66,23 @@
     USE MPI
 
+
     IMPLICIT NONE
 
-
-    PRIVATE
-    SAVE
-
-    INTEGER(iwp), PARAMETER, PUBLIC :: da_desclen       =  8  !<
-    INTEGER(iwp), PARAMETER, PUBLIC :: da_namelen       = 16  !<
-    INTEGER(iwp), PARAMETER, PUBLIC :: pmc_da_name_err  = 10  !<
-    INTEGER(iwp), PARAMETER, PUBLIC :: pmc_max_models   = 64  !<
-    INTEGER(iwp), PARAMETER, PUBLIC :: pmc_status_ok    =  0  !<
-    INTEGER(iwp), PARAMETER, PUBLIC :: pmc_status_error = -1  !<
-
-    INTEGER(iwp), PUBLIC ::  pmc_max_array  !< max # of arrays which can be coupled
-                                            !< - will be determined dynamically in pmc_interface
-
-
-    TYPE, PUBLIC :: xy_ind  !< pair of indices in horizontal plane
-       INTEGER(iwp) ::  i
-       INTEGER(iwp) ::  j
+    INTEGER(iwp) ::  pmc_max_array  !< max # of arrays which can be coupled
+                                    !< - will be determined dynamically in pmc_interface
+
+    INTEGER(iwp), PARAMETER ::  da_desclen       =  8  !<
+    INTEGER(iwp), PARAMETER ::  da_namelen       = 16  !<
+    INTEGER(iwp), PARAMETER ::  pmc_da_name_err  = 10  !<
+    INTEGER(iwp), PARAMETER ::  pmc_max_models   = 64  !<
+    INTEGER(iwp), PARAMETER ::  pmc_status_ok    =  0  !<
+    INTEGER(iwp), PARAMETER ::  pmc_status_error = -1  !<
+
+    TYPE ::  xy_ind  !< pair of indices in horizontal plane
+       INTEGER(iwp) ::  i  !<
+       INTEGER(iwp) ::  j  !<
     END TYPE
 
-    TYPE, PUBLIC ::  arraydef
+    TYPE ::  arraydef
        CHARACTER(LEN=da_namelen) ::  Name  !< name of array
 
@@ -91,7 +92,6 @@
        INTEGER(iwp) ::  RecvSize     !< size in receive buffer
        INTEGER(iwp) ::  SendSize     !< size in send buffer
-
-       INTEGER(idp) ::  RecvIndex  !< index in receive buffer
-       INTEGER(idp) ::  SendIndex  !< index in send buffer
+       INTEGER(idp) ::  RecvIndex    !< index in receive buffer
+       INTEGER(idp) ::  SendIndex    !< index in send buffer
 
        INTEGER(iwp), DIMENSION(4) ::  a_dim  !< size of dimensions
@@ -107,38 +107,61 @@
     END TYPE arraydef
 
-
-    TYPE(arraydef), PUBLIC, POINTER  :: next  !<
-
-
-    TYPE, PUBLIC ::  pedef
-       INTEGER(iwp) :: nr_arrays = 0  !< number of arrays which will be transfered
-       INTEGER(iwp) :: nrele          !< number of elements, same for all arrays
+    TYPE ::  pedef
+       INTEGER(iwp) ::  nr_arrays = 0  !< number of arrays which will be transfered
+       INTEGER(iwp) ::  nrele          !< number of elements, same for all arrays
 
        TYPE(arraydef), POINTER, DIMENSION(:) ::  array_list  !< list of data arrays to be transfered
-       TYPE(xy_ind), POINTER, DIMENSION(:)   ::  locInd      !< xy index local array for remote PE
+
+       TYPE(xy_ind), POINTER, DIMENSION(:) ::  locInd  !< xy index local array for remote PE
     END TYPE pedef
 
-
-    TYPE, PUBLIC ::  childdef
-       INTEGER(iwp) ::  inter_comm         !< inter communicator model and child
-       INTEGER(iwp) ::  inter_npes         !< number of PEs child model
-       INTEGER(iwp) ::  intra_comm         !< intra communicator model and child
-       INTEGER(iwp) ::  intra_rank         !< rank within intra_comm
-       INTEGER(iwp) ::  model_comm         !< communicator of this model
-       INTEGER(iwp) ::  model_npes         !< number of PEs this model
-       INTEGER(iwp) ::  model_rank         !< rank of this model
-       INTEGER(idp) ::  totalbuffersize    !<
-       INTEGER(iwp) ::  win_parent_child   !< MPI RMA for preparing data on parent AND child side
+    TYPE ::  childdef
+       INTEGER(iwp) ::  inter_comm        !< inter communicator model and child
+       INTEGER(iwp) ::  inter_npes        !< number of PEs child model
+       INTEGER(iwp) ::  intra_comm        !< intra communicator model and child
+       INTEGER(iwp) ::  intra_rank        !< rank within intra_comm
+       INTEGER(iwp) ::  model_comm        !< communicator of this model
+       INTEGER(iwp) ::  model_npes        !< number of PEs this model
+       INTEGER(iwp) ::  model_rank        !< rank of this model
+       INTEGER(idp) ::  totalbuffersize   !<
+       INTEGER(iwp) ::  win_parent_child  !< MPI RMA for preparing data on parent AND child side
+
        TYPE(pedef), DIMENSION(:), POINTER ::  pes  !< list of all child PEs
     END TYPE childdef
 
-
-    TYPE, PUBLIC ::  da_namedef  !< data array name definition
+    TYPE ::  da_namedef  !< data array name definition
        CHARACTER(LEN=da_desclen) ::  childdesc     !< child array description
        CHARACTER(LEN=da_namelen) ::  nameonchild   !< name of array within child
        CHARACTER(LEN=da_namelen) ::  nameonparent  !< name of array within parent
        CHARACTER(LEN=da_desclen) ::  parentdesc    !< parent array description
-       INTEGER(iwp)              ::  couple_index  !< unique number of array
+
+       INTEGER(iwp) ::  couple_index  !< unique number of array
     END TYPE da_namedef
+
+    TYPE(arraydef), POINTER ::  next  !<
+
+    SAVE
+
+    PRIVATE
+
+!
+!-- Public functions
+    PUBLIC pmc_g_setname
+
+!
+!-- Public variables, constants and types
+    PUBLIC arraydef,                                                                               &
+           childdef,                                                                               &
+           da_desclen,                                                                             &
+           da_namedef,                                                                             &
+           da_namelen,                                                                             &
+           next,                                                                                   &
+           pedef,                                                                                  &
+           pmc_da_name_err,                                                                        &
+           pmc_max_array,                                                                          &
+           pmc_max_models,                                                                         &
+           pmc_status_error,                                                                       &
+           pmc_status_ok,                                                                          &
+           xy_ind
 
     INTERFACE pmc_g_setname
@@ -146,7 +169,7 @@
     END INTERFACE pmc_g_setname
 
-    PUBLIC pmc_g_setname
 
  CONTAINS
+
 
 !---------------------------------------------------------------------------------------------------!
@@ -157,15 +180,14 @@
  SUBROUTINE pmc_g_setname( mychild, couple_index, aname )
 
-    IMPLICIT NONE
-
-    CHARACTER(LEN=*)              ::  aname         !<
-
-    INTEGER(iwp), INTENT(IN)      ::  couple_index  !<
+    CHARACTER(LEN=*), INTENT(IN) ::  aname  !<
 
     INTEGER(iwp) ::  i  !<
 
-    TYPE(childdef), INTENT(INOUT) ::  mychild       !<
-
-    TYPE(pedef), POINTER    ::  ape  !<
+    INTEGER(iwp), INTENT(IN) ::  couple_index  !<
+
+    TYPE(childdef), INTENT(INOUT) ::  mychild  !<
+
+    TYPE(pedef), POINTER ::  ape  !<
+
 
 !
@@ -180,5 +202,6 @@
 
  END SUBROUTINE pmc_g_setname
-
 #endif
+
+
  END MODULE pmc_general
Index: palm/trunk/SOURCE/pmc_parent_mod.f90
===================================================================
--- palm/trunk/SOURCE/pmc_parent_mod.f90	(revision 4829)
+++ palm/trunk/SOURCE/pmc_parent_mod.f90	(revision 4830)
@@ -1,3 +1,3 @@
- MODULE pmc_parent
+!> @file pmc_parent_mod.f90
 !--------------------------------------------------------------------------------------------------!
 ! This file is part of the PALM model system.
@@ -25,5 +25,8 @@
 ! -----------------
 ! $Id$
-! pmc_s_set_2d_index_list revised for accelerating the code. Subroutine 
+! Reformatted to follow PALM coding standard
+!
+! 4828 2021-01-05 11:21:41Z Giersch
+! pmc_s_set_2d_index_list revised for accelerating the code. Subroutine
 ! description added.
 !
@@ -54,9 +57,13 @@
 ! Initial revision by K. Ketelsen
 !
-!--------------------------------------------------------------------------------------------------!
+! Authors:
+! --------
+!> @author Klaus Ketelsen (no affiliation)
+!
 ! Description:
 ! ------------
 !> Parent part of Palm Model Coupler
 !--------------------------------------------------------------------------------------------------!
+ MODULE pmc_parent
 
 #if defined( __parallel )
@@ -66,4 +73,5 @@
 
     USE kinds
+
     USE pmc_general,                                                                               &
         ONLY: arraydef,                                                                            &
@@ -89,67 +97,31 @@
               pmc_time
 
-   IMPLICIT NONE
-
-
-   PRIVATE
-   SAVE
-
-   INTEGER ::  next_array_in_list = 0  !<
-
-   TYPE childindexdef
-      INTEGER                              ::  nrpoints       !<
-      INTEGER, DIMENSION(:,:), ALLOCATABLE ::  index_list_2d  !<
-   END TYPE childindexdef
-
-   TYPE(childdef), DIMENSION(pmc_max_models),PUBLIC ::  children     !<
-   TYPE(childindexdef), DIMENSION(pmc_max_models)   ::  indchildren  !<
-
-
-   PUBLIC pmc_parent_for_child
-
-
-   INTERFACE pmc_parentinit
-      MODULE PROCEDURE  pmc_parentinit
-   END INTERFACE pmc_parentinit
-
-    INTERFACE pmc_s_set_2d_index_list
-        MODULE PROCEDURE pmc_s_set_2d_index_list
-    END INTERFACE pmc_s_set_2d_index_list
-
-    INTERFACE pmc_s_clear_next_array_list
-        MODULE PROCEDURE pmc_s_clear_next_array_list
-    END INTERFACE pmc_s_clear_next_array_list
-
-    INTERFACE pmc_s_getnextarray
-        MODULE PROCEDURE pmc_s_getnextarray
-    END INTERFACE pmc_s_getnextarray
-
-    INTERFACE pmc_s_set_dataarray
-        MODULE PROCEDURE pmc_s_set_dataarray_2d
-        MODULE PROCEDURE pmc_s_set_dataarray_3d
-        MODULE PROCEDURE pmc_s_set_dataarray_ip2d
-    END INTERFACE pmc_s_set_dataarray
-
-    INTERFACE pmc_s_setind_and_allocmem
-        MODULE PROCEDURE pmc_s_setind_and_allocmem
-    END INTERFACE pmc_s_setind_and_allocmem
-
-    INTERFACE pmc_s_fillbuffer
-        MODULE PROCEDURE pmc_s_fillbuffer
-    END INTERFACE pmc_s_fillbuffer
-
-    INTERFACE pmc_s_getdata_from_buffer
-        MODULE PROCEDURE pmc_s_getdata_from_buffer
-    END INTERFACE pmc_s_getdata_from_buffer
-
-    INTERFACE pmc_s_set_active_data_array
-        MODULE PROCEDURE pmc_s_set_active_data_array
-    END INTERFACE pmc_s_set_active_data_array
-
-    INTERFACE pmc_s_get_child_npes
-        MODULE PROCEDURE pmc_s_get_child_npes
-    END INTERFACE pmc_s_get_child_npes
-
-    PUBLIC pmc_parentinit,                                                                         &
+
+    IMPLICIT NONE
+
+    INTEGER ::  next_array_in_list = 0  !<
+
+    TYPE childindexdef
+       INTEGER ::  nrpoints  !<
+
+       INTEGER, DIMENSION(:,:), ALLOCATABLE ::  index_list_2d  !<
+    END TYPE childindexdef
+
+    TYPE(childdef), DIMENSION(pmc_max_models) ::  children  !<
+
+    TYPE(childindexdef), DIMENSION(pmc_max_models) ::  indchildren  !<
+
+    SAVE
+
+    PRIVATE
+
+!
+!-- Public functions
+    PUBLIC pmc_parent_for_child
+
+!
+!-- Public variables, constants and types
+    PUBLIC children,                                                                               &
+           pmc_parentinit,                                                                         &
            pmc_s_clear_next_array_list,                                                            &
            pmc_s_fillbuffer,                                                                       &
@@ -162,4 +134,47 @@
            pmc_s_get_child_npes
 
+    INTERFACE pmc_parentinit
+       MODULE PROCEDURE  pmc_parentinit
+    END INTERFACE pmc_parentinit
+
+    INTERFACE pmc_s_set_2d_index_list
+       MODULE PROCEDURE pmc_s_set_2d_index_list
+    END INTERFACE pmc_s_set_2d_index_list
+
+    INTERFACE pmc_s_clear_next_array_list
+       MODULE PROCEDURE pmc_s_clear_next_array_list
+    END INTERFACE pmc_s_clear_next_array_list
+
+    INTERFACE pmc_s_getnextarray
+       MODULE PROCEDURE pmc_s_getnextarray
+    END INTERFACE pmc_s_getnextarray
+
+    INTERFACE pmc_s_set_dataarray
+       MODULE PROCEDURE pmc_s_set_dataarray_2d
+       MODULE PROCEDURE pmc_s_set_dataarray_3d
+       MODULE PROCEDURE pmc_s_set_dataarray_ip2d
+    END INTERFACE pmc_s_set_dataarray
+
+    INTERFACE pmc_s_setind_and_allocmem
+       MODULE PROCEDURE pmc_s_setind_and_allocmem
+    END INTERFACE pmc_s_setind_and_allocmem
+
+    INTERFACE pmc_s_fillbuffer
+       MODULE PROCEDURE pmc_s_fillbuffer
+    END INTERFACE pmc_s_fillbuffer
+
+    INTERFACE pmc_s_getdata_from_buffer
+       MODULE PROCEDURE pmc_s_getdata_from_buffer
+    END INTERFACE pmc_s_getdata_from_buffer
+
+    INTERFACE pmc_s_set_active_data_array
+       MODULE PROCEDURE pmc_s_set_active_data_array
+    END INTERFACE pmc_s_set_active_data_array
+
+    INTERFACE pmc_s_get_child_npes
+       MODULE PROCEDURE pmc_s_get_child_npes
+    END INTERFACE pmc_s_get_child_npes
+
+
  CONTAINS
 
@@ -168,10 +183,7 @@
 ! Description:
 ! ------------
-!
 !> If this thread is intended as parent, initialize parent part of parent-client data transfer
 !--------------------------------------------------------------------------------------------------!
  SUBROUTINE pmc_parentinit
-
-    IMPLICIT NONE
 
     INTEGER(iwp) ::  childid  !<
@@ -182,5 +194,4 @@
 
     DO  i = 1, SIZE( pmc_parent_for_child ) - 1
-
        childid = pmc_parent_for_child( i )
 
@@ -194,4 +205,5 @@
        CALL MPI_COMM_REMOTE_SIZE( children(childid)%inter_comm, children(childid)%inter_npes,      &
                                   istat )
+
 !
 !--    Intra communicator is used for MPI_GET
@@ -201,4 +213,5 @@
 
        ALLOCATE( children(childid)%pes(children(childid)%inter_npes) )
+
 !
 !--    Allocate array of TYPE arraydef for all child PEs to store information of the transfer array
@@ -208,13 +221,12 @@
 
        CALL get_da_names_from_child( childid )
-
     ENDDO
 
  END SUBROUTINE pmc_parentinit
 
-!--------------------------------------------------------------------------------------------------!
-! Description:
-! ------------
-!
+
+!--------------------------------------------------------------------------------------------------!
+! Description:
+! ------------
 !> thread 0 transfers the index list, which contains all parent grid cells involved in
 !> parent client data transfer to the thread, on which this grid cell is located
@@ -222,17 +234,17 @@
  SUBROUTINE pmc_s_set_2d_index_list( childid, index_list )
 
-     IMPLICIT NONE
+     INTEGER(iwp) ::  ian        !<
+     INTEGER(iwp) ::  i          !<
+     INTEGER(iwp) ::  ip         !<
+     INTEGER(iwp) ::  istat      !<
+     INTEGER(iwp) ::  max_cells  !<
 
      INTEGER(iwp), INTENT(IN) ::  childid  !<
-     INTEGER(iwp), DIMENSION(:,:), INTENT(INOUT) ::  index_list   !<
-
-     INTEGER(iwp) ::  ian    !<
-     INTEGER(iwp) ::  i      !<
-     INTEGER(iwp) ::  ip     !<
-     INTEGER(iwp) ::  istat  !<
-     INTEGER(iwp) ::  max_cells  !<
-
-     INTEGER(iwp), DIMENSION(:), ALLOCATABLE     ::  cells_on_pe  !<
-     INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE   ::  lo_ind_list  !<
+
+     INTEGER(iwp), DIMENSION(:,:), INTENT(INOUT) ::  index_list  !<
+
+     INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  cells_on_pe  !<
+
+     INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  lo_ind_list  !<
 
 
@@ -240,30 +252,29 @@
 !
 !--     Compute maximum number of grid cells located on one parent thread
-
-        ALLOCATE(cells_on_pe(0:m_model_npes-1))
+        ALLOCATE( cells_on_pe(0:m_model_npes-1) )
         cells_on_pe = 0
 
-        DO i=1,SIZE( index_list, 2 )
+        DO  i = 1, SIZE( index_list, 2 )
            cells_on_pe(index_list(6,i )) = cells_on_pe(index_list(6,i ))+1
-        END DO
-
-        max_cells = MAXVAL(cells_on_pe)
+        ENDDO
+
+        max_cells = MAXVAL( cells_on_pe )
+
 !
 !--     Allocate temp array for thread dependent transfer of index_list
-
-        ALLOCATE(lo_ind_list(SIZE(index_list,1),max_cells))
+        ALLOCATE( lo_ind_list(SIZE( index_list,1 ),max_cells) )
 
         DO  ip = 0, m_model_npes-1
 !
 !--        Split into parent processes
-
            ian = 0
 
-           DO i=1,SIZE( index_list, 2 )
-              IF(index_list(6,i ) == ip )   THEN
+           DO  i = 1, SIZE( index_list, 2 )
+              IF ( index_list(6,i) == ip )  THEN
                  ian = ian+1
                  lo_ind_list(:,ian) = index_list(:,i)
-              END IF
-           END DO
+              ENDIF
+           ENDDO
+
 !
 !--        Send data to other parent processes
@@ -274,10 +285,10 @@
 !--           ian = 0, in order to avoid errors when array bounds are checked.
               ALLOCATE( indchildren(childid)%index_list_2d(6,1:ian) )
-              IF ( ian > 0)  THEN
+              IF ( ian > 0 )  THEN
                   indchildren(childid)%index_list_2d(:,1:ian) = lo_ind_list(:,1:ian)
               ENDIF
            ELSE
               CALL MPI_SEND( ian, 1, MPI_INTEGER, ip, 1000, m_model_comm, istat )
-              IF ( ian > 0)  THEN
+              IF ( ian > 0 )  THEN
                   CALL MPI_SEND( lo_ind_list, 6*ian, MPI_INTEGER, ip, 1001, m_model_comm, istat )
               ENDIF
@@ -285,6 +296,6 @@
         ENDDO
 
-        DEALLOCATE(lo_ind_list)
-        DEALLOCATE(cells_on_pe)
+        DEALLOCATE( lo_ind_list )
+        DEALLOCATE( cells_on_pe )
      ELSE
         CALL MPI_RECV( indchildren(childid)%nrpoints, 1, MPI_INTEGER, 0, 1000, m_model_comm,       &
@@ -300,4 +311,5 @@
         ENDIF
      ENDIF
+
      CALL set_pe_index_list( children(childid), indchildren(childid)%index_list_2d,                &
                              indchildren(childid)%nrpoints )
@@ -309,14 +321,9 @@
 ! Description:
 ! ------------
-!
 !> Before creating an array list with arrays schedule for parent client transfer
 !> make sure that the list is empty
 !--------------------------------------------------------------------------------------------------!
-
  SUBROUTINE pmc_s_clear_next_array_list
 
-
-    IMPLICIT NONE
-
     next_array_in_list = 0
 
@@ -328,5 +335,4 @@
 !
 !-- Althoug there are no linked lists any more in PMC, this call still looks like working with a list
-
     CHARACTER(LEN=*), INTENT(OUT) ::  myname  !<
 
@@ -334,7 +340,10 @@
 
     TYPE(pedef),    POINTER ::  ape  !<
-    TYPE(arraydef), POINTER ::  ar   !<
+
+    TYPE(arraydef), POINTER ::  ar  !<
+
 
     next_array_in_list = next_array_in_list + 1
+
 !
 !-- Array names are the same on all children processes, so take first process to get the name
@@ -350,7 +359,7 @@
     ar => ape%array_list(next_array_in_list)
     myname = ar%name
+
 !
 !-- Return true if there is still an array in the list
-
     pmc_s_getnextarray = .TRUE.
 
@@ -358,20 +367,16 @@
 
 
-
-!--------------------------------------------------------------------------------------------------!
-! Description:
-! ------------
-!
+!--------------------------------------------------------------------------------------------------!
+! Description:
+! ------------
 !> add 2D real array to list of arrays scheduled for parent-client transfer
 !--------------------------------------------------------------------------------------------------!
  SUBROUTINE pmc_s_set_dataarray_2d( childid, array, array_2 )
 
-    IMPLICIT NONE
-
     INTEGER(iwp) ::  nrdims  !<
 
     INTEGER(iwp), INTENT(IN) ::  childid  !<
 
-    INTEGER(iwp), DIMENSION(4) :: dims  !<
+    INTEGER(iwp), DIMENSION(4) ::  dims  !<
 
     REAL(wp), INTENT(IN), DIMENSION(:,:), POINTER ::  array  !<
@@ -402,18 +407,15 @@
 ! Description:
 ! ------------
-!
 !> add 2D integer array to list of arrays scheduled for parent-client transfer
 !--------------------------------------------------------------------------------------------------!
  SUBROUTINE pmc_s_set_dataarray_ip2d( childid, array )
 
-    IMPLICIT NONE
-
     INTEGER(iwp) ::  nrdims  !<
 
-    INTEGER(iwp),INTENT(IN) ::  childid  !<
+    INTEGER(iwp), DIMENSION(4) ::  dims  !<
+
+    INTEGER(iwp), INTENT(IN) ::  childid  !<
 
     INTEGER(idp), INTENT(IN), DIMENSION(:,:), POINTER ::  array  !<
-
-    INTEGER(iwp), DIMENSION(4) ::  dims  !<
 
     TYPE(C_PTR) ::  array_adr  !<
@@ -434,10 +436,7 @@
 ! Description:
 ! ------------
-!
 !> add 3D real array to list of arrays scheduled for parent-client transfer
 !--------------------------------------------------------------------------------------------------!
  SUBROUTINE pmc_s_set_dataarray_3d( childid, array, nz_cl, nz, array_2 )
-
-    IMPLICIT NONE
 
     INTEGER(iwp) ::  nrdims  !<
@@ -455,4 +454,5 @@
     TYPE(C_PTR) ::  array_adr   !<
     TYPE(C_PTR) ::  second_adr  !<
+
 
     nrdims  = 3
@@ -479,6 +479,10 @@
 ! Description:
 ! ------------
-!
-!> @Todo: Missing subroutine description.
+!> Naming convention for appendices:   _pc  -> parent to child transfer
+!>                                     _cp  -> child to parent transfer
+!>                                     send -> parent to child transfer
+!>                                     recv -> child to parent transfer
+!>
+!> @todo: Missing subroutine description.
 !--------------------------------------------------------------------------------------------------!
  SUBROUTINE pmc_s_setind_and_allocmem( childid )
@@ -486,12 +490,4 @@
     USE control_parameters,                                                                        &
         ONLY:  message_string
-
-    IMPLICIT NONE
-
-!
-!-- Naming convention for appendices:   _pc  -> parent to child transfer
-!--                                     _cp  -> child to parent transfer
-!--                                     send -> parent to child transfer
-!--                                     recv -> child to parent transfer
 
     INTEGER(iwp) ::  arlen         !<
@@ -502,5 +498,4 @@
     INTEGER(iwp) ::  myindex       !<
     INTEGER(iwp) ::  total_npes    !< Total Number of PEs Parent and Child
-
     INTEGER(idp) ::  bufsize       !< size of MPI data window
 
@@ -517,5 +512,6 @@
     TYPE(C_PTR) ::  base_ptr  !<
 
-    TYPE(pedef),    POINTER ::  ape  !<
+    TYPE(pedef), POINTER ::  ape  !<
+
     TYPE(arraydef), POINTER ::  ar   !<
 
@@ -526,4 +522,5 @@
     myindex = 1
     bufsize = 8
+
 !
 !-- All Child processes get the same number of arrays.
@@ -539,9 +536,6 @@
 !-- First stride: compute size and set index
     DO  i = 1, children(childid)%inter_npes
-
        ape => children(childid)%pes(i)
-
        DO  j = 1, ape%nr_arrays
-
           ar  => ape%array_list(j)
           IF ( ar%nrdims == 2 )  THEN
@@ -553,8 +547,8 @@
           ENDIF
           ar%sendindex = myindex
+
 !
 !--       Using intra communicator for MPU_Alltoall, the numbers of the child processes are after
 !--       the parent ones.
-
           myindex_s(j,i-1+children(childid)%model_npes) = myindex
 
@@ -563,10 +557,9 @@
           ar%sendsize = arlen
        ENDDO
-
-    ENDDO
+    ENDDO
+
 !
 !-- Using MPI_Alltoall to send indices from  Parent to Child
 !-- The data comming back from the child processes are ignored.
-
     CALL MPI_ALLTOALL( myindex_s, lo_nr_arrays, MPI_INTEGER, myindex_r, lo_nr_arrays, MPI_INTEGER, &
                        children(childid)%intra_comm, ierr )
@@ -579,4 +572,5 @@
     CALL MPI_ALLTOALL( myindex_s, lo_nr_arrays, MPI_INTEGER, myindex_r, lo_nr_arrays, MPI_INTEGER, &
                        children(childid)%intra_comm, ierr )
+
 !
 !-- Create RMA (One Sided Communication) window for data buffer parent to child transfer.
@@ -592,18 +586,16 @@
     CALL MPI_WIN_CREATE( base_array_pc, winsize, wp, MPI_INFO_NULL, children(childid)%intra_comm,  &
                          children(childid)%win_parent_child, ierr )
+
 !
 !-- Open window to set data
     CALL MPI_WIN_FENCE( 0, children(childid)%win_parent_child, ierr )
+
 !
 !-- Second stride: set buffer pointer
     DO  i = 1, children(childid)%inter_npes
-
        ape => children(childid)%pes(i)
-
        DO  j = 1, ape%nr_arrays
-
           ar => ape%array_list(j)
           ar%sendbuf = C_LOC( base_array_pc(ar%sendindex) )
-
           IF ( ar%sendindex + ar%sendsize > bufsize )  THEN
              WRITE( message_string, '(a,i4,4i7,1x,a)' ) 'parent buffer too small ',i ,             &
@@ -613,7 +605,9 @@
        ENDDO
     ENDDO
+
 !
 !-- Child to parent direction
     bufsize = 8
+
 !
 !-- First stride: compute size and set index
@@ -643,4 +637,5 @@
 
     CALL MPI_BARRIER( children(childid)%intra_comm, ierr )
+
 !
 !-- Second stride: set buffer pointer
@@ -659,10 +654,7 @@
 ! Description:
 ! ------------
-!
 !> Fill buffer in RMA window to enable the client to fetch the dat with MPI_Get
 !--------------------------------------------------------------------------------------------------!
  SUBROUTINE pmc_s_fillbuffer( childid, waittime, particle_transfer )
-
-    IMPLICIT NONE
 
     INTEGER(iwp) ::  ierr     !<
@@ -687,5 +679,5 @@
     REAL(wp) ::  t2  !<
 
-    REAL(wp), INTENT(OUT), OPTIONAL ::  waittime           !<
+    REAL(wp), INTENT(OUT), OPTIONAL ::  waittime  !<
 
     REAL(wp), POINTER, DIMENSION(:) ::  buf  !<
@@ -695,5 +687,6 @@
     REAL(wp), POINTER, DIMENSION(:,:,:) ::  data_3d  !<
 
-    TYPE(pedef),    POINTER ::  ape  !<
+    TYPE(pedef), POINTER ::  ape  !<
+
     TYPE(arraydef), POINTER ::  ar   !<
 
@@ -702,5 +695,5 @@
 !-- without sychronization at this point and a barrier is not necessary.
 !-- Please note that waittime has to be set in pmc_s_fillbuffer AND pmc_c_getbuffer.
-    IF ( PRESENT( waittime) )  THEN
+    IF ( PRESENT( waittime ) )  THEN
       t1 = pmc_time()
       CALL MPI_BARRIER( children(childid)%intra_comm, ierr )
@@ -717,7 +710,5 @@
           ar => ape%array_list(j)
           myindex = 1
-
           IF ( ar%dimkey == 2 .AND. .NOT.lo_ptrans  )  THEN         ! PALM 2D REAL*8 Array
-
              buf_shape(1) = ape%nrele
              CALL C_F_POINTER( ar%sendbuf, buf, buf_shape )
@@ -727,7 +718,5 @@
                 myindex = myindex + 1
              ENDDO
-
           ELSEIF ( ar%dimkey == 3  .AND. .NOT.lo_ptrans  )  THEN      ! PALM 3D REAL*8 Array
-
              buf_shape(1) = ape%nrele*ar%a_dim(4)
              CALL C_F_POINTER( ar%sendbuf, buf, buf_shape )
@@ -739,5 +728,4 @@
              ENDDO
           ELSEIF ( ar%dimkey == 22 .AND. lo_ptrans  )  THEN  ! 2D INTEGER*8 Array for particle Transfer
-
              buf_shape(1) = ape%nrele
              CALL C_F_POINTER( ar%sendbuf, ibuf, buf_shape )
@@ -750,4 +738,5 @@
         ENDDO
     ENDDO
+
 !
 !-- Buffer is filled
@@ -757,14 +746,10 @@
 
 
-
-!--------------------------------------------------------------------------------------------------!
-! Description:
-! ------------
-!
+!--------------------------------------------------------------------------------------------------!
+! Description:
+! ------------
 !> Get client data from RMM window
 !--------------------------------------------------------------------------------------------------!
  SUBROUTINE pmc_s_getdata_from_buffer( childid, waittime , particle_transfer, child_process_nr )
-
-    IMPLICIT NONE
 
     INTEGER(iwp) ::  ierr       !<
@@ -805,5 +790,6 @@
     REAL(wp), POINTER, DIMENSION(:,:,:) ::  data_3d  !<
 
-    TYPE(pedef),   POINTER  ::  ape  !<
+    TYPE(pedef), POINTER  ::  ape  !<
+
     TYPE(arraydef), POINTER ::  ar   !<
 
@@ -832,5 +818,5 @@
     ENDIF
 
-    DO  ip = ip_start,ip_end
+    DO  ip = ip_start, ip_end
        ape => children(childid)%pes(ip)
        DO  j = 1, ape%nr_arrays
@@ -848,5 +834,7 @@
              CYCLE            ! Particle arrays are not transfered here
           ENDIF
+
           buf_shape(1) = nr
+
           IF(lo_ptrans)   THEN
              CALL C_F_POINTER( ar%recvbuf, ibuf, buf_shape )
@@ -874,7 +862,8 @@
              CALL MPI_WIN_UNLOCK( target_pe, children(childid)%win_parent_child, ierr )
           ENDIF
+
           myindex = 1
+
           IF ( ar%dimkey == 2  .AND.  .NOT. lo_ptrans )  THEN
-
              CALL C_F_POINTER( ar%data, data_2d, ar%a_dim(1:2) )
              DO  ij = 1, ape%nrele
@@ -882,7 +871,5 @@
                 myindex = myindex + 1
              ENDDO
-
           ELSE IF ( ar%dimkey == 3  .AND.  .NOT. lo_ptrans )  THEN
-
              CALL C_F_POINTER( ar%data, data_3d, ar%a_dim(1:3) )
              DO  ij = 1, ape%nrele
@@ -891,7 +878,5 @@
                 myindex = myindex + ar%a_dim(4)
              ENDDO
-
           ELSE IF ( ar%dimkey == 22 .AND. lo_ptrans)  THEN
-
              CALL C_F_POINTER( ar%data, idata_2d, ar%a_dim(1:2) )
              DO  ij = 1, ape%nrele
@@ -899,5 +884,4 @@
                 myindex = myindex + 1
              ENDDO
-
           ENDIF
        ENDDO
@@ -910,5 +894,4 @@
 ! Description:
 ! ------------
-!
 !> broadcast name of transfer arrays from child thread 0 to parent threads
 !--------------------------------------------------------------------------------------------------!
@@ -917,9 +900,8 @@
 !
 !-- Get data array description and name from child
-    IMPLICIT NONE
-
     INTEGER(iwp), INTENT(IN) ::  childid  !<
 
     TYPE(da_namedef) ::  myname  !<
+
 
     DO
@@ -939,10 +921,8 @@
 
 
-
-!--------------------------------------------------------------------------------------------------!
-! Description:
-! ------------
-!
-!> @Todo: Missing subroutine description.
+!--------------------------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> @todo: Missing subroutine description.
 !--------------------------------------------------------------------------------------------------!
  SUBROUTINE pmc_s_setarray( childid, nrdims, dims, array_adr, second_adr, dimkey )
@@ -950,6 +930,4 @@
 !
 !-- Set array for child inter process 0
-    IMPLICIT NONE
-
     INTEGER(iwp) ::  i  !< local counter
 
@@ -965,5 +943,6 @@
     TYPE(C_PTR), INTENT(IN), OPTIONAL ::  second_adr  !<
 
-    TYPE(pedef),    POINTER ::  ape  !<
+    TYPE(pedef), POINTER ::  ape  !<
+
     TYPE(arraydef), POINTER ::  ar   !<
 
@@ -985,5 +964,4 @@
           ar%po_data(2) = C_NULL_PTR
        ENDIF
-
     ENDDO
 
@@ -991,14 +969,10 @@
 
 
-
-!--------------------------------------------------------------------------------------------------!
-! Description:
-! ------------
-!
-!> @Todo: Missing subroutine description.
+!--------------------------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> @todo: Missing subroutine description.
 !--------------------------------------------------------------------------------------------------!
  SUBROUTINE pmc_s_set_active_data_array( childid, iactive )
-
-    IMPLICIT NONE
 
     INTEGER(iwp) :: ip  !<
@@ -1008,5 +982,6 @@
     INTEGER(iwp), INTENT(IN) ::  iactive  !<
 
-    TYPE(pedef),    POINTER ::  ape  !<
+    TYPE(pedef), POINTER ::  ape  !<
+
     TYPE(arraydef), POINTER ::  ar   !<
 
@@ -1024,6 +999,11 @@
  END SUBROUTINE pmc_s_set_active_data_array
 
+
+ !--------------------------------------------------------------------------------------------------!
+ ! Description:
+ ! ------------
+ !> @todo: Missing function description.
+ !--------------------------------------------------------------------------------------------------!
  INTEGER FUNCTION pmc_s_get_child_npes( child_id )
-   IMPLICIT NONE
 
    INTEGER(iwp),INTENT(IN) ::  child_id  !<
@@ -1032,17 +1012,14 @@
 
    RETURN
+
  END FUNCTION pmc_s_get_child_npes
 
 
-
-!--------------------------------------------------------------------------------------------------!
-! Description:
-! ------------
-!
-!> @Todo: Missing subroutine description.
+!--------------------------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> @todo: Missing subroutine description.
 !--------------------------------------------------------------------------------------------------!
  SUBROUTINE set_pe_index_list( mychild, index_list, nrp )
-
-    IMPLICIT NONE
 
     INTEGER(iwp) :: i        !<
@@ -1070,4 +1047,5 @@
     TYPE(pedef), POINTER ::  ape  !<
 
+
 !
 !-- First, count entries for every remote child process
@@ -1076,4 +1054,5 @@
        ape%nrele = 0
     ENDDO
+
 !
 !-- Loop over number of coarse grid cells
@@ -1090,4 +1069,5 @@
 
     remind = 0
+
 !
 !-- Second, create lists
@@ -1101,7 +1081,9 @@
        ape%locind(ind)%j = index_list(2,j)
     ENDDO
+
 !
 !-- Prepare number of elements for children processes
     CALL pmc_alloc_mem( rldef, mychild%inter_npes * 2 )
+
 !
 !-- Number of child processes * size of INTEGER (i just arbitrary INTEGER)
@@ -1109,4 +1091,5 @@
 
     CALL MPI_WIN_CREATE( rldef, winsize, iwp, MPI_INFO_NULL, mychild%intra_comm, indwin, ierr )
+
 !
 !-- Open window to set data
@@ -1115,4 +1098,5 @@
     rldef(1) = 0            ! Index on remote process 0
     rldef(2) = remind(1)    ! Number of elements on remote process 0
+
 !
 !-- Reserve buffer for index array
@@ -1122,7 +1106,9 @@
        rldef(i2+1) = remind(i)                      ! Number of elements on remote process
     ENDDO
+
 !
 !-- Close window to allow child to access data
     CALL MPI_WIN_FENCE( 0, indwin, ierr )
+
 !
 !-- Child has retrieved data
@@ -1131,4 +1117,5 @@
     i2 = 2 * mychild%inter_npes - 1
     winsize = ( rldef(i2) + rldef(i2+1) ) * 2
+
 !
 !-- Make sure, MPI_ALLOC_MEM works
@@ -1140,7 +1127,9 @@
     CALL MPI_WIN_CREATE( remindw, winsize * STORAGE_SIZE( i ) / 8, iwp, MPI_INFO_NULL,             &
                          mychild%intra_comm, indwin2, ierr )
+
 !
 !-- Open window to set data
     CALL MPI_WIN_FENCE( 0, indwin2, ierr )
+
 !
 !-- Create the 2D index list
@@ -1154,7 +1143,9 @@
        rldef(i2)      = rldef(i2)+2
     ENDDO
+
 !
 !-- All data are set
     CALL MPI_WIN_FENCE( 0, indwin2, ierr )
+
 !
 !-- Don't know why, but this barrier is necessary before windows can be freed
@@ -1167,10 +1158,11 @@
 !
 !-- TODO: check if the following idea needs to be done
-!-- Sollte funktionieren, Problem mit MPI implementation
+!-- Should work, Problem with MPI implementation
 !-- https://www.lrz.de/services/software/parallel/mpi/onesided
 !-- CALL MPI_Free_mem (remindw, ierr)
 
  END SUBROUTINE set_pe_index_list
-
 #endif
+
+
  END MODULE pmc_parent
