SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
sys2blacs_.c
Go to the documentation of this file.
1#include "Bdef.h"
2
3#if (INTFACE == C_CALL)
4Int Csys2blacs_handle(MPI_Comm SysCtxt)
5#else
7#endif
8{
9#if (INTFACE == C_CALL)
10 Int i, j, DEF_WORLD;
11 MPI_Comm *tSysCtxt;
12 extern Int BI_MaxNSysCtxt;
13 extern MPI_Comm *BI_SysContxts;
14
15 if (BI_COMM_WORLD == NULL)
16 Cblacs_pinfo(&i, &j);
17 if (SysCtxt == MPI_COMM_NULL)
18 BI_BlacsErr(-1, __LINE__, __FILE__,
19 "Cannot define a BLACS system handle based on MPI_COMM_NULL");
20/*
21 * See if we already have this system handle stored
22 */
23 for (i=0; i < BI_MaxNSysCtxt; i++)
24 if (BI_SysContxts[i] == SysCtxt) return(i);
25/*
26 * The first time in this routine, we need to define MPI_COMM_WORLD, if it isn't
27 * what is already being defined.
28 */
29 DEF_WORLD = ( (!BI_SysContxts) && (SysCtxt != MPI_COMM_WORLD) );
30/*
31 * Find free slot in system context array
32 */
33 for (i=0; i < BI_MaxNSysCtxt; i++)
34 if (BI_SysContxts[i] == MPI_COMM_NULL) break;
35/*
36 * If needed, get a bigger system context array
37 */
38 if (i == BI_MaxNSysCtxt)
39 {
41 if ( (MAXNSYSCTXT == 1) && (DEF_WORLD) ) j++;
42 tSysCtxt = (MPI_Comm *) malloc(j * sizeof(MPI_Comm));
43 for (i=0; i < BI_MaxNSysCtxt; i++) tSysCtxt[i] = BI_SysContxts[i];
45 for (j=i; j < BI_MaxNSysCtxt; j++) tSysCtxt[j] = MPI_COMM_NULL;
47 BI_SysContxts = tSysCtxt;
48 }
49 if (DEF_WORLD) BI_SysContxts[i++] = MPI_COMM_WORLD;
50 BI_SysContxts[i] = SysCtxt;
51 return(i);
52#else
53 return(*SysCtxt);
54#endif
55}
Int BI_MaxNSysCtxt
MPI_Comm * BI_SysContxts
#define Int
Definition Bconfig.h:22
void BI_BlacsErr(Int ConTxt, Int line, char *file, char *form,...)
Definition BI_BlacsErr.c:3
Int * BI_COMM_WORLD
#define MAXNSYSCTXT
Definition Bdef.h:80
void Cblacs_pinfo()
Int sys2blacs_handle_(Int *SysCtxt)
Definition sys2blacs_.c:6