9{
   12 
   13   MPI_Comm Cblacs2sys_handle(
Int BlacsCtxt);
 
   15 
   17   Int info, i, j, *iptr;
 
   18   Int myrow, mycol, nprow, npcol, Ng;
 
   20   MPI_Comm comm, tcomm;
   21   MPI_Group grp, tgrp;
   22 
   27 
   28
   29
   30
   32   {
   37   }
   38 
   39   nprow = 
Mpval(nprow0);
 
   40   npcol = 
Mpval(npcol0);
 
   41   Ng = nprow * npcol;
   42   if ( (Ng > 
BI_Np) || (nprow < 1) || (npcol < 1) )
 
   44                  "Illegal grid (%d x %d), #procs=%d", nprow, npcol, 
BI_Np);
 
   45
   46
   47
   48   if (Ng > 2) i = Ng;
   49   else i = 2;
   50   iptr = (
Int *) malloc(i*
sizeof(
Int));
 
   51   for (j=0; j < npcol; j++)
   52   {
   53      for (i=0; i < nprow; i++) iptr[i*npcol+j] = usermap[j*
Mpval(ldup)+i];
 
   54   }
   55#if (INTFACE == C_CALL)
   57   for (j=0; j < Ng; j++) miptr[j] = iptr[j];
   58   tcomm = Cblacs2sys_handle(*ConTxt);
   59   MPI_Comm_group(tcomm, &grp);           
   60   MPI_Group_incl(grp, Ng, miptr, &tgrp);  
   61   MPI_Comm_create(tcomm, tgrp, &comm);   
   62   MPI_Group_free(&tgrp);
   63   MPI_Group_free(&grp);
   64   free(miptr);
   65#else  
   67#endif
   68 
   69
   70
   71
   72   if (comm == MPI_COMM_NULL)
   73   {
   75      free(iptr);
   76      return;
   77   }
   78 
   79
   80
   81
   82
   83
   85
   86
   87
   89
   90
   91
   93   {
  101   }
  103   *ConTxt = i;
  104 
  106   MPI_Comm_dup(comm, &ctxt->
pscp.
comm); 
 
  107   MPI_Comm_rank(comm, &Iam);            
  108   myrow = Iam / npcol;
  109   mycol = Iam % npcol;
  110 
  111
  112
  113
  114   MPI_Comm_split(comm, myrow, mycol, &ctxt->
rscp.
comm);
 
  115
  116
  117
  118   MPI_Comm_split(comm, mycol, myrow, &ctxt->
cscp.
comm);
 
  119 
  129 
  130
  131
  132
  133
  134
  141   free(iptr);
  142 
  143}
BLACSCONTEXT ** BI_MyContxts
MPI_Comm BI_TransUserComm(Int Ucomm, Int Np, Int *pmap)
void BI_BlacsErr(Int ConTxt, Int line, char *file, char *form,...)