6.3. Canonical MPI_PACK and MPI_UNPACK
Up: Datatypes
Next: Collective Communication
Previous: Pack and Unpack
These procedures read/write data to/from the buffer in the
"external32" data
format specified in Section External Data Representation: "external32", and calculate the size needed
for packing. Their first arguments specify the data format, for future
extensibility, but
currently
the only valid value of the datarep
argument is "external32".
Advice to users.
These procedures could be used, for example, to send typed data in a portable
format from one MPI implementation to another.
( End of advice to users.)
The buffer will contain exactly the packed data, without headers.
MPI_BYTE should be used to send and receive data that is packed
using MPI_PACK_EXTERNAL.
Rationale.
MPI_PACK_EXTERNAL specifies that there is no header on the message
and further
specifies the exact format of the data. Since MPI_PACK may (and is
allowed
to) use a header, the datatype MPI_PACKED cannot be used for data
packed with
MPI_PACK_EXTERNAL.
( End of rationale.)
MPI_PACK_EXTERNAL(datarep, inbuf, incount, datatype, outbuf, outsize, position) |
IN datarep | data representation (string) |
IN inbuf | input buffer start (choice) |
IN incount | number of input data items (integer) |
IN datatype | datatype of each input data item (handle) |
OUT outbuf | output buffer start (choice) |
IN outsize | output buffer size, in bytes (integer) |
INOUT position | current position in buffer, in bytes (integer) |
C binding
int MPI_Pack_external(const char datarep[], const void *inbuf, int incount, MPI_Datatype datatype, void *outbuf, MPI_Aint outsize, MPI_Aint *position)
int MPI_Pack_external_c(const char datarep[], const void *inbuf, MPI_Count incount, MPI_Datatype datatype, void *outbuf, MPI_Count outsize, MPI_Count *position)
Fortran 2008 binding
MPI_Pack_external(datarep, inbuf, incount, datatype, outbuf, outsize, position, ierror)
CHARACTER(LEN=*), INTENT(IN) :: datarep
TYPE(*), DIMENSION(..), INTENT(IN) :: inbuf
INTEGER, INTENT(IN) :: incount
TYPE(MPI_Datatype), INTENT(IN) :: datatype
TYPE(*), DIMENSION(..) :: outbuf
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(IN) :: outsize
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(INOUT) :: position
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
MPI_Pack_external(datarep, inbuf, incount, datatype, outbuf, outsize, position, ierror) !(_c)
CHARACTER(LEN=*), INTENT(IN) :: datarep
TYPE(*), DIMENSION(..), INTENT(IN) :: inbuf
INTEGER(KIND=MPI_COUNT_KIND), INTENT(IN) :: incount, outsize
TYPE(MPI_Datatype), INTENT(IN) :: datatype
TYPE(*), DIMENSION(..) :: outbuf
INTEGER(KIND=MPI_COUNT_KIND), INTENT(INOUT) :: position
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
MPI_PACK_EXTERNAL(DATAREP, INBUF, INCOUNT, DATATYPE, OUTBUF, OUTSIZE, POSITION, IERROR)
CHARACTER*(*) DATAREP
<type> INBUF(*), OUTBUF(*)
INTEGER INCOUNT, DATATYPE, IERROR
INTEGER(KIND=MPI_ADDRESS_KIND) OUTSIZE, POSITION
MPI_UNPACK_EXTERNAL(datarep, inbuf, insize, position, outbuf, outcount, datatype) |
IN datarep | data representation (string) |
IN inbuf | input buffer start (choice) |
IN insize | input buffer size, in bytes (integer) |
INOUT position | current position in buffer, in bytes (integer) |
OUT outbuf | output buffer start (choice) |
IN outcount | number of output data items (integer) |
IN datatype | datatype of output data item (handle) |
C binding
int MPI_Unpack_external(const char datarep[], const void *inbuf, MPI_Aint insize, MPI_Aint *position, void *outbuf, int outcount, MPI_Datatype datatype)
int MPI_Unpack_external_c(const char datarep[], const void *inbuf, MPI_Count insize, MPI_Count *position, void *outbuf, MPI_Count outcount, MPI_Datatype datatype)
Fortran 2008 binding
MPI_Unpack_external(datarep, inbuf, insize, position, outbuf, outcount, datatype, ierror)
CHARACTER(LEN=*), INTENT(IN) :: datarep
TYPE(*), DIMENSION(..), INTENT(IN) :: inbuf
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(IN) :: insize
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(INOUT) :: position
TYPE(*), DIMENSION(..) :: outbuf
INTEGER, INTENT(IN) :: outcount
TYPE(MPI_Datatype), INTENT(IN) :: datatype
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
MPI_Unpack_external(datarep, inbuf, insize, position, outbuf, outcount, datatype, ierror) !(_c)
CHARACTER(LEN=*), INTENT(IN) :: datarep
TYPE(*), DIMENSION(..), INTENT(IN) :: inbuf
INTEGER(KIND=MPI_COUNT_KIND), INTENT(IN) :: insize, outcount
INTEGER(KIND=MPI_COUNT_KIND), INTENT(INOUT) :: position
TYPE(*), DIMENSION(..) :: outbuf
TYPE(MPI_Datatype), INTENT(IN) :: datatype
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
MPI_UNPACK_EXTERNAL(DATAREP, INBUF, INSIZE, POSITION, OUTBUF, OUTCOUNT, DATATYPE, IERROR)
CHARACTER*(*) DATAREP
<type> INBUF(*), OUTBUF(*)
INTEGER(KIND=MPI_ADDRESS_KIND) INSIZE, POSITION
INTEGER OUTCOUNT, DATATYPE, IERROR
MPI_PACK_EXTERNAL_SIZE(datarep, incount, datatype, size) |
IN datarep | data representation (string) |
IN incount | number of input data items (integer) |
IN datatype | datatype of each input data item (handle) |
OUT size | output buffer size, in bytes (integer) |
C binding
int MPI_Pack_external_size(const char datarep[], int incount, MPI_Datatype datatype, MPI_Aint *size)
int MPI_Pack_external_size_c(const char datarep[], MPI_Count incount, MPI_Datatype datatype, MPI_Count *size)
Fortran 2008 binding
MPI_Pack_external_size(datarep, incount, datatype, size, ierror)
CHARACTER(LEN=*), INTENT(IN) :: datarep
INTEGER, INTENT(IN) :: incount
TYPE(MPI_Datatype), INTENT(IN) :: datatype
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(OUT) :: size
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
MPI_Pack_external_size(datarep, incount, datatype, size, ierror) !(_c)
CHARACTER(LEN=*), INTENT(IN) :: datarep
INTEGER(KIND=MPI_COUNT_KIND), INTENT(IN) :: incount
TYPE(MPI_Datatype), INTENT(IN) :: datatype
INTEGER(KIND=MPI_COUNT_KIND), INTENT(OUT) :: size
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
MPI_PACK_EXTERNAL_SIZE(DATAREP, INCOUNT, DATATYPE, SIZE, IERROR)
CHARACTER*(*) DATAREP
INTEGER INCOUNT, DATATYPE, IERROR
INTEGER(KIND=MPI_ADDRESS_KIND) SIZE
Up: Datatypes
Next: Collective Communication
Previous: Pack and Unpack
Return to MPI-4.1 Standard Index
Return to MPI Forum Home Page
(Unofficial) MPI-4.1 of November 2, 2023
HTML Generated on November 19, 2023