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.

Row of blocks representing a vector, details are described in figcaption.
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.

Row of blocks representing a vector, details are described in figcaption.
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.

Row of blocks representing a vector, details are described in figcaption.
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.
 
©  |   Cornell University    |   Center for Advanced Computing    |   Copyright Statement    |   Inclusivity Statement