Ice Sheet System Model  4.18
Code documentation
Macros | Functions
input_parse.cpp File Reference

needed by Chacox.cpp More...

#include "./Chacox.h"

Go to the source code of this file.

Macros

#define __FUNCT__   "input_parse"
 

Functions

int input_parse (char *outassignname, char *outfilename, int *architecture, int *ndims_tot, int mesh_dims[3], int *global_method, int *local_method, int *rqi_flag, int *vmax, int *ndims, int *nprocs, double options[10], int *nparts)
 

Detailed Description

needed by Chacox.cpp

Definition in file input_parse.cpp.

Macro Definition Documentation

◆ __FUNCT__

#define __FUNCT__   "input_parse"

Definition at line 8 of file input_parse.cpp.

Function Documentation

◆ input_parse()

int input_parse ( char *  outassignname,
char *  outfilename,
int *  architecture,
int *  ndims_tot,
int  mesh_dims[3],
int *  global_method,
int *  local_method,
int *  rqi_flag,
int *  vmax,
int *  ndims,
int *  nprocs,
double  options[10],
int *  nparts 
)

Definition at line 10 of file input_parse.cpp.

25 {
26 
27  #ifdef _HAVE_CHACO_ //only works if Chaco library has been compiled in.
28 
29  extern int SEQUENCE; /* sequence instead of partition graph? */
30  extern int ARCHITECTURE; /* 0=> hypercube, d=> d-dimensional mesh */
31  extern int OUTPUT_ASSIGN; /* write assignments to file? */
32  extern int ECHO; /* copy input to screen? results to file? */
33  extern int DEBUG_TRACE; /* trace main execution path */
34  extern int PROMPT; /* prompt for input? */
35  extern int MATCH_TYPE; /* max-matching routine to call */
36  int eigensolver; /* which kind of eigensolver to use */
37 
38  if (DEBUG_TRACE > 0) {
39  _printf_("<Entering input_parse>\n");
40  }
41 
42  if (PROMPT) {
43  _printf_("Parallel machine architecture:\n");
44  _printf_(" (0) Hypercube\n");
45  _printf_(" (1) One-dimensional mesh\n");
46  _printf_(" (2) Two-dimensional mesh\n");
47  _printf_(" (3) Three-dimensional mesh\n");
48  }
49  *architecture = (int)options[OPT_ARCH];
50  if (*architecture < 0 || *architecture > 3) {
51  printf("%s -- Architecture %d must be between 0 and 3.\n",__FUNCT__,*architecture);
52  return(-1);
53  }
54 
55  /* Name output assignment file. */
56  if (PROMPT)
57  _printf_("Assignment output file: ");
58  outassignname = NULL;
59 
60  /* Name output results file. */
61  if (PROMPT)
62  _printf_("File name for saving run results: ");
63  outfilename = NULL;
64 
65  /* Initialize the method flags */
66  *rqi_flag = 0;
67  *global_method = 0;
68 
69  /* Get global method, if any. */
70  if (SEQUENCE) {
71  *global_method = 2;
72  }
73  else {
74  if (PROMPT) {
75  _printf_("Global partitioning method:\n");
76  _printf_(" (1) Multilevel-KL\n");
77  _printf_(" (2) Spectral\n");
78  _printf_(" (3) Inertial\n");
79  _printf_(" (4) Linear\n");
80  _printf_(" (5) Random\n");
81  _printf_(" (6) Scattered\n");
82  _printf_(" (7) Read-from-file\n");
83  }
84  *global_method = (int)options[OPT_GLOBAL];
85  if (*global_method < 1 || *global_method > 7) {
86  printf("%s -- Global method %d must be between 1 and 7.\n",__FUNCT__,*global_method);
87  return(-1);
88  }
89  }
90 
91  if (*global_method == 7) { /* Name and open input assignment file. */
92  if (PROMPT)
93  _printf_("Assignment input file: ");
94  }
95 
96  else if (*global_method == 3) {
97  if (PROMPT)
98  _printf_("Geometry input file name: ");
99  }
100 
101  else if (*global_method == 2) {
102  if (PROMPT) {
103  _printf_("Eigensolver:\n");
104  _printf_(" (1) Multilevel RQI/Symmlq\n");
105  _printf_(" (2) Lanczos\n");
106  }
107  eigensolver = (int)options[OPT_RQI];
108  if (eigensolver < 0 || eigensolver > 2) {
109  printf("%s -- RQI/Symmlq flag %d must be between 0 and 2.\n",__FUNCT__,eigensolver);
110  return(-1);
111  }
112  if (eigensolver == 1) {
113  if (MATCH_TYPE == 5) { /* geometric matching */
114  if (PROMPT)
115  _printf_("Geometry input file name: ");
116  }
117  *rqi_flag = 1;
118  if (PROMPT)
119  _printf_("Number of vertices to coarsen down to: ");
120  *vmax = (int)options[OPT_VMAX];
121  if (*vmax <= 0) {
122  printf("%s -- Vmax %d must be greater then 0.\n",__FUNCT__,*vmax);
123  return(-1);
124  }
125  }
126  else if (eigensolver == 0 || eigensolver == 2) {
127  *rqi_flag = 0;
128  }
129  }
130 
131  else if (*global_method == 1) {
132  if (MATCH_TYPE == 5) { /* geometric matching */
133  if (PROMPT)
134  _printf_("Geometry input file name: ");
135  }
136  if (PROMPT)
137  _printf_("Number of vertices to coarsen down to: ");
138  *vmax = (int)options[OPT_VMAX];
139  if (*vmax <= 0) {
140  printf("%s -- Vmax %d must be greater then 0.\n",__FUNCT__,*vmax);
141  return(-1);
142  }
143  }
144 
145  if (SEQUENCE) {
146  *local_method = 2;
147  if (*architecture == 0) {
148  *ndims_tot = 1;
149  }
150  else if (*architecture > 0) {
151  mesh_dims[0] = 2;
152  mesh_dims[1] = mesh_dims[2] = 1;
153  }
154  *ndims = 1;
155  goto End_Label;
156  }
157 
158  /* Get local method, if any */
159  *local_method = 0;
160  if (*global_method == 1)
161  *local_method = 1;
162  else {
163  if (PROMPT) {
164  _printf_("Local refinement method:\n");
165  _printf_(" (1) Kernighan-Lin\n");
166  _printf_(" (2) None\n");
167  }
168  *local_method = (int)options[OPT_LOCAL];
169  if (*local_method < 1 || *local_method > 2) {
170  printf("%s -- Local method %d must be 1 and 2.\n",__FUNCT__,*local_method);
171  return(-1);
172  }
173  }
174 
175  /* Now learn about the parallel architecture. */
176  if (*architecture == 0) {
177  /* Get total number of hypercube dimensions in which to partition. */
178  *ndims_tot = 0;
179  if (PROMPT)
180  _printf_("Total number of target hypercube dimensions: ");
181  *ndims_tot = nparts[0];
182  if (*ndims_tot < 1) {
183  _printf_(" Number of divisions must be at least 1\n");
184  printf("%s -- Number of divisions %d must be at least 1.\n",
185  __FUNCT__,nparts[0]);
186  return(-1);
187  }
188  *nprocs = 1 << (*ndims_tot);
189  }
190 
191  else { /* Get dimensions of mesh. */
192  mesh_dims[1] = mesh_dims[2] = 1;
193  if (*architecture == 2) {
194  if (PROMPT)
195  _printf_("X and Y extent of of 2-D mesh: ");
196  mesh_dims[0] = nparts[0];
197  mesh_dims[1] = nparts[1];
198  }
199  else if (*architecture == 3) {
200  if (PROMPT)
201  _printf_("X, Y and Z extent of 3-D mesh: ");
202  mesh_dims[0] = nparts[0];
203  mesh_dims[1] = nparts[1];
204  mesh_dims[2] = nparts[2];
205  }
206  else { /* Anything else => 1-D mesh */
207  if (PROMPT)
208  _printf_("Size of 1-D mesh: ");
209  mesh_dims[0] = nparts[0];
210  *architecture = 1;
211  }
212  *nprocs = mesh_dims[0] * mesh_dims[1] * mesh_dims[2];
213  }
214 
215  /* Get number of dimensions in which to partition at each level. */
216  *ndims = 0;
217  if (*nprocs <= 3) {
218  *ndims = 1;
219  }
220  else if (*nprocs <= 7) {
221  if (PROMPT) {
222  _printf_("Partitioning dimension: \n");
223  _printf_(" (1) Bisection\n");
224  _printf_(" (2) Quadrisection\n");
225  }
226  *ndims = (int)options[OPT_NDIMS];
227  if (*ndims < 1 || *ndims > 2) {
228  printf("%s -- Ndims %d must be 1 or 2 for %d processors.\n",__FUNCT__,*ndims,*nprocs);
229  return(-1);
230  }
231  }
232  else {
233  if (PROMPT) {
234  _printf_("Partitioning dimension: \n");
235  _printf_(" (1) Bisection\n");
236  _printf_(" (2) Quadrisection\n");
237  _printf_(" (3) Octasection\n");
238  }
239  *ndims = (int)options[OPT_NDIMS];
240  if (*ndims < 1 || *ndims > 3) {
241  printf("%s -- Ndims %d must be between 1 and 3 for %d processors.\n",__FUNCT__,*ndims,*nprocs);
242  return(-1);
243  }
244  }
245 End_Label:
246 
247  if (*global_method == 1 || *rqi_flag) {
248  if (*vmax < 2 * (1 << *ndims)) {
249  *vmax = 2 * (1 << *ndims);
250  }
251  }
252 
253  return(0);
254 
255  #else //#ifdef _HAVE_CHACO_
256  return(0);
257  #endif
258 }
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
__FUNCT__
#define __FUNCT__
Definition: input_parse.cpp:8