Index: palm/trunk/SOURCE/pmc_handle_communicator.f90
===================================================================
--- palm/trunk/SOURCE/pmc_handle_communicator.f90	(revision 1765)
+++ palm/trunk/SOURCE/pmc_handle_communicator.f90	(revision 1779)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! ------------------
-!
+! only the total number of PEs is given in the nestpar-NAMELIST,
+! additional comments included
 !
 ! Former revisions:
@@ -62,6 +63,5 @@
       INTEGER  ::  id
       INTEGER  ::  parent_id
-      INTEGER  ::  npe_x
-      INTEGER  ::  npe_y
+      INTEGER  ::  npe_total
 
       REAL(wp) ::  lower_left_x
@@ -155,6 +155,5 @@
             start_pe(1) = 0
             DO  i = 2, m_nrofcpl+1
-               start_pe(i) = start_pe(i-1) +                                   &
-                             m_couplers(i-1)%npe_x * m_couplers(i-1)%npe_y
+               start_pe(i) = start_pe(i-1) + m_couplers(i-1)%npe_total
             ENDDO
 
@@ -162,14 +161,10 @@
 !--         The number of cores provided with the run must be the same as the
 !--         total sum of cores required by all nest domains
-!--         TO_DO: can we use > instead of /= ?
             IF ( start_pe(m_nrofcpl+1) /= m_world_npes )  THEN
-!--            TO_DO: this IF statement is redundant
-               IF ( m_world_rank == 0 )  THEN
-                  WRITE ( message_string, '(A,I6,A,I6,A)' )                    &
-                                  'nesting-setup requires more MPI procs (',   &
-                                  start_pe(m_nrofcpl+1), ') than provided (',  &
-                                  m_world_npes,')'
-                  CALL message( 'pmc_init_model', 'PA0229', 3, 2, 0, 6, 0 )
-               ENDIF
+               WRITE ( message_string, '(A,I6,A,I6,A)' )                       &
+                               'nesting-setup requires more MPI procs (',      &
+                               start_pe(m_nrofcpl+1), ') than provided (',     &
+                               m_world_npes,')'
+               CALL message( 'pmc_init_model', 'PA0229', 3, 2, 0, 6, 0 )
             ENDIF
 
@@ -210,6 +205,5 @@
          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_x,        1, MPI_INTEGER, 0, MPI_COMM_WORLD, istat )
-         CALL MPI_BCAST( m_couplers(i)%npe_y,        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 )
@@ -233,12 +227,4 @@
       CALL MPI_COMM_SPLIT( MPI_COMM_WORLD, m_my_cpl_id, m_my_cpl_rank, comm,   &
                            istat )
-      IF ( istat /= MPI_SUCCESS )  THEN
-!
-!--      TO_DO: replace by message-call
-!--      TO_DO: Can this really happen, or is this just for the debugging phase?
-         IF ( m_world_rank == 0 )  WRITE (0,*) 'PMC: Error in MPI_Comm_split '
-         CALL MPI_ABORT( MPI_COMM_WORLD, ierr, istat )
-      ENDIF
-
 !
 !--   Get size and rank of the model running on this PE
@@ -256,5 +242,5 @@
 
 !
-!--   TO_DO: describe what is happening here, and why
+!--   Save the current model communicator for PMC internal use
       m_model_comm = comm
 
@@ -268,6 +254,8 @@
          IF ( m_couplers(i)%parent_id == m_my_cpl_id )  THEN
 !
-!--         Collect server PEs
-!--         TO_DO: explain in more details, what is done here
+!--         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),   &
@@ -278,18 +266,12 @@
          ELSEIF ( i == m_my_cpl_id)  THEN
 !
-!--         Collect client PEs
-!--         TO_DO: explain in more detail, what is happening here
+!--         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
-
-         IF ( istat /= MPI_SUCCESS )  THEN
-!
-!--         TO_DO: replace by message-call
-!--         TO_DO: can this really happen, or is this just for debugging?
-            IF ( m_world_rank == 0 )  WRITE (0,*) 'PMC: Error in Coupler Setup '
-            CALL MPI_ABORT( MPI_COMM_WORLD, ierr, istat )
          ENDIF
 
@@ -309,10 +291,6 @@
          ENDIF
       ENDDO
-!--   TO_DO: explain why this is done
-      pmc_server_for_client(clientcount+1) = -1
-
 !
 !--   Get the size of the server model
-!--   TO_DO: what does "size" mean here? Number of PEs?
       IF ( m_my_cpl_id > 1 )  THEN
          CALL MPI_COMM_REMOTE_SIZE( m_to_server_comm, m_server_remote_size,    &
@@ -337,9 +315,6 @@
 !
 !-- Make module private variables available to palm
-!-- TO_DO: why can't they be available from the beginning, i.e. why do they
-!--        first have to be declared as different private variables?
    SUBROUTINE pmc_get_local_model_info( my_cpl_id, my_cpl_parent_id, cpl_name, &
-                                        npe_x, npe_y, lower_left_x,            &
-                                        lower_left_y )
+                                        npe_total, lower_left_x, lower_left_y )
 
       USE kinds
@@ -350,15 +325,12 @@
       INTEGER, INTENT(OUT), OPTIONAL          ::  my_cpl_id
       INTEGER, INTENT(OUT), OPTIONAL          ::  my_cpl_parent_id
-      INTEGER, INTENT(OUT), OPTIONAL          ::  npe_x
-      INTEGER, INTENT(OUT), OPTIONAL          ::  npe_y
+      INTEGER, INTENT(OUT), OPTIONAL          ::  npe_total
       REAL(wp), INTENT(OUT), OPTIONAL         ::  lower_left_x
       REAL(wp), INTENT(OUT), OPTIONAL         ::  lower_left_y
 
-!--   TO_DO: is the PRESENT clause really required here?
       IF ( PRESENT( my_cpl_id )           )  my_cpl_id        = m_my_cpl_id
       IF ( PRESENT( my_cpl_parent_id )    )  my_cpl_parent_id = m_couplers(my_cpl_id)%parent_id
       IF ( PRESENT( cpl_name )            )  cpl_name         = m_couplers(my_cpl_id)%name
-      IF ( PRESENT( npe_x )               )  npe_x            = m_couplers(my_cpl_id)%npe_x
-      IF ( PRESENT( npe_y )               )  npe_y            = m_couplers(my_cpl_id)%npe_y
+      IF ( PRESENT( npe_total )           )  npe_total        = m_couplers(my_cpl_id)%npe_total
       IF ( PRESENT( lower_left_x )        )  lower_left_x     = m_couplers(my_cpl_id)%lower_left_x
       IF ( PRESENT( lower_left_y )        )  lower_left_y     = m_couplers(my_cpl_id)%lower_left_y
@@ -378,7 +350,4 @@
 
 
-
-!-- TO_DO: what does this comment mean?
-! Private SUBROUTINEs
  SUBROUTINE read_coupling_layout( nesting_mode, pmc_status )
 
@@ -438,9 +407,9 @@
 
        IF ( m_couplers(i)%id /= -1  .AND.  i <= pmc_max_modell )  THEN
-          WRITE ( 0, '(A,A,1X,4I7,1X,2F10.2)' )  'Set up Model  ',             &
-                              TRIM( m_couplers(i)%name ), m_couplers(i)%id,    &
-                              m_couplers(i)%Parent_id, m_couplers(i)%npe_x,    &
-                              m_couplers(i)%npe_y, m_couplers(i)%lower_left_x, &
-                              m_couplers(i)%lower_left_y
+          WRITE ( 0, '(A,A,1X,3I7,1X,2F10.2)' )  'Set up Model  ',             &
+                             TRIM( m_couplers(i)%name ), m_couplers(i)%id,     &
+                             m_couplers(i)%Parent_id, m_couplers(i)%npe_total, &
+                             m_couplers(i)%lower_left_x,                       &
+                             m_couplers(i)%lower_left_y
        ELSE
 !
