I'm trying to set up a very simple 1 * 2 grid using the following code:
int nprow, npcol, myrow, mycol, myid;
char rowcol[1] = "R";
nprow = 1;
npcol = size / nprow;
if(npcol * nprow != size){
printf("Error");
MPI_Finalize();
exit(1);
}
Cblacs_pinfo(&myid, &size);
Cblacs_get(0, 0, &ictxt);
Cblacs_gridinit(&ictxt, rowcol, nprow, npcol);
Cblacs_pcoord(ictxt, myid, &myrow, &mycol);
printf("rank = %d, nprow = %d, npcol = %d, myrow = %d, mycol = %d\n", rank, nprow, npcol, myrow, mycol); }
The problem is that the Cblacs_pcoord
function seems to be changing nprow to 0 no matter what it is initailly set to and this, in turn, gives 0 for every myrow while the npcol and mycol variables are always correct for any number of processors used. I am very confused since this function shouldn't touch nprow but I've printed nprow after every line of code and it is the correct value until after that function is called.
If I'm missing any information that would help you answer my question please let me know and I will update accordingly.