next up previous contents
Next: MPICOMMRANK MPI Communicator Rank Up: MPI Functions Previous: MPIBCAST MPI Broadcast   Contents

Subsections

MPIRECV MPI Receive Array

Usage

This function receives an array from a source node on a given communicator with the specified tag. The general syntax for its use is

  y = mpirecv(rank,tag,comm)

where rank is the rank of the node sending the message, tag is the message tag and comm is the communicator to use. If no communicator is provided, then MPI_COMM_WORLD is used.

Example

The mpirecv command is fairly straightforward to use. Its power is in the ability to receive arrays of arbitrary complexity, including cell arrays, structures, strings, etc. Here is an example of an mpisend and mpirecv being used on the same node to pass a structure through MPI.

--> mpiinit
--> x.color = 'blue';
--> x.pi = 3;
--> x.cells = {'2',2};
--> mpisend(x,0,32);
--> y = mpirecv(0,32)
y = 
  <structure array> - size: [1 1]
    color: blue
    pi: [3]
    cells: {[1 2] cell }



Samit K. Basu 2005-03-16