Criação de Tipo Derivado (cont.)
block_lengths[0] = block_lengths[1] = block_lengths[2] = 1;
/* Build a derived datatype consisting of two floats and an int */
typelist[0] = MPI_FLOAT; typelist[1] = MPI_FLOAT; typelist[2] = MPI_INT;
/* First element, a, is at displacement 0 */
/* Calculate other displacements relative to a */
MPI_Address(a_ptr, &start_address);
/* Find address of b and displacement from a */
MPI_Address(b_ptr, &address); displacements[1] = address - start_address;
/* Find address of n and displacement from a */
MPI_Address(n_ptr, &address); displacements[2] = address - start_address;
/* Build the derived datatype */
MPI_Type_struct(3, block_lengths, displacements, typelist, mesg_mpi_t_ptr);
/* Commit it -- tell system we'll be using it for communication. */
MPI_Type_commit(mesg_mpi_t_ptr); }