ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp
Revision: 1934
Committed: Mon Aug 26 14:15:09 2013 UTC (11 years, 8 months ago) by gezelter
File size: 33731 byte(s)
Log Message:
Added OH bond time correlation function

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

Properties

Name Value
svn:keywords Author Id Revision Date