ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/staticProps/StaticPropsCmd.c
Revision: 2240
Committed: Thu May 26 22:45:00 2005 UTC (19 years, 3 months ago) by tim
Content type: text/plain
File size: 12909 byte(s)
Log Message:
adding AtomNameVisitor to convert atom name to its base name; wrappingvisitor
now wrap back to the center of the mass; adding P2OrderParameter into StaticProps

File Contents

# User Rev Content
1 tim 1994 /*
2     File autogenerated by gengetopt version 2.11
3     generated with the following command:
4 tim 2240 /home/maul/gezelter/tim/bin/gengetopt -i StaticProps.ggo -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    
12     #include <stdio.h>
13     #include <stdlib.h>
14     #include <string.h>
15    
16     /* If we use autoconf. */
17     #ifdef HAVE_CONFIG_H
18     #include "config.h"
19     #endif
20    
21     #include "getopt.h"
22    
23 tim 1995 #include "StaticPropsCmd.h"
24 tim 1994
25     void
26     cmdline_parser_print_version (void)
27     {
28     printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
29     }
30    
31     void
32     cmdline_parser_print_help (void)
33     {
34     cmdline_parser_print_version ();
35     printf("\n"
36 tim 2240 "Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE);
37 tim 1994 printf("\n");
38 tim 2053 printf(" -h, --help Print help and exit\n");
39     printf(" -V, --version Print version and exit\n");
40     printf(" -i, --input=filename input dump file\n");
41     printf(" -o, --output=filename output file name\n");
42     printf(" -n, --step=INT process every n frame (default=`1')\n");
43     printf(" -r, --nrbins=INT number of bins for distance (default=`100')\n");
44     printf(" -a, --nanglebins=INT number of bins for cos(angle) (default=\n `50')\n");
45     printf(" -l, --length=DOUBLE maximum length (Defaults to 1/2 smallest \n length of first frame)\n");
46     printf(" --sele1=selection script select first stuntdouble set\n");
47     printf(" --sele2=selection script select second stuntdouble set\n");
48     printf(" --refsele=selection script select reference (use and only use with \n --gxyz)\n");
49 tim 1994 printf("\n");
50     printf(" Group: staticProps an option of this group is required\n");
51 tim 2053 printf(" --gofr g(r)\n");
52     printf(" --r_theta g(r, cos(theta))\n");
53     printf(" --r_omega g(r, cos(omega))\n");
54     printf(" --theta_omega g(cos(theta), cos(omega))\n");
55     printf(" --gxyz g(x, y, z)\n");
56 tim 2240 printf(" --p2 p2 order parameter\n");
57 tim 1994 }
58    
59    
60     static char *gengetopt_strdup (const char *s);
61    
62     /* gengetopt_strdup() */
63     /* strdup.c replacement of strdup, which is not standard */
64     char *
65     gengetopt_strdup (const char *s)
66     {
67     char *result = (char*)malloc(strlen(s) + 1);
68     if (result == (char*)0)
69     return (char*)0;
70     strcpy(result, s);
71     return result;
72     }
73    
74     int
75     cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
76     {
77     int c; /* Character of the parsed option. */
78     int missing_required_options = 0;
79     int staticProps_group_counter = 0;
80    
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 tim 1995 args_info->step_given = 0 ;
87     args_info->nrbins_given = 0 ;
88 tim 1994 args_info->nanglebins_given = 0 ;
89     args_info->length_given = 0 ;
90     args_info->sele1_given = 0 ;
91     args_info->sele2_given = 0 ;
92 tim 2053 args_info->refsele_given = 0 ;
93 tim 1994 args_info->gofr_given = 0 ;
94     args_info->r_theta_given = 0 ;
95     args_info->r_omega_given = 0 ;
96     args_info->theta_omega_given = 0 ;
97 tim 2053 args_info->gxyz_given = 0 ;
98 tim 2240 args_info->p2_given = 0 ;
99     #define clear_args() { \
100     args_info->input_arg = NULL; \
101     args_info->output_arg = NULL; \
102     args_info->step_arg = 1 ;\
103     args_info->nrbins_arg = 100 ;\
104     args_info->nanglebins_arg = 50 ;\
105     args_info->sele1_arg = NULL; \
106     args_info->sele2_arg = NULL; \
107     args_info->refsele_arg = NULL; \
108     }
109 tim 1994
110     clear_args();
111    
112     optarg = 0;
113     optind = 1;
114     opterr = 1;
115     optopt = '?';
116    
117     while (1)
118     {
119     int option_index = 0;
120     char *stop_char;
121    
122     static struct option long_options[] = {
123     { "help", 0, NULL, 'h' },
124     { "version", 0, NULL, 'V' },
125     { "input", 1, NULL, 'i' },
126     { "output", 1, NULL, 'o' },
127 tim 1995 { "step", 1, NULL, 'n' },
128     { "nrbins", 1, NULL, 'r' },
129 tim 1994 { "nanglebins", 1, NULL, 'a' },
130     { "length", 1, NULL, 'l' },
131     { "sele1", 1, NULL, 0 },
132     { "sele2", 1, NULL, 0 },
133 tim 2053 { "refsele", 1, NULL, 0 },
134 tim 1994 { "gofr", 0, NULL, 0 },
135     { "r_theta", 0, NULL, 0 },
136     { "r_omega", 0, NULL, 0 },
137     { "theta_omega", 0, NULL, 0 },
138 tim 2053 { "gxyz", 0, NULL, 0 },
139 tim 2240 { "p2", 0, NULL, 0 },
140 tim 1994 { NULL, 0, NULL, 0 }
141     };
142    
143     stop_char = 0;
144 tim 1995 c = getopt_long (argc, argv, "hVi:o:n:r:a:l:", long_options, &option_index);
145 tim 1994
146     if (c == -1) break; /* Exit from `while (1)' loop. */
147    
148     switch (c)
149     {
150     case 'h': /* Print help and exit. */
151     clear_args ();
152     cmdline_parser_print_help ();
153     exit (EXIT_SUCCESS);
154    
155     case 'V': /* Print version and exit. */
156     clear_args ();
157     cmdline_parser_print_version ();
158     exit (EXIT_SUCCESS);
159    
160     case 'i': /* input dump file. */
161     if (args_info->input_given)
162     {
163     fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE);
164     clear_args ();
165     exit (EXIT_FAILURE);
166     }
167     args_info->input_given = 1;
168     args_info->input_arg = gengetopt_strdup (optarg);
169     break;
170    
171     case 'o': /* output file name. */
172     if (args_info->output_given)
173     {
174     fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE);
175     clear_args ();
176     exit (EXIT_FAILURE);
177     }
178     args_info->output_given = 1;
179     args_info->output_arg = gengetopt_strdup (optarg);
180     break;
181    
182 tim 1995 case 'n': /* process every n frame. */
183     if (args_info->step_given)
184 tim 1994 {
185 tim 1995 fprintf (stderr, "%s: `--step' (`-n') option given more than once\n", CMDLINE_PARSER_PACKAGE);
186 tim 1994 clear_args ();
187     exit (EXIT_FAILURE);
188     }
189 tim 1995 args_info->step_given = 1;
190     args_info->step_arg = strtol (optarg,&stop_char,0);
191 tim 1994 break;
192    
193 tim 1995 case 'r': /* number of bins for distance. */
194     if (args_info->nrbins_given)
195 tim 1994 {
196 tim 1995 fprintf (stderr, "%s: `--nrbins' (`-r') option given more than once\n", CMDLINE_PARSER_PACKAGE);
197 tim 1994 clear_args ();
198     exit (EXIT_FAILURE);
199     }
200 tim 1995 args_info->nrbins_given = 1;
201     args_info->nrbins_arg = strtol (optarg,&stop_char,0);
202 tim 1994 break;
203    
204     case 'a': /* number of bins for cos(angle). */
205     if (args_info->nanglebins_given)
206     {
207     fprintf (stderr, "%s: `--nanglebins' (`-a') option given more than once\n", CMDLINE_PARSER_PACKAGE);
208     clear_args ();
209     exit (EXIT_FAILURE);
210     }
211     args_info->nanglebins_given = 1;
212     args_info->nanglebins_arg = strtol (optarg,&stop_char,0);
213     break;
214    
215 tim 2038 case 'l': /* maximum length (Defaults to 1/2 smallest length of first frame). */
216 tim 1994 if (args_info->length_given)
217     {
218     fprintf (stderr, "%s: `--length' (`-l') option given more than once\n", CMDLINE_PARSER_PACKAGE);
219     clear_args ();
220     exit (EXIT_FAILURE);
221     }
222     args_info->length_given = 1;
223     args_info->length_arg = strtod (optarg, NULL);
224     break;
225    
226    
227     case 0: /* Long option with no short option */
228     /* select first stuntdouble set. */
229     if (strcmp (long_options[option_index].name, "sele1") == 0)
230 tim 2240 {
231     if (args_info->sele1_given)
232     {
233     fprintf (stderr, "%s: `--sele1' option given more than once\n", CMDLINE_PARSER_PACKAGE);
234     clear_args ();
235     exit (EXIT_FAILURE);
236     }
237     args_info->sele1_given = 1;
238     args_info->sele1_arg = gengetopt_strdup (optarg);
239     break;
240     }
241 tim 1994
242     /* select second stuntdouble set. */
243     else if (strcmp (long_options[option_index].name, "sele2") == 0)
244 tim 2240 {
245     if (args_info->sele2_given)
246     {
247     fprintf (stderr, "%s: `--sele2' option given more than once\n", CMDLINE_PARSER_PACKAGE);
248     clear_args ();
249     exit (EXIT_FAILURE);
250     }
251     args_info->sele2_given = 1;
252     args_info->sele2_arg = gengetopt_strdup (optarg);
253     break;
254     }
255 tim 1994
256 tim 2053 /* select reference (use and only use with --gxyz). */
257     else if (strcmp (long_options[option_index].name, "refsele") == 0)
258 tim 2240 {
259     if (args_info->refsele_given)
260     {
261     fprintf (stderr, "%s: `--refsele' option given more than once\n", CMDLINE_PARSER_PACKAGE);
262     clear_args ();
263     exit (EXIT_FAILURE);
264     }
265     args_info->refsele_given = 1;
266     args_info->refsele_arg = gengetopt_strdup (optarg);
267     break;
268     }
269 tim 2053
270 tim 1994 /* g(r). */
271     else if (strcmp (long_options[option_index].name, "gofr") == 0)
272 tim 2240 {
273     if (args_info->gofr_given)
274     {
275     fprintf (stderr, "%s: `--gofr' option given more than once\n", CMDLINE_PARSER_PACKAGE);
276     clear_args ();
277     exit (EXIT_FAILURE);
278     }
279     args_info->gofr_given = 1; staticProps_group_counter += 1;
280 tim 1994
281 tim 2240 break;
282     }
283 tim 1994
284     /* g(r, cos(theta)). */
285     else if (strcmp (long_options[option_index].name, "r_theta") == 0)
286 tim 2240 {
287     if (args_info->r_theta_given)
288     {
289     fprintf (stderr, "%s: `--r_theta' option given more than once\n", CMDLINE_PARSER_PACKAGE);
290     clear_args ();
291     exit (EXIT_FAILURE);
292     }
293     args_info->r_theta_given = 1; staticProps_group_counter += 1;
294 tim 1994
295 tim 2240 break;
296     }
297 tim 1994
298     /* g(r, cos(omega)). */
299     else if (strcmp (long_options[option_index].name, "r_omega") == 0)
300 tim 2240 {
301     if (args_info->r_omega_given)
302     {
303     fprintf (stderr, "%s: `--r_omega' option given more than once\n", CMDLINE_PARSER_PACKAGE);
304     clear_args ();
305     exit (EXIT_FAILURE);
306     }
307     args_info->r_omega_given = 1; staticProps_group_counter += 1;
308 tim 1994
309 tim 2240 break;
310     }
311 tim 1994
312     /* g(cos(theta), cos(omega)). */
313     else if (strcmp (long_options[option_index].name, "theta_omega") == 0)
314 tim 2240 {
315     if (args_info->theta_omega_given)
316     {
317     fprintf (stderr, "%s: `--theta_omega' option given more than once\n", CMDLINE_PARSER_PACKAGE);
318     clear_args ();
319     exit (EXIT_FAILURE);
320     }
321     args_info->theta_omega_given = 1; staticProps_group_counter += 1;
322 tim 1994
323 tim 2240 break;
324     }
325 tim 1994
326     /* g(x, y, z). */
327 tim 2053 else if (strcmp (long_options[option_index].name, "gxyz") == 0)
328 tim 2240 {
329     if (args_info->gxyz_given)
330     {
331     fprintf (stderr, "%s: `--gxyz' option given more than once\n", CMDLINE_PARSER_PACKAGE);
332     clear_args ();
333     exit (EXIT_FAILURE);
334     }
335     args_info->gxyz_given = 1; staticProps_group_counter += 1;
336 tim 1994
337 tim 2240 break;
338     }
339 tim 1994
340 tim 2240 /* p2 order parameter. */
341     else if (strcmp (long_options[option_index].name, "p2") == 0)
342     {
343     if (args_info->p2_given)
344     {
345     fprintf (stderr, "%s: `--p2' option given more than once\n", CMDLINE_PARSER_PACKAGE);
346     clear_args ();
347     exit (EXIT_FAILURE);
348     }
349     args_info->p2_given = 1; staticProps_group_counter += 1;
350    
351     break;
352     }
353    
354 tim 1994
355     case '?': /* Invalid option. */
356     /* `getopt_long' already printed an error message. */
357     exit (EXIT_FAILURE);
358    
359     default: /* bug: option not considered. */
360     fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c);
361     abort ();
362     } /* switch */
363     } /* while */
364    
365     if ( staticProps_group_counter != 1)
366     {
367     fprintf (stderr, "%s: %d options of group staticProps were given. One is required\n", CMDLINE_PARSER_PACKAGE, staticProps_group_counter);
368     missing_required_options = 1;
369     }
370    
371    
372     if (! args_info->input_given)
373     {
374     fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE);
375     missing_required_options = 1;
376     }
377     if ( missing_required_options )
378     exit (EXIT_FAILURE);
379    
380     return 0;
381     }