MPI_TYPE_STRUCT, MPI_Type_struct Purpose Returns a new datatype that represents count blocks. Each is defined by an entry in array_of_blocklengths, array_of_displacements and array_of_types. Displacements are expressed in bytes. C synopsis #include int MPI_Type_struct(int count,int *array_of_blocklengths, MPI_Aint *array_of_displacements,MPI_Datatype *array_of_types, MPI_datatype *newtype); FORTRAN synopsis include 'mpif.h' or use mpi MPI_TYPE_STRUCT(INTEGER COUNT,INTEGER ARRAY_OF_BLOCKLENGTHS(*), INTEGER ARRAY_OF DISPLACEMENTS(*),INTEGER ARRAY_OF_TYPES(*), INTEGER NEWTYPE,INTEGER IERROR) Parameters count is an integer specifying the number of blocks. It is also the number of entries in arrays array_of_types, array_of_displacements and array_of_blocklengths. (IN) array_of_blocklengths is the number of elements in each block (array of integer). That is, array_of_blocklengths(i) specifies the number of instances of type array_of_types(i) in block(i). (IN) array_of_displacements is the byte displacement of each block (array of integer) (IN) array_of_types is the datatype comprising each block. That is, block(i) is made of a concatenation of type array_of_types(i). (array of handles to datatype objects) (IN) newtype is the new datatype (handle) (OUT) IERROR is the FORTRAN return code. It is always the last argument. Description This subroutine returns a new datatype that represents count blocks. Each is defined by an entry in array_of_blocklengths, array_of_displacements and array_of_types. Displacements are expressed in bytes. MPI_TYPE_STRUCT is the most general type of constructor. It allows each block to consist of replications of different datatypes. It is the only constructor that allows MPI pseudo types MPI_LB and MPI_UB. Without these pseudo types, the extent of a datatype is the range from the first byte to the last byte rounded up as needed to meet boundary requirements. For example, if a type is made of an integer followed by two characters, it will still have an extent of 8 because it is padded to meet the boundary constraints of an integer. This is intended to match the behavior of a compiler defining an array of such structures. Because there may be cases in which this default behavior is not correct, MPI provides a means to set explicit upper and lower bounds which may not be directly related to the lowest and highest displacement datatype. When the pseudo type MPI_UB is used, the upper bound will be the value specified as the displacement of the MPI_UB block. No rounding for alignment is done. MPI_LB can be used to set an explicit lower bound but its use does not suppress rounding. When MPI_UB is not used, the upper bound of the datatype is adjusted to make the extent a multiple of the type's most boundary constrained component. The marker placed by a MPI_LB or MPI_UB is "sticky." For example, suppose type A is defined with a MPI_UB at 100. Type B is defined with a type A at 0 and a MPI_UB at 50. In effect, type B has received a MPI_UB at 50 and an inherited MPI_UB at 100. Because the inherited MPI_UB is higher, it is kept in the type B definition and the MPI_UB explicitly placed at 50 is discarded. Notes MPI_TYPE_CREATE_STRUCT supersedes MPI_TYPE_STRUCT. For FORTRAN 64-bit codes, an array of integer may not be enough to represent array_of_displacements. When array_of_displacements is known to be representable by an array of integer, this subroutine remains usable at your own risk. New codes should always use MPI_TYPE_CREATE_STRUCT. newtype must be committed using MPI_TYPE_COMMIT before being used for communication. For most computer architectures there will be trade offs between alignment of data for best performance and wasting of space by data structure padding to achieve optimal alignment. A compiler must make decisions about when to pad, striking some balance. MPI is a run time library which does not have direct access to the compiler's decisions but must make an effort to add appropriate padding in calls to MPI_TYPE_STRUCT or MPI_TYPE_CREATE_STRUCT. The IBM XLF and XLC compilers will force double word alignment for structures that begin with a DW item (8 byte integer or 8 byte floating point) and PE MPI will match this behavior by padding the extent in MPI_TYPE_STRUCT or MPI_TYPE_CREATE_STRUCT. To write fully portable MPI code when there are structures that may get different padding on different systems, you should consider using an MPI_UB marker or calling MPI_TYPE_CREATE_RESIZED for explicit control of the datatype's extent and upper bound. Errors Invalid count count < 0 Invalid blocklength blocklength[i] < 0 Undefined oldtype in array_of_types MPI not initialized MPI already finalized Related information MPI_TYPE_COMMIT MPI_TYPE_FREE MPI_TYPE_GET_CONTENTS MPI_TYPE_GET_ENVELOPE MPI_TYPE_CREATE_STRUCT MPI_TYPE_CREATE_RESIZED