SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
free_handle_.c
Go to the documentation of this file.
1#include "Bdef.h"
2
3#if (INTFACE == C_CALL)
4void Cfree_blacs_system_handle(Int ISysCtxt)
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
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}
Int BI_MaxNSysCtxt
MPI_Comm * BI_SysContxts
#define Int
Definition Bconfig.h:22
#define MAXNSYSCTXT
Definition Bdef.h:80
void BI_BlacsWarn(Int ConTxt, Int line, char *file, char *form,...)
Definition BI_BlacsWarn.c:3
void free_blacs_system_handle_(Int *ISysCxt)
Definition free_handle_.c:6