ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/staticProps/StaticPropsCmd.c
Revision: 1180
Committed: Mon Sep 17 20:05:51 2007 UTC (17 years, 7 months ago) by chuckv
Content type: text/plain
File size: 53274 byte(s)
Log Message:
Added code to compute bond angle distributions.

File Contents

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