A vector-derived datatype follows a regular pattern but, at the same time, allows
for "holes" via a stride. The stride normally exceeds the block length.
Vector-derived datatype. In this example, each data element uses two blocks. The stride is five blocks, leaving 3 blocks between each element.
An indexed-derived datatype relies on arrays to hold element lengths and displacements,
permitting holes that are arbitrary in location and size.
Indexed-derived datatype. In this example, both the element lengths and blocks between elements are variable. The block length expresses the size of each element in terms of the count of a basic datatype and the displacement defines the starting position of each element relative to the start of the vector. The first element has length 3 and displacement 0, while the second element has length 2 and displacement 5. This leaves two blocks between the first two elements.
A struct-derived datatype consists of elements that may be of different basic
datatypes; therefore, displacements must be given in bytes.
Struct-derived datatype. Like the index-derived datatype example, both the element lengths and number of spaces between the elements are variable. Unlike the index-derived datatype, size is measured in bytes instead of counts of a particular basic datatype. For struct-derived datatypes, the block length gives the size of each element in bytes and the displacement defines the starting position of each element relative to the start of the vector.