! An atmosphere model subroutine for Multi-Process Handshaking utility
! to facilitate a plug & play style programming using single executable.
! Written by Yun (Helen) He and Chris Ding, NERSC/LBNL, December 2000.


      subroutine ccm3_8 (CCM_World)

      use MPH_all
      implicit none

      integer CCM_World, myProc, myProc_global
      integer local_sum, global_sum

      call MPI_COMM_RANK (MPI_COMM_WORLD, myProc_global, ierr)
      call MPI_COMM_RANK (CCM_World, myProc, ierr)
      if (myProc==0) call MPH_redirect_output ('ccm')
      write(*,*) myProc, ' in ccm === ', myProc_global, ' in global'
      write(*,*) 'MPH_global_proc_id()=', MPH_global_proc_id()
      write(*,*)'my comp_id=', MPH_get_component_id("atmosphere")


!------ Do MPI operations in local world -------

      call MPI_REDUCE (myProc, local_sum, 1, MPI_INTEGER, 
     &                 MPI_SUM, 0, CCM_World, ierr)
      call MPI_REDUCE (myProc_global, global_sum, 1, 
     &                 MPI_INTEGER, MPI_SUM, 0, CCM_World, ierr)
      if (myProc == 0) then
         write(*,*)' sum of local ranks in ccm is ', local_sum
         write(*,*)' sum of global ranks in ccm is ', global_sum
      endif

      end subroutine
