NAME
MMPPIIPPaacckk - Packs data of a given datatype into contiguous memory.
SSYYNNTTAAXX CC SSyynnttaaxx#include
int MPIPack(void *inbuf, int incount, MPIDatatype datatype, void *outbuf, int outsize, int *position, MPIComm comm) FFoorrttrraann SSyynnttaaxx INCLUDE 'mpif.h' MPIPACK(INBUF, INCOUNT, DATATYPE, OUTBUF,OUTSIZE, POSITION,COMM, IERROR)
INBUF(*), OUTBUF(*) INTEGER INCOUNT, DATATYPE, OUTSIZE, POSITION, COMM, IERROR
CC++++ SSyynnttaaxx#include
void Datatype::Pack(const void* inbuf, int incount, void *outbuf, int outsize, int& position, const Comm &comm) const IINNPPUUTT PPAARRAAMMEETTEERRSS inbuf Input buffer start (choice). incount Number of input data items (integer). datatype Datatype of each input data item (handle). outsize Output buffer size, in bytes (integer). comm Communicator for packed message (handle). IINNPPUUTT//OOUUTTPPUUTT PPAARRAAMMEETTEERR position Current position in buffer, in bytes (integer). OOUUTTPPUUTT PPAARRAAMMEETTEERRSS outbuf Output buffer start (choice).IERROR Fortran only: Error status (integer).
DESCRIPTION
Packs the message in the send buffer specified by inbuf, incount, datatype into the buffer space specified by outbuf and outsize. The input buffer can be any communication buffer allowed in MPISend. The output buffer is a contiguous storage area containing outsize bytes,starting at the address outbuf (length is counted in bytes, not ele-
ments, as if it were a communication buffer for a message of type MPIPacked). The input value of position is the first location in the output buffer to be used for packing. position is incremented by the size of the packed message, and the output value of position is the first location in the output buffer following the locations occupied by the packedmessage. The comm argument is the communicator that will be subse-
quently used for sending the packed message. EExxaammppllee:: An example using MPIPack: int position, i, j, a[2]; char buff[1000]; .... MPICommrank(MPICOMMWORLD, &myrank); if (myrank == 0) { / * SENDER CODE */ position = 0; MPIPack(&i, 1, MPIINT, buff, 1000, &position, MPICOMMWORLD); MPIPack(&j, 1, MPIINT, buff, 1000, &position, MPICOMMWORLD); MPISend( buff, position, MPIPACKED, 1, 0, MPICOMMWORLD); } else /* RECEIVER CODE */ MPIRecv( a, 2, MPIINT, 0, 0, MPICOMMWORLD) } EERRRROORRSS Almost all MPI routines return an error value; C routines as the valueof the function and Fortran routines in the last argument. C++ func-
tions do not return errors. If the default error handler is set toMPI::ERRORSTHROWEXCEPTIONS, then on error the C++ exception mechanism
will be used to throw an MPI:Exception object. Before the error value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job, except for I/O function errors. The error handler may be changed withMPICommseterrhandler; the predefined error handler MPIERRORSRETURN
may be used to cause error values to be returned. Note that MPI does not guarantee that an MPI program can continue past an error.SEE ALSO
MPIUnpack MPIPacksize Open MPI 1.2 September 2006 MPIPack(3OpenMPI)