Index: palm/trunk/SOURCE/pmc_handle_communicator_mod.f90
===================================================================
--- palm/trunk/SOURCE/pmc_handle_communicator_mod.f90	(revision 1883)
+++ palm/trunk/SOURCE/pmc_handle_communicator_mod.f90	(revision 1900)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! re-formatting to match PALM style
 ! 
 ! Former revisions:
@@ -32,5 +32,4 @@
 ! 1850 2016-04-08 13:29:27Z maronga
 ! Module renamed
-!
 !
 ! 1808 2016-04-05 19:44:00Z raasch
@@ -79,347 +78,353 @@
 #endif
 
-   USE pmc_general,                                                            &
-       ONLY: pmc_status_ok, pmc_status_error, pmc_max_modell
-
-   IMPLICIT NONE
-
-   TYPE pmc_layout
-
-      CHARACTER(len=32) ::  name
-
-      INTEGER  ::  id
-      INTEGER  ::  parent_id
-      INTEGER  ::  npe_total
-
-      REAL(wp) ::  lower_left_x
-      REAL(wp) ::  lower_left_y
-
-   END TYPE pmc_layout
-
-   PUBLIC  pmc_status_ok, pmc_status_error
-
-   INTEGER, PARAMETER, PUBLIC ::  pmc_error_npes          = 1  ! illegal number of PEs
-   INTEGER, PARAMETER, PUBLIC ::  pmc_namelist_error      = 2  ! error(s) in nestpar namelist
-   INTEGER, PARAMETER, PUBLIC ::  pmc_no_namelist_found   = 3  ! No couple layout file found
-
-   ! Coupler Setup
-
-   INTEGER                                    :: m_world_comm !global nesting communicator
-   INTEGER                                    :: m_my_CPL_id  !Coupler id of this model
-   INTEGER                                    :: m_Parent_id  !Coupler id of parent of this model
-   INTEGER                                    :: m_ncpl       !Number of Couplers in layout file
-
-   TYPE(PMC_layout),DIMENSION(PMC_MAX_MODELL) :: m_couplers   !Information of all couplers
-
-   ! MPI settings
-
-   INTEGER,PUBLIC                    :: m_model_comm          !Communicator of this model
-   INTEGER,PUBLIC                    :: m_to_server_comm      !Communicator to the server
-   INTEGER,DIMENSION(PMC_MAX_MODELL) :: m_to_client_comm      !Communicator to the client(s)
-   INTEGER,PUBLIC                    :: m_world_rank
-   INTEGER                           :: m_world_npes
-   INTEGER,PUBLIC                    :: m_model_rank
-   INTEGER,PUBLIC                    :: m_model_npes
-   INTEGER                           :: m_server_remote_size  !Number of Server PE's
-
-   PUBLIC m_to_client_comm
-
-   !Indicates this PE is server for Cleint NR
-
-   INTEGER,DIMENSION(:),POINTER,PUBLIC :: PMC_Server_for_Client
-
-   INTERFACE pmc_is_rootmodel
-      MODULE PROCEDURE pmc_is_rootmodel
-   END INTERFACE pmc_is_rootmodel
-
-   INTERFACE pmc_get_model_info
-      MODULE PROCEDURE pmc_get_model_info
-   END INTERFACE pmc_get_model_info
-
-   PUBLIC pmc_get_model_info, pmc_init_model, pmc_is_rootmodel
+    USE pmc_general,                                                           &
+        ONLY: pmc_status_ok, pmc_status_error, pmc_max_models
+
+    IMPLICIT NONE
+
+    TYPE pmc_layout
+
+       CHARACTER(LEN=32) ::  name
+
+       INTEGER  ::  id            !<
+       INTEGER  ::  parent_id     !<
+       INTEGER  ::  npe_total     !<
+
+       REAL(wp) ::  lower_left_x  !<
+       REAL(wp) ::  lower_left_y  !<
+
+    END TYPE pmc_layout
+
+    PUBLIC  pmc_status_ok, pmc_status_error
+
+    INTEGER, PARAMETER, PUBLIC ::  pmc_error_npes        = 1  !< illegal number of PEs
+    INTEGER, PARAMETER, PUBLIC ::  pmc_namelist_error    = 2  !< error(s) in nestpar namelist
+    INTEGER, PARAMETER, PUBLIC ::  pmc_no_namelist_found = 3  !< no couple layout namelist found
+
+    INTEGER ::  m_world_comm  !< global nesting communicator
+    INTEGER ::  m_my_cpl_id   !< coupler id of this model
+    INTEGER ::  m_parent_id   !< coupler id of parent of this model
+    INTEGER ::  m_ncpl        !< number of couplers given in nestpar namelist
+
+    TYPE(pmc_layout), DIMENSION(pmc_max_models) ::  m_couplers  !< information of all couplers
+
+    INTEGER, PUBLIC ::  m_model_comm          !< communicator of this model
+    INTEGER, PUBLIC ::  m_to_server_comm      !< communicator to the server
+    INTEGER, PUBLIC ::  m_world_rank          !<
+    INTEGER         ::  m_world_npes          !<
+    INTEGER, PUBLIC ::  m_model_rank          !<
+    INTEGER, PUBLIC ::  m_model_npes          !<
+    INTEGER         ::  m_server_remote_size  !< number of server PEs
+
+    INTEGER, DIMENSION(pmc_max_models), PUBLIC ::  m_to_client_comm   !< communicator to the client(s)
+    INTEGER, DIMENSION(:), POINTER, PUBLIC ::  pmc_server_for_client  !<
+
+
+    INTERFACE pmc_is_rootmodel
+       MODULE PROCEDURE pmc_is_rootmodel
+    END INTERFACE pmc_is_rootmodel
+
+    INTERFACE pmc_get_model_info
+       MODULE PROCEDURE pmc_get_model_info
+    END INTERFACE pmc_get_model_info
+
+    PUBLIC pmc_get_model_info, pmc_init_model, pmc_is_rootmodel
 
  CONTAINS
 
-   SUBROUTINE pmc_init_model( comm, nesting_datatransfer_mode, nesting_mode,   &
+ SUBROUTINE pmc_init_model( comm, nesting_datatransfer_mode, nesting_mode,     &
                               pmc_status )
 
-      USE control_parameters,                                                  &
-          ONLY:  message_string
-
-      USE pegrid,                                                              &
-          ONLY:  myid
+    USE control_parameters,                                                    &
+        ONLY:  message_string
+
+    USE pegrid,                                                                &
+        ONLY:  myid
 
       IMPLICIT NONE
 
-      CHARACTER(LEN=7), INTENT(OUT) ::  nesting_mode
-      CHARACTER(LEN=7), INTENT(OUT) ::  nesting_datatransfer_mode
-
-      INTEGER, INTENT(OUT)                ::  comm
-      INTEGER, INTENT(OUT)                ::  pmc_status
-
-      INTEGER                             ::  i, ierr, istat
-      INTEGER,DIMENSION(pmc_max_modell+1) ::  start_pe
-      INTEGER                             ::  m_my_cpl_rank
-      INTEGER                             ::  tag, clientcount
-      INTEGER,DIMENSION(pmc_max_modell)   ::  activeserver  ! I am active server for this client ID
-
-      pmc_status   = pmc_status_ok
-      comm         = -1
-      m_world_comm = MPI_COMM_WORLD
-      m_my_cpl_id  = -1
-      clientcount  =  0
-      activeserver = -1
-      start_pe(:)  =  0
-
-      CALL  MPI_COMM_RANK( MPI_COMM_WORLD, m_world_rank, istat )
-      CALL  MPI_COMM_SIZE( MPI_COMM_WORLD, m_world_npes, istat )
-!
-!--   Only PE 0 of root model reads
-      IF ( m_world_rank == 0 )  THEN
-
-         CALL read_coupling_layout( nesting_datatransfer_mode, nesting_mode,   &
-                                    pmc_status )
-
-         IF ( pmc_status /= pmc_no_namelist_found  .AND.                       &
-              pmc_status /= pmc_namelist_error )                               &
-         THEN
-!
-!--         Calculate start PE of every model
-            start_pe(1) = 0
-            DO  i = 2, m_ncpl+1
-               start_pe(i) = start_pe(i-1) + m_couplers(i-1)%npe_total
-            ENDDO
-
-!
-!--         The number of cores provided with the run must be the same as the
-!--         total sum of cores required by all nest domains
-            IF ( start_pe(m_ncpl+1) /= m_world_npes )  THEN
-               WRITE ( message_string, '(A,I6,A,I6,A)' )                       &
-                               'nesting-setup requires more MPI procs (',      &
-                               start_pe(m_ncpl+1), ') than provided (',        &
-                               m_world_npes,')'
-               CALL message( 'pmc_init_model', 'PA0229', 3, 2, 0, 6, 0 )
-            ENDIF
-
-         ENDIF
-
-      ENDIF
-!
-!--   Broadcast the read status. This synchronises all other PEs with PE 0 of
-!--   the root model. Without synchronisation, they would not behave in the
-!--   correct way (e.g. they would not return in case of a missing NAMELIST)
-      CALL MPI_BCAST( pmc_status, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, istat )
-
-      IF ( pmc_status == pmc_no_namelist_found )  THEN
-!
-!--      Not a nested run; return the MPI_WORLD communicator
-         comm = MPI_COMM_WORLD
-         RETURN
-
-      ELSEIF ( pmc_status == pmc_namelist_error )  THEN
-!
-!--      Only the root model gives the error message. Others are aborted by the
-!--      message-routine with MPI_ABORT. Must be done this way since myid and
-!--      comm2d have not yet been assigned at this point.
-         IF ( m_world_rank == 0 )  THEN
-            message_string = 'errors in \$nestpar'
-            CALL message( 'pmc_init_model', 'PA0223', 3, 2, 0, 6, 0 )
-         ENDIF
-
-      ENDIF
-
-      CALL MPI_BCAST( m_ncpl,          1, MPI_INTEGER, 0, MPI_COMM_WORLD, istat)
-      CALL MPI_BCAST( start_pe, m_ncpl+1, MPI_INTEGER, 0, MPI_COMM_WORLD, istat)
-
-!
-!--   Broadcast coupling layout
-      DO  i = 1, m_ncpl
-         CALL MPI_BCAST( m_couplers(i)%name, LEN( m_couplers(i)%name ), MPI_CHARACTER, 0, MPI_COMM_WORLD, istat )
-         CALL MPI_BCAST( m_couplers(i)%id,           1, MPI_INTEGER, 0, MPI_COMM_WORLD, istat )
-         CALL MPI_BCAST( m_couplers(i)%Parent_id,    1, MPI_INTEGER, 0, MPI_COMM_WORLD, istat )
-         CALL MPI_BCAST( m_couplers(i)%npe_total,    1, MPI_INTEGER, 0, MPI_COMM_WORLD, istat )
-         CALL MPI_BCAST( m_couplers(i)%lower_left_x, 1, MPI_REAL,    0, MPI_COMM_WORLD, istat )
-         CALL MPI_BCAST( m_couplers(i)%lower_left_y, 1, MPI_REAL,    0, MPI_COMM_WORLD, istat )
-      ENDDO
-      CALL MPI_BCAST( nesting_mode, LEN( nesting_mode ), MPI_CHARACTER, 0, MPI_COMM_WORLD, istat )
-      CALL MPI_BCAST( nesting_datatransfer_mode, LEN(nesting_datatransfer_mode), MPI_CHARACTER, 0, MPI_COMM_WORLD, istat )
-
-!
-!--   Assign global MPI processes to individual models by setting the couple id
-      DO  i = 1, m_ncpl
-         IF ( m_world_rank >= start_pe(i)  .AND.  m_world_rank < start_pe(i+1) ) &
-         THEN
-            m_my_cpl_id = i
-            EXIT
-         ENDIF
-      ENDDO
-      m_my_cpl_rank = m_world_rank - start_pe(i)
-
-!
-!--   MPI_COMM_WORLD is the communicator for ALL models (MPI-1 approach).
-!--   The communictors for the individual models as created by MPI_COMM_SPLIT.
-!--   The color of the model is represented by the coupler id
-      CALL MPI_COMM_SPLIT( MPI_COMM_WORLD, m_my_cpl_id, m_my_cpl_rank, comm,   &
-                           istat )
-!
-!--   Get size and rank of the model running on this PE
-      CALL  MPI_COMM_RANK( comm, m_model_rank, istat )
-      CALL  MPI_COMM_SIZE( comm, m_model_npes, istat )
-
-!
-!--   Broadcast (from PE 0) the parent id and id of every model
-      DO  i = 1, m_ncpl
-         CALL MPI_BCAST( m_couplers(i)%parent_id, 1, MPI_INTEGER, 0,           &
-                         MPI_COMM_WORLD, istat )
-         CALL MPI_BCAST( m_couplers(i)%id,        1, MPI_INTEGER, 0,           &
-                         MPI_COMM_WORLD, istat )
-      ENDDO
-
-!
-!--   Save the current model communicator for PMC internal use
-      m_model_comm = comm
-
-!
-!--   Create intercommunicator between server and clients.
-!--   MPI_INTERCOMM_CREATE creates an intercommunicator between 2 groups of
-!--   different colors.
-!--   The grouping was done above with MPI_COMM_SPLIT
-      DO  i = 2, m_ncpl
-
-         IF ( m_couplers(i)%parent_id == m_my_cpl_id )  THEN
-!
-!--         Collect server PEs.
-!--         Every model exept the root model has a parent model which acts as
-!--         server model. Create an intercommunicator to connect current PE to
-!--         all client PEs
-            tag = 500 + i
-            CALL MPI_INTERCOMM_CREATE( comm, 0, MPI_COMM_WORLD, start_pe(i),   &
-                                       tag, m_to_client_comm(i), istat)
-            clientcount = clientcount + 1
-            activeserver(i) = 1
-
-         ELSEIF ( i == m_my_cpl_id)  THEN
-!
-!--         Collect client PEs.
-!--         Every model exept the root model has a paremt model which acts as
-!--         server model. Create an intercommunicator to connect current PE to
-!--         all server PEs
-            tag = 500 + i
-            CALL MPI_INTERCOMM_CREATE( comm, 0, MPI_COMM_WORLD,                &
-                                       start_pe(m_couplers(i)%parent_id),      &
-                                       tag, m_to_server_comm, istat )
-         ENDIF
-
-      ENDDO
-
-!
-!--   If I am server, count the number of clients that I have
-!--   Although this loop is symmetric on all processes, the "activeserver" flag
-!--   is true (==1) on the respective individual PE only.
-      ALLOCATE( pmc_server_for_client(clientcount+1) )
-
-      clientcount = 0
-      DO  i = 2, m_ncpl
-         IF ( activeserver(i) == 1 )  THEN
-            clientcount = clientcount + 1
-            pmc_server_for_client(clientcount) = i
-         ENDIF
-      ENDDO
-!
-!--   Get the size of the server model
-      IF ( m_my_cpl_id > 1 )  THEN
-         CALL MPI_COMM_REMOTE_SIZE( m_to_server_comm, m_server_remote_size,    &
-                                    istat)
-      ELSE
-!
-!--      The root model does not have a server
-         m_server_remote_size = -1             !
-      ENDIF
-!
-!--   Set myid to non-tero value except for the root domain. This is a setting
-!--   for the message routine which is called at the end of pmci_init. That
-!--   routine outputs messages for myid = 0, only. However, myid has not been
-!--   assigened so far, so that all PEs of the root model would output a
-!--   message. To avoid this, set myid to some other value except for PE0 of the
-!--   root domain.
-      IF ( m_world_rank /= 0 )  myid = 1
-
-   END SUBROUTINE PMC_init_model
-
-
+    CHARACTER(LEN=7), INTENT(OUT) ::  nesting_mode               !<
+    CHARACTER(LEN=7), INTENT(OUT) ::  nesting_datatransfer_mode  !<
+
+    INTEGER, INTENT(OUT) ::  comm        !<
+    INTEGER, INTENT(OUT) ::  pmc_status  !<
+
+    INTEGER ::  clientcount    !<
+    INTEGER ::  i              !<
+    INTEGER ::  ierr           !<
+    INTEGER ::  istat          !<
+    INTEGER ::  m_my_cpl_rank  !<
+    INTEGER ::  tag            !<
+
+    INTEGER, DIMENSION(pmc_max_models)   ::  activeserver  ! I am active server for this client ID
+    INTEGER, DIMENSION(pmc_max_models+1) ::  start_pe
+
+    pmc_status   = pmc_status_ok
+    comm         = -1
+    m_world_comm = MPI_COMM_WORLD
+    m_my_cpl_id  = -1
+    clientcount  =  0
+    activeserver = -1
+    start_pe(:)  =  0
+
+    CALL MPI_COMM_RANK( MPI_COMM_WORLD, m_world_rank, istat )
+    CALL MPI_COMM_SIZE( MPI_COMM_WORLD, m_world_npes, istat )
+!
+!-- Only PE 0 of root model reads
+    IF ( m_world_rank == 0 )  THEN
+
+       CALL read_coupling_layout( nesting_datatransfer_mode, nesting_mode,     &
+                                  pmc_status )
+
+       IF ( pmc_status /= pmc_no_namelist_found  .AND.                         &
+            pmc_status /= pmc_namelist_error )                                 &
+       THEN
+!
+!--       Calculate start PE of every model
+          start_pe(1) = 0
+          DO  i = 2, m_ncpl+1
+             start_pe(i) = start_pe(i-1) + m_couplers(i-1)%npe_total
+          ENDDO
+
+!
+!--       The number of cores provided with the run must be the same as the
+!--       total sum of cores required by all nest domains
+          IF ( start_pe(m_ncpl+1) /= m_world_npes )  THEN
+             WRITE ( message_string, '(A,I6,A,I6,A)' )                         &
+                             'nesting-setup requires more MPI procs (',        &
+                             start_pe(m_ncpl+1), ') than provided (',          &
+                             m_world_npes,')'
+             CALL message( 'pmc_init_model', 'PA0229', 3, 2, 0, 6, 0 )
+          ENDIF
+
+       ENDIF
+
+    ENDIF
+!
+!-- Broadcast the read status. This synchronises all other PEs with PE 0 of
+!-- the root model. Without synchronisation, they would not behave in the
+!-- correct way (e.g. they would not return in case of a missing NAMELIST)
+    CALL MPI_BCAST( pmc_status, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, istat )
+
+    IF ( pmc_status == pmc_no_namelist_found )  THEN
+!
+!--    Not a nested run; return the MPI_WORLD communicator
+       comm = MPI_COMM_WORLD
+       RETURN
+
+    ELSEIF ( pmc_status == pmc_namelist_error )  THEN
+!
+!--    Only the root model gives the error message. Others are aborted by the
+!--    message-routine with MPI_ABORT. Must be done this way since myid and
+!--    comm2d have not yet been assigned at this point.
+       IF ( m_world_rank == 0 )  THEN
+          message_string = 'errors in \$nestpar'
+          CALL message( 'pmc_init_model', 'PA0223', 3, 2, 0, 6, 0 )
+       ENDIF
+
+    ENDIF
+
+    CALL MPI_BCAST( m_ncpl,          1, MPI_INTEGER, 0, MPI_COMM_WORLD, istat)
+    CALL MPI_BCAST( start_pe, m_ncpl+1, MPI_INTEGER, 0, MPI_COMM_WORLD, istat)
+
+!
+!-- Broadcast coupling layout
+    DO  i = 1, m_ncpl
+       CALL MPI_BCAST( m_couplers(i)%name, LEN( m_couplers(i)%name ),          &
+                       MPI_CHARACTER, 0, MPI_COMM_WORLD, istat )
+       CALL MPI_BCAST( m_couplers(i)%id,           1, MPI_INTEGER, 0,          &
+                       MPI_COMM_WORLD, istat )
+       CALL MPI_BCAST( m_couplers(i)%Parent_id,    1, MPI_INTEGER, 0,          &
+                       MPI_COMM_WORLD, istat )
+       CALL MPI_BCAST( m_couplers(i)%npe_total,    1, MPI_INTEGER, 0,          &
+                       MPI_COMM_WORLD, istat )
+       CALL MPI_BCAST( m_couplers(i)%lower_left_x, 1, MPI_REAL,    0,          &
+                       MPI_COMM_WORLD, istat )
+       CALL MPI_BCAST( m_couplers(i)%lower_left_y, 1, MPI_REAL,    0,          &
+                       MPI_COMM_WORLD, istat )
+    ENDDO
+    CALL MPI_BCAST( nesting_mode, LEN( nesting_mode ), MPI_CHARACTER, 0,       &
+                    MPI_COMM_WORLD, istat )
+    CALL MPI_BCAST( nesting_datatransfer_mode, LEN(nesting_datatransfer_mode), &
+                    MPI_CHARACTER, 0, MPI_COMM_WORLD, istat )
+
+!
+!-- Assign global MPI processes to individual models by setting the couple id
+    DO  i = 1, m_ncpl
+       IF ( m_world_rank >= start_pe(i)  .AND.  m_world_rank < start_pe(i+1) ) &
+       THEN
+          m_my_cpl_id = i
+          EXIT
+       ENDIF
+    ENDDO
+    m_my_cpl_rank = m_world_rank - start_pe(i)
+
+!
+!-- MPI_COMM_WORLD is the communicator for ALL models (MPI-1 approach).
+!-- The communictors for the individual models as created by MPI_COMM_SPLIT.
+!-- The color of the model is represented by the coupler id
+    CALL MPI_COMM_SPLIT( MPI_COMM_WORLD, m_my_cpl_id, m_my_cpl_rank, comm,     &
+                         istat )
+!
+!-- Get size and rank of the model running on this PE
+    CALL  MPI_COMM_RANK( comm, m_model_rank, istat )
+    CALL  MPI_COMM_SIZE( comm, m_model_npes, istat )
+
+!
+!-- Broadcast (from PE 0) the parent id and id of every model
+    DO  i = 1, m_ncpl
+       CALL MPI_BCAST( m_couplers(i)%parent_id, 1, MPI_INTEGER, 0,             &
+                       MPI_COMM_WORLD, istat )
+       CALL MPI_BCAST( m_couplers(i)%id,        1, MPI_INTEGER, 0,             &
+                       MPI_COMM_WORLD, istat )
+    ENDDO
+
+!
+!-- Save the current model communicator for pmc internal use
+    m_model_comm = comm
+
+!
+!-- Create intercommunicator between server and clients.
+!-- MPI_INTERCOMM_CREATE creates an intercommunicator between 2 groups of
+!-- different colors.
+!-- The grouping was done above with MPI_COMM_SPLIT
+    DO  i = 2, m_ncpl
+
+       IF ( m_couplers(i)%parent_id == m_my_cpl_id )  THEN
+!
+!--       Collect server PEs.
+!--       Every model exept the root model has a parent model which acts as
+!--       server model. Create an intercommunicator to connect current PE to
+!--       all client PEs
+          tag = 500 + i
+          CALL MPI_INTERCOMM_CREATE( comm, 0, MPI_COMM_WORLD, start_pe(i),     &
+                                     tag, m_to_client_comm(i), istat)
+          clientcount = clientcount + 1
+          activeserver(i) = 1
+
+       ELSEIF ( i == m_my_cpl_id)  THEN
+!
+!--       Collect client PEs.
+!--       Every model exept the root model has a paremt model which acts as
+!--       server model. Create an intercommunicator to connect current PE to
+!--       all server PEs
+          tag = 500 + i
+          CALL MPI_INTERCOMM_CREATE( comm, 0, MPI_COMM_WORLD,                  &
+                                     start_pe(m_couplers(i)%parent_id),        &
+                                     tag, m_to_server_comm, istat )
+       ENDIF
+
+    ENDDO
+
+!
+!-- If I am server, count the number of clients that I have
+!-- Although this loop is symmetric on all processes, the "activeserver" flag
+!-- is true (==1) on the respective individual PE only.
+    ALLOCATE( pmc_server_for_client(clientcount+1) )
+
+    clientcount = 0
+    DO  i = 2, m_ncpl
+       IF ( activeserver(i) == 1 )  THEN
+          clientcount = clientcount + 1
+          pmc_server_for_client(clientcount) = i
+       ENDIF
+    ENDDO
+!
+!-- Get the size of the server model
+    IF ( m_my_cpl_id > 1 )  THEN
+       CALL MPI_COMM_REMOTE_SIZE( m_to_server_comm, m_server_remote_size,      &
+                                  istat)
+    ELSE
+!
+!--    The root model does not have a server
+       m_server_remote_size = -1
+    ENDIF
+!
+!-- Set myid to non-tero value except for the root domain. This is a setting
+!-- for the message routine which is called at the end of pmci_init. That
+!-- routine outputs messages for myid = 0, only. However, myid has not been
+!-- assigened so far, so that all PEs of the root model would output a
+!-- message. To avoid this, set myid to some other value except for PE0 of the
+!-- root domain.
+    IF ( m_world_rank /= 0 )  myid = 1
+
+ END SUBROUTINE PMC_init_model
+
+
+
+ SUBROUTINE pmc_get_model_info( comm_world_nesting, cpl_id, cpl_name,          &
+                                cpl_parent_id, lower_left_x, lower_left_y,     &
+                                ncpl, npe_total, request_for_cpl_id )
 !
 !-- Provide module private variables of the pmc for PALM
-    SUBROUTINE pmc_get_model_info( comm_world_nesting, cpl_id, cpl_name,       &
-                                   cpl_parent_id, lower_left_x, lower_left_y,  &
-                                   ncpl, npe_total, request_for_cpl_id )
-
-      USE kinds
-
-      IMPLICIT NONE
-
-      CHARACTER(LEN=*), INTENT(OUT), OPTIONAL ::  cpl_name
-
-      INTEGER, INTENT(IN), OPTIONAL ::  request_for_cpl_id
-
-      INTEGER, INTENT(OUT), OPTIONAL ::  comm_world_nesting
-      INTEGER, INTENT(OUT), OPTIONAL ::  cpl_id
-      INTEGER, INTENT(OUT), OPTIONAL ::  cpl_parent_id
-      INTEGER, INTENT(OUT), OPTIONAL ::  ncpl
-      INTEGER, INTENT(OUT), OPTIONAL ::  npe_total
-
-      INTEGER ::  requested_cpl_id
-
-      REAL(wp), INTENT(OUT), OPTIONAL ::  lower_left_x
-      REAL(wp), INTENT(OUT), OPTIONAL ::  lower_left_y
-
-!
-!--   Set the requested coupler id
-      IF ( PRESENT( request_for_cpl_id ) )  THEN
-         requested_cpl_id = request_for_cpl_id
-!
-!--      Check for allowed range of values
-         IF ( requested_cpl_id < 1 .OR. requested_cpl_id > m_ncpl )  RETURN
-      ELSE
-         requested_cpl_id = m_my_cpl_id
-      ENDIF
-
-!
-!--   Return the requested information
-      IF ( PRESENT( comm_world_nesting )  )  THEN
-         comm_world_nesting = m_world_comm
-      ENDIF
-      IF ( PRESENT( cpl_id )        )  THEN
-         cpl_id = requested_cpl_id
-      ENDIF
-      IF ( PRESENT( cpl_parent_id ) )  THEN
-         cpl_parent_id = m_couplers(requested_cpl_id)%parent_id
-      ENDIF
-      IF ( PRESENT( cpl_name )      )  THEN
-         cpl_name = m_couplers(requested_cpl_id)%name
-      ENDIF
-      IF ( PRESENT( ncpl )          )  THEN
-         ncpl = m_ncpl
-      ENDIF
-      IF ( PRESENT( npe_total )     )  THEN
-         npe_total = m_couplers(requested_cpl_id)%npe_total
-      ENDIF
-      IF ( PRESENT( lower_left_x )  )  THEN
-         lower_left_x = m_couplers(requested_cpl_id)%lower_left_x
-      ENDIF
-      IF ( PRESENT( lower_left_y )  )  THEN
-         lower_left_y = m_couplers(requested_cpl_id)%lower_left_y
-      ENDIF
-
-   END SUBROUTINE pmc_get_model_info
-
-
-
-   LOGICAL function pmc_is_rootmodel( )
-
-      IMPLICIT NONE
-
-      pmc_is_rootmodel = ( m_my_cpl_id == 1 )
-
-   END FUNCTION pmc_is_rootmodel
+
+    USE kinds
+
+    IMPLICIT NONE
+
+    CHARACTER(LEN=*), INTENT(OUT), OPTIONAL ::  cpl_name  !<
+
+    INTEGER, INTENT(IN), OPTIONAL ::  request_for_cpl_id  !<
+
+    INTEGER, INTENT(OUT), OPTIONAL ::  comm_world_nesting  !<
+    INTEGER, INTENT(OUT), OPTIONAL ::  cpl_id              !<
+    INTEGER, INTENT(OUT), OPTIONAL ::  cpl_parent_id       !<
+    INTEGER, INTENT(OUT), OPTIONAL ::  ncpl                !<
+    INTEGER, INTENT(OUT), OPTIONAL ::  npe_total           !<
+
+    INTEGER ::  requested_cpl_id  !<
+
+    REAL(wp), INTENT(OUT), OPTIONAL ::  lower_left_x  !<
+    REAL(wp), INTENT(OUT), OPTIONAL ::  lower_left_y  !<
+
+!
+!-- Set the requested coupler id
+    IF ( PRESENT( request_for_cpl_id ) )  THEN
+       requested_cpl_id = request_for_cpl_id
+!
+!--    Check for allowed range of values
+       IF ( requested_cpl_id < 1  .OR.  requested_cpl_id > m_ncpl )  RETURN
+    ELSE
+       requested_cpl_id = m_my_cpl_id
+    ENDIF
+
+!
+!-- Return the requested information
+    IF ( PRESENT( comm_world_nesting )  )  THEN
+       comm_world_nesting = m_world_comm
+    ENDIF
+    IF ( PRESENT( cpl_id )        )  THEN
+       cpl_id = requested_cpl_id
+    ENDIF
+    IF ( PRESENT( cpl_parent_id ) )  THEN
+       cpl_parent_id = m_couplers(requested_cpl_id)%parent_id
+    ENDIF
+    IF ( PRESENT( cpl_name )      )  THEN
+       cpl_name = m_couplers(requested_cpl_id)%name
+    ENDIF
+    IF ( PRESENT( ncpl )          )  THEN
+       ncpl = m_ncpl
+    ENDIF
+    IF ( PRESENT( npe_total )     )  THEN
+       npe_total = m_couplers(requested_cpl_id)%npe_total
+    ENDIF
+    IF ( PRESENT( lower_left_x )  )  THEN
+       lower_left_x = m_couplers(requested_cpl_id)%lower_left_x
+    ENDIF
+    IF ( PRESENT( lower_left_y )  )  THEN
+       lower_left_y = m_couplers(requested_cpl_id)%lower_left_y
+    ENDIF
+
+ END SUBROUTINE pmc_get_model_info
+
+
+
+ LOGICAL function pmc_is_rootmodel( )
+
+    IMPLICIT NONE
+
+    pmc_is_rootmodel = ( m_my_cpl_id == 1 )
+
+ END FUNCTION pmc_is_rootmodel
 
 
@@ -436,5 +441,5 @@
     INTEGER                ::  i, istat
 
-    TYPE(pmc_layout), DIMENSION(pmc_max_modell) ::  domain_layouts
+    TYPE(pmc_layout), DIMENSION(pmc_max_models) ::  domain_layouts
 
 !-- TO_DO: include anterp_relax_length_? into nestpar and communicate them.
@@ -443,5 +448,5 @@
 !
 !-- Initialize some coupling variables
-    domain_layouts(1:pmc_max_modell)%id = -1
+    domain_layouts(1:pmc_max_models)%id = -1
     m_ncpl =   0
 
@@ -480,13 +485,13 @@
 !
 !-- Get the number of nested models given in the nestpar-NAMELIST
-    DO  i = 1, pmc_max_modell
+    DO  i = 1, pmc_max_models
 !
 !--    When id=-1 is found for the first time, the list of domains is finished
-       IF ( m_couplers(i)%id == -1  .OR.  i == pmc_max_modell )  THEN
+       IF ( m_couplers(i)%id == -1  .OR.  i == pmc_max_models )  THEN
           IF ( m_couplers(i)%id == -1 )  THEN
              m_ncpl = i - 1
              EXIT
           ELSE
-             m_ncpl = pmc_max_modell
+             m_ncpl = pmc_max_models
           ENDIF
        ENDIF
