      program send_recv
      include 'mpif.h'

      integer ierr,myrank,tnode
      integer a(11)
      integer istat(mpi_status_size)
c
      call mpi_init(ierr)
      call mpi_comm_size(MPI_COMM_WORLD,tnode,ierr)
      call mpi_comm_rank(MPI_COMM_WORLD,myrank,ierr)
c
      lb = 10 /tnode
      lc = mod(10,tnode)
c
      if(myrank+1 .le. lc) then
         is = myrank *lb +myrank +1
         ie = is +lb
      else
         is = myrank *lb +lc +1
         ie = is +lb -1
      end if
c
      do 10 i = is, ie
         a(i) = i **2
 10   continue
c
      do 30 l = 1, tnode-1
         if(myrank .ne. 0)then
            call mpi_send(a(lb*l+lc+1),lb,mpi_integer,0,l,
     &                    mpi_comm_world,ierr)
         else
            call mpi_recv(a(lb*l+lc+1),lb,mpi_integer,l,l,
     &                    mpi_comm_world,istat,ierr)
         end if
 30   continue
c
 100  format(a3,i3,a5,i4)
      do 20 j = 1,10
         if(myrank.EQ.0)then
            write(*,100)'a(',j,') = ',a(j)
         end if
 20   continue
c
      call mpi_finalize(ierr)
      stop
      end

c
ccc  Result
c
c % mpirun -np 2 ./a.out
c a(  1 ) =    1
c a(  2 ) =    4
c a(  3 ) =    9
c a(  4 ) =   16
c a(  5 ) =   25
c a(  6 ) =   36
c a(  7 ) =   49
c a(  8 ) =   64
c a(  9 ) =   81
c a( 10 ) =  100
