ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/dynamicProps/DynamicPropsCmd.c
Revision: 3084
Committed: Thu Dec 14 19:38:56 2006 UTC (17 years, 8 months ago) by chuckv
Content type: text/plain
File size: 19133 byte(s)
Log Message:
Code to run radial rcorr.

File Contents

# User Rev Content
1 tim 2004 /*
2 chuckv 3084 File autogenerated by gengetopt version 2.15
3 tim 2004 generated with the following command:
4 chuckv 3084 gengetopt -i DynamicProps.ggo --file-name=DynamicPropsCmd
5 tim 2004
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 chuckv 3084 /* If we use autoconf. */
12     #ifdef HAVE_CONFIG_H
13     #include "config.h"
14     #endif
15 tim 2004
16     #include <stdio.h>
17     #include <stdlib.h>
18     #include <string.h>
19    
20     #include "getopt.h"
21    
22     #include "DynamicPropsCmd.h"
23    
24 chuckv 3084 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->sele1_given = 0 ;
46     args_info->sele2_given = 0 ;
47     args_info->order_given = 0 ;
48     args_info->rcorr_given = 0 ;
49     args_info->vcorr_given = 0 ;
50     args_info->dcorr_given = 0 ;
51     args_info->lcorr_given = 0 ;
52     args_info->r_rcorr_given = 0 ;
53     args_info->dynamicProps_group_counter = 0 ;
54     }
55    
56     static
57     void clear_args (struct gengetopt_args_info *args_info)
58     {
59     args_info->input_arg = NULL;
60     args_info->input_orig = NULL;
61     args_info->output_arg = NULL;
62     args_info->output_orig = NULL;
63     args_info->sele1_arg = NULL;
64     args_info->sele1_orig = NULL;
65     args_info->sele2_arg = NULL;
66     args_info->sele2_orig = NULL;
67     args_info->order_orig = NULL;
68    
69     }
70    
71 tim 2004 void
72     cmdline_parser_print_version (void)
73     {
74     printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
75     }
76    
77     void
78     cmdline_parser_print_help (void)
79     {
80     cmdline_parser_print_version ();
81 chuckv 3084 printf("\nUsage: DynamicProps [OPTIONS]...\n\n");
82     printf("%s\n"," -h, --help Print help and exit");
83     printf("%s\n"," -V, --version Print version and exit");
84     printf("%s\n"," -i, --input=filename input dump file");
85     printf("%s\n"," -o, --output=filename output file name");
86     printf("%s\n"," --sele1=selection script select first stuntdouble set");
87     printf("%s\n"," --sele2=selection script select second stuntdouble set (if sele2 is not \n set, use script from sele1)");
88     printf("%s\n"," --order=INT Lengendre Polynomial Order");
89     printf("%s\n","\n Group: dynamicProps\n an option of this group is required");
90     printf("%s\n"," -r, --rcorr rmsd");
91     printf("%s\n"," -v, --vcorr velocity correlation function");
92     printf("%s\n"," -d, --dcorr dipole correlation function");
93     printf("%s\n"," -l, --lcorr Lengendre correlation function");
94     printf("%s\n"," --r_rcorr Radial rmsd");
95    
96 tim 2004 }
97    
98 chuckv 3084 void
99     cmdline_parser_init (struct gengetopt_args_info *args_info)
100     {
101     clear_given (args_info);
102     clear_args (args_info);
103     }
104 tim 2004
105 chuckv 3084 static void
106     cmdline_parser_release (struct gengetopt_args_info *args_info)
107     {
108    
109     if (args_info->input_arg)
110     {
111     free (args_info->input_arg); /* free previous argument */
112     args_info->input_arg = 0;
113     }
114     if (args_info->input_orig)
115     {
116     free (args_info->input_orig); /* free previous argument */
117     args_info->input_orig = 0;
118     }
119     if (args_info->output_arg)
120     {
121     free (args_info->output_arg); /* free previous argument */
122     args_info->output_arg = 0;
123     }
124     if (args_info->output_orig)
125     {
126     free (args_info->output_orig); /* free previous argument */
127     args_info->output_orig = 0;
128     }
129     if (args_info->sele1_arg)
130     {
131     free (args_info->sele1_arg); /* free previous argument */
132     args_info->sele1_arg = 0;
133     }
134     if (args_info->sele1_orig)
135     {
136     free (args_info->sele1_orig); /* free previous argument */
137     args_info->sele1_orig = 0;
138     }
139     if (args_info->sele2_arg)
140     {
141     free (args_info->sele2_arg); /* free previous argument */
142     args_info->sele2_arg = 0;
143     }
144     if (args_info->sele2_orig)
145     {
146     free (args_info->sele2_orig); /* free previous argument */
147     args_info->sele2_orig = 0;
148     }
149     if (args_info->order_orig)
150     {
151     free (args_info->order_orig); /* free previous argument */
152     args_info->order_orig = 0;
153     }
154    
155     clear_given (args_info);
156     }
157 tim 2004
158 chuckv 3084 int
159     cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
160     {
161     FILE *outfile;
162     int i = 0;
163    
164     outfile = fopen(filename, "w");
165    
166     if (!outfile)
167     {
168     fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
169     return EXIT_FAILURE;
170     }
171    
172     if (args_info->help_given) {
173     fprintf(outfile, "%s\n", "help");
174     }
175     if (args_info->version_given) {
176     fprintf(outfile, "%s\n", "version");
177     }
178     if (args_info->input_given) {
179     if (args_info->input_orig) {
180     fprintf(outfile, "%s=\"%s\"\n", "input", args_info->input_orig);
181     } else {
182     fprintf(outfile, "%s\n", "input");
183     }
184     }
185     if (args_info->output_given) {
186     if (args_info->output_orig) {
187     fprintf(outfile, "%s=\"%s\"\n", "output", args_info->output_orig);
188     } else {
189     fprintf(outfile, "%s\n", "output");
190     }
191     }
192     if (args_info->sele1_given) {
193     if (args_info->sele1_orig) {
194     fprintf(outfile, "%s=\"%s\"\n", "sele1", args_info->sele1_orig);
195     } else {
196     fprintf(outfile, "%s\n", "sele1");
197     }
198     }
199     if (args_info->sele2_given) {
200     if (args_info->sele2_orig) {
201     fprintf(outfile, "%s=\"%s\"\n", "sele2", args_info->sele2_orig);
202     } else {
203     fprintf(outfile, "%s\n", "sele2");
204     }
205     }
206     if (args_info->order_given) {
207     if (args_info->order_orig) {
208     fprintf(outfile, "%s=\"%s\"\n", "order", args_info->order_orig);
209     } else {
210     fprintf(outfile, "%s\n", "order");
211     }
212     }
213     if (args_info->rcorr_given) {
214     fprintf(outfile, "%s\n", "rcorr");
215     }
216     if (args_info->vcorr_given) {
217     fprintf(outfile, "%s\n", "vcorr");
218     }
219     if (args_info->dcorr_given) {
220     fprintf(outfile, "%s\n", "dcorr");
221     }
222     if (args_info->lcorr_given) {
223     fprintf(outfile, "%s\n", "lcorr");
224     }
225     if (args_info->r_rcorr_given) {
226     fprintf(outfile, "%s\n", "r_rcorr");
227     }
228    
229     fclose (outfile);
230    
231     i = EXIT_SUCCESS;
232     return i;
233     }
234    
235     void
236     cmdline_parser_free (struct gengetopt_args_info *args_info)
237     {
238     cmdline_parser_release (args_info);
239     }
240    
241    
242 tim 2004 /* gengetopt_strdup() */
243     /* strdup.c replacement of strdup, which is not standard */
244     char *
245     gengetopt_strdup (const char *s)
246     {
247 chuckv 3084 char *result = NULL;
248     if (!s)
249     return result;
250    
251     result = (char*)malloc(strlen(s) + 1);
252 tim 2004 if (result == (char*)0)
253     return (char*)0;
254     strcpy(result, s);
255     return result;
256     }
257    
258 chuckv 3084 static void
259     reset_group_dynamicProps(struct gengetopt_args_info *args_info);
260    
261     static void
262     reset_group_dynamicProps(struct gengetopt_args_info *args_info)
263 tim 2004 {
264 chuckv 3084 if (! args_info->dynamicProps_group_counter)
265     return;
266 tim 2004
267     args_info->rcorr_given = 0 ;
268     args_info->vcorr_given = 0 ;
269     args_info->dcorr_given = 0 ;
270 tim 2576 args_info->lcorr_given = 0 ;
271 chuckv 3084 args_info->r_rcorr_given = 0 ;
272    
273     args_info->dynamicProps_group_counter = 0;
274 tim 2576 }
275 tim 2004
276 chuckv 3084 int
277     cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
278     {
279     return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
280     }
281 tim 2004
282 chuckv 3084 int
283     cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
284     {
285     int result;
286    
287     result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL);
288    
289     if (result == EXIT_FAILURE)
290     {
291     cmdline_parser_free (args_info);
292     exit (EXIT_FAILURE);
293     }
294    
295     return result;
296     }
297    
298     int
299     cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
300     {
301     int result = EXIT_SUCCESS;
302    
303     if (cmdline_parser_required2(args_info, prog_name, NULL) > 0)
304     result = EXIT_FAILURE;
305    
306     if (result == EXIT_FAILURE)
307     {
308     cmdline_parser_free (args_info);
309     exit (EXIT_FAILURE);
310     }
311    
312     return result;
313     }
314    
315     int
316     cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
317     {
318     int error = 0;
319    
320     if (! args_info->input_given)
321     {
322     fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : ""));
323     error = 1;
324     }
325     if (args_info->dynamicProps_group_counter == 0)
326     {
327     fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required.%s\n", prog_name, args_info->dynamicProps_group_counter, (additional_error ? additional_error : ""));
328     error = 1;
329     }
330    
331    
332     return error;
333     }
334    
335     int
336     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)
337     {
338     int c; /* Character of the parsed option. */
339    
340     int error = 0;
341     struct gengetopt_args_info local_args_info;
342    
343     if (initialize)
344     cmdline_parser_init (args_info);
345    
346     cmdline_parser_init (&local_args_info);
347    
348 tim 2004 optarg = 0;
349     optind = 1;
350     opterr = 1;
351     optopt = '?';
352    
353     while (1)
354     {
355     int option_index = 0;
356     char *stop_char;
357    
358     static struct option long_options[] = {
359     { "help", 0, NULL, 'h' },
360     { "version", 0, NULL, 'V' },
361     { "input", 1, NULL, 'i' },
362     { "output", 1, NULL, 'o' },
363     { "sele1", 1, NULL, 0 },
364     { "sele2", 1, NULL, 0 },
365 tim 2576 { "order", 1, NULL, 0 },
366 tim 2004 { "rcorr", 0, NULL, 'r' },
367     { "vcorr", 0, NULL, 'v' },
368     { "dcorr", 0, NULL, 'd' },
369 tim 2576 { "lcorr", 0, NULL, 'l' },
370 chuckv 3084 { "r_rcorr", 0, NULL, 0 },
371 tim 2004 { NULL, 0, NULL, 0 }
372     };
373    
374     stop_char = 0;
375 tim 2671 c = getopt_long (argc, argv, "hVi:o:rvdl", long_options, &option_index);
376 tim 2004
377     if (c == -1) break; /* Exit from `while (1)' loop. */
378    
379     switch (c)
380     {
381     case 'h': /* Print help and exit. */
382     cmdline_parser_print_help ();
383 chuckv 3084 cmdline_parser_free (&local_args_info);
384 tim 2004 exit (EXIT_SUCCESS);
385    
386     case 'V': /* Print version and exit. */
387     cmdline_parser_print_version ();
388 chuckv 3084 cmdline_parser_free (&local_args_info);
389 tim 2004 exit (EXIT_SUCCESS);
390    
391     case 'i': /* input dump file. */
392 chuckv 3084 if (local_args_info.input_given)
393 tim 2004 {
394 chuckv 3084 fprintf (stderr, "%s: `--input' (`-i') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
395     goto failure;
396 tim 2004 }
397 chuckv 3084 if (args_info->input_given && ! override)
398     continue;
399     local_args_info.input_given = 1;
400 tim 2004 args_info->input_given = 1;
401 chuckv 3084 if (args_info->input_arg)
402     free (args_info->input_arg); /* free previous string */
403 tim 2004 args_info->input_arg = gengetopt_strdup (optarg);
404 chuckv 3084 if (args_info->input_orig)
405     free (args_info->input_orig); /* free previous string */
406     args_info->input_orig = gengetopt_strdup (optarg);
407 tim 2004 break;
408    
409     case 'o': /* output file name. */
410 chuckv 3084 if (local_args_info.output_given)
411 tim 2004 {
412 chuckv 3084 fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
413     goto failure;
414 tim 2004 }
415 chuckv 3084 if (args_info->output_given && ! override)
416     continue;
417     local_args_info.output_given = 1;
418 tim 2004 args_info->output_given = 1;
419 chuckv 3084 if (args_info->output_arg)
420     free (args_info->output_arg); /* free previous string */
421 tim 2004 args_info->output_arg = gengetopt_strdup (optarg);
422 chuckv 3084 if (args_info->output_orig)
423     free (args_info->output_orig); /* free previous string */
424     args_info->output_orig = gengetopt_strdup (optarg);
425 tim 2004 break;
426    
427 tim 2671 case 'r': /* rmsd. */
428 chuckv 3084 if (local_args_info.rcorr_given)
429 tim 2004 {
430 chuckv 3084 fprintf (stderr, "%s: `--rcorr' (`-r') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
431     goto failure;
432 tim 2004 }
433 chuckv 3084 if (args_info->rcorr_given && ! override)
434     continue;
435     local_args_info.rcorr_given = 1;
436 tim 2004 args_info->rcorr_given = 1;
437 chuckv 3084 if (args_info->dynamicProps_group_counter && override)
438     reset_group_dynamicProps (args_info);
439     args_info->dynamicProps_group_counter += 1;
440     break;
441 tim 2004
442     case 'v': /* velocity correlation function. */
443 chuckv 3084 if (local_args_info.vcorr_given)
444 tim 2004 {
445 chuckv 3084 fprintf (stderr, "%s: `--vcorr' (`-v') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
446     goto failure;
447 tim 2004 }
448 chuckv 3084 if (args_info->vcorr_given && ! override)
449     continue;
450     local_args_info.vcorr_given = 1;
451 tim 2004 args_info->vcorr_given = 1;
452 chuckv 3084 if (args_info->dynamicProps_group_counter && override)
453     reset_group_dynamicProps (args_info);
454     args_info->dynamicProps_group_counter += 1;
455     break;
456 tim 2004
457     case 'd': /* dipole correlation function. */
458 chuckv 3084 if (local_args_info.dcorr_given)
459 tim 2004 {
460 chuckv 3084 fprintf (stderr, "%s: `--dcorr' (`-d') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
461     goto failure;
462 tim 2004 }
463 chuckv 3084 if (args_info->dcorr_given && ! override)
464     continue;
465     local_args_info.dcorr_given = 1;
466 tim 2004 args_info->dcorr_given = 1;
467 chuckv 3084 if (args_info->dynamicProps_group_counter && override)
468     reset_group_dynamicProps (args_info);
469     args_info->dynamicProps_group_counter += 1;
470     break;
471 tim 2004
472 tim 2576 case 'l': /* Lengendre correlation function. */
473 chuckv 3084 if (local_args_info.lcorr_given)
474 tim 2576 {
475 chuckv 3084 fprintf (stderr, "%s: `--lcorr' (`-l') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
476     goto failure;
477 tim 2576 }
478 chuckv 3084 if (args_info->lcorr_given && ! override)
479     continue;
480     local_args_info.lcorr_given = 1;
481 tim 2576 args_info->lcorr_given = 1;
482 chuckv 3084 if (args_info->dynamicProps_group_counter && override)
483     reset_group_dynamicProps (args_info);
484     args_info->dynamicProps_group_counter += 1;
485     break;
486 tim 2004
487 tim 2576
488 tim 2004 case 0: /* Long option with no short option */
489     /* select first stuntdouble set. */
490     if (strcmp (long_options[option_index].name, "sele1") == 0)
491 tim 2576 {
492 chuckv 3084 if (local_args_info.sele1_given)
493 tim 2576 {
494 chuckv 3084 fprintf (stderr, "%s: `--sele1' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
495     goto failure;
496 tim 2576 }
497 chuckv 3084 if (args_info->sele1_given && ! override)
498     continue;
499     local_args_info.sele1_given = 1;
500 tim 2576 args_info->sele1_given = 1;
501 chuckv 3084 if (args_info->sele1_arg)
502     free (args_info->sele1_arg); /* free previous string */
503 tim 2576 args_info->sele1_arg = gengetopt_strdup (optarg);
504 chuckv 3084 if (args_info->sele1_orig)
505     free (args_info->sele1_orig); /* free previous string */
506     args_info->sele1_orig = gengetopt_strdup (optarg);
507 tim 2576 }
508 tim 2004 /* select second stuntdouble set (if sele2 is not set, use script from sele1). */
509     else if (strcmp (long_options[option_index].name, "sele2") == 0)
510 tim 2576 {
511 chuckv 3084 if (local_args_info.sele2_given)
512 tim 2576 {
513 chuckv 3084 fprintf (stderr, "%s: `--sele2' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
514     goto failure;
515 tim 2576 }
516 chuckv 3084 if (args_info->sele2_given && ! override)
517     continue;
518     local_args_info.sele2_given = 1;
519 tim 2576 args_info->sele2_given = 1;
520 chuckv 3084 if (args_info->sele2_arg)
521     free (args_info->sele2_arg); /* free previous string */
522 tim 2576 args_info->sele2_arg = gengetopt_strdup (optarg);
523 chuckv 3084 if (args_info->sele2_orig)
524     free (args_info->sele2_orig); /* free previous string */
525     args_info->sele2_orig = gengetopt_strdup (optarg);
526 tim 2576 }
527     /* Lengendre Polynomial Order. */
528     else if (strcmp (long_options[option_index].name, "order") == 0)
529     {
530 chuckv 3084 if (local_args_info.order_given)
531 tim 2576 {
532 chuckv 3084 fprintf (stderr, "%s: `--order' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
533     goto failure;
534 tim 2576 }
535 chuckv 3084 if (args_info->order_given && ! override)
536     continue;
537     local_args_info.order_given = 1;
538 tim 2576 args_info->order_given = 1;
539 chuckv 3084 args_info->order_arg = strtol (optarg, &stop_char, 0);
540     if (!(stop_char && *stop_char == '\0')) {
541     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
542     goto failure;
543     }
544     if (args_info->order_orig)
545     free (args_info->order_orig); /* free previous string */
546     args_info->order_orig = gengetopt_strdup (optarg);
547     }
548     /* Radial rmsd. */
549     else if (strcmp (long_options[option_index].name, "r_rcorr") == 0)
550     {
551     if (local_args_info.r_rcorr_given)
552     {
553     fprintf (stderr, "%s: `--r_rcorr' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
554     goto failure;
555     }
556     if (args_info->r_rcorr_given && ! override)
557     continue;
558     local_args_info.r_rcorr_given = 1;
559     args_info->r_rcorr_given = 1;
560     if (args_info->dynamicProps_group_counter && override)
561     reset_group_dynamicProps (args_info);
562     args_info->dynamicProps_group_counter += 1;
563 tim 2576 break;
564     }
565    
566 chuckv 3084 break;
567 tim 2004 case '?': /* Invalid option. */
568     /* `getopt_long' already printed an error message. */
569 chuckv 3084 goto failure;
570 tim 2004
571     default: /* bug: option not considered. */
572 chuckv 3084 fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
573 tim 2004 abort ();
574     } /* switch */
575     } /* while */
576    
577 chuckv 3084 if (args_info->dynamicProps_group_counter > 1)
578 tim 2004 {
579 chuckv 3084 fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required.%s\n", argv[0], args_info->dynamicProps_group_counter, (additional_error ? additional_error : ""));
580     error = 1;
581 tim 2004 }
582    
583    
584 chuckv 3084
585     if (check_required)
586 tim 2004 {
587 chuckv 3084 error += cmdline_parser_required2 (args_info, argv[0], additional_error);
588 tim 2004 }
589    
590 chuckv 3084 cmdline_parser_release (&local_args_info);
591    
592     if ( error )
593     return (EXIT_FAILURE);
594    
595 tim 2004 return 0;
596 chuckv 3084
597     failure:
598    
599     cmdline_parser_release (&local_args_info);
600     return (EXIT_FAILURE);
601 tim 2004 }