next up previous index
Next: Vector Up: Datatype Constructors Previous: Datatype Constructors


The simplest constructor is MPI_Type_contiguous, the C language interface of which is given by:

MPI_Type_contiguous(int count, MPI_Datatype oldtype, MPI_Datatype *newtype)
In Fortran this function has the following interface:
mpi_type_contiguous(count, oldtype, newtype, ierror)
integer count, oldtype, newtype, ierror
This function specifies a new derived MPI type, the reference to which is going to be stored on newtype, which comprises count items of type oldtype stored contiguously in the processor's memory. MPI semantics assume that the concatenation preserves the extent of the original data.

For example gluing together three objects of type:

{(double, 0), (char, 8)}
will produce
{(double, 0), (char, 8), (double, 16), (char, 24), (double, 32), (char, 40)}
If we have used some other function to define the {(double, 0), (char, 8)} and called it, say, named_double, then the new data type could be called three_named_doubles and it's creation in C would be accouplished as follows:
MPI_Type_contiguous(3, named_double, &three_named_doubles);
We have already encountered this function in our program which calculated forces between particles. There we used function mpi_type_contiguous in order to construct an MPI data type that could be used to transfer a structure comprising 3 coordinates of a particle and its mass between MPI processes.

So how to define an MPI datatype that stores a double precision floating point number and a character? For this we will have to use function MPI_Type_struct. This function has a very complicated synopsis because it lets an MPI programmer construct an object that picks up data items of any types, even derived types, from any memory locations. So we are going to leave the discussion of this function for the time being, instead looking at simpler functions and gradually getting closer to understanding how MPI_Type_struct works.

next up previous index
Next: Vector Up: Datatype Constructors Previous: Datatype Constructors
Zdzislaw Meglicki