C
C    second - test program that sends an array of floats from the first process
C             of a group to the last, using send and recv
C
C
      integer function worker( argc, argv )
      integer argc
      integer argv
      include "mpif.h"
C
      integer rank, size, to, from, tag, count, i, ierr
      integer src, dest
      integer st_source, st_tag, st_count
C      MPI_Status status
      integer status(MPI_STATUS_SIZE)
      double precision data(100)

      call MPI_INIT( ierr )
      call MPI_COMM_RANK( MPI_COMM_WORLD, rank, ierr )
      call MPI_COMM_SIZE( MPI_COMM_WORLD, size, ierr )
      print *, "Process ", rank, " of ", size, " is alive"
C
      src = size - 1
      dest = 0
C      
      if (rank .eq. src) then
         to     = dest
         count  = 10
         tag    = 2001
         do 10 i=1, 10
 10         data(i) = i
         call MPI_SEND( data, count, MPI_DOUBLE_PRECISION, to, tag, 
     &                  MPI_COMM_WORLD, ierr )
         print *, rank, " sent"
         print *, (data(i),i=1,10)
      elseif (rank .eq. dest) then
         tag   = MPI_ANY_TAG
         count = 10		
         from  = MPI_ANY_SOURCE
         call MPI_RECV(data, count, MPI_DOUBLE_PRECISION, from, tag, 
     &                 MPI_COMM_WORLD, status, ierr ) 
            
c         call MPI_GET_SOURCE( status, st_source )
c         call MPI_GET_TAG(    status, st_tag )
c         call MPI_GET_COUNT(  status, st_count )
         st_count  = status(MPI_STATUS_COUNT)
         st_source = status(MPI_STATUS_SOURCE)
         st_tag    = status(MPI_STATUS_TAG)
c         
         print *, "Status info: source = ", st_source, 
     &             " tag = ", st_tag, " count = ", st_count
         print *, rank, " received", (data(i),i=1,10)
      endif
        
        call MPI_FINALIZE( ierr )
        print *, "Process ", rank, " exiting"
        return
        end

