rendered paste body#include <stdlib.h>#include <stdio.h>#include <mpi.h>#include <mpix.h>// BLACS#ifdef GPAW_NO_UNDERSCORE_CBLACS#define Cblacs_gridexit_ Cblacs_gridexit#define Cblacs_gridinit_ Cblacs_gridinit#define Csys2blacs_handle_ Csys2blacs_handle#define Cblacs2sys_handle_ Cblacs2sys_handle#endifvoid Cblacs_gridexit_(int ConTxt);void Cblacs_gridinit_(int* ConTxt, char* order, int nprow, int npcol);int Csys2blacs_handle_(MPI_Comm comm);MPI_Comm Cblacs2sys_handle_(int ConTxt);// End of BLACS int main(int argc, char *argv[]){ int nprow = 4; int npcol = 4; int iam, nprocs; int ConTxt; int result = 0; char order = 'R'; // Create blacs grid on this communicator MPI_Comm bg_comm; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_rank(MPI_COMM_WORLD, &iam); // Sanity check on MPI_COMM_WORLD, then reset result to zero. MPIX_Get_property(MPI_COMM_WORLD, MPIDO_RECT_COMM, &result); if(result) fprintf(stderr, "MPI_COMM_WORLD is a rectangular comm\n"); result = 0; ConTxt = Csys2blacs_handle_(MPI_COMM_WORLD); Cblacs_gridinit_(&ConTxt, &order, nprow, npcol); if (ConTxt != -1) { bg_comm = Cblacs2sys_handle_(ConTxt); MPIX_Get_property(bg_comm, MPIDO_RECT_COMM, &result); if(result) fprintf(stderr, "bg_comm is a rectangular subcomm\n"); } MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize();}