      include 'mpif.h'
      parameter(numdat=100)
      integer status(MPI_STATUS_SIZE),senddata(numdat),recvdata(numdat)
      integer source,dest,tag
      call MPI_INIT(ierr)
      call MPI_COMM_RANK(MPI_COMM_WORLD,myrank,ierr)
      call MPI_COMM_SIZE(MPI_COMM_WORLD,nprocs,ierr)
      icount=(numdat-1)/nprocs+1
      if(myrank.eq.0)then
        open(10,file='fort.10')
        read(10,*) senddata
        do i=1,nprocs-1
          dest=i
          tag=myrank
          call MPI_SEND(senddata(icount*i+1),icount,MPI_INTEGER,
     &                  dest,tag,MPI_COMM_WORLD,ierr)
        enddo
        recvdata=senddata
      else
        source=0
        tag=source
        call MPI_RECV(recvdata(icount*myrank+1),icount,MPI_INTEGER,
     &                source,tag,MPI_COMM_WORLD,status,ierr)
      endif
      isum=0
      do i=1,icount
        isum=isum+recvdata(icount*myrank+i)
      enddo
      write(6,*) myrank,':sum= ',isum
      call MPI_FINALIZE(ierr)
      stop
      end
