<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 4, 2013 at 3:45 AM, Aya Aya <span dir="ltr"><<a href="mailto:aya_tounsi@hotmail.fr" target="_blank">aya_tounsi@hotmail.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I want to send (scatter) an array of N element of the structure below, with sizeof(Tab)=T<br><br>struct bloc<br>
{<br> int T;<br> double *Tab;<br>};<br>typedef struct bloc BLOC;<br><br>I wonder if it is possible to create a new MPI_Datatype for this structure (the size of Tab depends on T), or the only way is to sent it as an array (using Scatterv).</div>
</blockquote></div><br>You can create a datatype for one particular instance of this structure (fixed location of the array and fixed size T), but not a "dynamic datatype" that sends any instance of this struct. There is not an MPI_Scatterw, however, so you have to pack a homogeneous buffer yourself. Since you can't allocate on the receiver without knowing the size T, do an MPI_Scatter of the sizes T (if you don't somehow know this already), allocate, and do an MPI_Scatterv out of a single packed array (containing the concatenation of all the Tabs).</div>
</div>