c-----------------------------------------------c
      program sendtest
c-----------------------------------------------c
      implicit double precision(a-h,o-z)
      real*8  u(125000)
# ifdef MPI
 
include mpif.h 
real*8  t0,t1,t2,t3
      integer istatus(MPI_STATUS_SIZE)
c      MPI_Status stat
#endif

#ifdef MPI
      call MPI_INIT( ierr )
      call MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr )
      call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
#endif
      write(*,*)  'finished mpi initialisation: myid is', myid
      if(numprocs.ne.2) then
        write(*,*) 'Invalid numprocs and/or nps',numprocs,'.ne.',2
        stop
      endif

      do 200 i=1,125000
         di = i
         u(i) = 2.5d0*di
  200   continue
         npkt = 125000
#ifdef MPI
      if(myid.eq.0) then
      write(*,*) 'buffersize=',1000000,'myid=',0,'destination=',1
                call MPI_SEND(u(1),npkt,MPI_DOUBLE_PRECISION,1,
     &                        99,MPI_COMM_WORLD,ierr)
      write(*,*) 'finished mpi_send with ierr=',ierr
      else
      write(*,*) 'buffersize=',1000000,'myid=',1,'source=',0
                call MPI_RECV(u(1),npkt,MPI_DOUBLE_PRECISION,0,
     &                        99,MPI_COMM_WORLD,istatus,ierr)           
      write(*,*) 'finished mpi_recv with ierr=',ierr
      endif
      if(myid.eq.1) then
      write(*,*) 'buffersize=',1000000,'myid=',1,'destination=',0
                call MPI_SEND(u(1),npkt,MPI_DOUBLE_PRECISION,0,
     &                        99,MPI_COMM_WORLD,ierr)
      write(*,*) 'finished mpi_reverse_send with ierr=',ierr
      else
      write(*,*) 'buffersize=',1000000,'myid=',0,'source=',1
                call MPI_RECV(u(1),npkt,MPI_DOUBLE_PRECISION,1,
     &                        99,MPI_COMM_WORLD,istatus,ierr)           
      write(*,*) 'finished mpi_reverse_recv with ierr=',ierr
      endif
      call MPI_FINALIZE(irc)
#endif
      end
