ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp
Revision: 1915
Committed: Mon Jul 29 17:55:17 2013 UTC (11 years, 9 months ago) by gezelter
File size: 32696 byte(s)
Log Message:
Added Legendre Correlation function (as a function of Z), working on architecture for Ewald
Fixed some bugs in FlucQ


File Contents

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

Properties

Name Value
svn:keywords Author Id Revision Date