title: MPI, C, derived types, struct of vectors?
body: <p>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:</p>
  
  <pre><code>class RestartData {
    int dsr;
    double firea2sorgn;
    int ifwoody[NUM_PFT];
    double rootfrac[MAX_ROT_LAY][NUM_PFT];
    ....
    ....
  }
  </code></pre>
  
  <p>I think that using the <code>MPI_Type_struct</code> is appropriate. 
  (e.g. <a href="http://www.open-mpi.org/doc/v1.5/man3/MPI_Type_struct.3.php" rel="nofollow noreferrer">http://www.open-mpi.org/doc/v1.5/man3/MPI_Type_struct.3.php</a>)</p>
  
  <p>And I more or less follow the example in this question: <a href="https://stackoverflow.com/questions/9864510/struct-serialization-in-c-and-sending-over-mpi">struct serialization in C and transfer over MPI</a>, but I am not sure how to handle the 2D arrays. Can I make an <code>MPI_Type_struct</code> that contains several <code>MPI_Type_vector</code>s? I have been unable to find an example of creating an <code>MPI_Type_struct</code> containing 2D arrays. Am I on the right approach? </p>
  
  <p>Thanks in advance.</p>
  
  <hr>
  
  <p>** 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)</p>