ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/nanoparticleBuilder/nanoparticleBuilderCmd.c
Revision: 3044
Committed: Fri Oct 13 20:16:59 2006 UTC (17 years, 10 months ago) by chuckv
Content type: text/plain
File size: 26054 byte(s)
Log Message:
Changed nanoparticle builder for new dump syntax.

File Contents

# User Rev Content
1 chuckv 2352 /*
2 chuckv 3044 File autogenerated by gengetopt version 2.15
3 chuckv 2352 generated with the following command:
4 chuckv 3044 gengetopt -u -i nanoparticleBuilder.ggo -F nanoparticleBuilderCmd
5 chuckv 2352
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     /* If we use autoconf. */
12     #ifdef HAVE_CONFIG_H
13     #include "config.h"
14     #endif
15    
16     #include <stdio.h>
17     #include <stdlib.h>
18     #include <string.h>
19    
20     #include "getopt.h"
21    
22     #include "nanoparticleBuilderCmd.h"
23    
24     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     struct ShellRadius_list
36     {
37     double ShellRadius_arg;
38 chuckv 3044 char *ShellRadius_orig;
39 chuckv 2352 struct ShellRadius_list * next;
40     };
41    
42     struct molFraction_list
43     {
44     double molFraction_arg;
45 chuckv 3044 char *molFraction_orig;
46 chuckv 2352 struct molFraction_list * next;
47     };
48    
49     struct vacancyRadius_list
50     {
51     double vacancyRadius_arg;
52 chuckv 3044 char *vacancyRadius_orig;
53 chuckv 2352 struct vacancyRadius_list * next;
54     };
55    
56     static char *
57     gengetopt_strdup (const char *s);
58    
59     static
60     void clear_given (struct gengetopt_args_info *args_info)
61     {
62     args_info->help_given = 0 ;
63     args_info->version_given = 0 ;
64     args_info->output_given = 0 ;
65     args_info->latticeCnst_given = 0 ;
66     args_info->radius_given = 0 ;
67     args_info->ShellRadius_given = 0 ;
68     args_info->molFraction_given = 0 ;
69     args_info->vacancyPCT_given = 0 ;
70     args_info->vacancyRadius_given = 0 ;
71     }
72    
73     static
74     void clear_args (struct gengetopt_args_info *args_info)
75     {
76     args_info->output_arg = NULL;
77 chuckv 3044 args_info->output_orig = NULL;
78     args_info->latticeCnst_orig = NULL;
79     args_info->radius_orig = NULL;
80 chuckv 2352 args_info->ShellRadius_arg = NULL;
81 chuckv 3044 args_info->ShellRadius_orig = NULL;
82 chuckv 2352 args_info->molFraction_arg = NULL;
83 chuckv 3044 args_info->molFraction_orig = NULL;
84     args_info->vacancyPCT_orig = NULL;
85 chuckv 2352 args_info->vacancyRadius_arg = NULL;
86 chuckv 3044 args_info->vacancyRadius_orig = NULL;
87    
88 chuckv 2352 }
89    
90     void
91     cmdline_parser_print_version (void)
92     {
93     printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
94     }
95    
96     void
97     cmdline_parser_print_help (void)
98     {
99     cmdline_parser_print_version ();
100     printf("\n%s\n", "Builds spherical random or core-shell nanoparticles and outputs a xyz input \nfile");
101     printf("\nUsage: nanoparticleBuilder [OPTIONS]... [FILES]...\n\n");
102     printf("%s\n"," -h, --help Print help and exit");
103     printf("%s\n"," -V, --version Print version and exit");
104     printf("%s\n"," -o, --output=STRING Output file name");
105     printf("%s\n"," --latticeCnst=DOUBLE Lattice spacing in Angstroms for cubic lattice.");
106     printf("%s\n"," --radius=DOUBLE Nanoparticle radius in Angstroms");
107     printf("%s\n"," --ShellRadius=DOUBLE Radius from the center of the particle to start a \n new shell in multi-component core-shell \n particle. Specified for each component > 1 in \n md file.");
108     printf("%s\n"," --molFraction=DOUBLE (Default) Builds a multi-component random mixed \n nanoparticle. Mole Fraction must be specified \n for each componet > 1 in MD file.");
109     printf("%s\n"," --vacancyPCT=DOUBLE Percentage of vacancies to build");
110     printf("%s\n"," --vacancyRadius=DOUBLE Radius arround core-shell where vacancies should \n be located.");
111    
112     }
113    
114     void
115     cmdline_parser_init (struct gengetopt_args_info *args_info)
116     {
117     clear_given (args_info);
118     clear_args (args_info);
119    
120     args_info->inputs = NULL;
121     args_info->inputs_num = 0;
122     }
123    
124 chuckv 3044 static void
125     cmdline_parser_release (struct gengetopt_args_info *args_info)
126 chuckv 2352 {
127    
128     unsigned int i;
129     if (args_info->output_arg)
130     {
131     free (args_info->output_arg); /* free previous argument */
132     args_info->output_arg = 0;
133     }
134 chuckv 3044 if (args_info->output_orig)
135 chuckv 2352 {
136 chuckv 3044 free (args_info->output_orig); /* free previous argument */
137     args_info->output_orig = 0;
138 chuckv 2352 }
139 chuckv 3044 if (args_info->latticeCnst_orig)
140     {
141     free (args_info->latticeCnst_orig); /* free previous argument */
142     args_info->latticeCnst_orig = 0;
143     }
144     if (args_info->radius_orig)
145     {
146     free (args_info->radius_orig); /* free previous argument */
147     args_info->radius_orig = 0;
148     }
149 chuckv 2352 if (args_info->ShellRadius_arg)
150     {
151 chuckv 3044 for (i = 0; i < args_info->ShellRadius_given; ++i)
152     {
153     if (args_info->ShellRadius_orig [i])
154     {
155     free (args_info->ShellRadius_orig [i]); /* free previous argument */
156     args_info->ShellRadius_orig [i] = 0;
157     }
158     }
159 chuckv 2352 free (args_info->ShellRadius_arg); /* free previous argument */
160     args_info->ShellRadius_arg = 0;
161 chuckv 3044 free (args_info->ShellRadius_orig); /* free previous argument */
162     args_info->ShellRadius_orig = 0;
163 chuckv 2352 }
164     if (args_info->molFraction_arg)
165     {
166 chuckv 3044 for (i = 0; i < args_info->molFraction_given; ++i)
167     {
168     if (args_info->molFraction_orig [i])
169     {
170     free (args_info->molFraction_orig [i]); /* free previous argument */
171     args_info->molFraction_orig [i] = 0;
172     }
173     }
174 chuckv 2352 free (args_info->molFraction_arg); /* free previous argument */
175     args_info->molFraction_arg = 0;
176 chuckv 3044 free (args_info->molFraction_orig); /* free previous argument */
177     args_info->molFraction_orig = 0;
178 chuckv 2352 }
179 chuckv 3044 if (args_info->vacancyPCT_orig)
180     {
181     free (args_info->vacancyPCT_orig); /* free previous argument */
182     args_info->vacancyPCT_orig = 0;
183     }
184 chuckv 2352 if (args_info->vacancyRadius_arg)
185     {
186 chuckv 3044 for (i = 0; i < args_info->vacancyRadius_given; ++i)
187     {
188     if (args_info->vacancyRadius_orig [i])
189     {
190     free (args_info->vacancyRadius_orig [i]); /* free previous argument */
191     args_info->vacancyRadius_orig [i] = 0;
192     }
193     }
194 chuckv 2352 free (args_info->vacancyRadius_arg); /* free previous argument */
195     args_info->vacancyRadius_arg = 0;
196 chuckv 3044 free (args_info->vacancyRadius_orig); /* free previous argument */
197     args_info->vacancyRadius_orig = 0;
198 chuckv 2352 }
199    
200     for (i = 0; i < args_info->inputs_num; ++i)
201     free (args_info->inputs [i]);
202    
203     if (args_info->inputs_num)
204     free (args_info->inputs);
205    
206     clear_given (args_info);
207     }
208    
209 chuckv 3044 int
210     cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
211     {
212     FILE *outfile;
213     int i = 0;
214    
215     outfile = fopen(filename, "w");
216    
217     if (!outfile)
218     {
219     fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
220     return EXIT_FAILURE;
221     }
222    
223     if (args_info->help_given) {
224     fprintf(outfile, "%s\n", "help");
225     }
226     if (args_info->version_given) {
227     fprintf(outfile, "%s\n", "version");
228     }
229     if (args_info->output_given) {
230     if (args_info->output_orig) {
231     fprintf(outfile, "%s=\"%s\"\n", "output", args_info->output_orig);
232     } else {
233     fprintf(outfile, "%s\n", "output");
234     }
235     }
236     if (args_info->latticeCnst_given) {
237     if (args_info->latticeCnst_orig) {
238     fprintf(outfile, "%s=\"%s\"\n", "latticeCnst", args_info->latticeCnst_orig);
239     } else {
240     fprintf(outfile, "%s\n", "latticeCnst");
241     }
242     }
243     if (args_info->radius_given) {
244     if (args_info->radius_orig) {
245     fprintf(outfile, "%s=\"%s\"\n", "radius", args_info->radius_orig);
246     } else {
247     fprintf(outfile, "%s\n", "radius");
248     }
249     }
250     if (args_info->ShellRadius_orig)
251     {
252     for (i = 0; i < args_info->ShellRadius_given; ++i)
253     {
254     if (args_info->ShellRadius_orig [i])
255     {
256     fprintf(outfile, "%s=\"%s\"\n", "ShellRadius", args_info->ShellRadius_orig [i]);
257     }
258     }
259     }
260     if (args_info->molFraction_orig)
261     {
262     for (i = 0; i < args_info->molFraction_given; ++i)
263     {
264     if (args_info->molFraction_orig [i])
265     {
266     fprintf(outfile, "%s=\"%s\"\n", "molFraction", args_info->molFraction_orig [i]);
267     }
268     }
269     }
270     if (args_info->vacancyPCT_given) {
271     if (args_info->vacancyPCT_orig) {
272     fprintf(outfile, "%s=\"%s\"\n", "vacancyPCT", args_info->vacancyPCT_orig);
273     } else {
274     fprintf(outfile, "%s\n", "vacancyPCT");
275     }
276     }
277     if (args_info->vacancyRadius_orig)
278     {
279     for (i = 0; i < args_info->vacancyRadius_given; ++i)
280     {
281     if (args_info->vacancyRadius_orig [i])
282     {
283     fprintf(outfile, "%s=\"%s\"\n", "vacancyRadius", args_info->vacancyRadius_orig [i]);
284     }
285     }
286     }
287    
288     fclose (outfile);
289    
290     i = EXIT_SUCCESS;
291     return i;
292     }
293    
294     void
295     cmdline_parser_free (struct gengetopt_args_info *args_info)
296     {
297     cmdline_parser_release (args_info);
298     }
299    
300    
301 chuckv 2352 /* gengetopt_strdup() */
302     /* strdup.c replacement of strdup, which is not standard */
303     char *
304     gengetopt_strdup (const char *s)
305     {
306     char *result = NULL;
307     if (!s)
308     return result;
309    
310     result = (char*)malloc(strlen(s) + 1);
311     if (result == (char*)0)
312     return (char*)0;
313     strcpy(result, s);
314     return result;
315     }
316    
317     static char *
318     get_multiple_arg_token(const char *arg)
319     {
320     char *tok, *ret;
321     size_t len;
322    
323     if (!arg)
324     return NULL;
325    
326     tok = strchr (arg, ',');
327    
328     if (tok)
329     len = (size_t)(tok - arg + 1);
330     else
331     len = strlen (arg) + 1;
332    
333     ret = (char *) malloc (len);
334     strncpy (ret, arg, len-1);
335     ret[len-1] = '\0';
336    
337     return ret;
338     }
339    
340     static char *
341     get_multiple_arg_token_next(const char *arg)
342     {
343     char *tok;
344    
345     if (!arg)
346     return NULL;
347    
348     tok = strchr (arg, ',');
349    
350     if (! tok || strlen(tok) == 1)
351     return 0;
352    
353     return tok+1;
354     }
355    
356     int
357     cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
358     {
359     return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
360     }
361    
362     int
363     cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
364     {
365     int result;
366    
367     result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL);
368    
369     if (result == EXIT_FAILURE)
370     {
371     cmdline_parser_free (args_info);
372     exit (EXIT_FAILURE);
373     }
374    
375     return result;
376     }
377    
378     int
379     cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
380     {
381     int result = EXIT_SUCCESS;
382    
383     if (cmdline_parser_required2(args_info, prog_name, NULL) > 0)
384     result = EXIT_FAILURE;
385    
386     if (result == EXIT_FAILURE)
387     {
388     cmdline_parser_free (args_info);
389     exit (EXIT_FAILURE);
390     }
391    
392     return result;
393     }
394    
395     int
396     cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
397     {
398     int error = 0;
399    
400     if (! args_info->latticeCnst_given)
401     {
402     fprintf (stderr, "%s: '--latticeCnst' option required%s\n", prog_name, (additional_error ? additional_error : ""));
403     error = 1;
404     }
405     if (! args_info->radius_given)
406     {
407     fprintf (stderr, "%s: '--radius' option required%s\n", prog_name, (additional_error ? additional_error : ""));
408     error = 1;
409     }
410    
411     return error;
412     }
413    
414     int
415     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)
416     {
417     int c; /* Character of the parsed option. */
418     char *multi_token, *multi_next; /* for multiple options */
419    
420     int i; /* Counter */
421    
422     struct ShellRadius_list * ShellRadius_list = NULL,* ShellRadius_new = NULL;
423     struct molFraction_list * molFraction_list = NULL,* molFraction_new = NULL;
424     struct vacancyRadius_list * vacancyRadius_list = NULL,* vacancyRadius_new = NULL;
425     int error = 0;
426     struct gengetopt_args_info local_args_info;
427    
428     if (initialize)
429     cmdline_parser_init (args_info);
430    
431     cmdline_parser_init (&local_args_info);
432    
433     optarg = 0;
434     optind = 1;
435     opterr = 1;
436     optopt = '?';
437    
438     while (1)
439     {
440     int option_index = 0;
441     char *stop_char;
442    
443     static struct option long_options[] = {
444     { "help", 0, NULL, 'h' },
445     { "version", 0, NULL, 'V' },
446     { "output", 1, NULL, 'o' },
447     { "latticeCnst", 1, NULL, 0 },
448     { "radius", 1, NULL, 0 },
449     { "ShellRadius", 1, NULL, 0 },
450     { "molFraction", 1, NULL, 0 },
451     { "vacancyPCT", 1, NULL, 0 },
452     { "vacancyRadius", 1, NULL, 0 },
453     { NULL, 0, NULL, 0 }
454     };
455    
456     stop_char = 0;
457     c = getopt_long (argc, argv, "hVo:", long_options, &option_index);
458    
459     if (c == -1) break; /* Exit from `while (1)' loop. */
460    
461     switch (c)
462     {
463     case 'h': /* Print help and exit. */
464     cmdline_parser_print_help ();
465 chuckv 3044 cmdline_parser_free (&local_args_info);
466 chuckv 2352 exit (EXIT_SUCCESS);
467    
468     case 'V': /* Print version and exit. */
469     cmdline_parser_print_version ();
470 chuckv 3044 cmdline_parser_free (&local_args_info);
471 chuckv 2352 exit (EXIT_SUCCESS);
472    
473     case 'o': /* Output file name. */
474     if (local_args_info.output_given)
475     {
476     fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
477     goto failure;
478     }
479     if (args_info->output_given && ! override)
480     continue;
481     local_args_info.output_given = 1;
482     args_info->output_given = 1;
483     if (args_info->output_arg)
484     free (args_info->output_arg); /* free previous string */
485     args_info->output_arg = gengetopt_strdup (optarg);
486 chuckv 3044 if (args_info->output_orig)
487     free (args_info->output_orig); /* free previous string */
488     args_info->output_orig = gengetopt_strdup (optarg);
489 chuckv 2352 break;
490    
491    
492     case 0: /* Long option with no short option */
493     /* Lattice spacing in Angstroms for cubic lattice.. */
494 chuckv 3044 if (strcmp (long_options[option_index].name, "latticeCnst") == 0)
495 chuckv 2352 {
496     if (local_args_info.latticeCnst_given)
497     {
498     fprintf (stderr, "%s: `--latticeCnst' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
499     goto failure;
500     }
501     if (args_info->latticeCnst_given && ! override)
502     continue;
503     local_args_info.latticeCnst_given = 1;
504     args_info->latticeCnst_given = 1;
505 chuckv 3044 args_info->latticeCnst_arg = strtod (optarg, &stop_char);
506     if (!(stop_char && *stop_char == '\0')) {
507     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
508     goto failure;
509     }
510     if (args_info->latticeCnst_orig)
511     free (args_info->latticeCnst_orig); /* free previous string */
512     args_info->latticeCnst_orig = gengetopt_strdup (optarg);
513 chuckv 2352 }
514     /* Nanoparticle radius in Angstroms. */
515     else if (strcmp (long_options[option_index].name, "radius") == 0)
516     {
517     if (local_args_info.radius_given)
518     {
519     fprintf (stderr, "%s: `--radius' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
520     goto failure;
521     }
522     if (args_info->radius_given && ! override)
523     continue;
524     local_args_info.radius_given = 1;
525     args_info->radius_given = 1;
526 chuckv 3044 args_info->radius_arg = strtod (optarg, &stop_char);
527     if (!(stop_char && *stop_char == '\0')) {
528     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
529     goto failure;
530     }
531     if (args_info->radius_orig)
532     free (args_info->radius_orig); /* free previous string */
533     args_info->radius_orig = gengetopt_strdup (optarg);
534 chuckv 2352 }
535     /* Radius from the center of the particle to start a new shell in multi-component core-shell particle. Specified for each component > 1 in md file.. */
536     else if (strcmp (long_options[option_index].name, "ShellRadius") == 0)
537     {
538     local_args_info.ShellRadius_given++;
539    
540     multi_token = get_multiple_arg_token(optarg);
541     multi_next = get_multiple_arg_token_next (optarg);
542    
543     while (1)
544     {
545     ShellRadius_new = (struct ShellRadius_list *) malloc (sizeof (struct ShellRadius_list));
546     ShellRadius_new->next = ShellRadius_list;
547     ShellRadius_list = ShellRadius_new;
548 chuckv 3044 ShellRadius_new->ShellRadius_arg = strtod (multi_token, &stop_char);
549     if (!(stop_char && *stop_char == '\0')) {
550     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], multi_token);
551     goto failure;
552     }
553     ShellRadius_new->ShellRadius_orig = multi_token;
554 chuckv 2352
555     if (multi_next)
556     {
557     multi_token = get_multiple_arg_token(multi_next);
558     multi_next = get_multiple_arg_token_next (multi_next);
559     local_args_info.ShellRadius_given++;
560     }
561     else
562     break;
563     }
564     break;
565     }
566     /* (Default) Builds a multi-component random mixed nanoparticle. Mole Fraction must be specified for each componet > 1 in MD file.. */
567     else if (strcmp (long_options[option_index].name, "molFraction") == 0)
568     {
569     local_args_info.molFraction_given++;
570    
571     multi_token = get_multiple_arg_token(optarg);
572     multi_next = get_multiple_arg_token_next (optarg);
573    
574     while (1)
575     {
576     molFraction_new = (struct molFraction_list *) malloc (sizeof (struct molFraction_list));
577     molFraction_new->next = molFraction_list;
578     molFraction_list = molFraction_new;
579 chuckv 3044 molFraction_new->molFraction_arg = strtod (multi_token, &stop_char);
580     if (!(stop_char && *stop_char == '\0')) {
581     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], multi_token);
582     goto failure;
583     }
584     molFraction_new->molFraction_orig = multi_token;
585 chuckv 2352
586     if (multi_next)
587     {
588     multi_token = get_multiple_arg_token(multi_next);
589     multi_next = get_multiple_arg_token_next (multi_next);
590     local_args_info.molFraction_given++;
591     }
592     else
593     break;
594     }
595     break;
596     }
597     /* Percentage of vacancies to build. */
598     else if (strcmp (long_options[option_index].name, "vacancyPCT") == 0)
599     {
600     if (local_args_info.vacancyPCT_given)
601     {
602     fprintf (stderr, "%s: `--vacancyPCT' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
603     goto failure;
604     }
605     if (args_info->vacancyPCT_given && ! override)
606     continue;
607     local_args_info.vacancyPCT_given = 1;
608     args_info->vacancyPCT_given = 1;
609 chuckv 3044 args_info->vacancyPCT_arg = strtod (optarg, &stop_char);
610     if (!(stop_char && *stop_char == '\0')) {
611     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
612     goto failure;
613     }
614     if (args_info->vacancyPCT_orig)
615     free (args_info->vacancyPCT_orig); /* free previous string */
616     args_info->vacancyPCT_orig = gengetopt_strdup (optarg);
617 chuckv 2352 }
618     /* Radius arround core-shell where vacancies should be located.. */
619     else if (strcmp (long_options[option_index].name, "vacancyRadius") == 0)
620     {
621     local_args_info.vacancyRadius_given++;
622    
623     multi_token = get_multiple_arg_token(optarg);
624     multi_next = get_multiple_arg_token_next (optarg);
625    
626     while (1)
627     {
628     vacancyRadius_new = (struct vacancyRadius_list *) malloc (sizeof (struct vacancyRadius_list));
629     vacancyRadius_new->next = vacancyRadius_list;
630     vacancyRadius_list = vacancyRadius_new;
631 chuckv 3044 vacancyRadius_new->vacancyRadius_arg = strtod (multi_token, &stop_char);
632     if (!(stop_char && *stop_char == '\0')) {
633     fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], multi_token);
634     goto failure;
635     }
636     vacancyRadius_new->vacancyRadius_orig = multi_token;
637 chuckv 2352
638     if (multi_next)
639     {
640     multi_token = get_multiple_arg_token(multi_next);
641     multi_next = get_multiple_arg_token_next (multi_next);
642     local_args_info.vacancyRadius_given++;
643     }
644     else
645     break;
646     }
647     break;
648     }
649    
650     break;
651     case '?': /* Invalid option. */
652     /* `getopt_long' already printed an error message. */
653     goto failure;
654    
655     default: /* bug: option not considered. */
656     fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
657     abort ();
658     } /* switch */
659     } /* while */
660    
661    
662     if (local_args_info.ShellRadius_given && ShellRadius_list)
663     {
664     struct ShellRadius_list *tmp;
665     args_info->ShellRadius_arg = (double *) realloc (args_info->ShellRadius_arg, (args_info->ShellRadius_given + local_args_info.ShellRadius_given) * sizeof (double));
666 chuckv 3044 args_info->ShellRadius_orig = (char **) realloc (args_info->ShellRadius_orig, (args_info->ShellRadius_given + local_args_info.ShellRadius_given) * sizeof (char *));
667 chuckv 2352 for (i = (local_args_info.ShellRadius_given - 1); i >= 0; --i)
668     {
669     tmp = ShellRadius_list;
670     args_info->ShellRadius_arg [i + args_info->ShellRadius_given] = ShellRadius_list->ShellRadius_arg;
671 chuckv 3044 args_info->ShellRadius_orig [i + args_info->ShellRadius_given] = ShellRadius_list->ShellRadius_orig;
672 chuckv 2352 ShellRadius_list = ShellRadius_list->next;
673     free (tmp);
674     }
675     }
676    
677     if (local_args_info.molFraction_given && molFraction_list)
678     {
679     struct molFraction_list *tmp;
680     args_info->molFraction_arg = (double *) realloc (args_info->molFraction_arg, (args_info->molFraction_given + local_args_info.molFraction_given) * sizeof (double));
681 chuckv 3044 args_info->molFraction_orig = (char **) realloc (args_info->molFraction_orig, (args_info->molFraction_given + local_args_info.molFraction_given) * sizeof (char *));
682 chuckv 2352 for (i = (local_args_info.molFraction_given - 1); i >= 0; --i)
683     {
684     tmp = molFraction_list;
685     args_info->molFraction_arg [i + args_info->molFraction_given] = molFraction_list->molFraction_arg;
686 chuckv 3044 args_info->molFraction_orig [i + args_info->molFraction_given] = molFraction_list->molFraction_orig;
687 chuckv 2352 molFraction_list = molFraction_list->next;
688     free (tmp);
689     }
690     }
691    
692     if (local_args_info.vacancyRadius_given && vacancyRadius_list)
693     {
694     struct vacancyRadius_list *tmp;
695     args_info->vacancyRadius_arg = (double *) realloc (args_info->vacancyRadius_arg, (args_info->vacancyRadius_given + local_args_info.vacancyRadius_given) * sizeof (double));
696 chuckv 3044 args_info->vacancyRadius_orig = (char **) realloc (args_info->vacancyRadius_orig, (args_info->vacancyRadius_given + local_args_info.vacancyRadius_given) * sizeof (char *));
697 chuckv 2352 for (i = (local_args_info.vacancyRadius_given - 1); i >= 0; --i)
698     {
699     tmp = vacancyRadius_list;
700     args_info->vacancyRadius_arg [i + args_info->vacancyRadius_given] = vacancyRadius_list->vacancyRadius_arg;
701 chuckv 3044 args_info->vacancyRadius_orig [i + args_info->vacancyRadius_given] = vacancyRadius_list->vacancyRadius_orig;
702 chuckv 2352 vacancyRadius_list = vacancyRadius_list->next;
703     free (tmp);
704     }
705     }
706    
707    
708     args_info->ShellRadius_given += local_args_info.ShellRadius_given;
709     local_args_info.ShellRadius_given = 0;
710     args_info->molFraction_given += local_args_info.molFraction_given;
711     local_args_info.molFraction_given = 0;
712     args_info->vacancyRadius_given += local_args_info.vacancyRadius_given;
713     local_args_info.vacancyRadius_given = 0;
714    
715     if (check_required)
716     {
717     error += cmdline_parser_required2 (args_info, argv[0], additional_error);
718     }
719    
720 chuckv 3044 cmdline_parser_release (&local_args_info);
721 chuckv 2352
722     if ( error )
723     return (EXIT_FAILURE);
724    
725     if (optind < argc)
726     {
727     int i = 0 ;
728    
729     args_info->inputs_num = argc - optind ;
730     args_info->inputs =
731     (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
732     while (optind < argc)
733     args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind++]) ;
734     }
735    
736     return 0;
737    
738     failure:
739     if (ShellRadius_list)
740     {
741     struct ShellRadius_list *tmp;
742     while (ShellRadius_list)
743     {
744     tmp = ShellRadius_list;
745 chuckv 3044 free (ShellRadius_list->ShellRadius_orig);
746 chuckv 2352 ShellRadius_list = ShellRadius_list->next;
747     free (tmp);
748     }
749     }
750     if (molFraction_list)
751     {
752     struct molFraction_list *tmp;
753     while (molFraction_list)
754     {
755     tmp = molFraction_list;
756 chuckv 3044 free (molFraction_list->molFraction_orig);
757 chuckv 2352 molFraction_list = molFraction_list->next;
758     free (tmp);
759     }
760     }
761     if (vacancyRadius_list)
762     {
763     struct vacancyRadius_list *tmp;
764     while (vacancyRadius_list)
765     {
766     tmp = vacancyRadius_list;
767 chuckv 3044 free (vacancyRadius_list->vacancyRadius_orig);
768 chuckv 2352 vacancyRadius_list = vacancyRadius_list->next;
769     free (tmp);
770     }
771     }
772    
773 chuckv 3044 cmdline_parser_release (&local_args_info);
774 chuckv 2352 return (EXIT_FAILURE);
775     }