NAME
MMPPIITTyyppeessttrruucctt - Creates a struct data type - use of this routine is
deprecated. SSYYNNTTAAXX CC SSyynnttaaxx#include
int MPITypestruct(int count, int *arrayofblocklengths, MPIAint *arrayofdisplacements, MPIDatatype *arrayoftypes, MPIDatatype *newtype) FFoorrttrraann SSyynnttaaxx INCLUDE 'mpif.h' MPITYPESTRUCT(COUNT, ARRAYOFBLOCKLENGTHS, ARRAYOFDISPLACEMENTS, ARRAYOFTYPES,NEWTYPE, IERROR)
INTEGER COUNT, ARRAYOFBLOCKLENGTHS(*) INTEGER ARRAYOFDISPLACEMENTS(*)INTEGER ARRAYOFTYPES(*), NEWTYPE, IERROR
IINNPPUUTT PPAARRAAMMEETTEERRSS count Number of blocks (integer) also number of entries in arraysarrayoftypes, arrayofdisplacements, and arrayofblock-
lengths. arrayofblocklengths Number of elements in each block (array). arrayofdisplacements Byte displacement of each block (array). arrayoftypes Type of elements in each block (array of handles to datatype objects). OOUUTTPPUUTT PPAARRAAMMEETTEERRSS newtype New datatype (handle).IERROR Fortran only: Error status (integer).
DESCRIPTION
Note that use of this routine is deprecated as of MPI-2. Use
MPITypecreatestruct instead. This deprecated routine is not available in C++.MPITypestruct is the most general type constructor. It further gener-
alizes MPITypehindexed in that it allows each block to consist of replications of different datatypes. EExxaammppllee:: Let type1 have type map {(double, 0), (char, 8)} with extent 16. Let B = (2, 1, 3), D = (0, 16, 26), and T = (MPIFLOAT, type1, MPICHAR). Then a call to MPITypestruct(3, B, D, T, newtype) returns a datatype with type map {(float, 0), (float,4), (double, 16), (char, 24), (char, 26), (char, 27), (char, 28)} That is, two copies of MPIFLOAT starting at 0, followed by one copy of type1 starting at 16, followed by three copies of MPICHAR, starting at 26. (We assume that a float occupies 4 bytes.)For more information, see section 3.12.1 of the MPI-1.1 Standard.
NNOOTTEESS If an upperbound is set explicitly by using the MPI datatype MPIUB, the corresponding index must be positive.The MPI-1 Standard originally made vague statements about padding and
alignment; this was intended to allow the simple definition of struc-
tures that could be sent with a count greater than one. For example, struct {int a; char b;} foo; may have sizeof(foo) = sizeof(int) + sizeof(char); defining the extent of a datatype as including an epsilon, which would have allowed an implementation to make the extent an MPI datatype for this structure equal to 2*sizeof(int). However, since different systems might define different paddings, a clarification to the standard made epsilon zero. Thus, if you define a structure datatype and wish to send or receive multiple items, you should explicitly include an MPIUB entry as the last member of the structure. For example, the following code can be used for the structure foo: blen[0] = 1; indices[0] = 0; oldtypes[0] = MPIINT;blen[1] = 1; indices[1] = &foo.b - &foo; oldtypes[1] = MPICHAR;
blen[2] = 1; indices[2] = sizeof(foo); oldtypes[2] = MPIUB; MPITypestruct( 3, blen, indices, oldtypes, &newtype ); 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
MPITypecreatestruct MPITypecreatehindexed Open MPI 1.2 September 2006 MPITypestruct(3OpenMPI)