I have problems with writing 2d block cyclic distributed array in file.
I've tried this things:
rc=MPI_File_open(MPI_COMM_WORLD, rez, MPI_MODE_WRONLY, MPI_INFO_NULL, &cFile);
if(rc){printf("Failed to open file! Error: %d \n", rc);MPI_Finalize();
fflush(stdout);}
else
{
MPI_File_write_all(cFile, MatC, loccC*locrC, compa, &status);
}
...
rc=MPI_File_open(MPI_COMM_WORLD, rez, MPI_MODE_WRONLY, MPI_INFO_NULL, &cFile);
if(rc){printf("Failed to open file! Error: %d \n", rc);MPI_Finalize();
fflush(stdout);}
else
{
MPI_File_write_ordered(cFile, MatC, loccC*locrC, compa, &status);
}
...
rc=MPI_File_open(MPI_COMM_WORLD, rez, MPI_MODE_WRONLY, MPI_INFO_NULL, &cFile);
if(rc){printf("Failed to open file! Error: %d \n", rc);MPI_Finalize();
fflush(stdout);}
else
{
MPI_File_write_shared(cFile, MatC, loccC*locrC, compa, &status);
}
I couldn't find nothing in this post (But just how to read a file and format it into 2d block cyclic distributed array (which I've succeeded using that post)): MPI IO Reading and Writing Block Cyclic Matrix
Sorry for my terrible English :(
You told you have used this post: MPI IO Reading and Writing Block Cyclic Matrix. We must assume some things - such as dimensions of matrix MatC: let's assume ther are m rows and n columns. Dimensions of block in MatC, let's assume they are m_b and n_b. Let's assume number of processors is nproc, and that rank of proc is saved in variable node. Also, we must know dimensions of 2D-torus (processor grid), for our example p and q. Here's how you do that:
int dims[]={m, n}, dargs[]={m_b, n_b}, distribs[]={MPI_DISTRIBUTE_CYCLIC, MPI_DISTRIBUTE_CYCLIC}, nproc, dim[]={p, q};
char nat[]="native";
MPI_Datatype dcarray, compa; //don't know what type compa is
...
MPI_Type_create_darray(nproc, node, 2, dims, distribs, dargs, dim, MPI_ORDER_C, compa, &dcarray);
MPI_Type_commit(&dcarray);
rc=MPI_File_open(comm, rez, MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &cFile);
if(rc){printf("Failed to open file! Error: %d \n", rc);MPI_Finalize(); fflush(stdout);}
else
{
MPI_File_set_view(cFile, 0, compa, dcarray, nat, MPI_INFO_NULL);
MPI_File_write_all(cFile, MatC, locrC*loccC, compa, &status);
}
MPI_File_close(&cFile);