MPI_Recv function - Message Passing Interface (original) (raw)

Performs a receive operation and does not return until a matching message is received.

Syntax

int MPIAPI MPI_Recv(
  _In_opt_ void         *buf,
           int          count,
           MPI_Datatype datatype,
           int          source,
           int          tag,
           MPI_Comm     comm,
  _Out_    MPI_Status   *status
);

Parameters

Return value

Returns MPI_SUCCESS on success. Otherwise, the return value is an error code.

In Fortran, the return value is stored in the IERROR parameter.

Fortran

    MPI_RECV(BUF, COUNT, DATATYPE, SOURCE, TAG, COMM, STATUS, IERROR)
        <type> BUF(*)
        INTEGER COUNT, DATATYPE, SOURCE, TAG, COMM, STATUS(MPI_STATUS_SIZE), IERROR

The length of the received message must be less than or equal to the length of the receive buffer. This function returns an overflow error if all incoming data does not fit into the receive buffer.

If the received message is shorter than the buffer, only the part of the buffer that corresponds to the message is modified. The remainder of the buffer is not modified.

Processes can send messages to themselves. However, it is unsafe to do so with the blocking send and receive operations, MPI_Send and MPI_Recv, because these blocking send and receive operations can cause a deadlock.

Note

There is an asymmetry between send and receive operations. A receive operation can accept messages from an arbitrary sender, but a send operation must specify a unique receiver. This implements a push style of communication, where data transfer is effected by the sender, rather than a pull style where data transfer is effected by the receiver.

Requirements

Product HPC Pack 2012 MS-MPI Redistributable Package, HPC Pack 2008 R2 MS-MPI Redistributable Package, HPC Pack 2008 MS-MPI Redistributable Package or HPC Pack 2008 Client Utilities
Header Mpi.h; Mpif.h
Library Msmpi.lib
DLL Msmpi.dll

See also

MPI Point to Point Functions

MPI_Send

MPI_Irecv

MPI_Datatype

MPI_Comm

MPI_Status