      program main
      include 'mpif.h'
      integer i,istart,iend,isum,isum1
      integer nprocs,myrank,ierr,istat(MPI_STATUS_SIZE)
      call mpi_init(ierr)
      call mpi_comm_size(MPI_COMM_WORLD,nprocs,ierr)
      call mpi_comm_rank(MPI_COMM_WORLD,myrank,ierr)
      istart=myrank*50+1
      iend=(myrank+1)*50
      isum=0
      do i=istart, iend
         isum=isum+i
      end do
      if (myrank.eq.1) then
         call mpi_send(isum,1,MPI_INTEGER,0,100,MPI_COMM_WORLD,ierr)
      else
         call mpi_recv(isum1,1,MPI_INTEGER,1,100,MPI_COMM_WORLD,istat,
     *                 ierr)
      end if
      if (myrank.eq.0) write(6,*) 'sum =', isum+isum1
      call mpi_finalize(ierr)
      stop
      end
