ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp
Revision: 1795
Committed: Fri Sep 7 18:13:55 2012 UTC (12 years, 7 months ago) by gezelter
File size: 30040 byte(s)
Log Message:
Windows fixes

File Contents

# Content
1 /*
2 File autogenerated by gengetopt version 2.22.4
3 generated with the following command:
4 gengetopt -F DynamicPropsCmd -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 #ifndef FIX_UNUSED
21 #define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
22 #endif
23
24 #ifdef WIN32
25 #include "utils/wingetopt.h"
26 #else
27 #include <getopt.h>
28 #endif
29
30 #include "DynamicPropsCmd.h"
31
32 const char *gengetopt_args_info_purpose = "";
33
34 const char *gengetopt_args_info_usage = "Usage: DynamicProps [OPTIONS]... [FILES]...";
35
36 const char *gengetopt_args_info_description = "";
37
38 const char *gengetopt_args_info_help[] = {
39 " -h, --help Print help and exit",
40 " -V, --version Print version and exit",
41 " -i, --input=filename input dump file",
42 " -o, --output=filename output file name",
43 " --sele1=selection script select first stuntdouble set",
44 " --sele2=selection script select second stuntdouble set (if sele2 is not \n set, use script from sele1)",
45 " --order=INT Lengendre Polynomial Order",
46 " -m, --memory=memory specification\n Available memory (defaults to 2G) \n (default=`2G')",
47 "\n Group: dynamicProps\n an option of this group is required",
48 " -r, --rcorr rmsd",
49 " -v, --vcorr velocity correlation function",
50 " -d, --dcorr dipole correlation function",
51 " -l, --lcorr Lengendre correlation function",
52 " -s, --sdcorr System dipole correlation function",
53 " --r_rcorr Radial rmsd",
54 " --thetacorr Angular rmsd",
55 " --drcorr Directional rmsd for particles with unit \n vectors",
56 " --helfandEcorr Helfand moment for thermal conductvity",
57 " -p, --momentum Helfand momentum for viscosity",
58 " --stresscorr Stress tensor correlation function",
59 0
60 };
61
62 typedef enum {ARG_NO
63 , ARG_STRING
64 , ARG_INT
65 } cmdline_parser_arg_type;
66
67 static
68 void clear_given (struct gengetopt_args_info *args_info);
69 static
70 void clear_args (struct gengetopt_args_info *args_info);
71
72 static int
73 cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
74 struct cmdline_parser_params *params, const char *additional_error);
75
76 static int
77 cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
78
79 static char *
80 gengetopt_strdup (const char *s);
81
82 static
83 void clear_given (struct gengetopt_args_info *args_info)
84 {
85 args_info->help_given = 0 ;
86 args_info->version_given = 0 ;
87 args_info->input_given = 0 ;
88 args_info->output_given = 0 ;
89 args_info->sele1_given = 0 ;
90 args_info->sele2_given = 0 ;
91 args_info->order_given = 0 ;
92 args_info->memory_given = 0 ;
93 args_info->rcorr_given = 0 ;
94 args_info->vcorr_given = 0 ;
95 args_info->dcorr_given = 0 ;
96 args_info->lcorr_given = 0 ;
97 args_info->sdcorr_given = 0 ;
98 args_info->r_rcorr_given = 0 ;
99 args_info->thetacorr_given = 0 ;
100 args_info->drcorr_given = 0 ;
101 args_info->helfandEcorr_given = 0 ;
102 args_info->momentum_given = 0 ;
103 args_info->stresscorr_given = 0 ;
104 args_info->dynamicProps_group_counter = 0 ;
105 }
106
107 static
108 void clear_args (struct gengetopt_args_info *args_info)
109 {
110 FIX_UNUSED (args_info);
111 args_info->input_arg = NULL;
112 args_info->input_orig = NULL;
113 args_info->output_arg = NULL;
114 args_info->output_orig = NULL;
115 args_info->sele1_arg = NULL;
116 args_info->sele1_orig = NULL;
117 args_info->sele2_arg = NULL;
118 args_info->sele2_orig = NULL;
119 args_info->order_orig = NULL;
120 args_info->memory_arg = gengetopt_strdup ("2G");
121 args_info->memory_orig = NULL;
122
123 }
124
125 static
126 void init_args_info(struct gengetopt_args_info *args_info)
127 {
128
129
130 args_info->help_help = gengetopt_args_info_help[0] ;
131 args_info->version_help = gengetopt_args_info_help[1] ;
132 args_info->input_help = gengetopt_args_info_help[2] ;
133 args_info->output_help = gengetopt_args_info_help[3] ;
134 args_info->sele1_help = gengetopt_args_info_help[4] ;
135 args_info->sele2_help = gengetopt_args_info_help[5] ;
136 args_info->order_help = gengetopt_args_info_help[6] ;
137 args_info->memory_help = gengetopt_args_info_help[7] ;
138 args_info->rcorr_help = gengetopt_args_info_help[9] ;
139 args_info->vcorr_help = gengetopt_args_info_help[10] ;
140 args_info->dcorr_help = gengetopt_args_info_help[11] ;
141 args_info->lcorr_help = gengetopt_args_info_help[12] ;
142 args_info->sdcorr_help = gengetopt_args_info_help[13] ;
143 args_info->r_rcorr_help = gengetopt_args_info_help[14] ;
144 args_info->thetacorr_help = gengetopt_args_info_help[15] ;
145 args_info->drcorr_help = gengetopt_args_info_help[16] ;
146 args_info->helfandEcorr_help = gengetopt_args_info_help[17] ;
147 args_info->momentum_help = gengetopt_args_info_help[18] ;
148 args_info->stresscorr_help = gengetopt_args_info_help[19] ;
149
150 }
151
152 void
153 cmdline_parser_print_version (void)
154 {
155 printf ("%s %s\n",
156 (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
157 CMDLINE_PARSER_VERSION);
158 }
159
160 static void print_help_common(void) {
161 cmdline_parser_print_version ();
162
163 if (strlen(gengetopt_args_info_purpose) > 0)
164 printf("\n%s\n", gengetopt_args_info_purpose);
165
166 if (strlen(gengetopt_args_info_usage) > 0)
167 printf("\n%s\n", gengetopt_args_info_usage);
168
169 printf("\n");
170
171 if (strlen(gengetopt_args_info_description) > 0)
172 printf("%s\n\n", gengetopt_args_info_description);
173 }
174
175 void
176 cmdline_parser_print_help (void)
177 {
178 int i = 0;
179 print_help_common();
180 while (gengetopt_args_info_help[i])
181 printf("%s\n", gengetopt_args_info_help[i++]);
182 }
183
184 void
185 cmdline_parser_init (struct gengetopt_args_info *args_info)
186 {
187 clear_given (args_info);
188 clear_args (args_info);
189 init_args_info (args_info);
190
191 args_info->inputs = 0;
192 args_info->inputs_num = 0;
193 }
194
195 void
196 cmdline_parser_params_init(struct cmdline_parser_params *params)
197 {
198 if (params)
199 {
200 params->override = 0;
201 params->initialize = 1;
202 params->check_required = 1;
203 params->check_ambiguity = 0;
204 params->print_errors = 1;
205 }
206 }
207
208 struct cmdline_parser_params *
209 cmdline_parser_params_create(void)
210 {
211 struct cmdline_parser_params *params =
212 (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
213 cmdline_parser_params_init(params);
214 return params;
215 }
216
217 static void
218 free_string_field (char **s)
219 {
220 if (*s)
221 {
222 free (*s);
223 *s = 0;
224 }
225 }
226
227
228 static void
229 cmdline_parser_release (struct gengetopt_args_info *args_info)
230 {
231 unsigned int i;
232 free_string_field (&(args_info->input_arg));
233 free_string_field (&(args_info->input_orig));
234 free_string_field (&(args_info->output_arg));
235 free_string_field (&(args_info->output_orig));
236 free_string_field (&(args_info->sele1_arg));
237 free_string_field (&(args_info->sele1_orig));
238 free_string_field (&(args_info->sele2_arg));
239 free_string_field (&(args_info->sele2_orig));
240 free_string_field (&(args_info->order_orig));
241 free_string_field (&(args_info->memory_arg));
242 free_string_field (&(args_info->memory_orig));
243
244
245 for (i = 0; i < args_info->inputs_num; ++i)
246 free (args_info->inputs [i]);
247
248 if (args_info->inputs_num)
249 free (args_info->inputs);
250
251 clear_given (args_info);
252 }
253
254
255 static void
256 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
257 {
258 FIX_UNUSED (values);
259 if (arg) {
260 fprintf(outfile, "%s=\"%s\"\n", opt, arg);
261 } else {
262 fprintf(outfile, "%s\n", opt);
263 }
264 }
265
266
267 int
268 cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
269 {
270 int i = 0;
271
272 if (!outfile)
273 {
274 fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
275 return EXIT_FAILURE;
276 }
277
278 if (args_info->help_given)
279 write_into_file(outfile, "help", 0, 0 );
280 if (args_info->version_given)
281 write_into_file(outfile, "version", 0, 0 );
282 if (args_info->input_given)
283 write_into_file(outfile, "input", args_info->input_orig, 0);
284 if (args_info->output_given)
285 write_into_file(outfile, "output", args_info->output_orig, 0);
286 if (args_info->sele1_given)
287 write_into_file(outfile, "sele1", args_info->sele1_orig, 0);
288 if (args_info->sele2_given)
289 write_into_file(outfile, "sele2", args_info->sele2_orig, 0);
290 if (args_info->order_given)
291 write_into_file(outfile, "order", args_info->order_orig, 0);
292 if (args_info->memory_given)
293 write_into_file(outfile, "memory", args_info->memory_orig, 0);
294 if (args_info->rcorr_given)
295 write_into_file(outfile, "rcorr", 0, 0 );
296 if (args_info->vcorr_given)
297 write_into_file(outfile, "vcorr", 0, 0 );
298 if (args_info->dcorr_given)
299 write_into_file(outfile, "dcorr", 0, 0 );
300 if (args_info->lcorr_given)
301 write_into_file(outfile, "lcorr", 0, 0 );
302 if (args_info->sdcorr_given)
303 write_into_file(outfile, "sdcorr", 0, 0 );
304 if (args_info->r_rcorr_given)
305 write_into_file(outfile, "r_rcorr", 0, 0 );
306 if (args_info->thetacorr_given)
307 write_into_file(outfile, "thetacorr", 0, 0 );
308 if (args_info->drcorr_given)
309 write_into_file(outfile, "drcorr", 0, 0 );
310 if (args_info->helfandEcorr_given)
311 write_into_file(outfile, "helfandEcorr", 0, 0 );
312 if (args_info->momentum_given)
313 write_into_file(outfile, "momentum", 0, 0 );
314 if (args_info->stresscorr_given)
315 write_into_file(outfile, "stresscorr", 0, 0 );
316
317
318 i = EXIT_SUCCESS;
319 return i;
320 }
321
322 int
323 cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
324 {
325 FILE *outfile;
326 int i = 0;
327
328 outfile = fopen(filename, "w");
329
330 if (!outfile)
331 {
332 fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
333 return EXIT_FAILURE;
334 }
335
336 i = cmdline_parser_dump(outfile, args_info);
337 fclose (outfile);
338
339 return i;
340 }
341
342 void
343 cmdline_parser_free (struct gengetopt_args_info *args_info)
344 {
345 cmdline_parser_release (args_info);
346 }
347
348 /** @brief replacement of strdup, which is not standard */
349 char *
350 gengetopt_strdup (const char *s)
351 {
352 char *result = 0;
353 if (!s)
354 return result;
355
356 result = (char*)malloc(strlen(s) + 1);
357 if (result == (char*)0)
358 return (char*)0;
359 strcpy(result, s);
360 return result;
361 }
362
363 static void
364 reset_group_dynamicProps(struct gengetopt_args_info *args_info)
365 {
366 if (! args_info->dynamicProps_group_counter)
367 return;
368
369 args_info->rcorr_given = 0 ;
370 args_info->vcorr_given = 0 ;
371 args_info->dcorr_given = 0 ;
372 args_info->lcorr_given = 0 ;
373 args_info->sdcorr_given = 0 ;
374 args_info->r_rcorr_given = 0 ;
375 args_info->thetacorr_given = 0 ;
376 args_info->drcorr_given = 0 ;
377 args_info->helfandEcorr_given = 0 ;
378 args_info->momentum_given = 0 ;
379 args_info->stresscorr_given = 0 ;
380
381 args_info->dynamicProps_group_counter = 0;
382 }
383
384 int
385 cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
386 {
387 return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
388 }
389
390 int
391 cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
392 struct cmdline_parser_params *params)
393 {
394 int result;
395 result = cmdline_parser_internal (argc, argv, args_info, params, 0);
396
397 if (result == EXIT_FAILURE)
398 {
399 cmdline_parser_free (args_info);
400 exit (EXIT_FAILURE);
401 }
402
403 return result;
404 }
405
406 int
407 cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
408 {
409 int result;
410 struct cmdline_parser_params params;
411
412 params.override = override;
413 params.initialize = initialize;
414 params.check_required = check_required;
415 params.check_ambiguity = 0;
416 params.print_errors = 1;
417
418 result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
419
420 if (result == EXIT_FAILURE)
421 {
422 cmdline_parser_free (args_info);
423 exit (EXIT_FAILURE);
424 }
425
426 return result;
427 }
428
429 int
430 cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
431 {
432 int result = EXIT_SUCCESS;
433
434 if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
435 result = EXIT_FAILURE;
436
437 if (result == EXIT_FAILURE)
438 {
439 cmdline_parser_free (args_info);
440 exit (EXIT_FAILURE);
441 }
442
443 return result;
444 }
445
446 int
447 cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
448 {
449 int error = 0;
450 FIX_UNUSED (additional_error);
451
452 /* checks for required options */
453 if (! args_info->input_given)
454 {
455 fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : ""));
456 error = 1;
457 }
458
459 if (args_info->dynamicProps_group_counter == 0)
460 {
461 fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required%s.\n", prog_name, args_info->dynamicProps_group_counter, (additional_error ? additional_error : ""));
462 error = 1;
463 }
464
465
466 /* checks for dependences among options */
467
468 return error;
469 }
470
471
472 static char *package_name = 0;
473
474 /**
475 * @brief updates an option
476 * @param field the generic pointer to the field to update
477 * @param orig_field the pointer to the orig field
478 * @param field_given the pointer to the number of occurrence of this option
479 * @param prev_given the pointer to the number of occurrence already seen
480 * @param value the argument for this option (if null no arg was specified)
481 * @param possible_values the possible values for this option (if specified)
482 * @param default_value the default value (in case the option only accepts fixed values)
483 * @param arg_type the type of this option
484 * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
485 * @param override @see cmdline_parser_params.override
486 * @param no_free whether to free a possible previous value
487 * @param multiple_option whether this is a multiple option
488 * @param long_opt the corresponding long option
489 * @param short_opt the corresponding short option (or '-' if none)
490 * @param additional_error possible further error specification
491 */
492 static
493 int update_arg(void *field, char **orig_field,
494 unsigned int *field_given, unsigned int *prev_given,
495 char *value, const char *possible_values[],
496 const char *default_value,
497 cmdline_parser_arg_type arg_type,
498 int check_ambiguity, int override,
499 int no_free, int multiple_option,
500 const char *long_opt, char short_opt,
501 const char *additional_error)
502 {
503 char *stop_char = 0;
504 const char *val = value;
505 int found;
506 char **string_field;
507 FIX_UNUSED (field);
508
509 stop_char = 0;
510 found = 0;
511
512 if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
513 {
514 if (short_opt != '-')
515 fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
516 package_name, long_opt, short_opt,
517 (additional_error ? additional_error : ""));
518 else
519 fprintf (stderr, "%s: `--%s' option given more than once%s\n",
520 package_name, long_opt,
521 (additional_error ? additional_error : ""));
522 return 1; /* failure */
523 }
524
525 FIX_UNUSED (default_value);
526
527 if (field_given && *field_given && ! override)
528 return 0;
529 if (prev_given)
530 (*prev_given)++;
531 if (field_given)
532 (*field_given)++;
533 if (possible_values)
534 val = possible_values[found];
535
536 switch(arg_type) {
537 case ARG_INT:
538 if (val) *((int *)field) = strtol (val, &stop_char, 0);
539 break;
540 case ARG_STRING:
541 if (val) {
542 string_field = (char **)field;
543 if (!no_free && *string_field)
544 free (*string_field); /* free previous string */
545 *string_field = gengetopt_strdup (val);
546 }
547 break;
548 default:
549 break;
550 };
551
552 /* check numeric conversion */
553 switch(arg_type) {
554 case ARG_INT:
555 if (val && !(stop_char && *stop_char == '\0')) {
556 fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
557 return 1; /* failure */
558 }
559 break;
560 default:
561 ;
562 };
563
564 /* store the original value */
565 switch(arg_type) {
566 case ARG_NO:
567 break;
568 default:
569 if (value && orig_field) {
570 if (no_free) {
571 *orig_field = value;
572 } else {
573 if (*orig_field)
574 free (*orig_field); /* free previous string */
575 *orig_field = gengetopt_strdup (value);
576 }
577 }
578 };
579
580 return 0; /* OK */
581 }
582
583
584 int
585 cmdline_parser_internal (
586 int argc, char **argv, struct gengetopt_args_info *args_info,
587 struct cmdline_parser_params *params, const char *additional_error)
588 {
589 int c; /* Character of the parsed option. */
590
591 int error = 0;
592 struct gengetopt_args_info local_args_info;
593
594 int override;
595 int initialize;
596 int check_required;
597 int check_ambiguity;
598
599 package_name = argv[0];
600
601 override = params->override;
602 initialize = params->initialize;
603 check_required = params->check_required;
604 check_ambiguity = params->check_ambiguity;
605
606 if (initialize)
607 cmdline_parser_init (args_info);
608
609 cmdline_parser_init (&local_args_info);
610
611 optarg = 0;
612 optind = 0;
613 opterr = params->print_errors;
614 optopt = '?';
615
616 while (1)
617 {
618 int option_index = 0;
619
620 static struct option long_options[] = {
621 { "help", 0, NULL, 'h' },
622 { "version", 0, NULL, 'V' },
623 { "input", 1, NULL, 'i' },
624 { "output", 1, NULL, 'o' },
625 { "sele1", 1, NULL, 0 },
626 { "sele2", 1, NULL, 0 },
627 { "order", 1, NULL, 0 },
628 { "memory", 1, NULL, 'm' },
629 { "rcorr", 0, NULL, 'r' },
630 { "vcorr", 0, NULL, 'v' },
631 { "dcorr", 0, NULL, 'd' },
632 { "lcorr", 0, NULL, 'l' },
633 { "sdcorr", 0, NULL, 's' },
634 { "r_rcorr", 0, NULL, 0 },
635 { "thetacorr", 0, NULL, 0 },
636 { "drcorr", 0, NULL, 0 },
637 { "helfandEcorr", 0, NULL, 0 },
638 { "momentum", 0, NULL, 'p' },
639 { "stresscorr", 0, NULL, 0 },
640 { 0, 0, 0, 0 }
641 };
642
643 c = getopt_long (argc, argv, "hVi:o:m:rvdlsp", long_options, &option_index);
644
645 if (c == -1) break; /* Exit from `while (1)' loop. */
646
647 switch (c)
648 {
649 case 'h': /* Print help and exit. */
650 cmdline_parser_print_help ();
651 cmdline_parser_free (&local_args_info);
652 exit (EXIT_SUCCESS);
653
654 case 'V': /* Print version and exit. */
655 cmdline_parser_print_version ();
656 cmdline_parser_free (&local_args_info);
657 exit (EXIT_SUCCESS);
658
659 case 'i': /* input dump file. */
660
661
662 if (update_arg( (void *)&(args_info->input_arg),
663 &(args_info->input_orig), &(args_info->input_given),
664 &(local_args_info.input_given), optarg, 0, 0, ARG_STRING,
665 check_ambiguity, override, 0, 0,
666 "input", 'i',
667 additional_error))
668 goto failure;
669
670 break;
671 case 'o': /* output file name. */
672
673
674 if (update_arg( (void *)&(args_info->output_arg),
675 &(args_info->output_orig), &(args_info->output_given),
676 &(local_args_info.output_given), optarg, 0, 0, ARG_STRING,
677 check_ambiguity, override, 0, 0,
678 "output", 'o',
679 additional_error))
680 goto failure;
681
682 break;
683 case 'm': /* Available memory (defaults to 2G). */
684
685
686 if (update_arg( (void *)&(args_info->memory_arg),
687 &(args_info->memory_orig), &(args_info->memory_given),
688 &(local_args_info.memory_given), optarg, 0, "2G", ARG_STRING,
689 check_ambiguity, override, 0, 0,
690 "memory", 'm',
691 additional_error))
692 goto failure;
693
694 break;
695 case 'r': /* rmsd. */
696
697 if (args_info->dynamicProps_group_counter && override)
698 reset_group_dynamicProps (args_info);
699 args_info->dynamicProps_group_counter += 1;
700
701 if (update_arg( 0 ,
702 0 , &(args_info->rcorr_given),
703 &(local_args_info.rcorr_given), optarg, 0, 0, ARG_NO,
704 check_ambiguity, override, 0, 0,
705 "rcorr", 'r',
706 additional_error))
707 goto failure;
708
709 break;
710 case 'v': /* velocity correlation function. */
711
712 if (args_info->dynamicProps_group_counter && override)
713 reset_group_dynamicProps (args_info);
714 args_info->dynamicProps_group_counter += 1;
715
716 if (update_arg( 0 ,
717 0 , &(args_info->vcorr_given),
718 &(local_args_info.vcorr_given), optarg, 0, 0, ARG_NO,
719 check_ambiguity, override, 0, 0,
720 "vcorr", 'v',
721 additional_error))
722 goto failure;
723
724 break;
725 case 'd': /* dipole correlation function. */
726
727 if (args_info->dynamicProps_group_counter && override)
728 reset_group_dynamicProps (args_info);
729 args_info->dynamicProps_group_counter += 1;
730
731 if (update_arg( 0 ,
732 0 , &(args_info->dcorr_given),
733 &(local_args_info.dcorr_given), optarg, 0, 0, ARG_NO,
734 check_ambiguity, override, 0, 0,
735 "dcorr", 'd',
736 additional_error))
737 goto failure;
738
739 break;
740 case 'l': /* Lengendre correlation function. */
741
742 if (args_info->dynamicProps_group_counter && override)
743 reset_group_dynamicProps (args_info);
744 args_info->dynamicProps_group_counter += 1;
745
746 if (update_arg( 0 ,
747 0 , &(args_info->lcorr_given),
748 &(local_args_info.lcorr_given), optarg, 0, 0, ARG_NO,
749 check_ambiguity, override, 0, 0,
750 "lcorr", 'l',
751 additional_error))
752 goto failure;
753
754 break;
755 case 's': /* System dipole correlation function. */
756
757 if (args_info->dynamicProps_group_counter && override)
758 reset_group_dynamicProps (args_info);
759 args_info->dynamicProps_group_counter += 1;
760
761 if (update_arg( 0 ,
762 0 , &(args_info->sdcorr_given),
763 &(local_args_info.sdcorr_given), optarg, 0, 0, ARG_NO,
764 check_ambiguity, override, 0, 0,
765 "sdcorr", 's',
766 additional_error))
767 goto failure;
768
769 break;
770 case 'p': /* Helfand momentum for viscosity. */
771
772 if (args_info->dynamicProps_group_counter && override)
773 reset_group_dynamicProps (args_info);
774 args_info->dynamicProps_group_counter += 1;
775
776 if (update_arg( 0 ,
777 0 , &(args_info->momentum_given),
778 &(local_args_info.momentum_given), optarg, 0, 0, ARG_NO,
779 check_ambiguity, override, 0, 0,
780 "momentum", 'p',
781 additional_error))
782 goto failure;
783
784 break;
785
786 case 0: /* Long option with no short option */
787 /* select first stuntdouble set. */
788 if (strcmp (long_options[option_index].name, "sele1") == 0)
789 {
790
791
792 if (update_arg( (void *)&(args_info->sele1_arg),
793 &(args_info->sele1_orig), &(args_info->sele1_given),
794 &(local_args_info.sele1_given), optarg, 0, 0, ARG_STRING,
795 check_ambiguity, override, 0, 0,
796 "sele1", '-',
797 additional_error))
798 goto failure;
799
800 }
801 /* select second stuntdouble set (if sele2 is not set, use script from sele1). */
802 else if (strcmp (long_options[option_index].name, "sele2") == 0)
803 {
804
805
806 if (update_arg( (void *)&(args_info->sele2_arg),
807 &(args_info->sele2_orig), &(args_info->sele2_given),
808 &(local_args_info.sele2_given), optarg, 0, 0, ARG_STRING,
809 check_ambiguity, override, 0, 0,
810 "sele2", '-',
811 additional_error))
812 goto failure;
813
814 }
815 /* Lengendre Polynomial Order. */
816 else if (strcmp (long_options[option_index].name, "order") == 0)
817 {
818
819
820 if (update_arg( (void *)&(args_info->order_arg),
821 &(args_info->order_orig), &(args_info->order_given),
822 &(local_args_info.order_given), optarg, 0, 0, ARG_INT,
823 check_ambiguity, override, 0, 0,
824 "order", '-',
825 additional_error))
826 goto failure;
827
828 }
829 /* Radial rmsd. */
830 else if (strcmp (long_options[option_index].name, "r_rcorr") == 0)
831 {
832
833 if (args_info->dynamicProps_group_counter && override)
834 reset_group_dynamicProps (args_info);
835 args_info->dynamicProps_group_counter += 1;
836
837 if (update_arg( 0 ,
838 0 , &(args_info->r_rcorr_given),
839 &(local_args_info.r_rcorr_given), optarg, 0, 0, ARG_NO,
840 check_ambiguity, override, 0, 0,
841 "r_rcorr", '-',
842 additional_error))
843 goto failure;
844
845 }
846 /* Angular rmsd. */
847 else if (strcmp (long_options[option_index].name, "thetacorr") == 0)
848 {
849
850 if (args_info->dynamicProps_group_counter && override)
851 reset_group_dynamicProps (args_info);
852 args_info->dynamicProps_group_counter += 1;
853
854 if (update_arg( 0 ,
855 0 , &(args_info->thetacorr_given),
856 &(local_args_info.thetacorr_given), optarg, 0, 0, ARG_NO,
857 check_ambiguity, override, 0, 0,
858 "thetacorr", '-',
859 additional_error))
860 goto failure;
861
862 }
863 /* Directional rmsd for particles with unit vectors. */
864 else if (strcmp (long_options[option_index].name, "drcorr") == 0)
865 {
866
867 if (args_info->dynamicProps_group_counter && override)
868 reset_group_dynamicProps (args_info);
869 args_info->dynamicProps_group_counter += 1;
870
871 if (update_arg( 0 ,
872 0 , &(args_info->drcorr_given),
873 &(local_args_info.drcorr_given), optarg, 0, 0, ARG_NO,
874 check_ambiguity, override, 0, 0,
875 "drcorr", '-',
876 additional_error))
877 goto failure;
878
879 }
880 /* Helfand moment for thermal conductvity. */
881 else if (strcmp (long_options[option_index].name, "helfandEcorr") == 0)
882 {
883
884 if (args_info->dynamicProps_group_counter && override)
885 reset_group_dynamicProps (args_info);
886 args_info->dynamicProps_group_counter += 1;
887
888 if (update_arg( 0 ,
889 0 , &(args_info->helfandEcorr_given),
890 &(local_args_info.helfandEcorr_given), optarg, 0, 0, ARG_NO,
891 check_ambiguity, override, 0, 0,
892 "helfandEcorr", '-',
893 additional_error))
894 goto failure;
895
896 }
897 /* Stress tensor correlation function. */
898 else if (strcmp (long_options[option_index].name, "stresscorr") == 0)
899 {
900
901 if (args_info->dynamicProps_group_counter && override)
902 reset_group_dynamicProps (args_info);
903 args_info->dynamicProps_group_counter += 1;
904
905 if (update_arg( 0 ,
906 0 , &(args_info->stresscorr_given),
907 &(local_args_info.stresscorr_given), optarg, 0, 0, ARG_NO,
908 check_ambiguity, override, 0, 0,
909 "stresscorr", '-',
910 additional_error))
911 goto failure;
912
913 }
914
915 break;
916 case '?': /* Invalid option. */
917 /* `getopt_long' already printed an error message. */
918 goto failure;
919
920 default: /* bug: option not considered. */
921 fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
922 abort ();
923 } /* switch */
924 } /* while */
925
926 if (args_info->dynamicProps_group_counter > 1)
927 {
928 fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required%s.\n", argv[0], args_info->dynamicProps_group_counter, (additional_error ? additional_error : ""));
929 error = 1;
930 }
931
932
933
934 if (check_required)
935 {
936 error += cmdline_parser_required2 (args_info, argv[0], additional_error);
937 }
938
939 cmdline_parser_release (&local_args_info);
940
941 if ( error )
942 return (EXIT_FAILURE);
943
944 if (optind < argc)
945 {
946 int i = 0 ;
947 int found_prog_name = 0;
948 /* whether program name, i.e., argv[0], is in the remaining args
949 (this may happen with some implementations of getopt,
950 but surely not with the one included by gengetopt) */
951
952 i = optind;
953 while (i < argc)
954 if (argv[i++] == argv[0]) {
955 found_prog_name = 1;
956 break;
957 }
958 i = 0;
959
960 args_info->inputs_num = argc - optind - found_prog_name;
961 args_info->inputs =
962 (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
963 while (optind < argc)
964 if (argv[optind++] != argv[0])
965 args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ;
966 }
967
968 return 0;
969
970 failure:
971
972 cmdline_parser_release (&local_args_info);
973 return (EXIT_FAILURE);
974 }

Properties

Name Value
svn:keywords Author Id Revision Date