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 : amk_p2.c **/
36
/** AUTHOR : Francois PELLEGRINI **/
38
/** FUNCTION : Creates the target architecture file **/
39
/** for a weighted path with two vertices **/
40
/** used to bipartition graphs in parts of **/
41
/** different sizes. **/
43
/** DATES : # Version 3.0 : from : 17 jul 1995 **/
44
/** to : 17 jul 1995 **/
45
/** # Version 3.2 : from : 02 jun 1997 **/
46
/** to : 02 jun 1997 **/
47
/** # Version 3.4 : from : 03 feb 2000 **/
48
/** to : 03 feb 2000 **/
50
/************************************************************/
53
** The defines and includes.
63
** The static variables.
66
static int C_paraNum = 0; /* Number of parameters */
67
static int C_fileNum = 0; /* Number of file in arg list */
68
static File C_fileTab[C_FILENBR] = { /* File array */
71
static const char * C_usageList[] = {
72
"amk_p2 <wght0> [<wght1> [<output target file>]] <options>",
73
" -h : Display this help",
74
" -V : Print program version and copyright",
77
/************************************/
79
/* The main routine, which computes */
80
/* the decomposition. */
82
/************************************/
89
unsigned int wght[2] = {1, 1}; /* Vertex weights */
94
if ((argc >= 2) && (argv[1][0] == '?')) { /* If need for help */
95
usagePrint (stdout, C_usageList);
99
for (i = 0; i < C_FILENBR; i ++) /* Set default stream pointers */
100
C_fileTab[i].pntr = (C_fileTab[i].mode[0] == 'r') ? stdin : stdout;
101
for (i = 1; i < argc; i ++) { /* Loop for all option codes */
102
if ((argv[i][0] != '+') && /* If found a file name */
103
((argv[i][0] != '-') || (argv[i][1] == '\0'))) {
104
if (C_paraNum < 2) { /* If number of parameters not reached */
105
if ((wght[C_paraNum ++] = atoi (argv[i])) < 1) { /* Get vertex weights */
106
errorPrint ("main: invalid weight (\"%s\")", argv[i]);
109
continue; /* Process remaining parameters */
111
if (C_fileNum < C_FILEARGNBR) /* File name has been given */
112
C_fileTab[C_fileNum ++].name = argv[i];
114
errorPrint ("main: too many file names given");
118
else { /* If found an option name */
119
switch (argv[i][1]) {
120
case 'H' : /* Give the usage message */
122
usagePrint (stdout, C_usageList);
125
fprintf (stderr, "amk_p2, version %s - F. Pellegrini\n", SCOTCH_VERSION);
126
fprintf (stderr, "Copyright 2004,2007 ENSEIRB, INRIA & CNRS, France\n");
127
fprintf (stderr, "This software is libre/free software under CeCILL-C -- see the user's manual for more information\n");
130
errorPrint ("main: unprocessed option (\"%s\")", argv[i]);
136
for (i = 0; i < C_FILENBR; i ++) { /* For all file names */
137
if ((C_fileTab[i].name[0] != '-') || /* If not standard stream */
138
(C_fileTab[i].name[1] != '\0')) {
139
if ((C_fileTab[i].pntr = fopen (C_fileTab[i].name, C_fileTab[i].mode)) == NULL) { /* Open the file */
140
errorPrint ("main: cannot open file (%d)", i);
146
fprintf (C_filepntrtgtout, "deco\n0\n2\t3\n"); /* Print file header */
147
fprintf (C_filepntrtgtout, "0\t%u\t2\n", wght[0]); /* Print terminals */
148
fprintf (C_filepntrtgtout, "1\t%u\t3\n", wght[1]);
149
fprintf (C_filepntrtgtout, "1\n"); /* Print distance table */
152
for (i = 0; i < C_FILENBR; i ++) { /* For all file names */
153
if ((C_fileTab[i].name[0] != '-') || /* If not standard stream */
154
(C_fileTab[i].name[1] != '\0')) {
155
fclose (C_fileTab[i].pntr); /* Close the stream */
158
#endif /* X_DEBUG_MAIN1 */