      program send_recive
c
      include 'mpif.h'
      integer error,myrank,tnode,key1,key2
      integer istat(MPI_STATUS_SIZE)
c
      call MPI_INIT(error)
      call MPI_COMM_SIZE(MPI_COMM_WORLD,tnode,error)
      call MPI_COMM_RANK(MPI_COMM_WORLD,myrank,error)
c
      key1=100*tnode+myrank
      write(*,*)'key1 =',key1,'(I am ',myrank,')'
c
      if(myrank .EQ. 0)then
         call MPI_SEND(key1,1,MPI_INTEGER,1,1111,MPI_COMM_WORLD,error)
         call MPI_RECV(key2,1,MPI_INTEGER,1,2222,MPI_COMM_WORLD,
     &                 istat,error)
      else
         call MPI_RECV(key2,1,MPI_INTEGER,0,1111,MPI_COMM_WORLD,
     &                 istat,error)
         call MPI_SEND(key1,1,MPI_INTEGER,0,2222,MPI_COMM_WORLD,error)
      end if
c
      write(6,*)'key2 =',key2,'(I am ',myrank,')'
      call MPI_FINALIZE(error)
      stop
      end
c
ccc  Result  
c
c % mpirun -np 2 ./a.out
c  key1 =         200 (I am            0 )
c  key1 =         201 (I am            1 )
c  key2 =         201 (I am            0 )
c  key2 =         200 (I am            1 )
