ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/staticProps/StaticPropsCmd.c
Revision: 2241
Committed: Fri May 27 04:41:34 2005 UTC (19 years, 1 month ago) by tim
Content type: text/plain
File size: 16593 byte(s)
Log Message:
adding SCDOrderParameter into StaticProps

File Contents

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