ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
free_handle_.c
Go to the documentation of this file.
1 #include "Bdef.h"
2 
3 #if (INTFACE == C_CALL)
4 void Cfree_blacs_system_handle(int ISysCtxt)
5 #else
6 void free_blacs_system_handle_(int *ISysCxt)
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 
16  if ( (ISysCtxt < BI_MaxNSysCtxt) && (ISysCtxt > 0) )
17  {
18  if (BI_SysContxts[ISysCtxt] != MPI_COMM_NULL)
19  BI_SysContxts[ISysCtxt] = MPI_COMM_NULL;
20  else BI_BlacsWarn(-1, __LINE__, __FILE__,
21  "Trying to free non-existent system context handle %d", ISysCtxt);
22  }
23  else if (ISysCtxt == 0) return; /* never free MPI_COMM_WORLD */
24  else BI_BlacsWarn(-1, __LINE__, __FILE__,
25  "Trying to free non-existent system context handle %d", ISysCtxt);
26 
27 /*
28  * See if we have freed enough space to decrease the size of our table
29  */
30  for (i=j=0; i < BI_MaxNSysCtxt; i++)
31  if (BI_SysContxts[i] == MPI_COMM_NULL) j++;
32 /*
33  * If needed, get a smaller system context array
34  */
35  if (j > 2*MAXNSYSCTXT)
36  {
38  tSysCtxt = (MPI_Comm *) malloc(j * sizeof(MPI_Comm));
39  for (i=j=0; i < BI_MaxNSysCtxt; i++)
40  {
41  if (BI_SysContxts[i] != MPI_COMM_NULL)
42  tSysCtxt[j++] = BI_SysContxts[i];
43  }
45  for(; j < BI_MaxNSysCtxt; j++) tSysCtxt[j] = MPI_COMM_NULL;
46  free(BI_SysContxts);
47  BI_SysContxts = tSysCtxt;
48  }
49 #endif
50 }
BI_SysContxts
MPI_Comm * BI_SysContxts
Definition: BI_GlobalVars.c:12
MAXNSYSCTXT
#define MAXNSYSCTXT
Definition: Bdef.h:80
Bdef.h
BI_MaxNSysCtxt
int BI_MaxNSysCtxt
Definition: BI_GlobalVars.c:6
BI_BlacsWarn
void BI_BlacsWarn(int ConTxt, int line, char *file, char *form,...)
Definition: BI_BlacsWarn.c:3
free_blacs_system_handle_
void free_blacs_system_handle_(int *ISysCxt)
Definition: free_handle_.c:6