      program main
      include 'mpif.h'
      parameter(n=200)
      integer i,j,istart,iend
      double precision x(n),y(n)
      integer nprocs,myrank,ierr
      call mpi_init(ierr)
      call mpi_comm_size(MPI_COMM_WORLD,nprocs,ierr)
      call mpi_comm_rank(MPI_COMM_WORLD,myrank,ierr)
      istart=n*myrank/nprocs+1
      iend=n*(myrank+1)/nprocs
      do i=istart, iend
         x(i)=dble(i)
      end do
      call mpi_allgather(x(istart),iend-istart+1,MPI_DOUBLE_PRECISION,
     *                   y,iend-istart+1,MPI_DOUBLE_PRECISION,
     *                   MPI_COMM_WORLD,ierr)
      if (myrank.eq.0) then
         do i=1, n
            write(6,*) i, y(i)
         end do
      end if
      call mpi_finalize(ierr)
      stop
      end
