!----------------------------------------------------------------------- ! Original CCM without handshaking should look like this !----------------------------------------------------------------------- program main include 'mpif.h' implicit none integer ierr, myProc integer CCM_World integer local_sum ! MPI_COMM_WORLD is a MACRO substitution, not a variable. We recommend ! not to use it in your code. Instead use a VARIABLE with a name ! more specific to your code, such as CCM_WORLD. ! ! It's necessary to call MPI_COMM_DUP( MPI_COMM_WORLD, CCM_World, ierr) ! to copy the communicator pointered by MPI_COMM_WORLD to a ! communicator pointered by CCM_WORLD. ! ! Later on, when MPH_setup are invoked, the appropriate COMMUNICATOR ! is passed on directly to CCM_WORLD; no changes in the original codes ! is needed. call MPI_INIT (ierr) call MPI_COMM_DUP( MPI_COMM_WORLD, CCM_World, ierr) call MPI_COMM_RANK (CCM_World, myProc, ierr) call MPI_REDUCE (myProc, local_sum, 1, MPI_INTEGER, MPI_SUM, & 0, CCM_World, ierr) if (myProc == 0) then write(*,*)' sum of local ranks in ccm is ', local_sum endif call MPI_FINALIZE (ierr) end