ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp
Revision: 1811
Committed: Fri Nov 16 15:12:21 2012 UTC (12 years, 5 months ago) by gezelter
File size: 30880 byte(s)
Log Message:
Adding the selection correlation function, fixing a sample directory

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

Properties

Name Value
svn:keywords Author Id Revision Date