1 /* Copyright 2004,2007,2008,2010-2012,2014 IPB, Universite de Bordeaux, 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 : gtst.c **/
35 /** **/
36 /** AUTHOR : Francois PELLEGRINI **/
37 /** **/
38 /** FUNCTION : This program gives statistics on source **/
39 /** graphs. **/
40 /** **/
41 /** DATES : # Version 2.0 : from : 31 oct 1994 **/
42 /** to 03 nov 1994 **/
43 /** # Version 3.0 : from : 15 sep 1995 **/
44 /** to 19 sep 1995 **/
45 /** # Version 3.2 : from : 03 jun 1997 **/
46 /** to : 25 may 1998 **/
47 /** # Version 3.3 : from : 19 oct 1998 **/
48 /** to : 19 oct 1998 **/
49 /** # Version 3.4 : from : 10 oct 1999 **/
50 /** to 12 oct 1999 **/
51 /** # Version 4.0 : from : 10 sep 2003 **/
52 /** to : 10 sep 2003 **/
53 /** # Version 5.0 : from : 23 dec 2007 **/
54 /** to : 16 mar 2008 **/
55 /** # Version 5.1 : from : 01 jul 2010 **/
56 /** to : 14 feb 2011 **/
57 /** # Version 6.0 : from : 01 jan 2012 **/
58 /** to : 12 nov 2014 **/
59 /** **/
60 /************************************************************/
61
62 /*
63 ** The defines and includes.
64 */
65
66 #define GTST
67
68 #include "module.h"
69 #include "common.h"
70 #include "scotch.h"
71 #include "gtst.h"
72
73 /*
74 ** The static definitions.
75 */
76
77 static int C_fileNum = 0; /* Number of file in arg list */
78 static File C_fileTab[C_FILENBR] = { /* The file array */
79 { "r" },
80 { "w" } };
81
82 static const char * C_usageList[] = {
83 "gtst [<input graph file> [<output data file>]] <options>",
84 " -h : Display this help",
85 " -V : Print program version and copyright",
86 NULL };
87
88 /******************************/
89 /* */
90 /* This is the main function. */
91 /* */
92 /******************************/
93
94 int
main(int argc,char * argv[])95 main (
96 int argc,
97 char * argv[])
98 {
99 SCOTCH_Graph grafdat; /* Source graph */
100 SCOTCH_Num vertnbr;
101 SCOTCH_Num velomin;
102 SCOTCH_Num velomax;
103 SCOTCH_Num velosum;
104 double veloavg;
105 double velodlt;
106 SCOTCH_Num degrmin;
107 SCOTCH_Num degrmax;
108 double degravg;
109 double degrdlt;
110 SCOTCH_Num edgenbr;
111 SCOTCH_Num edlomin;
112 SCOTCH_Num edlomax;
113 SCOTCH_Num edlosum;
114 double edloavg;
115 double edlodlt;
116 int i;
117
118 errorProg ("gtst");
119
120 if ((argc >= 2) && (argv[1][0] == '?')) { /* If need for help */
121 usagePrint (stdout, C_usageList);
122 exit (0);
123 }
124
125 fileBlockInit (C_fileTab, C_FILENBR); /* Set default stream pointers */
126
127 for (i = 1; i < argc; i ++) { /* Loop for all option codes */
128 if ((argv[i][0] != '-') || (argv[i][1] == '\0') || (argv[i][1] == '.')) { /* If found a file name */
129 if (C_fileNum < C_FILEARGNBR) /* File name has been given */
130 fileBlockName (C_fileTab, C_fileNum ++) = argv[i];
131 else {
132 errorPrint ("main: too many file names given");
133 exit (1);
134 }
135 }
136 else { /* If found an option name */
137 switch (argv[i][1]) {
138 case 'H' : /* Give the usage message */
139 case 'h' :
140 usagePrint (stdout, C_usageList);
141 exit (0);
142 case 'V' :
143 fprintf (stderr, "gtst, version " SCOTCH_VERSION_STRING "\n");
144 fprintf (stderr, "Copyright 2004,2007,2008,2010-2012,2014 IPB, Universite de Bordeaux, INRIA & CNRS, France\n");
145 fprintf (stderr, "This software is libre/free software under CeCILL-C -- see the user's manual for more information\n");
146 return (0);
147 default :
148 errorPrint ("main: unprocessed option '%s'", argv[i]);
149 exit (1);
150 }
151 }
152 }
153
154 fileBlockOpen (C_fileTab, C_FILENBR); /* Open all files */
155
156 SCOTCH_graphInit (&grafdat);
157 SCOTCH_graphLoad (&grafdat, C_filepntrsrcinp, -1, 0);
158 SCOTCH_graphCheck (&grafdat);
159
160 SCOTCH_graphSize (&grafdat, &vertnbr, &edgenbr);
161 SCOTCH_graphStat (&grafdat, &velomin, &velomax, &velosum, &veloavg, &velodlt,
162 °rmin, °rmax, °ravg, °rdlt,
163 &edlomin, &edlomax, &edlosum, &edloavg, &edlodlt);
164
165 if (C_filepntrdatout != NULL) {
166 fprintf (C_filepntrdatout, "S\tVertex\tnbr=" SCOTCH_NUMSTRING "\n",
167 (SCOTCH_Num) vertnbr);
168 fprintf (C_filepntrdatout, "S\tVertex load\tmin=" SCOTCH_NUMSTRING "\tmax=" SCOTCH_NUMSTRING "\tsum=" SCOTCH_NUMSTRING "\tavg=%g\tdlt=%g\n",
169 (SCOTCH_Num) velomin, (SCOTCH_Num) velomax, (SCOTCH_Num) velosum, veloavg, velodlt);
170 fprintf (C_filepntrdatout, "S\tVertex degree\tmin=" SCOTCH_NUMSTRING "\tmax=" SCOTCH_NUMSTRING "\tsum=" SCOTCH_NUMSTRING "\tavg=%g\tdlt=%g\n",
171 (SCOTCH_Num) degrmin, (SCOTCH_Num) degrmax, (SCOTCH_Num) edgenbr, degravg, degrdlt);
172 fprintf (C_filepntrdatout, "S\tEdge\tnbr=" SCOTCH_NUMSTRING "\n",
173 (SCOTCH_Num) (edgenbr / 2));
174 fprintf (C_filepntrdatout, "S\tEdge load\tmin=" SCOTCH_NUMSTRING "\tmax=" SCOTCH_NUMSTRING "\tsum=" SCOTCH_NUMSTRING "\tavg=%g\tdlt=%g\n",
175 (SCOTCH_Num) edlomin, (SCOTCH_Num) edlomax, (SCOTCH_Num) edlosum, edloavg, edlodlt);
176 }
177
178 SCOTCH_graphExit (&grafdat);
179
180 fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end eventual (un)compression tasks */
181
182 #ifdef COMMON_PTHREAD
183 pthread_exit ((void *) 0); /* Allow potential (un)compression tasks to complete */
184 #endif /* COMMON_PTHREAD */
185 return (0);
186 }
187