IBM Books

MPI Subroutine Reference

MPI_PACK, MPI_Pack

Purpose

Packs the message in the specified send buffer into the specified buffer space.

C synopsis

#include <mpi.h>
int MPI_Pack(void* inbuf,int incount,MPI_Datatype datatype,
	     void *outbuf,int outsize,int *position,MPI_Comm comm);

C++ synopsis

#include mpi.h
void MPI::Datatype::Pack(const void* inbuf, int incount, void* outbuf, 
			 int outsize, int& position, const MPI::Comm& comm) 
			 const;

FORTRAN synopsis

include 'mpif.h' or use mpi
MPI_PACK(CHOICE INBUF,INTEGER INCOUNT,INTEGER DATATYPE,CHOICE OUTBUF,
	 INTEGER OUTSIZE,INTEGER POSITION,INTEGER COMM,INTEGER IERROR)

Parameters

inbuf
is the input buffer start (choice) (IN)

incount
is an integer specifying the number of input data items (IN)

datatype
is the datatype of each input data item (handle) (IN)

outbuf
is the output buffer start (choice) (OUT)

outsize
is an integer specifying the output buffer size in bytes (OUT)

position
is the current position in the output buffer counted in bytes (integer) (INOUT)

comm
is the communicator for sending the packed message (handle) (IN)

IERROR
is the FORTRAN return code. It is always the last argument.

Description

This subroutine packs the message specified by inbuf, incount, and datatype into the buffer space specified by outbuf and outsize. The input buffer is any communication buffer allowed in MPI_SEND. The output buffer is any contiguous storage space containing outsize bytes and starting at the address outbuf.

The input value of position is the beginning offset in the output buffer that will be used for packing. The output value of position is the offset in the output buffer following the locations occupied by the packed message. comm is the communicator that will be used for sending the packed message.

Notes

MPI_PACK must be used with some care in 64-bit applications because outsize and position are integers and can be subject to overflow.

Errors

Invalid incount
incount < 0

Invalid datatype

Type not committed

Invalid communicator

Outbuf too small

Negative length or position for buffer
outsize < 0 or position < 0

MPI not initialized

MPI already finalized

Related information

MPI_PACK_SIZE
MPI_UNPACK


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]