~ubuntu-branches/ubuntu/trusty/scotch/trusty

« back to all changes in this revision

Viewing changes to src/scotch/amk_p2.c

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2008-01-25 09:13:53 UTC
  • Revision ID: james.westby@ubuntu.com-20080125091353-zghdao60dfsyc2bt
Tags: upstream-5.0.1.dfsg
ImportĀ upstreamĀ versionĀ 5.0.1.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2004,2007 ENSEIRB, INRIA & CNRS
 
2
**
 
3
** This file is part of the Scotch software package for static mapping,
 
4
** graph partitioning and sparse matrix ordering.
 
5
**
 
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".
 
11
** 
 
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
 
16
** liability.
 
17
** 
 
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.
 
28
** 
 
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.
 
31
*/
 
32
/************************************************************/
 
33
/**                                                        **/
 
34
/**   NAME       : amk_p2.c                                **/
 
35
/**                                                        **/
 
36
/**   AUTHOR     : Francois PELLEGRINI                     **/
 
37
/**                                                        **/
 
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.                        **/
 
42
/**                                                        **/
 
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     **/
 
49
/**                                                        **/
 
50
/************************************************************/
 
51
 
 
52
/*
 
53
**  The defines and includes.
 
54
*/
 
55
 
 
56
#define AMK_P2
 
57
 
 
58
#include "common.h"
 
59
#include "scotch.h"
 
60
#include "amk_p2.h"
 
61
 
 
62
/*
 
63
**  The static variables.
 
64
*/
 
65
 
 
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              */
 
69
                              { "-", NULL, "w" } };
 
70
 
 
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",
 
75
  NULL };
 
76
 
 
77
/************************************/
 
78
/*                                  */
 
79
/* The main routine, which computes */
 
80
/* the decomposition.               */
 
81
/*                                  */
 
82
/************************************/
 
83
 
 
84
int
 
85
main (
 
86
int                         argc,
 
87
char *                      argv[])
 
88
{
 
89
  unsigned int        wght[2] = {1, 1};           /* Vertex weights */
 
90
  unsigned int        i;
 
91
 
 
92
  errorProg ("amk_p2");
 
93
 
 
94
  if ((argc >= 2) && (argv[1][0] == '?')) {       /* If need for help */
 
95
    usagePrint (stdout, C_usageList);
 
96
    return     (0);
 
97
  }
 
98
 
 
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]);
 
107
          return     (1);
 
108
        }
 
109
        continue;                                 /* Process remaining parameters */
 
110
      }
 
111
      if (C_fileNum < C_FILEARGNBR)               /* File name has been given */
 
112
        C_fileTab[C_fileNum ++].name = argv[i];
 
113
      else {
 
114
        errorPrint ("main: too many file names given");
 
115
        return     (1);
 
116
      }
 
117
    }
 
118
    else {                                       /* If found an option name */
 
119
      switch (argv[i][1]) {
 
120
        case 'H' :                               /* Give the usage message */
 
121
        case 'h' :
 
122
          usagePrint (stdout, C_usageList);
 
123
          return     (0);
 
124
        case 'V' :
 
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");
 
128
          return  (0);
 
129
        default :
 
130
          errorPrint ("main: unprocessed option (\"%s\")", argv[i]);
 
131
          return     (1);
 
132
      }
 
133
    }
 
134
  }
 
135
 
 
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);
 
141
        return     (1);
 
142
      }
 
143
    }
 
144
  }
 
145
 
 
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 */
 
150
 
 
151
#ifdef X_DEBUG_MAIN1
 
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 */
 
156
    }
 
157
  }
 
158
#endif /* X_DEBUG_MAIN1 */
 
159
 
 
160
  return (0);
 
161
}