next up previous contents
Next: MPI_Bcast Up: MPI - Message Passing Previous: MPI_Send   Contents

MPI_Recv

It makes sense to have a routine to receive messages when we have a routine to send off messages. Here is the synopsis:

int MPI_Recv( void *buf, int count, MPI_Datatype datatype, int source, 
          int tag, MPI_Comm comm, MPI_Status *status);
   *buf:     initial address of the send buffer
   count:    number of elements to be sent (nonnegative integer)
   datatype: datatype to be sent (e.g. MPI_INT, MPI_DOUBLE, etc.)
   source:   rank or processor number of the source
   tag:      message tag, to identify the content of message (integer)
   comm:     MPI Communicator handle
   *status:  status of the request
out of these parameters, most of them are similar to the parameters of MPI_Send except *buf is now a receive buffer, and *status tells us about the status of the request (which is ignored most of the time).

The return value is also similar to that of MPI_Send.

This routine is also blocking in the sense that the program execution will hold until it is confirmed that the data has been received into the buffer. If the corresponding MPI_Send sends more information than the count in the input parameter shows, then the routine returns an overflow error. If the sent data is shorter than called for, the buffer will only fill up partially.



J S 2002-08-14