      PROGRAM product
      INCLUDE 'mpif.h'
      INTEGER err, rank, size
      INTEGER source,result,root
      
C     run on 10 processors

      CALL MPI_INIT(err)
      CALL MPI_COMM_RANK(MPI_COMM_WORLD, rank, err)
      CALL MPI_COMM_SIZE(MPI_COMM_WORLD, size, err)
      
      root=7
      source=rank+1
      call MPI_BARRIER(MPI_COMM_WORLD,err)

      call MPI_REDUCE(source,result,1,MPI_INTEGER,MPI_PROD,
      &                       root,MPI_COMM_WORLD,err)
      if(rank.eq.root) then
         print *,'P:',rank,' prod result is ',result
      end if

      CALL MPI_FINALIZE(err)
      END

