<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Good morning,<br><br>I want to create a new MPI_DATATYPE for my structure FRAGMENT:<br><br><b>struct elt<br>{ </b><b>long ind;</b><br><b> double val;<br>};<br>typedef struct elt elt;<br><br>struct Fragment<br>{ <br> int num;<br> elt *elt;<br>};<br>typedef struct Fragment Fragment;</b><br><br>I tried the following code:<br><br><b>MPI_Datatype MPI_elt;<br>MPI_Datatype typeelt[3] = {MPI_LONG,</b><b>MPI_DOUBLE</b><b>};<br>int l_bloc[2]={1,1};<br>MPI_Aint dispo[2];<br>elt ELT;<br>MPI_Address(&ELT.ind, dispo); <br>MPI_Address(&ELT.val, dispo+1); <br>MPI_Aint base2 = dispo[0]; <br>for (j=0; j <2; j++) dispo[j] -= base2;<br>MPI_Type_struct(2, l_bloc,dispo,typeelt,&MPI_elt); <br>MPI_Type_commit(&MPI_elt);<br><br>MPI_Datatype MPI_FRAGMENT<br>MPI_Datatype type</b><b>FRAGMENT</b><b>[2] = {MPI_INT,MPI_AINT};<br>int l_bloc3[2]={1,1};<br>MPI_Aint disposition[2];<br>Fragment FN;<br>MPI_Address(&FN.num, disposition); <br>MPI_Address(&FN.elt, disposition+1);<br>MPI_Aint base3 = disposition[0]; <br>for (j=0; j <2; j++) disposition[j] -= base3;<br>MPI_Type_struct(2, l_bloc3,disposition, type</b><b>FRAGMENT</b><b>,&MPI_</b><b>FRAGMENT</b><b>); <br>MPI_Type_commit(&MPI_</b><b>FRAGMENT</b><b>);</b><br><br>And i used MPI_scatter to send data for all processor, <br><br><b>MPI_Scatter(F, count, MPI_FRAGMENT, &rbuf, count, MPI_FRAGMENT, 0, MPI_COMM_WORLD); <br><br>for(i=0;i<count;i++)<br> {printf("%d \n",rbuf[i].num);<br> for(j=0;j<</b><b>rbuf[i].num</b><b>;j++)<br> {printf("%f ",rbuf[i].elt[j].val);}<br> }</b><br><br>I get the right value of "<b>rbuf[i].num</b>", but i can't read all values of "<b>elt</b>":<br><br><br>19: 35.000000 <br>16: 10.000000 <br>17: <br>=====================================================================================<br>= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES<br>= EXIT CODE: 11<br>= CLEANING UP REMAINING PROCESSES<br>= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES<br>=====================================================================================<br>APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)<br><br>Any help please.<br>Thanks.<br><br>                                            </div></body>
</html>