ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/staticProps/StaticPropsCmd.c
Revision: 2763
Committed: Mon May 22 15:30:42 2006 UTC (18 years, 3 months ago) by xsun
Content type: text/plain
File size: 41495 byte(s)
Log Message:
fixed the bugs of Hxy.cpp.

File Contents

# User Rev Content
1 tim 1994 /*
2 gezelter 2701 File autogenerated by gengetopt version 2.16
3 tim 1994 generated with the following command:
4 gezelter 2701 gengetopt -F StaticPropsCmd
5 tim 1994
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 gezelter 2701 /* If we use autoconf. */
12     #ifdef HAVE_CONFIG_H
13     #include "config.h"
14     #endif
15 tim 1994
16     #include <stdio.h>
17     #include <stdlib.h>
18     #include <string.h>
19    
20     #include "getopt.h"
21    
22 tim 1995 #include "StaticPropsCmd.h"
23 tim 1994
24 gezelter 2701 static
25     void clear_given (struct gengetopt_args_info *args_info);
26     static
27     void clear_args (struct gengetopt_args_info *args_info);
28    
29     static int
30     cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error);
31    
32     static int
33     cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
34    
35     static char *
36     gengetopt_strdup (const char *s);
37    
38     static
39     void clear_given (struct gengetopt_args_info *args_info)
40     {
41     args_info->help_given = 0 ;
42     args_info->version_given = 0 ;
43     args_info->input_given = 0 ;
44     args_info->output_given = 0 ;
45     args_info->step_given = 0 ;
46     args_info->nrbins_given = 0 ;
47 xsun 2751 args_info->nbins_x_given = 0 ;
48     args_info->nbins_y_given = 0 ;
49 gezelter 2701 args_info->nanglebins_given = 0 ;
50     args_info->length_given = 0 ;
51     args_info->zoffset_given = 0 ;
52     args_info->sele1_given = 0 ;
53     args_info->sele2_given = 0 ;
54     args_info->sele3_given = 0 ;
55     args_info->refsele_given = 0 ;
56     args_info->molname_given = 0 ;
57     args_info->begin_given = 0 ;
58     args_info->end_given = 0 ;
59     args_info->gofr_given = 0 ;
60     args_info->r_theta_given = 0 ;
61     args_info->r_omega_given = 0 ;
62     args_info->theta_omega_given = 0 ;
63     args_info->gxyz_given = 0 ;
64     args_info->p2_given = 0 ;
65     args_info->scd_given = 0 ;
66     args_info->density_given = 0 ;
67     args_info->slab_density_given = 0 ;
68 xsun 2751 args_info->hxy_given = 0 ;
69 gezelter 2701 args_info->staticProps_group_counter = 0 ;
70     }
71    
72     static
73     void clear_args (struct gengetopt_args_info *args_info)
74     {
75     args_info->input_arg = NULL;
76     args_info->input_orig = NULL;
77     args_info->output_arg = NULL;
78     args_info->output_orig = NULL;
79     args_info->step_arg = 1;
80     args_info->step_orig = NULL;
81     args_info->nrbins_arg = 100;
82     args_info->nrbins_orig = NULL;
83 xsun 2751 args_info->nbins_x_arg = 100;
84     args_info->nbins_x_orig = NULL;
85     args_info->nbins_y_arg = 100;
86     args_info->nbins_y_orig = NULL;
87 gezelter 2701 args_info->nanglebins_arg = 50;
88     args_info->nanglebins_orig = NULL;
89     args_info->length_orig = NULL;
90     args_info->zoffset_arg = 0;
91     args_info->zoffset_orig = NULL;
92     args_info->sele1_arg = NULL;
93     args_info->sele1_orig = NULL;
94     args_info->sele2_arg = NULL;
95     args_info->sele2_orig = NULL;
96     args_info->sele3_arg = NULL;
97     args_info->sele3_orig = NULL;
98     args_info->refsele_arg = NULL;
99     args_info->refsele_orig = NULL;
100     args_info->molname_arg = NULL;
101     args_info->molname_orig = NULL;
102     args_info->begin_orig = NULL;
103     args_info->end_orig = NULL;
104    
105     }
106    
107 tim 1994 void
108     cmdline_parser_print_version (void)
109     {
110     printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
111     }
112    
113     void
114     cmdline_parser_print_help (void)
115     {
116     cmdline_parser_print_version ();
117 gezelter 2701 printf("\nUsage: StaticProps [OPTIONS]...\n\n");
118     printf("%s\n"," -h, --help Print help and exit");
119     printf("%s\n"," -V, --version Print version and exit");
120     printf("%s\n"," -i, --input=filename input dump file");
121     printf("%s\n"," -o, --output=filename output file name");
122     printf("%s\n"," -n, --step=INT process every n frame (default=`1')");
123 xsun 2763 printf("%s\n"," -r, --nrbins=INT number of bins for distance (default=`100')");
124     printf("%s\n"," -x, --nbins_x=INT number of bins in x axis (default=`100')");
125     printf("%s\n"," -y, --nbins_y=INT number of bins in y axis (default=`100')");
126 gezelter 2701 printf("%s\n"," -a, --nanglebins=INT number of bins for cos(angle) (default=`50')");
127     printf("%s\n"," -l, --length=DOUBLE maximum length (Defaults to 1/2 smallest length \n of first frame)");
128     printf("%s\n"," -z, --zoffset=DOUBLE Where to set the zero for the slab_density \n calculation (default=`0')");
129     printf("%s\n"," --sele1=selection script select the first stuntdouble set");
130     printf("%s\n"," --sele2=selection script select the second stuntdouble set");
131     printf("%s\n"," --sele3=selection script select the third stuntdouble set");
132     printf("%s\n"," --refsele=selection script\n select reference (use and only use with --gxyz)");
133     printf("%s\n"," --molname=STRING molecule name");
134     printf("%s\n"," --begin=INT begin interanl index");
135     printf("%s\n"," --end=INT end internal index");
136     printf("%s\n","\n Group: staticProps\n an option of this group is required");
137     printf("%s\n"," --gofr g(r)");
138     printf("%s\n"," --r_theta g(r, cos(theta))");
139     printf("%s\n"," --r_omega g(r, cos(omega))");
140     printf("%s\n"," --theta_omega g(cos(theta), cos(omega))");
141     printf("%s\n"," --gxyz g(x, y, z)");
142     printf("%s\n"," --p2 p2 order parameter (--sele1 and --sele2 must be \n specified)");
143     printf("%s\n"," --scd scd order parameter(either --sele1, --sele2, \n --sele3 are specified or --molname, --begin, \n --end are specified)");
144     printf("%s\n"," --density density plot (--sele1 must be specified)");
145     printf("%s\n"," --slab_density slab density (--sele1 must be specified)");
146 xsun 2763 printf("%s\n"," --hxy hxy (--sele1 must be specified)");
147 gezelter 2701
148 tim 1994 }
149    
150 gezelter 2701 void
151     cmdline_parser_init (struct gengetopt_args_info *args_info)
152     {
153     clear_given (args_info);
154     clear_args (args_info);
155     }
156 tim 1994
157 gezelter 2701 static void
158     cmdline_parser_release (struct gengetopt_args_info *args_info)
159     {
160    
161     if (args_info->input_arg)
162     {
163     free (args_info->input_arg); /* free previous argument */
164     args_info->input_arg = 0;
165     }
166     if (args_info->input_orig)
167     {
168     free (args_info->input_orig); /* free previous argument */
169     args_info->input_orig = 0;
170     }
171     if (args_info->output_arg)
172     {
173     free (args_info->output_arg); /* free previous argument */
174     args_info->output_arg = 0;
175     }
176     if (args_info->output_orig)
177     {
178     free (args_info->output_orig); /* free previous argument */
179     args_info->output_orig = 0;
180     }
181     if (args_info->step_orig)
182     {
183     free (args_info->step_orig); /* free previous argument */
184     args_info->step_orig = 0;
185     }
186     if (args_info->nrbins_orig)
187     {
188     free (args_info->nrbins_orig); /* free previous argument */
189     args_info->nrbins_orig = 0;
190     }
191 xsun 2763 if (args_info->nbins_x_orig)
192 xsun 2751 {
193     free (args_info->nbins_x_orig); /* free previous argument */
194     args_info->nbins_x_orig = 0;
195     }
196     if (args_info->nbins_y_orig)
197     {
198     free (args_info->nbins_y_orig); /* free previous argument */
199     args_info->nbins_y_orig = 0;
200     }
201 gezelter 2701 if (args_info->nanglebins_orig)
202     {
203     free (args_info->nanglebins_orig); /* free previous argument */
204     args_info->nanglebins_orig = 0;
205     }
206     if (args_info->length_orig)
207     {
208     free (args_info->length_orig); /* free previous argument */
209     args_info->length_orig = 0;
210     }
211     if (args_info->zoffset_orig)
212     {
213     free (args_info->zoffset_orig); /* free previous argument */
214     args_info->zoffset_orig = 0;
215     }
216     if (args_info->sele1_arg)
217     {
218     free (args_info->sele1_arg); /* free previous argument */
219     args_info->sele1_arg = 0;
220     }
221     if (args_info->sele1_orig)
222     {
223     free (args_info->sele1_orig); /* free previous argument */
224     args_info->sele1_orig = 0;
225     }
226     if (args_info->sele2_arg)
227     {
228     free (args_info->sele2_arg); /* free previous argument */
229     args_info->sele2_arg = 0;
230     }
231     if (args_info->sele2_orig)
232     {
233     free (args_info->sele2_orig); /* free previous argument */
234     args_info->sele2_orig = 0;
235     }
236     if (args_info->sele3_arg)
237     {
238     free (args_info->sele3_arg); /* free previous argument */
239     args_info->sele3_arg = 0;
240     }
241     if (args_info->sele3_orig)
242     {
243     free (args_info->sele3_orig); /* free previous argument */
244     args_info->sele3_orig = 0;
245     }
246     if (args_info->refsele_arg)
247     {
248     free (args_info->refsele_arg); /* free previous argument */
249     args_info->refsele_arg = 0;
250     }
251     if (args_info->refsele_orig)
252     {
253     free (args_info->refsele_orig); /* free previous argument */
254     args_info->refsele_orig = 0;
255     }
256     if (args_info->molname_arg)
257     {
258     free (args_info->molname_arg); /* free previous argument */
259     args_info->molname_arg = 0;
260     }
261     if (args_info->molname_orig)
262     {
263     free (args_info->molname_orig); /* free previous argument */
264     args_info->molname_orig = 0;
265     }
266     if (args_info->begin_orig)
267     {
268     free (args_info->begin_orig); /* free previous argument */
269     args_info->begin_orig = 0;
270     }
271     if (args_info->end_orig)
272     {
273     free (args_info->end_orig); /* free previous argument */
274     args_info->end_orig = 0;
275     }
276    
277     clear_given (args_info);
278     }
279 tim 1994
280 gezelter 2701 int
281     cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
282     {
283     FILE *outfile;
284     int i = 0;
285    
286     outfile = fopen(filename, "w");
287    
288     if (!outfile)
289     {
290     fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
291     return EXIT_FAILURE;
292     }
293    
294     if (args_info->help_given) {
295     fprintf(outfile, "%s\n", "help");
296     }
297     if (args_info->version_given) {
298     fprintf(outfile, "%s\n", "version");
299     }
300     if (args_info->input_given) {
301     if (args_info->input_orig) {
302     fprintf(outfile, "%s=\"%s\"\n", "input", args_info->input_orig);
303     } else {
304     fprintf(outfile, "%s\n", "input");
305     }
306     }
307     if (args_info->output_given) {
308     if (args_info->output_orig) {
309     fprintf(outfile, "%s=\"%s\"\n", "output", args_info->output_orig);
310     } else {
311     fprintf(outfile, "%s\n", "output");
312     }
313     }
314     if (args_info->step_given) {
315     if (args_info->step_orig) {
316     fprintf(outfile, "%s=\"%s\"\n", "step", args_info->step_orig);
317     } else {
318     fprintf(outfile, "%s\n", "step");
319     }
320     }
321     if (args_info->nrbins_given) {
322     if (args_info->nrbins_orig) {
323     fprintf(outfile, "%s=\"%s\"\n", "nrbins", args_info->nrbins_orig);
324     } else {
325     fprintf(outfile, "%s\n", "nrbins");
326     }
327     }
328 xsun 2751 if (args_info->nbins_x_given) {
329     if (args_info->nbins_x_orig) {
330     fprintf(outfile, "%s=\"%s\"\n", "nbins_x", args_info->nbins_x_orig);
331     } else {
332     fprintf(outfile, "%s\n", "nbins_x");
333     }
334     }
335     if (args_info->nbins_y_given) {
336     if (args_info->nbins_y_orig) {
337     fprintf(outfile, "%s=\"%s\"\n", "nbins_y", args_info->nbins_y_orig);
338     } else {
339     fprintf(outfile, "%s\n", "nbins_y");
340     }
341     }
342 gezelter 2701 if (args_info->nanglebins_given) {
343     if (args_info->nanglebins_orig) {
344     fprintf(outfile, "%s=\"%s\"\n", "nanglebins", args_info->nanglebins_orig);
345     } else {
346     fprintf(outfile, "%s\n", "nanglebins");
347     }
348     }
349     if (args_info->length_given) {
350     if (args_info->length_orig) {
351     fprintf(outfile, "%s=\"%s\"\n", "length", args_info->length_orig);
352     } else {
353     fprintf(outfile, "%s\n", "length");
354     }
355     }
356     if (args_info->zoffset_given) {
357     if (args_info->zoffset_orig) {
358     fprintf(outfile, "%s=\"%s\"\n", "zoffset", args_info->zoffset_orig);
359     } else {
360     fprintf(outfile, "%s\n", "zoffset");
361     }
362     }
363     if (args_info->sele1_given) {
364     if (args_info->sele1_orig) {
365     fprintf(outfile, "%s=\"%s\"\n", "sele1", args_info->sele1_orig);
366     } else {
367     fprintf(outfile, "%s\n", "sele1");
368     }
369     }
370     if (args_info->sele2_given) {
371     if (args_info->sele2_orig) {
372     fprintf(outfile, "%s=\"%s\"\n", "sele2", args_info->sele2_orig);
373     } else {
374     fprintf(outfile, "%s\n", "sele2");
375     }
376     }
377     if (args_info->sele3_given) {
378     if (args_info->sele3_orig) {
379     fprintf(outfile, "%s=\"%s\"\n", "sele3", args_info->sele3_orig);
380     } else {
381     fprintf(outfile, "%s\n", "sele3");
382     }
383     }
384     if (args_info->refsele_given) {
385     if (args_info->refsele_orig) {
386     fprintf(outfile, "%s=\"%s\"\n", "refsele", args_info->refsele_orig);
387     } else {
388     fprintf(outfile, "%s\n", "refsele");
389     }
390     }
391     if (args_info->molname_given) {
392     if (args_info->molname_orig) {
393     fprintf(outfile, "%s=\"%s\"\n", "molname", args_info->molname_orig);
394     } else {
395     fprintf(outfile, "%s\n", "molname");
396     }
397     }
398     if (args_info->begin_given) {
399     if (args_info->begin_orig) {
400     fprintf(outfile, "%s=\"%s\"\n", "begin", args_info->begin_orig);
401     } else {
402     fprintf(outfile, "%s\n", "begin");
403     }
404     }
405     if (args_info->end_given) {
406     if (args_info->end_orig) {
407     fprintf(outfile, "%s=\"%s\"\n", "end", args_info->end_orig);
408     } else {
409     fprintf(outfile, "%s\n", "end");
410     }
411     }
412     if (args_info->gofr_given) {
413     fprintf(outfile, "%s\n", "gofr");
414     }
415     if (args_info->r_theta_given) {
416     fprintf(outfile, "%s\n", "r_theta");
417     }
418     if (args_info->r_omega_given) {
419     fprintf(outfile, "%s\n", "r_omega");
420     }
421     if (args_info->theta_omega_given) {
422     fprintf(outfile, "%s\n", "theta_omega");
423     }
424     if (args_info->gxyz_given) {
425     fprintf(outfile, "%s\n", "gxyz");
426     }
427     if (args_info->p2_given) {
428     fprintf(outfile, "%s\n", "p2");
429     }
430     if (args_info->scd_given) {
431     fprintf(outfile, "%s\n", "scd");
432     }
433     if (args_info->density_given) {
434     fprintf(outfile, "%s\n", "density");
435     }
436     if (args_info->slab_density_given) {
437     fprintf(outfile, "%s\n", "slab_density");
438     }
439 xsun 2751 if (args_info->hxy_given) {
440     fprintf(outfile, "%s\n", "hxy");
441     }
442 xsun 2763
443 gezelter 2701 fclose (outfile);
444    
445     i = EXIT_SUCCESS;
446     return i;
447     }
448    
449     void
450     cmdline_parser_free (struct gengetopt_args_info *args_info)
451     {
452     cmdline_parser_release (args_info);
453     }
454    
455    
456 tim 1994 /* gengetopt_strdup() */
457     /* strdup.c replacement of strdup, which is not standard */
458     char *
459     gengetopt_strdup (const char *s)
460     {
461 gezelter 2701 char *result = NULL;
462     if (!s)
463     return result;
464    
465     result = (char*)malloc(strlen(s) + 1);
466 tim 1994 if (result == (char*)0)
467     return (char*)0;
468     strcpy(result, s);
469     return result;
470     }
471    
472 gezelter 2701 static void
473     reset_group_staticProps(struct gengetopt_args_info *args_info);
474    
475     static void
476     reset_group_staticProps(struct gengetopt_args_info *args_info)
477 tim 1994 {
478 gezelter 2701 if (! args_info->staticProps_group_counter)
479     return;
480 tim 1994
481     args_info->gofr_given = 0 ;
482     args_info->r_theta_given = 0 ;
483     args_info->r_omega_given = 0 ;
484     args_info->theta_omega_given = 0 ;
485 tim 2053 args_info->gxyz_given = 0 ;
486 tim 2240 args_info->p2_given = 0 ;
487 tim 2241 args_info->scd_given = 0 ;
488 tim 2242 args_info->density_given = 0 ;
489 tim 2539 args_info->slab_density_given = 0 ;
490 xsun 2763 args_info->hxy_given = 0 ;
491 gezelter 2701
492     args_info->staticProps_group_counter = 0;
493 tim 2240 }
494 tim 1994
495 gezelter 2701 int
496     cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
497     {
498     return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
499     }
500 tim 1994
501 gezelter 2701 int
502     cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
503     {
504     int result;
505    
506     result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL);
507    
508     if (result == EXIT_FAILURE)
509     {
510     cmdline_parser_free (args_info);
511     exit (EXIT_FAILURE);
512     }
513    
514     return result;
515     }
516    
517     int
518     cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
519     {
520     int result = EXIT_SUCCESS;
521    
522     if (cmdline_parser_required2(args_info, prog_name, NULL) > 0)
523     result = EXIT_FAILURE;
524    
525     if (result == EXIT_FAILURE)
526     {
527     cmdline_parser_free (args_info);
528     exit (EXIT_FAILURE);
529     }
530    
531     return result;
532     }
533    
534     int
535     cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
536     {
537     int error = 0;
538    
539     if (! args_info->input_given)
540     {
541     fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : ""));
542     error = 1;
543     }
544     if (args_info->staticProps_group_counter == 0)
545     {
546     fprintf (stderr, "%s: %d options of group staticProps were given. One is required.%s\n", prog_name, args_info->staticProps_group_counter, (additional_error ? additional_error : ""));
547     error = 1;
548     }
549    
550    
551     return error;
552     }
553    
554     int
555     cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error)
556     {
557     int c; /* Character of the parsed option. */
558    
559     int error = 0;
560     struct gengetopt_args_info local_args_info;
561    
562     if (initialize)
563     cmdline_parser_init (args_info);
564    
565     cmdline_parser_init (&local_args_info);
566    
567 tim 1994 optarg = 0;
568 gezelter 2701 optind = 0;
569 tim 1994 opterr = 1;
570     optopt = '?';
571    
572     while (1)
573     {
574     int option_index = 0;
575     char *stop_char;
576    
577     static struct option long_options[] = {
578     { "help", 0, NULL, 'h' },
579     { "version", 0, NULL, 'V' },
580     { "input", 1, NULL, 'i' },
581     { "output", 1, NULL, 'o' },
582 tim 1995 { "step", 1, NULL, 'n' },
583     { "nrbins", 1, NULL, 'r' },
584 xsun 2763 { "nbins_x", 1, NULL, 'x' },
585     { "nbins_y", 1, NULL, 'y' },
586 tim 1994 { "nanglebins", 1, NULL, 'a' },
587     { "length", 1, NULL, 'l' },
588 gezelter 2701 { "zoffset", 1, NULL, 'z' },
589 tim 1994 { "sele1", 1, NULL, 0 },
590     { "sele2", 1, NULL, 0 },
591 tim 2241 { "sele3", 1, NULL, 0 },
592 tim 2053 { "refsele", 1, NULL, 0 },
593 tim 2241 { "molname", 1, NULL, 0 },
594     { "begin", 1, NULL, 0 },
595     { "end", 1, NULL, 0 },
596 tim 1994 { "gofr", 0, NULL, 0 },
597     { "r_theta", 0, NULL, 0 },
598     { "r_omega", 0, NULL, 0 },
599     { "theta_omega", 0, NULL, 0 },
600 tim 2053 { "gxyz", 0, NULL, 0 },
601 tim 2240 { "p2", 0, NULL, 0 },
602 tim 2241 { "scd", 0, NULL, 0 },
603 tim 2242 { "density", 0, NULL, 0 },
604 tim 2539 { "slab_density", 0, NULL, 0 },
605 xsun 2751 { "hxy", 0, NULL, 0 },
606 tim 1994 { NULL, 0, NULL, 0 }
607     };
608    
609     stop_char = 0;
610 xsun 2763 c = getopt_long (argc, argv, "hVi:o:n:r:x:y:a:l:z:", long_options, &option_index);
611 tim 1994
612     if (c == -1) break; /* Exit from `while (1)' loop. */
613    
614     switch (c)
615     {
616     case 'h': /* Print help and exit. */
617     cmdline_parser_print_help ();
618 gezelter 2701 cmdline_parser_free (&local_args_info);
619 tim 1994 exit (EXIT_SUCCESS);
620    
621     case 'V': /* Print version and exit. */
622     cmdline_parser_print_version ();
623 gezelter 2701 cmdline_parser_free (&local_args_info);
624 tim 1994 exit (EXIT_SUCCESS);
625    
626     case 'i': /* input dump file. */
627 gezelter 2701 if (local_args_info.input_given)
628 tim 1994 {
629 gezelter 2701 fprintf (stderr, "%s: `--input' (`-i') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
630     goto failure;
631 tim 1994 }
632 gezelter 2701 if (args_info->input_given && ! override)
633     continue;
634     local_args_info.input_given = 1;
635 tim 1994 args_info->input_given = 1;
636 gezelter 2701 if (args_info->input_arg)
637     free (args_info->input_arg); /* free previous string */
638 tim 1994 args_info->input_arg = gengetopt_strdup (optarg);
639 gezelter 2701 if (args_info->input_orig)
640     free (args_info->input_orig); /* free previous string */
641     args_info->input_orig = gengetopt_strdup (optarg);
642 tim 1994 break;
643    
644     case 'o': /* output file name. */
645 gezelter 2701 if (local_args_info.output_given)
646 tim 1994 {
647 gezelter 2701 fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
648     goto failure;
649 tim 1994 }
650 gezelter 2701 if (args_info->output_given && ! override)
651     continue;
652     local_args_info.output_given = 1;
653 tim 1994 args_info->output_given = 1;
654 gezelter 2701 if (args_info->output_arg)
655     free (args_info->output_arg); /* free previous string */
656 tim 1994 args_info->output_arg = gengetopt_strdup (optarg);
657 gezelter 2701 if (args_info->output_orig)
658     free (args_info->output_orig); /* free previous string */
659     args_info->output_orig = gengetopt_strdup (optarg);
660 tim 1994 break;
661    
662 tim 1995 case 'n': /* process every n frame. */
663 gezelter 2701 if (local_args_info.step_given)
664 tim 1994 {
665 gezelter 2701 fprintf (stderr, "%s: `--step' (`-n') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
666     goto failure;
667 tim 1994 }
668 gezelter 2701 if (args_info->step_given && ! override)
669     continue;
670     local_args_info.step_given = 1;
671 tim 1995 args_info->step_given = 1;
672 gezelter 2701 args_info->step_arg = strtol (optarg, &stop_char, 0);
673     if (!(stop_char && *stop_char == '\0')) {
674     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
675     goto failure;
676     }
677     if (args_info->step_orig)
678     free (args_info->step_orig); /* free previous string */
679     args_info->step_orig = gengetopt_strdup (optarg);
680 tim 1994 break;
681    
682 tim 1995 case 'r': /* number of bins for distance. */
683 gezelter 2701 if (local_args_info.nrbins_given)
684 tim 1994 {
685 gezelter 2701 fprintf (stderr, "%s: `--nrbins' (`-r') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
686     goto failure;
687 tim 1994 }
688 gezelter 2701 if (args_info->nrbins_given && ! override)
689     continue;
690     local_args_info.nrbins_given = 1;
691 tim 1995 args_info->nrbins_given = 1;
692 gezelter 2701 args_info->nrbins_arg = strtol (optarg, &stop_char, 0);
693     if (!(stop_char && *stop_char == '\0')) {
694     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
695     goto failure;
696     }
697     if (args_info->nrbins_orig)
698     free (args_info->nrbins_orig); /* free previous string */
699     args_info->nrbins_orig = gengetopt_strdup (optarg);
700 tim 1994 break;
701    
702 xsun 2751 case 'x': /* number of bins in x axis. */
703     if (local_args_info.nbins_x_given)
704     {
705 xsun 2763 fprintf (stderr, "%s: `--nbins_x' (`-x') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
706 xsun 2751 goto failure;
707     }
708     if (args_info->nbins_x_given && ! override)
709     continue;
710     local_args_info.nbins_x_given = 1;
711     args_info->nbins_x_given = 1;
712     args_info->nbins_x_arg = strtol (optarg, &stop_char, 0);
713     if (!(stop_char && *stop_char == '\0')) {
714     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
715     goto failure;
716     }
717     if (args_info->nbins_x_orig)
718     free (args_info->nbins_x_orig); /* free previous string */
719     args_info->nbins_x_orig = gengetopt_strdup (optarg);
720     break;
721    
722     case 'y': /* number of bins in y axis. */
723     if (local_args_info.nbins_y_given)
724     {
725 xsun 2763 fprintf (stderr, "%s: `--nbins_y' (`-y') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
726 xsun 2751 goto failure;
727     }
728     if (args_info->nbins_y_given && ! override)
729     continue;
730     local_args_info.nbins_y_given = 1;
731     args_info->nbins_y_given = 1;
732     args_info->nbins_y_arg = strtol (optarg, &stop_char, 0);
733     if (!(stop_char && *stop_char == '\0')) {
734     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
735     goto failure;
736     }
737     if (args_info->nbins_y_orig)
738     free (args_info->nbins_y_orig); /* free previous string */
739     args_info->nbins_y_orig = gengetopt_strdup (optarg);
740     break;
741    
742 tim 1994 case 'a': /* number of bins for cos(angle). */
743 gezelter 2701 if (local_args_info.nanglebins_given)
744 tim 1994 {
745 gezelter 2701 fprintf (stderr, "%s: `--nanglebins' (`-a') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
746     goto failure;
747 tim 1994 }
748 gezelter 2701 if (args_info->nanglebins_given && ! override)
749     continue;
750     local_args_info.nanglebins_given = 1;
751 tim 1994 args_info->nanglebins_given = 1;
752 gezelter 2701 args_info->nanglebins_arg = strtol (optarg, &stop_char, 0);
753     if (!(stop_char && *stop_char == '\0')) {
754     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
755     goto failure;
756     }
757     if (args_info->nanglebins_orig)
758     free (args_info->nanglebins_orig); /* free previous string */
759     args_info->nanglebins_orig = gengetopt_strdup (optarg);
760 tim 1994 break;
761    
762 tim 2038 case 'l': /* maximum length (Defaults to 1/2 smallest length of first frame). */
763 gezelter 2701 if (local_args_info.length_given)
764 tim 1994 {
765 gezelter 2701 fprintf (stderr, "%s: `--length' (`-l') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
766     goto failure;
767 tim 1994 }
768 gezelter 2701 if (args_info->length_given && ! override)
769     continue;
770     local_args_info.length_given = 1;
771 tim 1994 args_info->length_given = 1;
772 gezelter 2701 args_info->length_arg = strtod (optarg, &stop_char);
773     if (!(stop_char && *stop_char == '\0')) {
774     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
775     goto failure;
776     }
777     if (args_info->length_orig)
778     free (args_info->length_orig); /* free previous string */
779     args_info->length_orig = gengetopt_strdup (optarg);
780 tim 1994 break;
781    
782 gezelter 2701 case 'z': /* Where to set the zero for the slab_density calculation. */
783     if (local_args_info.zoffset_given)
784     {
785     fprintf (stderr, "%s: `--zoffset' (`-z') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
786     goto failure;
787     }
788     if (args_info->zoffset_given && ! override)
789     continue;
790     local_args_info.zoffset_given = 1;
791     args_info->zoffset_given = 1;
792     args_info->zoffset_arg = strtod (optarg, &stop_char);
793     if (!(stop_char && *stop_char == '\0')) {
794     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
795     goto failure;
796     }
797     if (args_info->zoffset_orig)
798     free (args_info->zoffset_orig); /* free previous string */
799     args_info->zoffset_orig = gengetopt_strdup (optarg);
800     break;
801 tim 1994
802 gezelter 2701
803 tim 1994 case 0: /* Long option with no short option */
804 tim 2241 /* select the first stuntdouble set. */
805 tim 1994 if (strcmp (long_options[option_index].name, "sele1") == 0)
806 tim 2240 {
807 gezelter 2701 if (local_args_info.sele1_given)
808 tim 2240 {
809 gezelter 2701 fprintf (stderr, "%s: `--sele1' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
810     goto failure;
811 tim 2240 }
812 gezelter 2701 if (args_info->sele1_given && ! override)
813     continue;
814     local_args_info.sele1_given = 1;
815 tim 2240 args_info->sele1_given = 1;
816 gezelter 2701 if (args_info->sele1_arg)
817     free (args_info->sele1_arg); /* free previous string */
818 tim 2240 args_info->sele1_arg = gengetopt_strdup (optarg);
819 gezelter 2701 if (args_info->sele1_orig)
820     free (args_info->sele1_orig); /* free previous string */
821     args_info->sele1_orig = gengetopt_strdup (optarg);
822 tim 2240 }
823 tim 2241 /* select the second stuntdouble set. */
824 tim 1994 else if (strcmp (long_options[option_index].name, "sele2") == 0)
825 tim 2240 {
826 gezelter 2701 if (local_args_info.sele2_given)
827 tim 2240 {
828 gezelter 2701 fprintf (stderr, "%s: `--sele2' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
829     goto failure;
830 tim 2240 }
831 gezelter 2701 if (args_info->sele2_given && ! override)
832     continue;
833     local_args_info.sele2_given = 1;
834 tim 2240 args_info->sele2_given = 1;
835 gezelter 2701 if (args_info->sele2_arg)
836     free (args_info->sele2_arg); /* free previous string */
837 tim 2240 args_info->sele2_arg = gengetopt_strdup (optarg);
838 gezelter 2701 if (args_info->sele2_orig)
839     free (args_info->sele2_orig); /* free previous string */
840     args_info->sele2_orig = gengetopt_strdup (optarg);
841 tim 2240 }
842 tim 2241 /* select the third stuntdouble set. */
843     else if (strcmp (long_options[option_index].name, "sele3") == 0)
844     {
845 gezelter 2701 if (local_args_info.sele3_given)
846 tim 2241 {
847 gezelter 2701 fprintf (stderr, "%s: `--sele3' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
848     goto failure;
849 tim 2241 }
850 gezelter 2701 if (args_info->sele3_given && ! override)
851     continue;
852     local_args_info.sele3_given = 1;
853 tim 2241 args_info->sele3_given = 1;
854 gezelter 2701 if (args_info->sele3_arg)
855     free (args_info->sele3_arg); /* free previous string */
856 tim 2241 args_info->sele3_arg = gengetopt_strdup (optarg);
857 gezelter 2701 if (args_info->sele3_orig)
858     free (args_info->sele3_orig); /* free previous string */
859     args_info->sele3_orig = gengetopt_strdup (optarg);
860 tim 2241 }
861 tim 2053 /* select reference (use and only use with --gxyz). */
862     else if (strcmp (long_options[option_index].name, "refsele") == 0)
863 tim 2240 {
864 gezelter 2701 if (local_args_info.refsele_given)
865 tim 2240 {
866 gezelter 2701 fprintf (stderr, "%s: `--refsele' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
867     goto failure;
868 tim 2240 }
869 gezelter 2701 if (args_info->refsele_given && ! override)
870     continue;
871     local_args_info.refsele_given = 1;
872 tim 2240 args_info->refsele_given = 1;
873 gezelter 2701 if (args_info->refsele_arg)
874     free (args_info->refsele_arg); /* free previous string */
875 tim 2240 args_info->refsele_arg = gengetopt_strdup (optarg);
876 gezelter 2701 if (args_info->refsele_orig)
877     free (args_info->refsele_orig); /* free previous string */
878     args_info->refsele_orig = gengetopt_strdup (optarg);
879 tim 2240 }
880 tim 2241 /* molecule name. */
881     else if (strcmp (long_options[option_index].name, "molname") == 0)
882     {
883 gezelter 2701 if (local_args_info.molname_given)
884 tim 2241 {
885 gezelter 2701 fprintf (stderr, "%s: `--molname' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
886     goto failure;
887 tim 2241 }
888 gezelter 2701 if (args_info->molname_given && ! override)
889     continue;
890     local_args_info.molname_given = 1;
891 tim 2241 args_info->molname_given = 1;
892 gezelter 2701 if (args_info->molname_arg)
893     free (args_info->molname_arg); /* free previous string */
894 tim 2241 args_info->molname_arg = gengetopt_strdup (optarg);
895 gezelter 2701 if (args_info->molname_orig)
896     free (args_info->molname_orig); /* free previous string */
897     args_info->molname_orig = gengetopt_strdup (optarg);
898 tim 2241 }
899     /* begin interanl index. */
900     else if (strcmp (long_options[option_index].name, "begin") == 0)
901     {
902 gezelter 2701 if (local_args_info.begin_given)
903 tim 2241 {
904 gezelter 2701 fprintf (stderr, "%s: `--begin' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
905     goto failure;
906 tim 2241 }
907 gezelter 2701 if (args_info->begin_given && ! override)
908     continue;
909     local_args_info.begin_given = 1;
910 tim 2241 args_info->begin_given = 1;
911 gezelter 2701 args_info->begin_arg = strtol (optarg, &stop_char, 0);
912     if (!(stop_char && *stop_char == '\0')) {
913     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
914     goto failure;
915     }
916     if (args_info->begin_orig)
917     free (args_info->begin_orig); /* free previous string */
918     args_info->begin_orig = gengetopt_strdup (optarg);
919 tim 2241 }
920     /* end internal index. */
921     else if (strcmp (long_options[option_index].name, "end") == 0)
922     {
923 gezelter 2701 if (local_args_info.end_given)
924 tim 2241 {
925 gezelter 2701 fprintf (stderr, "%s: `--end' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
926     goto failure;
927 tim 2241 }
928 gezelter 2701 if (args_info->end_given && ! override)
929     continue;
930     local_args_info.end_given = 1;
931 tim 2241 args_info->end_given = 1;
932 gezelter 2701 args_info->end_arg = strtol (optarg, &stop_char, 0);
933     if (!(stop_char && *stop_char == '\0')) {
934     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
935     goto failure;
936     }
937     if (args_info->end_orig)
938     free (args_info->end_orig); /* free previous string */
939     args_info->end_orig = gengetopt_strdup (optarg);
940 tim 2241 }
941 tim 1994 /* g(r). */
942     else if (strcmp (long_options[option_index].name, "gofr") == 0)
943 tim 2240 {
944 gezelter 2701 if (local_args_info.gofr_given)
945 tim 2240 {
946 gezelter 2701 fprintf (stderr, "%s: `--gofr' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
947     goto failure;
948 tim 2240 }
949 gezelter 2701 if (args_info->gofr_given && ! override)
950     continue;
951     local_args_info.gofr_given = 1;
952     args_info->gofr_given = 1;
953     if (args_info->staticProps_group_counter && override)
954     reset_group_staticProps (args_info);
955     args_info->staticProps_group_counter += 1;
956 tim 2240 break;
957     }
958 tim 1994 /* g(r, cos(theta)). */
959     else if (strcmp (long_options[option_index].name, "r_theta") == 0)
960 tim 2240 {
961 gezelter 2701 if (local_args_info.r_theta_given)
962 tim 2240 {
963 gezelter 2701 fprintf (stderr, "%s: `--r_theta' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
964     goto failure;
965 tim 2240 }
966 gezelter 2701 if (args_info->r_theta_given && ! override)
967     continue;
968     local_args_info.r_theta_given = 1;
969     args_info->r_theta_given = 1;
970     if (args_info->staticProps_group_counter && override)
971     reset_group_staticProps (args_info);
972     args_info->staticProps_group_counter += 1;
973 tim 2240 break;
974     }
975 tim 1994 /* g(r, cos(omega)). */
976     else if (strcmp (long_options[option_index].name, "r_omega") == 0)
977 tim 2240 {
978 gezelter 2701 if (local_args_info.r_omega_given)
979 tim 2240 {
980 gezelter 2701 fprintf (stderr, "%s: `--r_omega' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
981     goto failure;
982 tim 2240 }
983 gezelter 2701 if (args_info->r_omega_given && ! override)
984     continue;
985     local_args_info.r_omega_given = 1;
986     args_info->r_omega_given = 1;
987     if (args_info->staticProps_group_counter && override)
988     reset_group_staticProps (args_info);
989     args_info->staticProps_group_counter += 1;
990 tim 2240 break;
991     }
992 tim 1994 /* g(cos(theta), cos(omega)). */
993     else if (strcmp (long_options[option_index].name, "theta_omega") == 0)
994 tim 2240 {
995 gezelter 2701 if (local_args_info.theta_omega_given)
996 tim 2240 {
997 gezelter 2701 fprintf (stderr, "%s: `--theta_omega' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
998     goto failure;
999 tim 2240 }
1000 gezelter 2701 if (args_info->theta_omega_given && ! override)
1001     continue;
1002     local_args_info.theta_omega_given = 1;
1003     args_info->theta_omega_given = 1;
1004     if (args_info->staticProps_group_counter && override)
1005     reset_group_staticProps (args_info);
1006     args_info->staticProps_group_counter += 1;
1007 tim 2240 break;
1008     }
1009 tim 1994 /* g(x, y, z). */
1010 tim 2053 else if (strcmp (long_options[option_index].name, "gxyz") == 0)
1011 tim 2240 {
1012 gezelter 2701 if (local_args_info.gxyz_given)
1013 tim 2240 {
1014 gezelter 2701 fprintf (stderr, "%s: `--gxyz' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1015     goto failure;
1016 tim 2240 }
1017 gezelter 2701 if (args_info->gxyz_given && ! override)
1018     continue;
1019     local_args_info.gxyz_given = 1;
1020     args_info->gxyz_given = 1;
1021     if (args_info->staticProps_group_counter && override)
1022     reset_group_staticProps (args_info);
1023     args_info->staticProps_group_counter += 1;
1024 tim 2240 break;
1025     }
1026 tim 2241 /* p2 order parameter (--sele1 and --sele2 must be specified). */
1027 tim 2240 else if (strcmp (long_options[option_index].name, "p2") == 0)
1028     {
1029 gezelter 2701 if (local_args_info.p2_given)
1030 tim 2240 {
1031 gezelter 2701 fprintf (stderr, "%s: `--p2' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1032     goto failure;
1033 tim 2240 }
1034 gezelter 2701 if (args_info->p2_given && ! override)
1035     continue;
1036     local_args_info.p2_given = 1;
1037     args_info->p2_given = 1;
1038     if (args_info->staticProps_group_counter && override)
1039     reset_group_staticProps (args_info);
1040     args_info->staticProps_group_counter += 1;
1041 tim 2240 break;
1042     }
1043 tim 2241 /* scd order parameter(either --sele1, --sele2, --sele3 are specified or --molname, --begin, --end are specified). */
1044     else if (strcmp (long_options[option_index].name, "scd") == 0)
1045     {
1046 gezelter 2701 if (local_args_info.scd_given)
1047 tim 2241 {
1048 gezelter 2701 fprintf (stderr, "%s: `--scd' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1049     goto failure;
1050 tim 2241 }
1051 gezelter 2701 if (args_info->scd_given && ! override)
1052     continue;
1053     local_args_info.scd_given = 1;
1054     args_info->scd_given = 1;
1055     if (args_info->staticProps_group_counter && override)
1056     reset_group_staticProps (args_info);
1057     args_info->staticProps_group_counter += 1;
1058 tim 2241 break;
1059     }
1060 tim 2242 /* density plot (--sele1 must be specified). */
1061     else if (strcmp (long_options[option_index].name, "density") == 0)
1062     {
1063 gezelter 2701 if (local_args_info.density_given)
1064 tim 2242 {
1065 gezelter 2701 fprintf (stderr, "%s: `--density' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1066     goto failure;
1067 tim 2242 }
1068 gezelter 2701 if (args_info->density_given && ! override)
1069     continue;
1070     local_args_info.density_given = 1;
1071     args_info->density_given = 1;
1072     if (args_info->staticProps_group_counter && override)
1073     reset_group_staticProps (args_info);
1074     args_info->staticProps_group_counter += 1;
1075 tim 2242 break;
1076     }
1077 tim 2539 /* slab density (--sele1 must be specified). */
1078     else if (strcmp (long_options[option_index].name, "slab_density") == 0)
1079     {
1080 gezelter 2701 if (local_args_info.slab_density_given)
1081 tim 2539 {
1082 gezelter 2701 fprintf (stderr, "%s: `--slab_density' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1083     goto failure;
1084 tim 2539 }
1085 gezelter 2701 if (args_info->slab_density_given && ! override)
1086     continue;
1087     local_args_info.slab_density_given = 1;
1088     args_info->slab_density_given = 1;
1089     if (args_info->staticProps_group_counter && override)
1090     reset_group_staticProps (args_info);
1091     args_info->staticProps_group_counter += 1;
1092 tim 2539 break;
1093     }
1094 xsun 2751 /* hxy (--sele1 must be specified). */
1095     else if (strcmp (long_options[option_index].name, "hxy") == 0)
1096     {
1097     if (local_args_info.hxy_given)
1098     {
1099     fprintf (stderr, "%s: `--hxy' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1100     goto failure;
1101     }
1102     if (args_info->hxy_given && ! override)
1103     continue;
1104     local_args_info.hxy_given = 1;
1105     args_info->hxy_given = 1;
1106     if (args_info->staticProps_group_counter && override)
1107     reset_group_staticProps (args_info);
1108     args_info->staticProps_group_counter += 1;
1109     break;
1110     }
1111 tim 2539
1112 gezelter 2701 break;
1113 tim 1994 case '?': /* Invalid option. */
1114     /* `getopt_long' already printed an error message. */
1115 gezelter 2701 goto failure;
1116 tim 1994
1117     default: /* bug: option not considered. */
1118 gezelter 2701 fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
1119 tim 1994 abort ();
1120     } /* switch */
1121     } /* while */
1122    
1123 gezelter 2701 if (args_info->staticProps_group_counter > 1)
1124 tim 1994 {
1125 gezelter 2701 fprintf (stderr, "%s: %d options of group staticProps were given. One is required.%s\n", argv[0], args_info->staticProps_group_counter, (additional_error ? additional_error : ""));
1126     error = 1;
1127 tim 1994 }
1128    
1129    
1130 gezelter 2701
1131     if (check_required)
1132 tim 1994 {
1133 gezelter 2701 error += cmdline_parser_required2 (args_info, argv[0], additional_error);
1134 tim 1994 }
1135    
1136 gezelter 2701 cmdline_parser_release (&local_args_info);
1137    
1138     if ( error )
1139     return (EXIT_FAILURE);
1140    
1141 tim 1994 return 0;
1142 gezelter 2701
1143     failure:
1144    
1145     cmdline_parser_release (&local_args_info);
1146     return (EXIT_FAILURE);
1147 tim 1994 }