Syntax:
MPI_Unpack und MPI_Pack bieten einerseits Möglichkeiten zum Entwerfen eigener Kommunikationsbibliotheken, zum anderen stellen sie Funktionalität zur Verfügung, die anders mit MPI nicht erreicht werden kann. Z.B. das Empfangen von Nachrichten in mehreren Stücken, wobei die nächste Empfangsoperation vom Inhalt der vorhergehenden Nachricht abhängt.
Aufruf:
#include "mpi.h"
int incount, outcount, position;
void *inbuf, *outbuf;
MPI_Datatype datatype;
MPI_Comm comm;
...
position=0;
MPI_Recv(inbuf, incount, MPI_PACKED, 0, MPI_ANY_TAG, comm, &status);
MPI_Unpack(inbuf, incount, &position, &i, 1, MPI_INT, comm);
MPI_Unpack(inbuf, incount, &position, outbuf, i, datatype, comm);
...