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