I need to create an MPI derived type to represent a class in my program. The class is fairly straight forward, but large (about 75 data members**). All the data members are single values, 1D arrays, or 2D arrays. Here is an example:
class RestartData {
int dsr;
double firea2sorgn;
int ifwoody[NUM_PFT];
double rootfrac[MAX_ROT_LAY][NUM_PFT];
....
....
}
I think that using the MPI_Type_struct
is appropriate.
(e.g. http://www.open-mpi.org/doc/v1.5/man3/MPI_Type_struct.3.php)
And I more or less follow the example in this question: struct serialization in C and transfer over MPI, but I am not sure how to handle the 2D arrays. Can I make an MPI_Type_struct
that contains several MPI_Type_vector
s? I have been unable to find an example of creating an MPI_Type_struct
containing 2D arrays. Am I on the right approach?
Thanks in advance.
** I think I understand the possible problems with passing a single large message, but in this case, the message is passed infrequently, and at a natural synchronization point (slaves sending data back to the master when they are done crunching numbers)