--- trunk/src/applications/nanoparticleBuilder/nanoparticleBuilderCmd.c 2005/10/11 21:57:22 653 +++ trunk/src/applications/nanoparticleBuilder/nanoparticleBuilderCmd.c 2006/10/18 19:35:07 1077 @@ -1,7 +1,7 @@ /* - File autogenerated by gengetopt version 2.13 + File autogenerated by gengetopt version 2.13.1 generated with the following command: - gengetopt -u -F nanoparticleBuilderCmd + gengetopt -F nanoparticleBuilderCmd --unamed-opts --no-handle-error The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: @@ -32,10 +32,10 @@ cmdline_parser_required2 (struct gengetopt_args_info * static int cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error); -struct ShellRadius_list +struct shellRadius_list { - double ShellRadius_arg; - struct ShellRadius_list * next; + double shellRadius_arg; + struct shellRadius_list * next; }; struct molFraction_list @@ -44,12 +44,6 @@ struct molFraction_list struct molFraction_list * next; }; -struct vacancyRadius_list -{ - double vacancyRadius_arg; - struct vacancyRadius_list * next; -}; - static char * gengetopt_strdup (const char *s); @@ -59,23 +53,21 @@ void clear_given (struct gengetopt_args_info *args_inf args_info->help_given = 0 ; args_info->version_given = 0 ; args_info->output_given = 0 ; - args_info->latticetype_given = 0 ; - args_info->latticeCnst_given = 0 ; + args_info->latticeConstant_given = 0 ; args_info->radius_given = 0 ; - args_info->ShellRadius_given = 0 ; + args_info->shellRadius_given = 0 ; args_info->molFraction_given = 0 ; - args_info->vacancyPCT_given = 0 ; - args_info->vacancyRadius_given = 0 ; + args_info->vacancyPercent_given = 0 ; + args_info->vacancyInnerRadius_given = 0 ; + args_info->vacancyOuterRadius_given = 0 ; } static void clear_args (struct gengetopt_args_info *args_info) { args_info->output_arg = NULL; - args_info->latticetype_arg = gengetopt_strdup ("fcc"); - args_info->ShellRadius_arg = NULL; + args_info->shellRadius_arg = NULL; args_info->molFraction_arg = NULL; - args_info->vacancyRadius_arg = NULL; } void @@ -88,18 +80,18 @@ cmdline_parser_print_help (void) cmdline_parser_print_help (void) { cmdline_parser_print_version (); - printf("\n%s\n", "Builds spherical random or core-shell nanoparticles and outputs a xyz input \nfile"); + printf("\n%s\n", "Builds spherical random or core-shell nanoparticles and outputs an OOPSE \nstartup file"); printf("\nUsage: nanoparticleBuilder [OPTIONS]... [FILES]...\n\n"); - printf("%s\n"," -h, --help Print help and exit"); - printf("%s\n"," -V, --version Print version and exit"); - printf("%s\n"," -o, --output=STRING Output file name"); - printf("%s\n"," --latticetype=STRING Lattice type string. Valid types are fcc,hcp,bcc. \n (default=`fcc')"); - printf("%s\n"," --latticeCnst=DOUBLE Lattice spacing in Angstroms for cubic lattice."); - printf("%s\n"," --radius=DOUBLE Nanoparticle radius in Angstroms"); - 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."); - 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."); - printf("%s\n"," --vacancyPCT=DOUBLE Percentage of vacancies to build"); - printf("%s\n"," --vacancyRadius=DOUBLE Radius arround core-shell where vacancies should \n be located."); + printf("%s\n"," -h, --help Print help and exit"); + printf("%s\n"," -V, --version Print version and exit"); + printf("%s\n"," -o, --output=STRING Output file name"); + printf("%s\n"," --latticeConstant=DOUBLE Lattice spacing in Angstroms for cubic lattice."); + printf("%s\n"," --radius=DOUBLE Nanoparticle radius in Angstroms"); + printf("%s\n"," --shellRadius=DOUBLE Radius containing within it only molecules of a \n specific component. Specified for each \n component > 1 in the template file."); + printf("%s\n"," --molFraction=DOUBLE Builds a multi-component random alloy \n nanoparticle. A mole Fraction must be \n specified for each component > 1 in the \n template file."); + printf("%s\n"," --vacancyPercent=DOUBLE Percentage of atoms to remove from within \n vacancy range"); + printf("%s\n"," --vacancyInnerRadius=DOUBLE\n Radius arround core-shell where vacancies \n should be located."); + printf("%s\n"," --vacancyOuterRadius=DOUBLE\n Radius arround core-shell where vacancies \n should be located."); } @@ -123,26 +115,16 @@ cmdline_parser_free (struct gengetopt_args_info *args_ free (args_info->output_arg); /* free previous argument */ args_info->output_arg = 0; } - if (args_info->latticetype_arg) + if (args_info->shellRadius_arg) { - free (args_info->latticetype_arg); /* free previous argument */ - args_info->latticetype_arg = 0; + free (args_info->shellRadius_arg); /* free previous argument */ + args_info->shellRadius_arg = 0; } - if (args_info->ShellRadius_arg) - { - free (args_info->ShellRadius_arg); /* free previous argument */ - args_info->ShellRadius_arg = 0; - } if (args_info->molFraction_arg) { free (args_info->molFraction_arg); /* free previous argument */ args_info->molFraction_arg = 0; } - if (args_info->vacancyRadius_arg) - { - free (args_info->vacancyRadius_arg); /* free previous argument */ - args_info->vacancyRadius_arg = 0; - } for (i = 0; i < args_info->inputs_num; ++i) free (args_info->inputs [i]); @@ -221,12 +203,6 @@ cmdline_parser2 (int argc, char * const *argv, struct result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL); - if (result == EXIT_FAILURE) - { - cmdline_parser_free (args_info); - exit (EXIT_FAILURE); - } - return result; } @@ -238,12 +214,6 @@ cmdline_parser_required (struct gengetopt_args_info *a if (cmdline_parser_required2(args_info, prog_name, NULL) > 0) result = EXIT_FAILURE; - if (result == EXIT_FAILURE) - { - cmdline_parser_free (args_info); - exit (EXIT_FAILURE); - } - return result; } @@ -252,11 +222,16 @@ cmdline_parser_required2 (struct gengetopt_args_info * { int error = 0; - if (! args_info->latticeCnst_given) + if (! args_info->output_given) { - fprintf (stderr, "%s: '--latticeCnst' option required%s\n", prog_name, (additional_error ? additional_error : "")); + fprintf (stderr, "%s: '--output' ('-o') option required%s\n", prog_name, (additional_error ? additional_error : "")); error = 1; } + if (! args_info->latticeConstant_given) + { + fprintf (stderr, "%s: '--latticeConstant' option required%s\n", prog_name, (additional_error ? additional_error : "")); + error = 1; + } if (! args_info->radius_given) { fprintf (stderr, "%s: '--radius' option required%s\n", prog_name, (additional_error ? additional_error : "")); @@ -274,9 +249,8 @@ cmdline_parser_internal (int argc, char * const *argv, int i; /* Counter */ - struct ShellRadius_list * ShellRadius_list = NULL,* ShellRadius_new = NULL; + struct shellRadius_list * shellRadius_list = NULL,* shellRadius_new = NULL; struct molFraction_list * molFraction_list = NULL,* molFraction_new = NULL; - struct vacancyRadius_list * vacancyRadius_list = NULL,* vacancyRadius_new = NULL; int error = 0; struct gengetopt_args_info local_args_info; @@ -299,13 +273,13 @@ cmdline_parser_internal (int argc, char * const *argv, { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, { "output", 1, NULL, 'o' }, - { "latticetype", 1, NULL, 0 }, - { "latticeCnst", 1, NULL, 0 }, + { "latticeConstant", 1, NULL, 0 }, { "radius", 1, NULL, 0 }, - { "ShellRadius", 1, NULL, 0 }, + { "shellRadius", 1, NULL, 0 }, { "molFraction", 1, NULL, 0 }, - { "vacancyPCT", 1, NULL, 0 }, - { "vacancyRadius", 1, NULL, 0 }, + { "vacancyPercent", 1, NULL, 0 }, + { "vacancyInnerRadius", 1, NULL, 0 }, + { "vacancyOuterRadius", 1, NULL, 0 }, { NULL, 0, NULL, 0 } }; @@ -318,10 +292,12 @@ cmdline_parser_internal (int argc, char * const *argv, { case 'h': /* Print help and exit. */ cmdline_parser_print_help (); + cmdline_parser_free (&local_args_info); exit (EXIT_SUCCESS); case 'V': /* Print version and exit. */ cmdline_parser_print_version (); + cmdline_parser_free (&local_args_info); exit (EXIT_SUCCESS); case 'o': /* Output file name. */ @@ -341,35 +317,19 @@ cmdline_parser_internal (int argc, char * const *argv, case 0: /* Long option with no short option */ - /* Lattice type string. Valid types are fcc,hcp,bcc.. */ - if (strcmp (long_options[option_index].name, "latticetype") == 0) - { - if (local_args_info.latticetype_given) - { - fprintf (stderr, "%s: `--latticetype' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); - goto failure; - } - if (args_info->latticetype_given && ! override) - continue; - local_args_info.latticetype_given = 1; - args_info->latticetype_given = 1; - if (args_info->latticetype_arg) - free (args_info->latticetype_arg); /* free previous string */ - args_info->latticetype_arg = gengetopt_strdup (optarg); - } /* Lattice spacing in Angstroms for cubic lattice.. */ - else if (strcmp (long_options[option_index].name, "latticeCnst") == 0) + if (strcmp (long_options[option_index].name, "latticeConstant") == 0) { - if (local_args_info.latticeCnst_given) + if (local_args_info.latticeConstant_given) { - fprintf (stderr, "%s: `--latticeCnst' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); + fprintf (stderr, "%s: `--latticeConstant' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } - if (args_info->latticeCnst_given && ! override) + if (args_info->latticeConstant_given && ! override) continue; - local_args_info.latticeCnst_given = 1; - args_info->latticeCnst_given = 1; - args_info->latticeCnst_arg = strtod (optarg, NULL); + local_args_info.latticeConstant_given = 1; + args_info->latticeConstant_given = 1; + args_info->latticeConstant_arg = strtod (optarg, NULL); } /* Nanoparticle radius in Angstroms. */ else if (strcmp (long_options[option_index].name, "radius") == 0) @@ -385,34 +345,34 @@ cmdline_parser_internal (int argc, char * const *argv, args_info->radius_given = 1; args_info->radius_arg = strtod (optarg, NULL); } - /* 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.. */ - else if (strcmp (long_options[option_index].name, "ShellRadius") == 0) + /* Radius containing within it only molecules of a specific component. Specified for each component > 1 in the template file.. */ + else if (strcmp (long_options[option_index].name, "shellRadius") == 0) { - local_args_info.ShellRadius_given++; + local_args_info.shellRadius_given++; multi_token = get_multiple_arg_token(optarg); multi_next = get_multiple_arg_token_next (optarg); while (1) { - ShellRadius_new = (struct ShellRadius_list *) malloc (sizeof (struct ShellRadius_list)); - ShellRadius_new->next = ShellRadius_list; - ShellRadius_list = ShellRadius_new; - ShellRadius_new->ShellRadius_arg = strtod (multi_token, NULL); + shellRadius_new = (struct shellRadius_list *) malloc (sizeof (struct shellRadius_list)); + shellRadius_new->next = shellRadius_list; + shellRadius_list = shellRadius_new; + shellRadius_new->shellRadius_arg = strtod (multi_token, NULL); free (multi_token); if (multi_next) { multi_token = get_multiple_arg_token(multi_next); multi_next = get_multiple_arg_token_next (multi_next); - local_args_info.ShellRadius_given++; + local_args_info.shellRadius_given++; } else break; } break; } - /* (Default) Builds a multi-component random mixed nanoparticle. Mole Fraction must be specified for each componet > 1 in MD file.. */ + /* Builds a multi-component random alloy nanoparticle. A mole Fraction must be specified for each component > 1 in the template file.. */ else if (strcmp (long_options[option_index].name, "molFraction") == 0) { local_args_info.molFraction_given++; @@ -439,47 +399,48 @@ cmdline_parser_internal (int argc, char * const *argv, } break; } - /* Percentage of vacancies to build. */ - else if (strcmp (long_options[option_index].name, "vacancyPCT") == 0) + /* Percentage of atoms to remove from within vacancy range. */ + else if (strcmp (long_options[option_index].name, "vacancyPercent") == 0) { - if (local_args_info.vacancyPCT_given) + if (local_args_info.vacancyPercent_given) { - fprintf (stderr, "%s: `--vacancyPCT' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); + fprintf (stderr, "%s: `--vacancyPercent' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } - if (args_info->vacancyPCT_given && ! override) + if (args_info->vacancyPercent_given && ! override) continue; - local_args_info.vacancyPCT_given = 1; - args_info->vacancyPCT_given = 1; - args_info->vacancyPCT_arg = strtod (optarg, NULL); + local_args_info.vacancyPercent_given = 1; + args_info->vacancyPercent_given = 1; + args_info->vacancyPercent_arg = strtod (optarg, NULL); } /* Radius arround core-shell where vacancies should be located.. */ - else if (strcmp (long_options[option_index].name, "vacancyRadius") == 0) + else if (strcmp (long_options[option_index].name, "vacancyInnerRadius") == 0) { - local_args_info.vacancyRadius_given++; - - multi_token = get_multiple_arg_token(optarg); - multi_next = get_multiple_arg_token_next (optarg); - - while (1) + if (local_args_info.vacancyInnerRadius_given) { - vacancyRadius_new = (struct vacancyRadius_list *) malloc (sizeof (struct vacancyRadius_list)); - vacancyRadius_new->next = vacancyRadius_list; - vacancyRadius_list = vacancyRadius_new; - vacancyRadius_new->vacancyRadius_arg = strtod (multi_token, NULL); - free (multi_token); - - if (multi_next) - { - multi_token = get_multiple_arg_token(multi_next); - multi_next = get_multiple_arg_token_next (multi_next); - local_args_info.vacancyRadius_given++; - } - else - break; + fprintf (stderr, "%s: `--vacancyInnerRadius' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); + goto failure; } - break; + if (args_info->vacancyInnerRadius_given && ! override) + continue; + local_args_info.vacancyInnerRadius_given = 1; + args_info->vacancyInnerRadius_given = 1; + args_info->vacancyInnerRadius_arg = strtod (optarg, NULL); } + /* Radius arround core-shell where vacancies should be located.. */ + else if (strcmp (long_options[option_index].name, "vacancyOuterRadius") == 0) + { + if (local_args_info.vacancyOuterRadius_given) + { + fprintf (stderr, "%s: `--vacancyOuterRadius' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); + goto failure; + } + if (args_info->vacancyOuterRadius_given && ! override) + continue; + local_args_info.vacancyOuterRadius_given = 1; + args_info->vacancyOuterRadius_given = 1; + args_info->vacancyOuterRadius_arg = strtod (optarg, NULL); + } break; case '?': /* Invalid option. */ @@ -493,15 +454,15 @@ cmdline_parser_internal (int argc, char * const *argv, } /* while */ - if (local_args_info.ShellRadius_given && ShellRadius_list) + if (local_args_info.shellRadius_given && shellRadius_list) { - struct ShellRadius_list *tmp; - args_info->ShellRadius_arg = (double *) realloc (args_info->ShellRadius_arg, (args_info->ShellRadius_given + local_args_info.ShellRadius_given) * sizeof (double)); - for (i = (local_args_info.ShellRadius_given - 1); i >= 0; --i) + struct shellRadius_list *tmp; + args_info->shellRadius_arg = (double *) realloc (args_info->shellRadius_arg, (args_info->shellRadius_given + local_args_info.shellRadius_given) * sizeof (double)); + for (i = (local_args_info.shellRadius_given - 1); i >= 0; --i) { - tmp = ShellRadius_list; - args_info->ShellRadius_arg [i + args_info->ShellRadius_given] = ShellRadius_list->ShellRadius_arg; - ShellRadius_list = ShellRadius_list->next; + tmp = shellRadius_list; + args_info->shellRadius_arg [i + args_info->shellRadius_given] = shellRadius_list->shellRadius_arg; + shellRadius_list = shellRadius_list->next; free (tmp); } } @@ -519,26 +480,11 @@ cmdline_parser_internal (int argc, char * const *argv, } } - if (local_args_info.vacancyRadius_given && vacancyRadius_list) - { - struct vacancyRadius_list *tmp; - args_info->vacancyRadius_arg = (double *) realloc (args_info->vacancyRadius_arg, (args_info->vacancyRadius_given + local_args_info.vacancyRadius_given) * sizeof (double)); - for (i = (local_args_info.vacancyRadius_given - 1); i >= 0; --i) - { - tmp = vacancyRadius_list; - args_info->vacancyRadius_arg [i + args_info->vacancyRadius_given] = vacancyRadius_list->vacancyRadius_arg; - vacancyRadius_list = vacancyRadius_list->next; - free (tmp); - } - } - - args_info->ShellRadius_given += local_args_info.ShellRadius_given; - local_args_info.ShellRadius_given = 0; + args_info->shellRadius_given += local_args_info.shellRadius_given; + local_args_info.shellRadius_given = 0; args_info->molFraction_given += local_args_info.molFraction_given; local_args_info.molFraction_given = 0; - args_info->vacancyRadius_given += local_args_info.vacancyRadius_given; - local_args_info.vacancyRadius_given = 0; if (check_required) { @@ -564,13 +510,13 @@ failure: return 0; failure: - if (ShellRadius_list) + if (shellRadius_list) { - struct ShellRadius_list *tmp; - while (ShellRadius_list) + struct shellRadius_list *tmp; + while (shellRadius_list) { - tmp = ShellRadius_list; - ShellRadius_list = ShellRadius_list->next; + tmp = shellRadius_list; + shellRadius_list = shellRadius_list->next; free (tmp); } } @@ -584,16 +530,6 @@ failure: free (tmp); } } - if (vacancyRadius_list) - { - struct vacancyRadius_list *tmp; - while (vacancyRadius_list) - { - tmp = vacancyRadius_list; - vacancyRadius_list = vacancyRadius_list->next; - free (tmp); - } - } cmdline_parser_free (&local_args_info); return (EXIT_FAILURE);