
        program main
        include 'mpif.h'

        integer rank, size, to, from, tag, count, i, ierr
        integer src, dest, st_source, st_tag, st_count
        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'
        dest = size - 1
        src = 0

        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)
        else if (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)
           call mpi_get_count(status, mpi_double_precision, st_count, 
     +                        ierr)
           st_source = status(mpi_source)
           st_tag = status(mpi_tag)

           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)
        end


