HI all, i code onde application to read from a file using fileviews with specifics offsets for each process.<br><br>But when i try to do this, the application enter on a loop, and the app remains without response.<br><br>The code is below.
<br><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">#include &lt;stdio.h&gt;</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
<span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">#include &quot;mpi.h&quot;</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
#define FILESIZE 1048576</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">#define INTS_PER_BLK 2
</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">int main(int argc, char **argv)</span>
<br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">{</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
<span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; int&nbsp; rank, nprocs, nints, bufsize;</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
<span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; MPI_File fh;</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
&nbsp;&nbsp;&nbsp; MPI_Datatype filetype;</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; MPI_Init(&amp;argc,&amp;argv);
</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; MPI_Comm_size(MPI_COMM_WORLD, &amp;nprocs);
</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; bufsize = FILESIZE/nprocs;</span>
<br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; int buf[10];</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
<span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; int buf2[10];</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
&nbsp;&nbsp;&nbsp; nints = bufsize/sizeof(int);</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; MPI_File_open(MPI_COMM_WORLD, &quot;
rupi.dat&quot;, MPI_MODE_RDONLY,MPI_INFO_NULL, &amp;fh);</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
&nbsp;&nbsp;&nbsp; MPI_Type_vector(3, 1, 3, MPI_INT, &amp;filetype);</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
&nbsp;&nbsp;&nbsp;&nbsp; MPI_Type_commit(&amp;filetype);</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
&nbsp;&nbsp;&nbsp; if(rank==0)</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; {</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
<span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; MPI_File_set_view(fh, 0, MPI_INT, filetype, &quot;native&quot;, MPI_INFO_NULL);</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
<span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; MPI_File_read(fh, buf, 3, MPI_INT, MPI_STATUS_IGNORE);</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
<span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int m;</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for(m=0; m&lt;=2;m++)</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; printf(&quot;\n --&gt; Matriz[%d] = %d&quot;,m,buf[m]);
</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
<span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; </span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
&nbsp;&nbsp;&nbsp; }</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; else</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
<span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; {</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; MPI_File_set_view(fh, sizeof(int), MPI_INT, filetype, &quot;native&quot;, MPI_INFO_NULL);</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; MPI_File_read(fh, buf2, 3, MPI_INT, MPI_STATUS_IGNORE);</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int m;</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for(m=0; m&lt;=2;m++)
</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
<span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; printf(&quot;\n --&gt; Matriz[%d] = %d&quot;,m,buf2[m]);</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
<span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
&nbsp;&nbsp;&nbsp; }</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; </span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
<span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; MPI_File_close(&amp;fh);</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
// &nbsp;&nbsp;&nbsp; MPI_Type_free(&amp;filetype);</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
<span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">&nbsp;&nbsp;&nbsp; MPI_Finalize();</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">
&nbsp;&nbsp;&nbsp; return 0;</span><br style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;"><span style="font-style: italic; background-color: rgb(204, 204, 204); font-weight: bold;">}<br><br><span style="font-style: italic;">
<span style="font-weight: bold;"><span style="background-color: rgb(255, 255, 255);"><span style="font-style: italic;"><span style="font-weight: bold;"><span style="font-style: italic;"><span style="font-weight: bold;">COULD YOU HELP ME?
</span></span><br>tHANKS IN ADVANCE<br><br>LUIZ MENDES<br><br></span></span></span></span></span></span>