I have a computer with nproc
processors and I'd like to initialize two blacs grids, one of the dimension p x q = nprocs
and one of the dimension 1 x 1
.
Assume MPI allready initialized and a routine finding good block sizes, the first grid is initialized via
call blacs_get( -1, 0, self%context )
call blacs_gridinit( self%context, 'R', self%nprows, self%npcols )
call blacs_gridinfo( self%context, self%nprows, self%npcols, self%myrow, self%mycol )
But how do I set up the second? Do I have to introduce another mpi communicator first?
As an answer and example, I share this implementation:
Which adds three blacs context, no need to initialize another MPI communicator, and amounts to the following output on four cores:
So, the crucial point is that the first argument of blacs_gridinit is an input/output argument, needing the globale blacs context of all processes as an input. It is recived in a new variable by the call to blacs_get, third argument.
What I found quite counter intuitive in this case is the fact, that the value of the context seems to follow some kind of sum rule, so after initializing the 1x1 grid and then again a 4x4 grid, the values of the 4x4 grid handle are not the same on all processes.