ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/staticProps/StaticPropsCmd.c
Revision: 2539
Committed: Mon Jan 9 22:14:32 2006 UTC (18 years, 6 months ago) by tim
Content type: text/plain
File size: 17991 byte(s)
Log Message:
fixing RhoZ

File Contents

# User Rev Content
1 tim 1994 /*
2     File autogenerated by gengetopt version 2.11
3     generated with the following command:
4 tim 2539 /home/maul/gezelter/tim/program/gengetopt-2.11/src/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    
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 tim 2241 printf(" --sele1=selection script select the first stuntdouble set\n");
47     printf(" --sele2=selection script select the second stuntdouble set\n");
48     printf(" --sele3=selection script select the third stuntdouble set\n");
49 tim 2053 printf(" --refsele=selection script select reference (use and only use with \n --gxyz)\n");
50 tim 2241 printf(" --molname=STRING molecule name\n");
51     printf(" --begin=INT begin interanl index\n");
52     printf(" --end=INT end internal index\n");
53 tim 1994 printf("\n");
54     printf(" Group: staticProps an option of this group is required\n");
55 tim 2053 printf(" --gofr g(r)\n");
56     printf(" --r_theta g(r, cos(theta))\n");
57     printf(" --r_omega g(r, cos(omega))\n");
58     printf(" --theta_omega g(cos(theta), cos(omega))\n");
59     printf(" --gxyz g(x, y, z)\n");
60 tim 2241 printf(" --p2 p2 order parameter (--sele1 and --sele2 must \n be specified)\n");
61     printf(" --scd scd order parameter(either --sele1, --sele2, \n --sele3 are specified or --molname, \n --begin, --end are specified)\n");
62 tim 2242 printf(" --density density plot (--sele1 must be specified)\n");
63 tim 2539 printf(" --slab_density slab density (--sele1 must be specified)\n");
64 tim 1994 }
65    
66    
67     static char *gengetopt_strdup (const char *s);
68    
69     /* gengetopt_strdup() */
70     /* strdup.c replacement of strdup, which is not standard */
71     char *
72     gengetopt_strdup (const char *s)
73     {
74     char *result = (char*)malloc(strlen(s) + 1);
75     if (result == (char*)0)
76     return (char*)0;
77     strcpy(result, s);
78     return result;
79     }
80    
81     int
82     cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
83     {
84     int c; /* Character of the parsed option. */
85     int missing_required_options = 0;
86     int staticProps_group_counter = 0;
87    
88    
89     args_info->help_given = 0 ;
90     args_info->version_given = 0 ;
91     args_info->input_given = 0 ;
92     args_info->output_given = 0 ;
93 tim 1995 args_info->step_given = 0 ;
94     args_info->nrbins_given = 0 ;
95 tim 1994 args_info->nanglebins_given = 0 ;
96     args_info->length_given = 0 ;
97     args_info->sele1_given = 0 ;
98     args_info->sele2_given = 0 ;
99 tim 2241 args_info->sele3_given = 0 ;
100 tim 2053 args_info->refsele_given = 0 ;
101 tim 2241 args_info->molname_given = 0 ;
102     args_info->begin_given = 0 ;
103     args_info->end_given = 0 ;
104 tim 1994 args_info->gofr_given = 0 ;
105     args_info->r_theta_given = 0 ;
106     args_info->r_omega_given = 0 ;
107     args_info->theta_omega_given = 0 ;
108 tim 2053 args_info->gxyz_given = 0 ;
109 tim 2240 args_info->p2_given = 0 ;
110 tim 2241 args_info->scd_given = 0 ;
111 tim 2242 args_info->density_given = 0 ;
112 tim 2539 args_info->slab_density_given = 0 ;
113 tim 2240 #define clear_args() { \
114     args_info->input_arg = NULL; \
115     args_info->output_arg = NULL; \
116     args_info->step_arg = 1 ;\
117     args_info->nrbins_arg = 100 ;\
118     args_info->nanglebins_arg = 50 ;\
119     args_info->sele1_arg = NULL; \
120     args_info->sele2_arg = NULL; \
121 tim 2241 args_info->sele3_arg = NULL; \
122 tim 2240 args_info->refsele_arg = NULL; \
123 tim 2241 args_info->molname_arg = NULL; \
124 tim 2240 }
125 tim 1994
126     clear_args();
127    
128     optarg = 0;
129     optind = 1;
130     opterr = 1;
131     optopt = '?';
132    
133     while (1)
134     {
135     int option_index = 0;
136     char *stop_char;
137    
138     static struct option long_options[] = {
139     { "help", 0, NULL, 'h' },
140     { "version", 0, NULL, 'V' },
141     { "input", 1, NULL, 'i' },
142     { "output", 1, NULL, 'o' },
143 tim 1995 { "step", 1, NULL, 'n' },
144     { "nrbins", 1, NULL, 'r' },
145 tim 1994 { "nanglebins", 1, NULL, 'a' },
146     { "length", 1, NULL, 'l' },
147     { "sele1", 1, NULL, 0 },
148     { "sele2", 1, NULL, 0 },
149 tim 2241 { "sele3", 1, NULL, 0 },
150 tim 2053 { "refsele", 1, NULL, 0 },
151 tim 2241 { "molname", 1, NULL, 0 },
152     { "begin", 1, NULL, 0 },
153     { "end", 1, NULL, 0 },
154 tim 1994 { "gofr", 0, NULL, 0 },
155     { "r_theta", 0, NULL, 0 },
156     { "r_omega", 0, NULL, 0 },
157     { "theta_omega", 0, NULL, 0 },
158 tim 2053 { "gxyz", 0, NULL, 0 },
159 tim 2240 { "p2", 0, NULL, 0 },
160 tim 2241 { "scd", 0, NULL, 0 },
161 tim 2242 { "density", 0, NULL, 0 },
162 tim 2539 { "slab_density", 0, NULL, 0 },
163 tim 1994 { NULL, 0, NULL, 0 }
164     };
165    
166     stop_char = 0;
167 tim 1995 c = getopt_long (argc, argv, "hVi:o:n:r:a:l:", long_options, &option_index);
168 tim 1994
169     if (c == -1) break; /* Exit from `while (1)' loop. */
170    
171     switch (c)
172     {
173     case 'h': /* Print help and exit. */
174     clear_args ();
175     cmdline_parser_print_help ();
176     exit (EXIT_SUCCESS);
177    
178     case 'V': /* Print version and exit. */
179     clear_args ();
180     cmdline_parser_print_version ();
181     exit (EXIT_SUCCESS);
182    
183     case 'i': /* input dump file. */
184     if (args_info->input_given)
185     {
186     fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE);
187     clear_args ();
188     exit (EXIT_FAILURE);
189     }
190     args_info->input_given = 1;
191     args_info->input_arg = gengetopt_strdup (optarg);
192     break;
193    
194     case 'o': /* output file name. */
195     if (args_info->output_given)
196     {
197     fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE);
198     clear_args ();
199     exit (EXIT_FAILURE);
200     }
201     args_info->output_given = 1;
202     args_info->output_arg = gengetopt_strdup (optarg);
203     break;
204    
205 tim 1995 case 'n': /* process every n frame. */
206     if (args_info->step_given)
207 tim 1994 {
208 tim 1995 fprintf (stderr, "%s: `--step' (`-n') option given more than once\n", CMDLINE_PARSER_PACKAGE);
209 tim 1994 clear_args ();
210     exit (EXIT_FAILURE);
211     }
212 tim 1995 args_info->step_given = 1;
213     args_info->step_arg = strtol (optarg,&stop_char,0);
214 tim 1994 break;
215    
216 tim 1995 case 'r': /* number of bins for distance. */
217     if (args_info->nrbins_given)
218 tim 1994 {
219 tim 1995 fprintf (stderr, "%s: `--nrbins' (`-r') option given more than once\n", CMDLINE_PARSER_PACKAGE);
220 tim 1994 clear_args ();
221     exit (EXIT_FAILURE);
222     }
223 tim 1995 args_info->nrbins_given = 1;
224     args_info->nrbins_arg = strtol (optarg,&stop_char,0);
225 tim 1994 break;
226    
227     case 'a': /* number of bins for cos(angle). */
228     if (args_info->nanglebins_given)
229     {
230     fprintf (stderr, "%s: `--nanglebins' (`-a') option given more than once\n", CMDLINE_PARSER_PACKAGE);
231     clear_args ();
232     exit (EXIT_FAILURE);
233     }
234     args_info->nanglebins_given = 1;
235     args_info->nanglebins_arg = strtol (optarg,&stop_char,0);
236     break;
237    
238 tim 2038 case 'l': /* maximum length (Defaults to 1/2 smallest length of first frame). */
239 tim 1994 if (args_info->length_given)
240     {
241     fprintf (stderr, "%s: `--length' (`-l') option given more than once\n", CMDLINE_PARSER_PACKAGE);
242     clear_args ();
243     exit (EXIT_FAILURE);
244     }
245     args_info->length_given = 1;
246     args_info->length_arg = strtod (optarg, NULL);
247     break;
248    
249    
250     case 0: /* Long option with no short option */
251 tim 2241 /* select the first stuntdouble set. */
252 tim 1994 if (strcmp (long_options[option_index].name, "sele1") == 0)
253 tim 2240 {
254     if (args_info->sele1_given)
255     {
256     fprintf (stderr, "%s: `--sele1' option given more than once\n", CMDLINE_PARSER_PACKAGE);
257     clear_args ();
258     exit (EXIT_FAILURE);
259     }
260     args_info->sele1_given = 1;
261     args_info->sele1_arg = gengetopt_strdup (optarg);
262     break;
263     }
264 tim 1994
265 tim 2241 /* select the second stuntdouble set. */
266 tim 1994 else if (strcmp (long_options[option_index].name, "sele2") == 0)
267 tim 2240 {
268     if (args_info->sele2_given)
269     {
270     fprintf (stderr, "%s: `--sele2' option given more than once\n", CMDLINE_PARSER_PACKAGE);
271     clear_args ();
272     exit (EXIT_FAILURE);
273     }
274     args_info->sele2_given = 1;
275     args_info->sele2_arg = gengetopt_strdup (optarg);
276     break;
277     }
278 tim 1994
279 tim 2241 /* select the third stuntdouble set. */
280     else if (strcmp (long_options[option_index].name, "sele3") == 0)
281     {
282     if (args_info->sele3_given)
283     {
284     fprintf (stderr, "%s: `--sele3' option given more than once\n", CMDLINE_PARSER_PACKAGE);
285     clear_args ();
286     exit (EXIT_FAILURE);
287     }
288     args_info->sele3_given = 1;
289     args_info->sele3_arg = gengetopt_strdup (optarg);
290     break;
291     }
292    
293 tim 2053 /* select reference (use and only use with --gxyz). */
294     else if (strcmp (long_options[option_index].name, "refsele") == 0)
295 tim 2240 {
296     if (args_info->refsele_given)
297     {
298     fprintf (stderr, "%s: `--refsele' option given more than once\n", CMDLINE_PARSER_PACKAGE);
299     clear_args ();
300     exit (EXIT_FAILURE);
301     }
302     args_info->refsele_given = 1;
303     args_info->refsele_arg = gengetopt_strdup (optarg);
304     break;
305     }
306 tim 2053
307 tim 2241 /* molecule name. */
308     else if (strcmp (long_options[option_index].name, "molname") == 0)
309     {
310     if (args_info->molname_given)
311     {
312     fprintf (stderr, "%s: `--molname' option given more than once\n", CMDLINE_PARSER_PACKAGE);
313     clear_args ();
314     exit (EXIT_FAILURE);
315     }
316     args_info->molname_given = 1;
317     args_info->molname_arg = gengetopt_strdup (optarg);
318     break;
319     }
320    
321     /* begin interanl index. */
322     else if (strcmp (long_options[option_index].name, "begin") == 0)
323     {
324     if (args_info->begin_given)
325     {
326     fprintf (stderr, "%s: `--begin' option given more than once\n", CMDLINE_PARSER_PACKAGE);
327     clear_args ();
328     exit (EXIT_FAILURE);
329     }
330     args_info->begin_given = 1;
331     args_info->begin_arg = strtol (optarg,&stop_char,0);
332     break;
333     }
334    
335     /* end internal index. */
336     else if (strcmp (long_options[option_index].name, "end") == 0)
337     {
338     if (args_info->end_given)
339     {
340     fprintf (stderr, "%s: `--end' option given more than once\n", CMDLINE_PARSER_PACKAGE);
341     clear_args ();
342     exit (EXIT_FAILURE);
343     }
344     args_info->end_given = 1;
345     args_info->end_arg = strtol (optarg,&stop_char,0);
346     break;
347     }
348    
349 tim 1994 /* g(r). */
350     else if (strcmp (long_options[option_index].name, "gofr") == 0)
351 tim 2240 {
352     if (args_info->gofr_given)
353     {
354     fprintf (stderr, "%s: `--gofr' option given more than once\n", CMDLINE_PARSER_PACKAGE);
355     clear_args ();
356     exit (EXIT_FAILURE);
357     }
358     args_info->gofr_given = 1; staticProps_group_counter += 1;
359 tim 1994
360 tim 2240 break;
361     }
362 tim 1994
363     /* g(r, cos(theta)). */
364     else if (strcmp (long_options[option_index].name, "r_theta") == 0)
365 tim 2240 {
366     if (args_info->r_theta_given)
367     {
368     fprintf (stderr, "%s: `--r_theta' option given more than once\n", CMDLINE_PARSER_PACKAGE);
369     clear_args ();
370     exit (EXIT_FAILURE);
371     }
372     args_info->r_theta_given = 1; staticProps_group_counter += 1;
373 tim 1994
374 tim 2240 break;
375     }
376 tim 1994
377     /* g(r, cos(omega)). */
378     else if (strcmp (long_options[option_index].name, "r_omega") == 0)
379 tim 2240 {
380     if (args_info->r_omega_given)
381     {
382     fprintf (stderr, "%s: `--r_omega' option given more than once\n", CMDLINE_PARSER_PACKAGE);
383     clear_args ();
384     exit (EXIT_FAILURE);
385     }
386     args_info->r_omega_given = 1; staticProps_group_counter += 1;
387 tim 1994
388 tim 2240 break;
389     }
390 tim 1994
391     /* g(cos(theta), cos(omega)). */
392     else if (strcmp (long_options[option_index].name, "theta_omega") == 0)
393 tim 2240 {
394     if (args_info->theta_omega_given)
395     {
396     fprintf (stderr, "%s: `--theta_omega' option given more than once\n", CMDLINE_PARSER_PACKAGE);
397     clear_args ();
398     exit (EXIT_FAILURE);
399     }
400     args_info->theta_omega_given = 1; staticProps_group_counter += 1;
401 tim 1994
402 tim 2240 break;
403     }
404 tim 1994
405     /* g(x, y, z). */
406 tim 2053 else if (strcmp (long_options[option_index].name, "gxyz") == 0)
407 tim 2240 {
408     if (args_info->gxyz_given)
409     {
410     fprintf (stderr, "%s: `--gxyz' option given more than once\n", CMDLINE_PARSER_PACKAGE);
411     clear_args ();
412     exit (EXIT_FAILURE);
413     }
414     args_info->gxyz_given = 1; staticProps_group_counter += 1;
415 tim 1994
416 tim 2240 break;
417     }
418 tim 1994
419 tim 2241 /* p2 order parameter (--sele1 and --sele2 must be specified). */
420 tim 2240 else if (strcmp (long_options[option_index].name, "p2") == 0)
421     {
422     if (args_info->p2_given)
423     {
424     fprintf (stderr, "%s: `--p2' option given more than once\n", CMDLINE_PARSER_PACKAGE);
425     clear_args ();
426     exit (EXIT_FAILURE);
427     }
428     args_info->p2_given = 1; staticProps_group_counter += 1;
429    
430     break;
431     }
432    
433 tim 2241 /* scd order parameter(either --sele1, --sele2, --sele3 are specified or --molname, --begin, --end are specified). */
434     else if (strcmp (long_options[option_index].name, "scd") == 0)
435     {
436     if (args_info->scd_given)
437     {
438     fprintf (stderr, "%s: `--scd' option given more than once\n", CMDLINE_PARSER_PACKAGE);
439     clear_args ();
440     exit (EXIT_FAILURE);
441     }
442     args_info->scd_given = 1; staticProps_group_counter += 1;
443    
444     break;
445     }
446    
447 tim 2242 /* density plot (--sele1 must be specified). */
448     else if (strcmp (long_options[option_index].name, "density") == 0)
449     {
450     if (args_info->density_given)
451     {
452     fprintf (stderr, "%s: `--density' option given more than once\n", CMDLINE_PARSER_PACKAGE);
453     clear_args ();
454     exit (EXIT_FAILURE);
455     }
456     args_info->density_given = 1; staticProps_group_counter += 1;
457    
458     break;
459     }
460    
461 tim 2539 /* slab density (--sele1 must be specified). */
462     else if (strcmp (long_options[option_index].name, "slab_density") == 0)
463     {
464     if (args_info->slab_density_given)
465     {
466     fprintf (stderr, "%s: `--slab_density' option given more than once\n", CMDLINE_PARSER_PACKAGE);
467     clear_args ();
468     exit (EXIT_FAILURE);
469     }
470     args_info->slab_density_given = 1; staticProps_group_counter += 1;
471    
472     break;
473     }
474    
475 tim 1994
476     case '?': /* Invalid option. */
477     /* `getopt_long' already printed an error message. */
478     exit (EXIT_FAILURE);
479    
480     default: /* bug: option not considered. */
481     fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c);
482     abort ();
483     } /* switch */
484     } /* while */
485    
486     if ( staticProps_group_counter != 1)
487     {
488     fprintf (stderr, "%s: %d options of group staticProps were given. One is required\n", CMDLINE_PARSER_PACKAGE, staticProps_group_counter);
489     missing_required_options = 1;
490     }
491    
492    
493     if (! args_info->input_given)
494     {
495     fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE);
496     missing_required_options = 1;
497     }
498     if ( missing_required_options )
499     exit (EXIT_FAILURE);
500    
501     return 0;
502     }