ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp
Revision: 1782
Committed: Wed Aug 22 02:28:28 2012 UTC (12 years, 8 months ago) by gezelter
File size: 29985 byte(s)
Log Message:
MERGE OpenMD development branch 1465:1781 into trunk

File Contents

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

Properties

Name Value
svn:keywords Author Id Revision Date