1
/* Copyright 2004,2007 ENSEIRB, INRIA & CNRS
3
** This file is part of the Scotch software package for static mapping,
4
** graph partitioning and sparse matrix ordering.
6
** This software is governed by the CeCILL-C license under French law
7
** and abiding by the rules of distribution of free software. You can
8
** use, modify and/or redistribute the software under the terms of the
9
** CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
10
** URL: "http://www.cecill.info".
12
** As a counterpart to the access to the source code and rights to copy,
13
** modify and redistribute granted by the license, users are provided
14
** only with a limited warranty and the software's author, the holder of
15
** the economic rights, and the successive licensors have only limited
18
** In this respect, the user's attention is drawn to the risks associated
19
** with loading, using, modifying and/or developing or reproducing the
20
** software by the user in light of its specific status of free software,
21
** that may mean that it is complicated to manipulate, and that also
22
** therefore means that it is reserved for developers and experienced
23
** professionals having in-depth computer knowledge. Users are therefore
24
** encouraged to load and test the software's suitability as regards
25
** their requirements in conditions enabling the security of their
26
** systems and/or data to be ensured and, more generally, to use and
27
** operate it in the same conditions as regards security.
29
** The fact that you are presently reading this means that you have had
30
** knowledge of the CeCILL-C license and that you accept its terms.
32
/************************************************************/
34
/** NAME : library_graph_f.c **/
36
/** AUTHOR : Francois PELLEGRINI **/
38
/** FUNCTION : This file contains the Fortran API for **/
39
/** the source graph handling routines of **/
40
/** the libSCOTCH library. **/
42
/** DATES : # Version 3.4 : from : 02 dec 1999 **/
43
/** to 15 nov 2001 **/
44
/** # Version 4.0 : from : 11 dec 2001 **/
45
/** to 17 mar 2005 **/
46
/** # Version 5.0 : from : 11 jul 2007 **/
47
/** to 11 jul 2007 **/
49
/************************************************************/
52
** The defines and includes.
61
/**************************************/
63
/* These routines are the Fortran API */
64
/* for the graph handling routines. */
66
/**************************************/
73
SCOTCHFGRAPHINIT, scotchfgraphinit, ( \
74
SCOTCH_Graph * const grafptr, \
75
int * const revaptr), \
78
*revaptr = SCOTCH_graphInit (grafptr);
86
SCOTCHFGRAPHEXIT, scotchfgraphexit, ( \
87
SCOTCH_Graph * const grafptr), \
90
SCOTCH_graphExit (grafptr);
98
SCOTCHFGRAPHFREE, scotchfgraphfree, ( \
99
SCOTCH_Graph * const grafptr), \
102
SCOTCH_graphFree (grafptr);
105
/* When an input stream is built from the given
106
** file handle, it is set as unbuffered, so as to
107
** allow for multiple stream reads from the same
108
** file handle. If it were buffered, too many
109
** input characters would be read on the first
114
SCOTCHFGRAPHLOAD, scotchfgraphload, ( \
115
SCOTCH_Graph * const grafptr, \
116
int * const fileptr, \
117
const SCOTCH_Num * const baseptr, \
118
const SCOTCH_Num * const flagptr, \
119
int * const revaptr), \
120
(grafptr, fileptr, baseptr, flagptr, revaptr))
122
FILE * stream; /* Stream to build from handle */
123
int filenum; /* Duplicated handle */
126
if ((filenum = dup (*fileptr)) < 0) { /* If cannot duplicate file descriptor */
127
errorPrint ("SCOTCHFGRAPHLOAD: cannot duplicate handle");
128
*revaptr = 1; /* Indicate error */
131
if ((stream = fdopen (filenum, "r+")) == NULL) { /* Build stream from handle */
132
errorPrint ("SCOTCHFGRAPHLOAD: cannot open input stream");
137
setbuf (stream, NULL); /* Do not buffer on input */
139
o = SCOTCH_graphLoad (grafptr, stream, *baseptr, *flagptr);
141
fclose (stream); /* This closes filenum too */
151
SCOTCHFGRAPHSAVE, scotchfgraphsave, ( \
152
const SCOTCH_Graph * const grafptr, \
153
int * const fileptr, \
154
int * const revaptr), \
155
(grafptr, fileptr, revaptr))
157
FILE * stream; /* Stream to build from handle */
158
int filenum; /* Duplicated handle */
161
if ((filenum = dup (*fileptr)) < 0) { /* If cannot duplicate file descriptor */
162
errorPrint ("SCOTCHFGRAPHSAVE: cannot duplicate handle");
164
*revaptr = 1; /* Indicate error */
167
if ((stream = fdopen (filenum, "w+")) == NULL) { /* Build stream from handle */
168
errorPrint ("SCOTCHFGRAPHSAVE: cannot open output stream");
174
o = SCOTCH_graphSave (grafptr, stream);
176
fclose (stream); /* This closes filenum too */
186
SCOTCHFGRAPHBUILD, scotchfgraphbuild, ( \
187
SCOTCH_Graph * const grafptr, \
188
const SCOTCH_Num * const baseptr, \
189
const SCOTCH_Num * const vertptr, \
190
const SCOTCH_Num * const verttab, \
191
const SCOTCH_Num * const vendtab, \
192
const SCOTCH_Num * const velotab, \
193
const SCOTCH_Num * const vlbltab, \
194
const SCOTCH_Num * const edgeptr, \
195
const SCOTCH_Num * const edgetab, \
196
const SCOTCH_Num * const edlotab, \
197
int * const revaptr), \
198
(grafptr, baseptr, vertptr, verttab, vendtab, \
199
velotab, vlbltab, edgeptr, edgetab, edlotab, \
202
*revaptr = SCOTCH_graphBuild (grafptr, *baseptr, *vertptr, verttab, vendtab,
203
velotab, vlbltab, *edgeptr, edgetab, edlotab);
211
SCOTCHFGRAPHSIZE, scotchfgraphsize, ( \
212
const SCOTCH_Graph * const grafptr, \
213
SCOTCH_Num * const vertptr, \
214
SCOTCH_Num * const edgeptr), \
215
(grafptr, vertptr, edgeptr))
217
SCOTCH_graphSize (grafptr, vertptr, edgeptr);
225
SCOTCHFGRAPHDATA, scotchfgraphdata, ( \
226
const SCOTCH_Graph * const grafptr, \
227
const SCOTCH_Num * const indxptr, \
228
SCOTCH_Num * const baseptr, \
229
SCOTCH_Num * const vertptr, \
230
SCOTCH_Num * const vertidx, \
231
SCOTCH_Num * const vendidx, \
232
SCOTCH_Num * const veloidx, \
233
SCOTCH_Num * const vlblidx, \
234
SCOTCH_Num * const edgeptr, \
235
SCOTCH_Num * const edgeidx, \
236
SCOTCH_Num * const edloidx), \
237
(grafptr, indxptr, baseptr, \
238
vertptr, vertidx, vendidx, veloidx, vlblidx, \
239
edgeptr, edgeidx, edloidx))
241
SCOTCH_Num * verttab; /* Pointer to graph arrays */
242
SCOTCH_Num * vendtab;
243
SCOTCH_Num * velotab;
244
SCOTCH_Num * vlbltab;
245
SCOTCH_Num * edgetab;
246
SCOTCH_Num * edlotab;
248
SCOTCH_graphData (grafptr, baseptr, vertptr, &verttab, &vendtab, &velotab, &vlbltab,
249
edgeptr, &edgetab, &edlotab);
250
*vertidx = (verttab - indxptr) + 1; /* Add 1 since Fortran indices start at 1 */
251
*vendidx = (vendtab - indxptr) + 1;
252
*veloidx = (velotab != NULL) ? (velotab - indxptr) + 1 : *vertidx;
253
*vlblidx = (vlbltab != NULL) ? (vlbltab - indxptr) + 1 : *vertidx;
254
*edgeidx = (edgetab - indxptr) + 1;
255
*edloidx = (edlotab != NULL) ? (edlotab - indxptr) + 1 : *edgeidx;
263
SCOTCHFGRAPHSTAT, scotchfgraphstat, ( \
264
const SCOTCH_Graph * const grafptr, \
265
SCOTCH_Num * const velominptr, \
266
SCOTCH_Num * const velomaxptr, \
267
SCOTCH_Num * const velosumptr, \
268
double * veloavgptr, \
269
double * velodltptr, \
270
SCOTCH_Num * const degrminptr, \
271
SCOTCH_Num * const degrmaxptr, \
272
double * degravgptr, \
273
double * degrdltptr, \
274
SCOTCH_Num * const edlominptr, \
275
SCOTCH_Num * const edlomaxptr, \
276
SCOTCH_Num * const edlosumptr, \
277
double * edloavgptr, \
278
double * edlodltptr), \
279
(grafptr, velominptr, velomaxptr, velosumptr, \
280
veloavgptr, velodltptr, degrminptr, \
281
degrmaxptr, degravgptr, degrdltptr, \
282
edlominptr, edlomaxptr, edlosumptr, \
283
edloavgptr, edlodltptr))
285
SCOTCH_graphStat (grafptr,
286
velominptr, velomaxptr, velosumptr, veloavgptr, velodltptr,
287
degrminptr, degrmaxptr, degravgptr, degrdltptr,
288
edlominptr, edlomaxptr, edlosumptr, edloavgptr, edlodltptr);