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 <stdio.h></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 "mpi.h"</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;"> int 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;"> 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;">
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;"> MPI_Init(&argc,&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;"> MPI_Comm_rank(MPI_COMM_WORLD, &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;"> MPI_Comm_size(MPI_COMM_WORLD, &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;"> 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;"> 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;"> 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;">
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;"> MPI_File_open(MPI_COMM_WORLD, "
rupi.dat", MPI_MODE_RDONLY,MPI_INFO_NULL, &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;">
MPI_Type_vector(3, 1, 3, MPI_INT, &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;">
MPI_Type_commit(&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;">
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;"> {</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;"> MPI_File_set_view(fh, 0, MPI_INT, filetype, "native", 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;"> 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;"> 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;">
for(m=0; m<=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;"> {
</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;"> printf("\n --> Matriz[%d] = %d",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;"> }</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;">
}</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;"> 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;"> {</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;">
MPI_File_set_view(fh, sizeof(int), MPI_INT, filetype, "native", 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;">
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;">
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;"> for(m=0; m<=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;"> {</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;"> printf("\n --> Matriz[%d] = %d",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;"> }</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;"> </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;"> MPI_File_close(&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;">
// MPI_Type_free(&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;"> 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;">
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>