OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
mumps_scotch.c
Go to the documentation of this file.
1/*
2 *
3 * This file is part of MUMPS 5.5.1, released
4 * on Tue Jul 12 13:17:24 UTC 2022
5 *
6 *
7 * Copyright 1991-2022 CERFACS, CNRS, ENS Lyon, INP Toulouse, Inria,
8 * Mumps Technologies, University of Bordeaux.
9 *
10 * This version of MUMPS is provided to you free of charge. It is
11 * released under the CeCILL-C license
12 * (see doc/CeCILL-C_V1-en.txt, doc/CeCILL-C_V1-fr.txt, and
13 * https://cecill.info/licences/Licence_CeCILL-C_V1-en.html)
14 *
15 */
16/* Interfacing with SCOTCH and pt-SCOTCH */
17#include <stdio.h>
18#include <stdlib.h>
19#include <string.h>
20#include "mumps_scotch.h"
21#if defined(scotch) || defined(ptscotch)
22void MUMPS_CALL
23MUMPS_SCOTCH_ORD( const MUMPS_INT * const n, /* NCMP or N */
24 const MUMPS_INT * const iwlen, /* LIW8 */
25 MUMPS_INT * const petab, /* IPE */
26 const MUMPS_INT * const pfree,
27 MUMPS_INT * const lentab, /* numbers of edges for each vertex */
28 MUMPS_INT * const iwtab,
29 MUMPS_INT * const nvtab, /* weight of nodes */
30 MUMPS_INT * const elentab, /* permutation on output (permtab) */
31 MUMPS_INT * const lasttab,
32 MUMPS_INT * const ncmpa,
33 MUMPS_INT * const weightused,
34 MUMPS_INT * const weightrequested )
35{
36/* weightused(out) = weightrequested since it is always used to build graph
37 FIXME it is not exploited on output and could be suppressed from interface
38 = 0 otherwise
39*/
40 MUMPS_INT * vendtab ; /* Vertex end array */
41 SCOTCH_Graph grafdat; /* Graph */
42 SCOTCH_Strat stratdat;
43 MUMPS_INT vertnum;
44 *weightused = *weightrequested;
45 vendtab=malloc(*n * sizeof(MUMPS_INT));
46 for (vertnum = 0; vertnum < *n; vertnum ++)
47 vendtab[vertnum] = petab[vertnum] + lentab[vertnum];
48 SCOTCH_graphInit (&grafdat);
49 if ( *weightrequested == 1 )
50 {
51 SCOTCH_graphBuild (&grafdat, 1, *n, (SCOTCH_Num *) petab, (SCOTCH_Num *) vendtab, (SCOTCH_Num *) nvtab, NULL, *iwlen, (SCOTCH_Num *) iwtab, NULL); /* Assume Fortran-based indexing */
52 }
53 else
54 {
55 SCOTCH_graphBuild (&grafdat, 1, *n, (SCOTCH_Num *) petab, (SCOTCH_Num *) vendtab, NULL, NULL, *iwlen, (SCOTCH_Num *) iwtab, NULL); /* Assume Fortran-based indexing */
56 }
57 SCOTCH_stratInit(&stratdat);
58 *ncmpa=SCOTCH_graphOrder(&grafdat, &stratdat, (SCOTCH_Num *) elentab, (SCOTCH_Num *) lasttab, NULL, NULL, NULL);
59 SCOTCH_stratExit(&stratdat);
60 SCOTCH_graphExit(&grafdat);
61 free(vendtab);
62}
63void MUMPS_CALL
64MUMPS_SCOTCH( const MUMPS_INT * const n,
65 const MUMPS_INT * const iwlen,
66 MUMPS_INT * const petab,
67 const MUMPS_INT * const pfree,
68 MUMPS_INT * const lentab,
69 MUMPS_INT * const iwtab,
70 MUMPS_INT * const nvtab,
71 MUMPS_INT * const elentab,
72 MUMPS_INT * const lasttab,
73 MUMPS_INT * const ncmpa,
74 MUMPS_INT * const weightused,
75 MUMPS_INT * const weightrequested )
76{
77/* weightused(out) = 1 if weight of nodes provided in nvtab are used (esmumpsv is called)
78 = 0 otherwise
79*/
80#if ((SCOTCH_VERSION == 6) && (SCOTCH_RELEASE >= 1)) || (SCOTCH_VERSION >= 7)
81/* esmumpsv prototype with 64-bit integers weights of nodes in the graph are used on entry (nvtab) */
82 if ( *weightrequested == 1 )
83 {
84 *ncmpa = esmumpsv( *n, *iwlen, petab, *pfree,
85 lentab, iwtab, nvtab, elentab, lasttab );
86 *weightused=1;
87 }
88 else
89 {
90 /* esmumps prototype with standard integers (weights of nodes not used on entry) */
91 *ncmpa = esmumps( *n, *iwlen, petab, *pfree,
92 lentab, iwtab, nvtab, elentab, lasttab );
93 *weightused=0;
94 }
95#else
96 /* esmumps prototype with standard integers (weights of nodes not used on entry) */
97 *ncmpa = esmumps( *n, *iwlen, petab, *pfree,
98 lentab, iwtab, nvtab, elentab, lasttab );
99 *weightused=0;
100#endif
101}
102void MUMPS_CALL
103MUMPS_SCOTCH_VERSION(MUMPS_INT *version)
104 {
105 *version = SCOTCH_VERSION;
106 return;
107}
108void MUMPS_CALL
109MUMPS_SCOTCH_GET_PTHREAD_NUMBER (MUMPS_INT *PTHREAD_NUMBER)
110 {
111 *PTHREAD_NUMBER = -1; /* NOT SET*/
112#if (SCOTCH_VERSION>=7)
113 if (getenv("SCOTCH_PTHREAD_NUMBER"))
114 {
115 *PTHREAD_NUMBER = atoi(getenv("SCOTCH_PTHREAD_NUMBER"));
116 }
117#endif
118 return;
119}
120void MUMPS_CALL
121MUMPS_SCOTCH_SET_PTHREAD_NUMBER (MUMPS_INT *PTHREAD_NUMBER)
122 {
123#if (SCOTCH_VERSION>=7)
124 char param[32];
125#if defined(MUMPS_WIN32)
126 int ierr;
127#endif
128 if (*PTHREAD_NUMBER == -1)
129 {
130#if defined(MUMPS_WIN32)
131 ierr = _putenv("SCOTCH_PTHREAD_NUMBER=");
132#else
133 unsetenv("SCOTCH_PTHREAD_NUMBER");
134#endif
135 }
136 else
137 {
138#if defined(MUMPS_WIN32)
139 sprintf(param, "SCOTCH_PTHREAD_NUMBER=%d",*PTHREAD_NUMBER);
140 ierr = _putenv(param);
141#else
142 sprintf(param, "%d", *PTHREAD_NUMBER);
143 setenv("SCOTCH_PTHREAD_NUMBER",param,1);
144#endif
145 }
146#endif
147 return;
148}
149#endif /* scotch or ptscotch*/
150#if defined(ptscotch)
151void MUMPS_CALL
152MUMPS_DGRAPHINIT(SCOTCH_Dgraph *graphptr, MPI_Fint *comm, MPI_Fint *ierr)
153{
154 MPI_Comm int_comm;
155 int_comm = MPI_Comm_f2c(*comm);
156 *ierr = SCOTCH_dgraphInit(graphptr, int_comm);
157 return;
158}
159#endif
LIBSEQ_INT MPI_Comm
Definition mpi.h:50
#define MUMPS_INT
#define MUMPS_CALL
n