LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2004-08-26 10:12:13


On Aug 26, 2004, at 11:08 AM, Jack C wrote:

>> Yes, you can use MPI_ANY_SOURCE as the peer argument. I'm not a huge
>> fan of MPI_ANY_SOURCE, but it seems suitable for this situation. You
>> can find out who sent to you by examining the MPI_Status argument --
>> it
>> will be in the field named MPI_SOURCE.
> the line I tried was:
> n = MPI_Recv(&f, 1, MPI_DOUBLE, MPI_ANY_SOURCE, 1, MPI_COMM_WORLD,
> MPI_SOURCE);
> However, it won't compile. Perhaps I don't understand the MPI_Status
> part? I
> did a man on MPI_Recv, and it sais MPI_Status went at the end...

You need to put a pointer to the MPI_Status at the end. The field that
will be filled is named MPI_SOURCE. For example:

        MPI_Status status;
        n = MPI_Recv(&f, 1, MPI_DOUBLE, MPI_ANY_SOURCE, 1, MPI_COMM_WORLD,
&status);
        printf("I received from: %d\n", status.MPI_SOURCE);

(typed off the top of my head; forgive typos)

-- 
{+} Jeff Squyres
{+} jsquyres_at_[hidden]
{+} http://www.lam-mpi.org/