1 |
/* |
2 |
File autogenerated by gengetopt version 2.16 |
3 |
generated with the following command: |
4 |
gengetopt -F StaticPropsCmd |
5 |
|
6 |
The developers of gengetopt consider the fixed text that goes in all |
7 |
gengetopt output files to be in the public domain: |
8 |
we make no copyright claims on it. |
9 |
*/ |
10 |
|
11 |
/* If we use autoconf. */ |
12 |
#ifdef HAVE_CONFIG_H |
13 |
#include "config.h" |
14 |
#endif |
15 |
|
16 |
#include <stdio.h> |
17 |
#include <stdlib.h> |
18 |
#include <string.h> |
19 |
|
20 |
#include "getopt.h" |
21 |
|
22 |
#include "StaticPropsCmd.h" |
23 |
|
24 |
static |
25 |
void clear_given (struct gengetopt_args_info *args_info); |
26 |
static |
27 |
void clear_args (struct gengetopt_args_info *args_info); |
28 |
|
29 |
static int |
30 |
cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error); |
31 |
|
32 |
static int |
33 |
cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error); |
34 |
|
35 |
static char * |
36 |
gengetopt_strdup (const char *s); |
37 |
|
38 |
static |
39 |
void clear_given (struct gengetopt_args_info *args_info) |
40 |
{ |
41 |
args_info->help_given = 0 ; |
42 |
args_info->version_given = 0 ; |
43 |
args_info->input_given = 0 ; |
44 |
args_info->output_given = 0 ; |
45 |
args_info->step_given = 0 ; |
46 |
args_info->nbins_given = 0 ; |
47 |
args_info->nbins_x_given = 0 ; |
48 |
args_info->nbins_y_given = 0 ; |
49 |
args_info->nanglebins_given = 0 ; |
50 |
args_info->length_given = 0 ; |
51 |
args_info->LegendreL_given = 0 ; |
52 |
args_info->rcut_given = 0 ; |
53 |
args_info->zoffset_given = 0 ; |
54 |
args_info->sele1_given = 0 ; |
55 |
args_info->sele2_given = 0 ; |
56 |
args_info->sele3_given = 0 ; |
57 |
args_info->refsele_given = 0 ; |
58 |
args_info->molname_given = 0 ; |
59 |
args_info->begin_given = 0 ; |
60 |
args_info->end_given = 0 ; |
61 |
args_info->bo_given = 0 ; |
62 |
args_info->gofr_given = 0 ; |
63 |
args_info->r_theta_given = 0 ; |
64 |
args_info->r_omega_given = 0 ; |
65 |
args_info->theta_omega_given = 0 ; |
66 |
args_info->gxyz_given = 0 ; |
67 |
args_info->p2_given = 0 ; |
68 |
args_info->rp2_given = 0 ; |
69 |
args_info->scd_given = 0 ; |
70 |
args_info->density_given = 0 ; |
71 |
args_info->slab_density_given = 0 ; |
72 |
args_info->hxy_given = 0 ; |
73 |
args_info->staticProps_group_counter = 0 ; |
74 |
} |
75 |
|
76 |
static |
77 |
void clear_args (struct gengetopt_args_info *args_info) |
78 |
{ |
79 |
args_info->input_arg = NULL; |
80 |
args_info->input_orig = NULL; |
81 |
args_info->output_arg = NULL; |
82 |
args_info->output_orig = NULL; |
83 |
args_info->step_arg = 1; |
84 |
args_info->step_orig = NULL; |
85 |
args_info->nbins_arg = 100; |
86 |
args_info->nbins_orig = NULL; |
87 |
args_info->nbins_x_arg = 100; |
88 |
args_info->nbins_x_orig = NULL; |
89 |
args_info->nbins_y_arg = 100; |
90 |
args_info->nbins_y_orig = NULL; |
91 |
args_info->nanglebins_arg = 50; |
92 |
args_info->nanglebins_orig = NULL; |
93 |
args_info->length_orig = NULL; |
94 |
args_info->LegendreL_orig = NULL; |
95 |
args_info->rcut_orig = NULL; |
96 |
args_info->zoffset_arg = 0; |
97 |
args_info->zoffset_orig = NULL; |
98 |
args_info->sele1_arg = NULL; |
99 |
args_info->sele1_orig = NULL; |
100 |
args_info->sele2_arg = NULL; |
101 |
args_info->sele2_orig = NULL; |
102 |
args_info->sele3_arg = NULL; |
103 |
args_info->sele3_orig = NULL; |
104 |
args_info->refsele_arg = NULL; |
105 |
args_info->refsele_orig = NULL; |
106 |
args_info->molname_arg = NULL; |
107 |
args_info->molname_orig = NULL; |
108 |
args_info->begin_orig = NULL; |
109 |
args_info->end_orig = NULL; |
110 |
|
111 |
} |
112 |
|
113 |
void |
114 |
cmdline_parser_print_version (void) |
115 |
{ |
116 |
printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); |
117 |
} |
118 |
|
119 |
void |
120 |
cmdline_parser_print_help (void) |
121 |
{ |
122 |
cmdline_parser_print_version (); |
123 |
printf("\nUsage: StaticProps [OPTIONS]...\n\n"); |
124 |
printf("%s\n"," -h, --help Print help and exit"); |
125 |
printf("%s\n"," -V, --version Print version and exit"); |
126 |
printf("%s\n"," -i, --input=filename input dump file"); |
127 |
printf("%s\n"," -o, --output=filename output file name"); |
128 |
printf("%s\n"," -n, --step=INT process every n frame (default=`1')"); |
129 |
printf("%s\n"," -b, --nbins=INT number of bins (general purpose) \n (default=`100')"); |
130 |
printf("%s\n"," -x, --nbins_x=INT number of bins in x axis (default=`100')"); |
131 |
printf("%s\n"," -y, --nbins_y=INT number of bins in y axis (default=`100')"); |
132 |
printf("%s\n"," -a, --nanglebins=INT number of bins for cos(angle) (default=`50')"); |
133 |
printf("%s\n"," --length=DOUBLE maximum length (Defaults to 1/2 smallest length \n of first frame)"); |
134 |
printf("%s\n"," -l, --LegendreL=INT Order of Legendre Polynomial (used for Bond \n Order calculations)"); |
135 |
printf("%s\n"," -c, --rcut=DOUBLE cutoff radius (rcut)"); |
136 |
printf("%s\n"," -z, --zoffset=DOUBLE Where to set the zero for the slab_density \n calculation (default=`0')"); |
137 |
printf("%s\n"," --sele1=selection script select the first stuntdouble set"); |
138 |
printf("%s\n"," --sele2=selection script select the second stuntdouble set"); |
139 |
printf("%s\n"," --sele3=selection script select the third stuntdouble set"); |
140 |
printf("%s\n"," --refsele=selection script\n select reference (use and only use with --gxyz)"); |
141 |
printf("%s\n"," --molname=STRING molecule name"); |
142 |
printf("%s\n"," --begin=INT begin internal index"); |
143 |
printf("%s\n"," --end=INT end internal index"); |
144 |
printf("%s\n","\n Group: staticProps\n an option of this group is required"); |
145 |
printf("%s\n"," --bo bond order parameter (--rcut and --LegendreL \n must be specified"); |
146 |
printf("%s\n"," -g, --gofr g(r)"); |
147 |
printf("%s\n"," --r_theta g(r, cos(theta))"); |
148 |
printf("%s\n"," --r_omega g(r, cos(omega))"); |
149 |
printf("%s\n"," --theta_omega g(cos(theta), cos(omega))"); |
150 |
printf("%s\n"," --gxyz g(x, y, z)"); |
151 |
printf("%s\n"," -p, --p2 p2 order parameter (--sele1 and --sele2 must be \n specified)"); |
152 |
printf("%s\n"," --rp2 rp2 order parameter (--sele1 and --sele2 must \n be specified)"); |
153 |
printf("%s\n"," -s, --scd scd order parameter (either --sele1, --sele2, \n --sele3 are specified or --molname, --begin, \n --end are specified)"); |
154 |
printf("%s\n"," -d, --density density plot"); |
155 |
printf("%s\n"," --slab_density slab density"); |
156 |
printf("%s\n"," --hxy hxy"); |
157 |
|
158 |
} |
159 |
|
160 |
void |
161 |
cmdline_parser_init (struct gengetopt_args_info *args_info) |
162 |
{ |
163 |
clear_given (args_info); |
164 |
clear_args (args_info); |
165 |
} |
166 |
|
167 |
static void |
168 |
cmdline_parser_release (struct gengetopt_args_info *args_info) |
169 |
{ |
170 |
|
171 |
if (args_info->input_arg) |
172 |
{ |
173 |
free (args_info->input_arg); /* free previous argument */ |
174 |
args_info->input_arg = 0; |
175 |
} |
176 |
if (args_info->input_orig) |
177 |
{ |
178 |
free (args_info->input_orig); /* free previous argument */ |
179 |
args_info->input_orig = 0; |
180 |
} |
181 |
if (args_info->output_arg) |
182 |
{ |
183 |
free (args_info->output_arg); /* free previous argument */ |
184 |
args_info->output_arg = 0; |
185 |
} |
186 |
if (args_info->output_orig) |
187 |
{ |
188 |
free (args_info->output_orig); /* free previous argument */ |
189 |
args_info->output_orig = 0; |
190 |
} |
191 |
if (args_info->step_orig) |
192 |
{ |
193 |
free (args_info->step_orig); /* free previous argument */ |
194 |
args_info->step_orig = 0; |
195 |
} |
196 |
if (args_info->nbins_orig) |
197 |
{ |
198 |
free (args_info->nbins_orig); /* free previous argument */ |
199 |
args_info->nbins_orig = 0; |
200 |
} |
201 |
if (args_info->nbins_x_orig) |
202 |
{ |
203 |
free (args_info->nbins_x_orig); /* free previous argument */ |
204 |
args_info->nbins_x_orig = 0; |
205 |
} |
206 |
if (args_info->nbins_y_orig) |
207 |
{ |
208 |
free (args_info->nbins_y_orig); /* free previous argument */ |
209 |
args_info->nbins_y_orig = 0; |
210 |
} |
211 |
if (args_info->nanglebins_orig) |
212 |
{ |
213 |
free (args_info->nanglebins_orig); /* free previous argument */ |
214 |
args_info->nanglebins_orig = 0; |
215 |
} |
216 |
if (args_info->length_orig) |
217 |
{ |
218 |
free (args_info->length_orig); /* free previous argument */ |
219 |
args_info->length_orig = 0; |
220 |
} |
221 |
if (args_info->LegendreL_orig) |
222 |
{ |
223 |
free (args_info->LegendreL_orig); /* free previous argument */ |
224 |
args_info->LegendreL_orig = 0; |
225 |
} |
226 |
if (args_info->rcut_orig) |
227 |
{ |
228 |
free (args_info->rcut_orig); /* free previous argument */ |
229 |
args_info->rcut_orig = 0; |
230 |
} |
231 |
if (args_info->zoffset_orig) |
232 |
{ |
233 |
free (args_info->zoffset_orig); /* free previous argument */ |
234 |
args_info->zoffset_orig = 0; |
235 |
} |
236 |
if (args_info->sele1_arg) |
237 |
{ |
238 |
free (args_info->sele1_arg); /* free previous argument */ |
239 |
args_info->sele1_arg = 0; |
240 |
} |
241 |
if (args_info->sele1_orig) |
242 |
{ |
243 |
free (args_info->sele1_orig); /* free previous argument */ |
244 |
args_info->sele1_orig = 0; |
245 |
} |
246 |
if (args_info->sele2_arg) |
247 |
{ |
248 |
free (args_info->sele2_arg); /* free previous argument */ |
249 |
args_info->sele2_arg = 0; |
250 |
} |
251 |
if (args_info->sele2_orig) |
252 |
{ |
253 |
free (args_info->sele2_orig); /* free previous argument */ |
254 |
args_info->sele2_orig = 0; |
255 |
} |
256 |
if (args_info->sele3_arg) |
257 |
{ |
258 |
free (args_info->sele3_arg); /* free previous argument */ |
259 |
args_info->sele3_arg = 0; |
260 |
} |
261 |
if (args_info->sele3_orig) |
262 |
{ |
263 |
free (args_info->sele3_orig); /* free previous argument */ |
264 |
args_info->sele3_orig = 0; |
265 |
} |
266 |
if (args_info->refsele_arg) |
267 |
{ |
268 |
free (args_info->refsele_arg); /* free previous argument */ |
269 |
args_info->refsele_arg = 0; |
270 |
} |
271 |
if (args_info->refsele_orig) |
272 |
{ |
273 |
free (args_info->refsele_orig); /* free previous argument */ |
274 |
args_info->refsele_orig = 0; |
275 |
} |
276 |
if (args_info->molname_arg) |
277 |
{ |
278 |
free (args_info->molname_arg); /* free previous argument */ |
279 |
args_info->molname_arg = 0; |
280 |
} |
281 |
if (args_info->molname_orig) |
282 |
{ |
283 |
free (args_info->molname_orig); /* free previous argument */ |
284 |
args_info->molname_orig = 0; |
285 |
} |
286 |
if (args_info->begin_orig) |
287 |
{ |
288 |
free (args_info->begin_orig); /* free previous argument */ |
289 |
args_info->begin_orig = 0; |
290 |
} |
291 |
if (args_info->end_orig) |
292 |
{ |
293 |
free (args_info->end_orig); /* free previous argument */ |
294 |
args_info->end_orig = 0; |
295 |
} |
296 |
|
297 |
clear_given (args_info); |
298 |
} |
299 |
|
300 |
int |
301 |
cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) |
302 |
{ |
303 |
FILE *outfile; |
304 |
int i = 0; |
305 |
|
306 |
outfile = fopen(filename, "w"); |
307 |
|
308 |
if (!outfile) |
309 |
{ |
310 |
fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); |
311 |
return EXIT_FAILURE; |
312 |
} |
313 |
|
314 |
if (args_info->help_given) { |
315 |
fprintf(outfile, "%s\n", "help"); |
316 |
} |
317 |
if (args_info->version_given) { |
318 |
fprintf(outfile, "%s\n", "version"); |
319 |
} |
320 |
if (args_info->input_given) { |
321 |
if (args_info->input_orig) { |
322 |
fprintf(outfile, "%s=\"%s\"\n", "input", args_info->input_orig); |
323 |
} else { |
324 |
fprintf(outfile, "%s\n", "input"); |
325 |
} |
326 |
} |
327 |
if (args_info->output_given) { |
328 |
if (args_info->output_orig) { |
329 |
fprintf(outfile, "%s=\"%s\"\n", "output", args_info->output_orig); |
330 |
} else { |
331 |
fprintf(outfile, "%s\n", "output"); |
332 |
} |
333 |
} |
334 |
if (args_info->step_given) { |
335 |
if (args_info->step_orig) { |
336 |
fprintf(outfile, "%s=\"%s\"\n", "step", args_info->step_orig); |
337 |
} else { |
338 |
fprintf(outfile, "%s\n", "step"); |
339 |
} |
340 |
} |
341 |
if (args_info->nbins_given) { |
342 |
if (args_info->nbins_orig) { |
343 |
fprintf(outfile, "%s=\"%s\"\n", "nbins", args_info->nbins_orig); |
344 |
} else { |
345 |
fprintf(outfile, "%s\n", "nbins"); |
346 |
} |
347 |
} |
348 |
if (args_info->nbins_x_given) { |
349 |
if (args_info->nbins_x_orig) { |
350 |
fprintf(outfile, "%s=\"%s\"\n", "nbins_x", args_info->nbins_x_orig); |
351 |
} else { |
352 |
fprintf(outfile, "%s\n", "nbins_x"); |
353 |
} |
354 |
} |
355 |
if (args_info->nbins_y_given) { |
356 |
if (args_info->nbins_y_orig) { |
357 |
fprintf(outfile, "%s=\"%s\"\n", "nbins_y", args_info->nbins_y_orig); |
358 |
} else { |
359 |
fprintf(outfile, "%s\n", "nbins_y"); |
360 |
} |
361 |
} |
362 |
if (args_info->nanglebins_given) { |
363 |
if (args_info->nanglebins_orig) { |
364 |
fprintf(outfile, "%s=\"%s\"\n", "nanglebins", args_info->nanglebins_orig); |
365 |
} else { |
366 |
fprintf(outfile, "%s\n", "nanglebins"); |
367 |
} |
368 |
} |
369 |
if (args_info->length_given) { |
370 |
if (args_info->length_orig) { |
371 |
fprintf(outfile, "%s=\"%s\"\n", "length", args_info->length_orig); |
372 |
} else { |
373 |
fprintf(outfile, "%s\n", "length"); |
374 |
} |
375 |
} |
376 |
if (args_info->LegendreL_given) { |
377 |
if (args_info->LegendreL_orig) { |
378 |
fprintf(outfile, "%s=\"%s\"\n", "LegendreL", args_info->LegendreL_orig); |
379 |
} else { |
380 |
fprintf(outfile, "%s\n", "LegendreL"); |
381 |
} |
382 |
} |
383 |
if (args_info->rcut_given) { |
384 |
if (args_info->rcut_orig) { |
385 |
fprintf(outfile, "%s=\"%s\"\n", "rcut", args_info->rcut_orig); |
386 |
} else { |
387 |
fprintf(outfile, "%s\n", "rcut"); |
388 |
} |
389 |
} |
390 |
if (args_info->zoffset_given) { |
391 |
if (args_info->zoffset_orig) { |
392 |
fprintf(outfile, "%s=\"%s\"\n", "zoffset", args_info->zoffset_orig); |
393 |
} else { |
394 |
fprintf(outfile, "%s\n", "zoffset"); |
395 |
} |
396 |
} |
397 |
if (args_info->sele1_given) { |
398 |
if (args_info->sele1_orig) { |
399 |
fprintf(outfile, "%s=\"%s\"\n", "sele1", args_info->sele1_orig); |
400 |
} else { |
401 |
fprintf(outfile, "%s\n", "sele1"); |
402 |
} |
403 |
} |
404 |
if (args_info->sele2_given) { |
405 |
if (args_info->sele2_orig) { |
406 |
fprintf(outfile, "%s=\"%s\"\n", "sele2", args_info->sele2_orig); |
407 |
} else { |
408 |
fprintf(outfile, "%s\n", "sele2"); |
409 |
} |
410 |
} |
411 |
if (args_info->sele3_given) { |
412 |
if (args_info->sele3_orig) { |
413 |
fprintf(outfile, "%s=\"%s\"\n", "sele3", args_info->sele3_orig); |
414 |
} else { |
415 |
fprintf(outfile, "%s\n", "sele3"); |
416 |
} |
417 |
} |
418 |
if (args_info->refsele_given) { |
419 |
if (args_info->refsele_orig) { |
420 |
fprintf(outfile, "%s=\"%s\"\n", "refsele", args_info->refsele_orig); |
421 |
} else { |
422 |
fprintf(outfile, "%s\n", "refsele"); |
423 |
} |
424 |
} |
425 |
if (args_info->molname_given) { |
426 |
if (args_info->molname_orig) { |
427 |
fprintf(outfile, "%s=\"%s\"\n", "molname", args_info->molname_orig); |
428 |
} else { |
429 |
fprintf(outfile, "%s\n", "molname"); |
430 |
} |
431 |
} |
432 |
if (args_info->begin_given) { |
433 |
if (args_info->begin_orig) { |
434 |
fprintf(outfile, "%s=\"%s\"\n", "begin", args_info->begin_orig); |
435 |
} else { |
436 |
fprintf(outfile, "%s\n", "begin"); |
437 |
} |
438 |
} |
439 |
if (args_info->end_given) { |
440 |
if (args_info->end_orig) { |
441 |
fprintf(outfile, "%s=\"%s\"\n", "end", args_info->end_orig); |
442 |
} else { |
443 |
fprintf(outfile, "%s\n", "end"); |
444 |
} |
445 |
} |
446 |
if (args_info->bo_given) { |
447 |
fprintf(outfile, "%s\n", "bo"); |
448 |
} |
449 |
if (args_info->gofr_given) { |
450 |
fprintf(outfile, "%s\n", "gofr"); |
451 |
} |
452 |
if (args_info->r_theta_given) { |
453 |
fprintf(outfile, "%s\n", "r_theta"); |
454 |
} |
455 |
if (args_info->r_omega_given) { |
456 |
fprintf(outfile, "%s\n", "r_omega"); |
457 |
} |
458 |
if (args_info->theta_omega_given) { |
459 |
fprintf(outfile, "%s\n", "theta_omega"); |
460 |
} |
461 |
if (args_info->gxyz_given) { |
462 |
fprintf(outfile, "%s\n", "gxyz"); |
463 |
} |
464 |
if (args_info->p2_given) { |
465 |
fprintf(outfile, "%s\n", "p2"); |
466 |
} |
467 |
if (args_info->rp2_given) { |
468 |
fprintf(outfile, "%s\n", "rp2"); |
469 |
} |
470 |
if (args_info->scd_given) { |
471 |
fprintf(outfile, "%s\n", "scd"); |
472 |
} |
473 |
if (args_info->density_given) { |
474 |
fprintf(outfile, "%s\n", "density"); |
475 |
} |
476 |
if (args_info->slab_density_given) { |
477 |
fprintf(outfile, "%s\n", "slab_density"); |
478 |
} |
479 |
if (args_info->hxy_given) { |
480 |
fprintf(outfile, "%s\n", "hxy"); |
481 |
} |
482 |
|
483 |
fclose (outfile); |
484 |
|
485 |
i = EXIT_SUCCESS; |
486 |
return i; |
487 |
} |
488 |
|
489 |
void |
490 |
cmdline_parser_free (struct gengetopt_args_info *args_info) |
491 |
{ |
492 |
cmdline_parser_release (args_info); |
493 |
} |
494 |
|
495 |
|
496 |
/* gengetopt_strdup() */ |
497 |
/* strdup.c replacement of strdup, which is not standard */ |
498 |
char * |
499 |
gengetopt_strdup (const char *s) |
500 |
{ |
501 |
char *result = NULL; |
502 |
if (!s) |
503 |
return result; |
504 |
|
505 |
result = (char*)malloc(strlen(s) + 1); |
506 |
if (result == (char*)0) |
507 |
return (char*)0; |
508 |
strcpy(result, s); |
509 |
return result; |
510 |
} |
511 |
|
512 |
static void |
513 |
reset_group_staticProps(struct gengetopt_args_info *args_info); |
514 |
|
515 |
static void |
516 |
reset_group_staticProps(struct gengetopt_args_info *args_info) |
517 |
{ |
518 |
if (! args_info->staticProps_group_counter) |
519 |
return; |
520 |
|
521 |
args_info->bo_given = 0 ; |
522 |
args_info->gofr_given = 0 ; |
523 |
args_info->r_theta_given = 0 ; |
524 |
args_info->r_omega_given = 0 ; |
525 |
args_info->theta_omega_given = 0 ; |
526 |
args_info->gxyz_given = 0 ; |
527 |
args_info->p2_given = 0 ; |
528 |
args_info->rp2_given = 0 ; |
529 |
args_info->scd_given = 0 ; |
530 |
args_info->density_given = 0 ; |
531 |
args_info->slab_density_given = 0 ; |
532 |
args_info->hxy_given = 0 ; |
533 |
|
534 |
args_info->staticProps_group_counter = 0; |
535 |
} |
536 |
|
537 |
int |
538 |
cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
539 |
{ |
540 |
return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); |
541 |
} |
542 |
|
543 |
int |
544 |
cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
545 |
{ |
546 |
int result; |
547 |
|
548 |
result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL); |
549 |
|
550 |
if (result == EXIT_FAILURE) |
551 |
{ |
552 |
cmdline_parser_free (args_info); |
553 |
exit (EXIT_FAILURE); |
554 |
} |
555 |
|
556 |
return result; |
557 |
} |
558 |
|
559 |
int |
560 |
cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) |
561 |
{ |
562 |
int result = EXIT_SUCCESS; |
563 |
|
564 |
if (cmdline_parser_required2(args_info, prog_name, NULL) > 0) |
565 |
result = EXIT_FAILURE; |
566 |
|
567 |
if (result == EXIT_FAILURE) |
568 |
{ |
569 |
cmdline_parser_free (args_info); |
570 |
exit (EXIT_FAILURE); |
571 |
} |
572 |
|
573 |
return result; |
574 |
} |
575 |
|
576 |
int |
577 |
cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) |
578 |
{ |
579 |
int error = 0; |
580 |
|
581 |
if (! args_info->input_given) |
582 |
{ |
583 |
fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : "")); |
584 |
error = 1; |
585 |
} |
586 |
if (args_info->staticProps_group_counter == 0) |
587 |
{ |
588 |
fprintf (stderr, "%s: %d options of group staticProps were given. One is required.%s\n", prog_name, args_info->staticProps_group_counter, (additional_error ? additional_error : "")); |
589 |
error = 1; |
590 |
} |
591 |
|
592 |
|
593 |
return error; |
594 |
} |
595 |
|
596 |
int |
597 |
cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error) |
598 |
{ |
599 |
int c; /* Character of the parsed option. */ |
600 |
|
601 |
int error = 0; |
602 |
struct gengetopt_args_info local_args_info; |
603 |
|
604 |
if (initialize) |
605 |
cmdline_parser_init (args_info); |
606 |
|
607 |
cmdline_parser_init (&local_args_info); |
608 |
|
609 |
optarg = 0; |
610 |
optind = 0; |
611 |
opterr = 1; |
612 |
optopt = '?'; |
613 |
|
614 |
while (1) |
615 |
{ |
616 |
int option_index = 0; |
617 |
char *stop_char; |
618 |
|
619 |
static struct option long_options[] = { |
620 |
{ "help", 0, NULL, 'h' }, |
621 |
{ "version", 0, NULL, 'V' }, |
622 |
{ "input", 1, NULL, 'i' }, |
623 |
{ "output", 1, NULL, 'o' }, |
624 |
{ "step", 1, NULL, 'n' }, |
625 |
{ "nbins", 1, NULL, 'b' }, |
626 |
{ "nbins_x", 1, NULL, 'x' }, |
627 |
{ "nbins_y", 1, NULL, 'y' }, |
628 |
{ "nanglebins", 1, NULL, 'a' }, |
629 |
{ "length", 1, NULL, 0 }, |
630 |
{ "LegendreL", 1, NULL, 'l' }, |
631 |
{ "rcut", 1, NULL, 'c' }, |
632 |
{ "zoffset", 1, NULL, 'z' }, |
633 |
{ "sele1", 1, NULL, 0 }, |
634 |
{ "sele2", 1, NULL, 0 }, |
635 |
{ "sele3", 1, NULL, 0 }, |
636 |
{ "refsele", 1, NULL, 0 }, |
637 |
{ "molname", 1, NULL, 0 }, |
638 |
{ "begin", 1, NULL, 0 }, |
639 |
{ "end", 1, NULL, 0 }, |
640 |
{ "bo", 0, NULL, 0 }, |
641 |
{ "gofr", 0, NULL, 'g' }, |
642 |
{ "r_theta", 0, NULL, 0 }, |
643 |
{ "r_omega", 0, NULL, 0 }, |
644 |
{ "theta_omega", 0, NULL, 0 }, |
645 |
{ "gxyz", 0, NULL, 0 }, |
646 |
{ "p2", 0, NULL, 'p' }, |
647 |
{ "rp2", 0, NULL, 0 }, |
648 |
{ "scd", 0, NULL, 's' }, |
649 |
{ "density", 0, NULL, 'd' }, |
650 |
{ "slab_density", 0, NULL, 0 }, |
651 |
{ "hxy", 0, NULL, 0 }, |
652 |
{ NULL, 0, NULL, 0 } |
653 |
}; |
654 |
|
655 |
stop_char = 0; |
656 |
c = getopt_long (argc, argv, "hVi:o:n:b:x:y:a:l:c:z:gpsd", long_options, &option_index); |
657 |
|
658 |
if (c == -1) break; /* Exit from `while (1)' loop. */ |
659 |
|
660 |
switch (c) |
661 |
{ |
662 |
case 'h': /* Print help and exit. */ |
663 |
cmdline_parser_print_help (); |
664 |
cmdline_parser_free (&local_args_info); |
665 |
exit (EXIT_SUCCESS); |
666 |
|
667 |
case 'V': /* Print version and exit. */ |
668 |
cmdline_parser_print_version (); |
669 |
cmdline_parser_free (&local_args_info); |
670 |
exit (EXIT_SUCCESS); |
671 |
|
672 |
case 'i': /* input dump file. */ |
673 |
if (local_args_info.input_given) |
674 |
{ |
675 |
fprintf (stderr, "%s: `--input' (`-i') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
676 |
goto failure; |
677 |
} |
678 |
if (args_info->input_given && ! override) |
679 |
continue; |
680 |
local_args_info.input_given = 1; |
681 |
args_info->input_given = 1; |
682 |
if (args_info->input_arg) |
683 |
free (args_info->input_arg); /* free previous string */ |
684 |
args_info->input_arg = gengetopt_strdup (optarg); |
685 |
if (args_info->input_orig) |
686 |
free (args_info->input_orig); /* free previous string */ |
687 |
args_info->input_orig = gengetopt_strdup (optarg); |
688 |
break; |
689 |
|
690 |
case 'o': /* output file name. */ |
691 |
if (local_args_info.output_given) |
692 |
{ |
693 |
fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
694 |
goto failure; |
695 |
} |
696 |
if (args_info->output_given && ! override) |
697 |
continue; |
698 |
local_args_info.output_given = 1; |
699 |
args_info->output_given = 1; |
700 |
if (args_info->output_arg) |
701 |
free (args_info->output_arg); /* free previous string */ |
702 |
args_info->output_arg = gengetopt_strdup (optarg); |
703 |
if (args_info->output_orig) |
704 |
free (args_info->output_orig); /* free previous string */ |
705 |
args_info->output_orig = gengetopt_strdup (optarg); |
706 |
break; |
707 |
|
708 |
case 'n': /* process every n frame. */ |
709 |
if (local_args_info.step_given) |
710 |
{ |
711 |
fprintf (stderr, "%s: `--step' (`-n') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
712 |
goto failure; |
713 |
} |
714 |
if (args_info->step_given && ! override) |
715 |
continue; |
716 |
local_args_info.step_given = 1; |
717 |
args_info->step_given = 1; |
718 |
args_info->step_arg = strtol (optarg, &stop_char, 0); |
719 |
if (!(stop_char && *stop_char == '\0')) { |
720 |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
721 |
goto failure; |
722 |
} |
723 |
if (args_info->step_orig) |
724 |
free (args_info->step_orig); /* free previous string */ |
725 |
args_info->step_orig = gengetopt_strdup (optarg); |
726 |
break; |
727 |
|
728 |
case 'b': /* number of bins (general purpose). */ |
729 |
if (local_args_info.nbins_given) |
730 |
{ |
731 |
fprintf (stderr, "%s: `--nbins' (`-b') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
732 |
goto failure; |
733 |
} |
734 |
if (args_info->nbins_given && ! override) |
735 |
continue; |
736 |
local_args_info.nbins_given = 1; |
737 |
args_info->nbins_given = 1; |
738 |
args_info->nbins_arg = strtol (optarg, &stop_char, 0); |
739 |
if (!(stop_char && *stop_char == '\0')) { |
740 |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
741 |
goto failure; |
742 |
} |
743 |
if (args_info->nbins_orig) |
744 |
free (args_info->nbins_orig); /* free previous string */ |
745 |
args_info->nbins_orig = gengetopt_strdup (optarg); |
746 |
break; |
747 |
|
748 |
case 'x': /* number of bins in x axis. */ |
749 |
if (local_args_info.nbins_x_given) |
750 |
{ |
751 |
fprintf (stderr, "%s: `--nbins_x' (`-x') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
752 |
goto failure; |
753 |
} |
754 |
if (args_info->nbins_x_given && ! override) |
755 |
continue; |
756 |
local_args_info.nbins_x_given = 1; |
757 |
args_info->nbins_x_given = 1; |
758 |
args_info->nbins_x_arg = strtol (optarg, &stop_char, 0); |
759 |
if (!(stop_char && *stop_char == '\0')) { |
760 |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
761 |
goto failure; |
762 |
} |
763 |
if (args_info->nbins_x_orig) |
764 |
free (args_info->nbins_x_orig); /* free previous string */ |
765 |
args_info->nbins_x_orig = gengetopt_strdup (optarg); |
766 |
break; |
767 |
|
768 |
case 'y': /* number of bins in y axis. */ |
769 |
if (local_args_info.nbins_y_given) |
770 |
{ |
771 |
fprintf (stderr, "%s: `--nbins_y' (`-y') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
772 |
goto failure; |
773 |
} |
774 |
if (args_info->nbins_y_given && ! override) |
775 |
continue; |
776 |
local_args_info.nbins_y_given = 1; |
777 |
args_info->nbins_y_given = 1; |
778 |
args_info->nbins_y_arg = strtol (optarg, &stop_char, 0); |
779 |
if (!(stop_char && *stop_char == '\0')) { |
780 |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
781 |
goto failure; |
782 |
} |
783 |
if (args_info->nbins_y_orig) |
784 |
free (args_info->nbins_y_orig); /* free previous string */ |
785 |
args_info->nbins_y_orig = gengetopt_strdup (optarg); |
786 |
break; |
787 |
|
788 |
case 'a': /* number of bins for cos(angle). */ |
789 |
if (local_args_info.nanglebins_given) |
790 |
{ |
791 |
fprintf (stderr, "%s: `--nanglebins' (`-a') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
792 |
goto failure; |
793 |
} |
794 |
if (args_info->nanglebins_given && ! override) |
795 |
continue; |
796 |
local_args_info.nanglebins_given = 1; |
797 |
args_info->nanglebins_given = 1; |
798 |
args_info->nanglebins_arg = strtol (optarg, &stop_char, 0); |
799 |
if (!(stop_char && *stop_char == '\0')) { |
800 |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
801 |
goto failure; |
802 |
} |
803 |
if (args_info->nanglebins_orig) |
804 |
free (args_info->nanglebins_orig); /* free previous string */ |
805 |
args_info->nanglebins_orig = gengetopt_strdup (optarg); |
806 |
break; |
807 |
|
808 |
case 'l': /* Order of Legendre Polynomial (used for Bond Order calculations). */ |
809 |
if (local_args_info.LegendreL_given) |
810 |
{ |
811 |
fprintf (stderr, "%s: `--LegendreL' (`-l') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
812 |
goto failure; |
813 |
} |
814 |
if (args_info->LegendreL_given && ! override) |
815 |
continue; |
816 |
local_args_info.LegendreL_given = 1; |
817 |
args_info->LegendreL_given = 1; |
818 |
args_info->LegendreL_arg = strtol (optarg, &stop_char, 0); |
819 |
if (!(stop_char && *stop_char == '\0')) { |
820 |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
821 |
goto failure; |
822 |
} |
823 |
if (args_info->LegendreL_orig) |
824 |
free (args_info->LegendreL_orig); /* free previous string */ |
825 |
args_info->LegendreL_orig = gengetopt_strdup (optarg); |
826 |
break; |
827 |
|
828 |
case 'c': /* cutoff radius (rcut). */ |
829 |
if (local_args_info.rcut_given) |
830 |
{ |
831 |
fprintf (stderr, "%s: `--rcut' (`-c') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
832 |
goto failure; |
833 |
} |
834 |
if (args_info->rcut_given && ! override) |
835 |
continue; |
836 |
local_args_info.rcut_given = 1; |
837 |
args_info->rcut_given = 1; |
838 |
args_info->rcut_arg = strtod (optarg, &stop_char); |
839 |
if (!(stop_char && *stop_char == '\0')) { |
840 |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
841 |
goto failure; |
842 |
} |
843 |
if (args_info->rcut_orig) |
844 |
free (args_info->rcut_orig); /* free previous string */ |
845 |
args_info->rcut_orig = gengetopt_strdup (optarg); |
846 |
break; |
847 |
|
848 |
case 'z': /* Where to set the zero for the slab_density calculation. */ |
849 |
if (local_args_info.zoffset_given) |
850 |
{ |
851 |
fprintf (stderr, "%s: `--zoffset' (`-z') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
852 |
goto failure; |
853 |
} |
854 |
if (args_info->zoffset_given && ! override) |
855 |
continue; |
856 |
local_args_info.zoffset_given = 1; |
857 |
args_info->zoffset_given = 1; |
858 |
args_info->zoffset_arg = strtod (optarg, &stop_char); |
859 |
if (!(stop_char && *stop_char == '\0')) { |
860 |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
861 |
goto failure; |
862 |
} |
863 |
if (args_info->zoffset_orig) |
864 |
free (args_info->zoffset_orig); /* free previous string */ |
865 |
args_info->zoffset_orig = gengetopt_strdup (optarg); |
866 |
break; |
867 |
|
868 |
case 'g': /* g(r). */ |
869 |
if (local_args_info.gofr_given) |
870 |
{ |
871 |
fprintf (stderr, "%s: `--gofr' (`-g') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
872 |
goto failure; |
873 |
} |
874 |
if (args_info->gofr_given && ! override) |
875 |
continue; |
876 |
local_args_info.gofr_given = 1; |
877 |
args_info->gofr_given = 1; |
878 |
if (args_info->staticProps_group_counter && override) |
879 |
reset_group_staticProps (args_info); |
880 |
args_info->staticProps_group_counter += 1; |
881 |
break; |
882 |
|
883 |
case 'p': /* p2 order parameter (--sele1 and --sele2 must be specified). */ |
884 |
if (local_args_info.p2_given) |
885 |
{ |
886 |
fprintf (stderr, "%s: `--p2' (`-p') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
887 |
goto failure; |
888 |
} |
889 |
if (args_info->p2_given && ! override) |
890 |
continue; |
891 |
local_args_info.p2_given = 1; |
892 |
args_info->p2_given = 1; |
893 |
if (args_info->staticProps_group_counter && override) |
894 |
reset_group_staticProps (args_info); |
895 |
args_info->staticProps_group_counter += 1; |
896 |
break; |
897 |
|
898 |
case 's': /* scd order parameter (either --sele1, --sele2, --sele3 are specified or --molname, --begin, --end are specified). */ |
899 |
if (local_args_info.scd_given) |
900 |
{ |
901 |
fprintf (stderr, "%s: `--scd' (`-s') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
902 |
goto failure; |
903 |
} |
904 |
if (args_info->scd_given && ! override) |
905 |
continue; |
906 |
local_args_info.scd_given = 1; |
907 |
args_info->scd_given = 1; |
908 |
if (args_info->staticProps_group_counter && override) |
909 |
reset_group_staticProps (args_info); |
910 |
args_info->staticProps_group_counter += 1; |
911 |
break; |
912 |
|
913 |
case 'd': /* density plot. */ |
914 |
if (local_args_info.density_given) |
915 |
{ |
916 |
fprintf (stderr, "%s: `--density' (`-d') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
917 |
goto failure; |
918 |
} |
919 |
if (args_info->density_given && ! override) |
920 |
continue; |
921 |
local_args_info.density_given = 1; |
922 |
args_info->density_given = 1; |
923 |
if (args_info->staticProps_group_counter && override) |
924 |
reset_group_staticProps (args_info); |
925 |
args_info->staticProps_group_counter += 1; |
926 |
break; |
927 |
|
928 |
|
929 |
case 0: /* Long option with no short option */ |
930 |
/* maximum length (Defaults to 1/2 smallest length of first frame). */ |
931 |
if (strcmp (long_options[option_index].name, "length") == 0) |
932 |
{ |
933 |
if (local_args_info.length_given) |
934 |
{ |
935 |
fprintf (stderr, "%s: `--length' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
936 |
goto failure; |
937 |
} |
938 |
if (args_info->length_given && ! override) |
939 |
continue; |
940 |
local_args_info.length_given = 1; |
941 |
args_info->length_given = 1; |
942 |
args_info->length_arg = strtod (optarg, &stop_char); |
943 |
if (!(stop_char && *stop_char == '\0')) { |
944 |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
945 |
goto failure; |
946 |
} |
947 |
if (args_info->length_orig) |
948 |
free (args_info->length_orig); /* free previous string */ |
949 |
args_info->length_orig = gengetopt_strdup (optarg); |
950 |
} |
951 |
/* select the first stuntdouble set. */ |
952 |
else if (strcmp (long_options[option_index].name, "sele1") == 0) |
953 |
{ |
954 |
if (local_args_info.sele1_given) |
955 |
{ |
956 |
fprintf (stderr, "%s: `--sele1' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
957 |
goto failure; |
958 |
} |
959 |
if (args_info->sele1_given && ! override) |
960 |
continue; |
961 |
local_args_info.sele1_given = 1; |
962 |
args_info->sele1_given = 1; |
963 |
if (args_info->sele1_arg) |
964 |
free (args_info->sele1_arg); /* free previous string */ |
965 |
args_info->sele1_arg = gengetopt_strdup (optarg); |
966 |
if (args_info->sele1_orig) |
967 |
free (args_info->sele1_orig); /* free previous string */ |
968 |
args_info->sele1_orig = gengetopt_strdup (optarg); |
969 |
} |
970 |
/* select the second stuntdouble set. */ |
971 |
else if (strcmp (long_options[option_index].name, "sele2") == 0) |
972 |
{ |
973 |
if (local_args_info.sele2_given) |
974 |
{ |
975 |
fprintf (stderr, "%s: `--sele2' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
976 |
goto failure; |
977 |
} |
978 |
if (args_info->sele2_given && ! override) |
979 |
continue; |
980 |
local_args_info.sele2_given = 1; |
981 |
args_info->sele2_given = 1; |
982 |
if (args_info->sele2_arg) |
983 |
free (args_info->sele2_arg); /* free previous string */ |
984 |
args_info->sele2_arg = gengetopt_strdup (optarg); |
985 |
if (args_info->sele2_orig) |
986 |
free (args_info->sele2_orig); /* free previous string */ |
987 |
args_info->sele2_orig = gengetopt_strdup (optarg); |
988 |
} |
989 |
/* select the third stuntdouble set. */ |
990 |
else if (strcmp (long_options[option_index].name, "sele3") == 0) |
991 |
{ |
992 |
if (local_args_info.sele3_given) |
993 |
{ |
994 |
fprintf (stderr, "%s: `--sele3' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
995 |
goto failure; |
996 |
} |
997 |
if (args_info->sele3_given && ! override) |
998 |
continue; |
999 |
local_args_info.sele3_given = 1; |
1000 |
args_info->sele3_given = 1; |
1001 |
if (args_info->sele3_arg) |
1002 |
free (args_info->sele3_arg); /* free previous string */ |
1003 |
args_info->sele3_arg = gengetopt_strdup (optarg); |
1004 |
if (args_info->sele3_orig) |
1005 |
free (args_info->sele3_orig); /* free previous string */ |
1006 |
args_info->sele3_orig = gengetopt_strdup (optarg); |
1007 |
} |
1008 |
/* select reference (use and only use with --gxyz). */ |
1009 |
else if (strcmp (long_options[option_index].name, "refsele") == 0) |
1010 |
{ |
1011 |
if (local_args_info.refsele_given) |
1012 |
{ |
1013 |
fprintf (stderr, "%s: `--refsele' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1014 |
goto failure; |
1015 |
} |
1016 |
if (args_info->refsele_given && ! override) |
1017 |
continue; |
1018 |
local_args_info.refsele_given = 1; |
1019 |
args_info->refsele_given = 1; |
1020 |
if (args_info->refsele_arg) |
1021 |
free (args_info->refsele_arg); /* free previous string */ |
1022 |
args_info->refsele_arg = gengetopt_strdup (optarg); |
1023 |
if (args_info->refsele_orig) |
1024 |
free (args_info->refsele_orig); /* free previous string */ |
1025 |
args_info->refsele_orig = gengetopt_strdup (optarg); |
1026 |
} |
1027 |
/* molecule name. */ |
1028 |
else if (strcmp (long_options[option_index].name, "molname") == 0) |
1029 |
{ |
1030 |
if (local_args_info.molname_given) |
1031 |
{ |
1032 |
fprintf (stderr, "%s: `--molname' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1033 |
goto failure; |
1034 |
} |
1035 |
if (args_info->molname_given && ! override) |
1036 |
continue; |
1037 |
local_args_info.molname_given = 1; |
1038 |
args_info->molname_given = 1; |
1039 |
if (args_info->molname_arg) |
1040 |
free (args_info->molname_arg); /* free previous string */ |
1041 |
args_info->molname_arg = gengetopt_strdup (optarg); |
1042 |
if (args_info->molname_orig) |
1043 |
free (args_info->molname_orig); /* free previous string */ |
1044 |
args_info->molname_orig = gengetopt_strdup (optarg); |
1045 |
} |
1046 |
/* begin internal index. */ |
1047 |
else if (strcmp (long_options[option_index].name, "begin") == 0) |
1048 |
{ |
1049 |
if (local_args_info.begin_given) |
1050 |
{ |
1051 |
fprintf (stderr, "%s: `--begin' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1052 |
goto failure; |
1053 |
} |
1054 |
if (args_info->begin_given && ! override) |
1055 |
continue; |
1056 |
local_args_info.begin_given = 1; |
1057 |
args_info->begin_given = 1; |
1058 |
args_info->begin_arg = strtol (optarg, &stop_char, 0); |
1059 |
if (!(stop_char && *stop_char == '\0')) { |
1060 |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
1061 |
goto failure; |
1062 |
} |
1063 |
if (args_info->begin_orig) |
1064 |
free (args_info->begin_orig); /* free previous string */ |
1065 |
args_info->begin_orig = gengetopt_strdup (optarg); |
1066 |
} |
1067 |
/* end internal index. */ |
1068 |
else if (strcmp (long_options[option_index].name, "end") == 0) |
1069 |
{ |
1070 |
if (local_args_info.end_given) |
1071 |
{ |
1072 |
fprintf (stderr, "%s: `--end' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1073 |
goto failure; |
1074 |
} |
1075 |
if (args_info->end_given && ! override) |
1076 |
continue; |
1077 |
local_args_info.end_given = 1; |
1078 |
args_info->end_given = 1; |
1079 |
args_info->end_arg = strtol (optarg, &stop_char, 0); |
1080 |
if (!(stop_char && *stop_char == '\0')) { |
1081 |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
1082 |
goto failure; |
1083 |
} |
1084 |
if (args_info->end_orig) |
1085 |
free (args_info->end_orig); /* free previous string */ |
1086 |
args_info->end_orig = gengetopt_strdup (optarg); |
1087 |
} |
1088 |
/* bond order parameter (--rcut and --LegendreL must be specified. */ |
1089 |
else if (strcmp (long_options[option_index].name, "bo") == 0) |
1090 |
{ |
1091 |
if (local_args_info.bo_given) |
1092 |
{ |
1093 |
fprintf (stderr, "%s: `--bo' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1094 |
goto failure; |
1095 |
} |
1096 |
if (args_info->bo_given && ! override) |
1097 |
continue; |
1098 |
local_args_info.bo_given = 1; |
1099 |
args_info->bo_given = 1; |
1100 |
if (args_info->staticProps_group_counter && override) |
1101 |
reset_group_staticProps (args_info); |
1102 |
args_info->staticProps_group_counter += 1; |
1103 |
break; |
1104 |
} |
1105 |
/* g(r, cos(theta)). */ |
1106 |
else if (strcmp (long_options[option_index].name, "r_theta") == 0) |
1107 |
{ |
1108 |
if (local_args_info.r_theta_given) |
1109 |
{ |
1110 |
fprintf (stderr, "%s: `--r_theta' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1111 |
goto failure; |
1112 |
} |
1113 |
if (args_info->r_theta_given && ! override) |
1114 |
continue; |
1115 |
local_args_info.r_theta_given = 1; |
1116 |
args_info->r_theta_given = 1; |
1117 |
if (args_info->staticProps_group_counter && override) |
1118 |
reset_group_staticProps (args_info); |
1119 |
args_info->staticProps_group_counter += 1; |
1120 |
break; |
1121 |
} |
1122 |
/* g(r, cos(omega)). */ |
1123 |
else if (strcmp (long_options[option_index].name, "r_omega") == 0) |
1124 |
{ |
1125 |
if (local_args_info.r_omega_given) |
1126 |
{ |
1127 |
fprintf (stderr, "%s: `--r_omega' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1128 |
goto failure; |
1129 |
} |
1130 |
if (args_info->r_omega_given && ! override) |
1131 |
continue; |
1132 |
local_args_info.r_omega_given = 1; |
1133 |
args_info->r_omega_given = 1; |
1134 |
if (args_info->staticProps_group_counter && override) |
1135 |
reset_group_staticProps (args_info); |
1136 |
args_info->staticProps_group_counter += 1; |
1137 |
break; |
1138 |
} |
1139 |
/* g(cos(theta), cos(omega)). */ |
1140 |
else if (strcmp (long_options[option_index].name, "theta_omega") == 0) |
1141 |
{ |
1142 |
if (local_args_info.theta_omega_given) |
1143 |
{ |
1144 |
fprintf (stderr, "%s: `--theta_omega' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1145 |
goto failure; |
1146 |
} |
1147 |
if (args_info->theta_omega_given && ! override) |
1148 |
continue; |
1149 |
local_args_info.theta_omega_given = 1; |
1150 |
args_info->theta_omega_given = 1; |
1151 |
if (args_info->staticProps_group_counter && override) |
1152 |
reset_group_staticProps (args_info); |
1153 |
args_info->staticProps_group_counter += 1; |
1154 |
break; |
1155 |
} |
1156 |
/* g(x, y, z). */ |
1157 |
else if (strcmp (long_options[option_index].name, "gxyz") == 0) |
1158 |
{ |
1159 |
if (local_args_info.gxyz_given) |
1160 |
{ |
1161 |
fprintf (stderr, "%s: `--gxyz' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1162 |
goto failure; |
1163 |
} |
1164 |
if (args_info->gxyz_given && ! override) |
1165 |
continue; |
1166 |
local_args_info.gxyz_given = 1; |
1167 |
args_info->gxyz_given = 1; |
1168 |
if (args_info->staticProps_group_counter && override) |
1169 |
reset_group_staticProps (args_info); |
1170 |
args_info->staticProps_group_counter += 1; |
1171 |
break; |
1172 |
} |
1173 |
/* rp2 order parameter (--sele1 and --sele2 must be specified). */ |
1174 |
else if (strcmp (long_options[option_index].name, "rp2") == 0) |
1175 |
{ |
1176 |
if (local_args_info.rp2_given) |
1177 |
{ |
1178 |
fprintf (stderr, "%s: `--rp2' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1179 |
goto failure; |
1180 |
} |
1181 |
if (args_info->rp2_given && ! override) |
1182 |
continue; |
1183 |
local_args_info.rp2_given = 1; |
1184 |
args_info->rp2_given = 1; |
1185 |
if (args_info->staticProps_group_counter && override) |
1186 |
reset_group_staticProps (args_info); |
1187 |
args_info->staticProps_group_counter += 1; |
1188 |
break; |
1189 |
} |
1190 |
/* slab density. */ |
1191 |
else if (strcmp (long_options[option_index].name, "slab_density") == 0) |
1192 |
{ |
1193 |
if (local_args_info.slab_density_given) |
1194 |
{ |
1195 |
fprintf (stderr, "%s: `--slab_density' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1196 |
goto failure; |
1197 |
} |
1198 |
if (args_info->slab_density_given && ! override) |
1199 |
continue; |
1200 |
local_args_info.slab_density_given = 1; |
1201 |
args_info->slab_density_given = 1; |
1202 |
if (args_info->staticProps_group_counter && override) |
1203 |
reset_group_staticProps (args_info); |
1204 |
args_info->staticProps_group_counter += 1; |
1205 |
break; |
1206 |
} |
1207 |
/* hxy. */ |
1208 |
else if (strcmp (long_options[option_index].name, "hxy") == 0) |
1209 |
{ |
1210 |
if (local_args_info.hxy_given) |
1211 |
{ |
1212 |
fprintf (stderr, "%s: `--hxy' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1213 |
goto failure; |
1214 |
} |
1215 |
if (args_info->hxy_given && ! override) |
1216 |
continue; |
1217 |
local_args_info.hxy_given = 1; |
1218 |
args_info->hxy_given = 1; |
1219 |
if (args_info->staticProps_group_counter && override) |
1220 |
reset_group_staticProps (args_info); |
1221 |
args_info->staticProps_group_counter += 1; |
1222 |
break; |
1223 |
} |
1224 |
|
1225 |
break; |
1226 |
case '?': /* Invalid option. */ |
1227 |
/* `getopt_long' already printed an error message. */ |
1228 |
goto failure; |
1229 |
|
1230 |
default: /* bug: option not considered. */ |
1231 |
fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); |
1232 |
abort (); |
1233 |
} /* switch */ |
1234 |
} /* while */ |
1235 |
|
1236 |
if (args_info->staticProps_group_counter > 1) |
1237 |
{ |
1238 |
fprintf (stderr, "%s: %d options of group staticProps were given. One is required.%s\n", argv[0], args_info->staticProps_group_counter, (additional_error ? additional_error : "")); |
1239 |
error = 1; |
1240 |
} |
1241 |
|
1242 |
|
1243 |
|
1244 |
if (check_required) |
1245 |
{ |
1246 |
error += cmdline_parser_required2 (args_info, argv[0], additional_error); |
1247 |
} |
1248 |
|
1249 |
cmdline_parser_release (&local_args_info); |
1250 |
|
1251 |
if ( error ) |
1252 |
return (EXIT_FAILURE); |
1253 |
|
1254 |
return 0; |
1255 |
|
1256 |
failure: |
1257 |
|
1258 |
cmdline_parser_release (&local_args_info); |
1259 |
return (EXIT_FAILURE); |
1260 |
} |