ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/nanoparticleBuilder/nanoparticleBuilderCmd.cpp
(Generate patch)

Comparing trunk/src/applications/nanoparticleBuilder/nanoparticleBuilderCmd.c (file contents):
Revision 653 by chuckv, Tue Oct 11 21:57:22 2005 UTC vs.
Revision 1077 by gezelter, Wed Oct 18 19:35:07 2006 UTC

# Line 1 | Line 1
1   /*
2 <  File autogenerated by gengetopt version 2.13
2 >  File autogenerated by gengetopt version 2.13.1
3    generated with the following command:
4 <  gengetopt -u -F nanoparticleBuilderCmd
4 >  gengetopt -F nanoparticleBuilderCmd --unamed-opts --no-handle-error
5  
6    The developers of gengetopt consider the fixed text that goes in all
7    gengetopt output files to be in the public domain:
# Line 32 | Line 32 | cmdline_parser_required2 (struct gengetopt_args_info *
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
35 > struct shellRadius_list
36   {
37 <  double ShellRadius_arg;
38 <  struct ShellRadius_list * next;
37 >  double shellRadius_arg;
38 >  struct shellRadius_list * next;
39   };
40  
41   struct molFraction_list
# Line 44 | Line 44 | struct molFraction_list
44    struct molFraction_list * next;
45   };
46  
47 struct vacancyRadius_list
48 {
49  double vacancyRadius_arg;
50  struct vacancyRadius_list * next;
51 };
52
47   static char *
48   gengetopt_strdup (const char *s);
49  
# Line 59 | Line 53 | void clear_given (struct gengetopt_args_info *args_inf
53    args_info->help_given = 0 ;
54    args_info->version_given = 0 ;
55    args_info->output_given = 0 ;
56 <  args_info->latticetype_given = 0 ;
63 <  args_info->latticeCnst_given = 0 ;
56 >  args_info->latticeConstant_given = 0 ;
57    args_info->radius_given = 0 ;
58 <  args_info->ShellRadius_given = 0 ;
58 >  args_info->shellRadius_given = 0 ;
59    args_info->molFraction_given = 0 ;
60 <  args_info->vacancyPCT_given = 0 ;
61 <  args_info->vacancyRadius_given = 0 ;
60 >  args_info->vacancyPercent_given = 0 ;
61 >  args_info->vacancyInnerRadius_given = 0 ;
62 >  args_info->vacancyOuterRadius_given = 0 ;
63   }
64  
65   static
66   void clear_args (struct gengetopt_args_info *args_info)
67   {
68    args_info->output_arg = NULL;
69 <  args_info->latticetype_arg = gengetopt_strdup ("fcc");
76 <  args_info->ShellRadius_arg = NULL;
69 >  args_info->shellRadius_arg = NULL;
70    args_info->molFraction_arg = NULL;
78  args_info->vacancyRadius_arg = NULL;
71   }
72  
73   void
# Line 88 | Line 80 | cmdline_parser_print_help (void)
80   cmdline_parser_print_help (void)
81   {
82    cmdline_parser_print_version ();
83 <  printf("\n%s\n", "Builds spherical random or core-shell nanoparticles and outputs a xyz input \nfile");
83 >  printf("\n%s\n", "Builds spherical random or core-shell nanoparticles and outputs an OOPSE \nstartup file");
84    printf("\nUsage: nanoparticleBuilder [OPTIONS]... [FILES]...\n\n");
85 <  printf("%s\n","  -h, --help                  Print help and exit");
86 <  printf("%s\n","  -V, --version               Print version and exit");
87 <  printf("%s\n","  -o, --output=STRING         Output file name");
88 <  printf("%s\n","      --latticetype=STRING    Lattice type string. Valid types are fcc,hcp,bcc. \n                                 (default=`fcc')");
89 <  printf("%s\n","      --latticeCnst=DOUBLE    Lattice spacing in Angstroms for cubic lattice.");
90 <  printf("%s\n","      --radius=DOUBLE         Nanoparticle radius in Angstroms");
91 <  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.");
92 <  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.");
93 <  printf("%s\n","      --vacancyPCT=DOUBLE     Percentage of vacancies to build");
94 <  printf("%s\n","      --vacancyRadius=DOUBLE  Radius arround core-shell where vacancies should \n                                be located.");
85 >  printf("%s\n","  -h, --help                    Print help and exit");
86 >  printf("%s\n","  -V, --version                 Print version and exit");
87 >  printf("%s\n","  -o, --output=STRING           Output file name");
88 >  printf("%s\n","      --latticeConstant=DOUBLE  Lattice spacing in Angstroms for cubic lattice.");
89 >  printf("%s\n","      --radius=DOUBLE           Nanoparticle radius in Angstroms");
90 >  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.");
91 >  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.");
92 >  printf("%s\n","      --vacancyPercent=DOUBLE   Percentage of atoms to remove from within \n                                  vacancy range");
93 >  printf("%s\n","      --vacancyInnerRadius=DOUBLE\n                                Radius arround core-shell where vacancies \n                                  should be located.");
94 >  printf("%s\n","      --vacancyOuterRadius=DOUBLE\n                                Radius arround core-shell where vacancies \n                                  should be located.");
95    
96   }
97  
# Line 123 | Line 115 | cmdline_parser_free (struct gengetopt_args_info *args_
115        free (args_info->output_arg); /* free previous argument */
116        args_info->output_arg = 0;
117      }
118 <  if (args_info->latticetype_arg)
118 >  if (args_info->shellRadius_arg)
119      {
120 <      free (args_info->latticetype_arg); /* free previous argument */
121 <      args_info->latticetype_arg = 0;
120 >      free (args_info->shellRadius_arg); /* free previous argument */
121 >      args_info->shellRadius_arg = 0;
122      }
131  if (args_info->ShellRadius_arg)
132    {
133      free (args_info->ShellRadius_arg); /* free previous argument */
134      args_info->ShellRadius_arg = 0;
135    }
123    if (args_info->molFraction_arg)
124      {
125        free (args_info->molFraction_arg); /* free previous argument */
126        args_info->molFraction_arg = 0;
127      }
141  if (args_info->vacancyRadius_arg)
142    {
143      free (args_info->vacancyRadius_arg); /* free previous argument */
144      args_info->vacancyRadius_arg = 0;
145    }
128    
129    for (i = 0; i < args_info->inputs_num; ++i)
130      free (args_info->inputs [i]);
# Line 221 | Line 203 | cmdline_parser2 (int argc, char * const *argv, struct
203  
204    result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL);
205  
224  if (result == EXIT_FAILURE)
225    {
226      cmdline_parser_free (args_info);
227      exit (EXIT_FAILURE);
228    }
229  
206    return result;
207   }
208  
# Line 238 | Line 214 | cmdline_parser_required (struct gengetopt_args_info *a
214    if (cmdline_parser_required2(args_info, prog_name, NULL) > 0)
215      result = EXIT_FAILURE;
216  
241  if (result == EXIT_FAILURE)
242    {
243      cmdline_parser_free (args_info);
244      exit (EXIT_FAILURE);
245    }
246  
217    return result;
218   }
219  
# Line 252 | Line 222 | cmdline_parser_required2 (struct gengetopt_args_info *
222   {
223    int error = 0;
224  
225 <  if (! args_info->latticeCnst_given)
225 >  if (! args_info->output_given)
226      {
227 <      fprintf (stderr, "%s: '--latticeCnst' option required%s\n", prog_name, (additional_error ? additional_error : ""));
227 >      fprintf (stderr, "%s: '--output' ('-o') option required%s\n", prog_name, (additional_error ? additional_error : ""));
228        error = 1;
229      }
230 +  if (! args_info->latticeConstant_given)
231 +    {
232 +      fprintf (stderr, "%s: '--latticeConstant' option required%s\n", prog_name, (additional_error ? additional_error : ""));
233 +      error = 1;
234 +    }
235    if (! args_info->radius_given)
236      {
237        fprintf (stderr, "%s: '--radius' option required%s\n", prog_name, (additional_error ? additional_error : ""));
# Line 274 | Line 249 | cmdline_parser_internal (int argc, char * const *argv,
249  
250    int i;        /* Counter */
251  
252 <  struct ShellRadius_list * ShellRadius_list = NULL,* ShellRadius_new = NULL;
252 >  struct shellRadius_list * shellRadius_list = NULL,* shellRadius_new = NULL;
253    struct molFraction_list * molFraction_list = NULL,* molFraction_new = NULL;
279  struct vacancyRadius_list * vacancyRadius_list = NULL,* vacancyRadius_new = NULL;
254    int error = 0;
255    struct gengetopt_args_info local_args_info;
256  
# Line 299 | Line 273 | cmdline_parser_internal (int argc, char * const *argv,
273          { "help",       0, NULL, 'h' },
274          { "version",    0, NULL, 'V' },
275          { "output",     1, NULL, 'o' },
276 <        { "latticetype",        1, NULL, 0 },
303 <        { "latticeCnst",        1, NULL, 0 },
276 >        { "latticeConstant",    1, NULL, 0 },
277          { "radius",     1, NULL, 0 },
278 <        { "ShellRadius",        1, NULL, 0 },
278 >        { "shellRadius",        1, NULL, 0 },
279          { "molFraction",        1, NULL, 0 },
280 <        { "vacancyPCT", 1, NULL, 0 },
281 <        { "vacancyRadius",      1, NULL, 0 },
280 >        { "vacancyPercent",     1, NULL, 0 },
281 >        { "vacancyInnerRadius", 1, NULL, 0 },
282 >        { "vacancyOuterRadius", 1, NULL, 0 },
283          { NULL, 0, NULL, 0 }
284        };
285  
# Line 318 | Line 292 | cmdline_parser_internal (int argc, char * const *argv,
292          {
293          case 'h':       /* Print help and exit.  */
294            cmdline_parser_print_help ();
295 +          cmdline_parser_free (&local_args_info);
296            exit (EXIT_SUCCESS);
297  
298          case 'V':       /* Print version and exit.  */
299            cmdline_parser_print_version ();
300 +          cmdline_parser_free (&local_args_info);
301            exit (EXIT_SUCCESS);
302  
303          case 'o':       /* Output file name.  */
# Line 341 | Line 317 | cmdline_parser_internal (int argc, char * const *argv,
317  
318  
319          case 0: /* Long option with no short option */
344          /* Lattice type string. Valid types are fcc,hcp,bcc..  */
345          if (strcmp (long_options[option_index].name, "latticetype") == 0)
346          {
347            if (local_args_info.latticetype_given)
348              {
349                fprintf (stderr, "%s: `--latticetype' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
350                goto failure;
351              }
352            if (args_info->latticetype_given && ! override)
353              continue;
354            local_args_info.latticetype_given = 1;
355            args_info->latticetype_given = 1;
356            if (args_info->latticetype_arg)
357              free (args_info->latticetype_arg); /* free previous string */
358            args_info->latticetype_arg = gengetopt_strdup (optarg);
359          }
320            /* Lattice spacing in Angstroms for cubic lattice..  */
321 <          else if (strcmp (long_options[option_index].name, "latticeCnst") == 0)
321 >          if (strcmp (long_options[option_index].name, "latticeConstant") == 0)
322            {
323 <            if (local_args_info.latticeCnst_given)
323 >            if (local_args_info.latticeConstant_given)
324                {
325 <                fprintf (stderr, "%s: `--latticeCnst' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
325 >                fprintf (stderr, "%s: `--latticeConstant' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
326                  goto failure;
327                }
328 <            if (args_info->latticeCnst_given && ! override)
328 >            if (args_info->latticeConstant_given && ! override)
329                continue;
330 <            local_args_info.latticeCnst_given = 1;
331 <            args_info->latticeCnst_given = 1;
332 <            args_info->latticeCnst_arg = strtod (optarg, NULL);
330 >            local_args_info.latticeConstant_given = 1;
331 >            args_info->latticeConstant_given = 1;
332 >            args_info->latticeConstant_arg = strtod (optarg, NULL);
333            }
334            /* Nanoparticle radius in Angstroms.  */
335            else if (strcmp (long_options[option_index].name, "radius") == 0)
# Line 385 | Line 345 | cmdline_parser_internal (int argc, char * const *argv,
345              args_info->radius_given = 1;
346              args_info->radius_arg = strtod (optarg, NULL);
347            }
348 <          /* 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..  */
349 <          else if (strcmp (long_options[option_index].name, "ShellRadius") == 0)
348 >          /* Radius containing within it only molecules of a specific component. Specified for each component > 1 in the template file..  */
349 >          else if (strcmp (long_options[option_index].name, "shellRadius") == 0)
350            {
351 <            local_args_info.ShellRadius_given++;
351 >            local_args_info.shellRadius_given++;
352            
353              multi_token = get_multiple_arg_token(optarg);
354              multi_next = get_multiple_arg_token_next (optarg);
355            
356              while (1)
357                {
358 <                ShellRadius_new = (struct ShellRadius_list *) malloc (sizeof (struct ShellRadius_list));
359 <                ShellRadius_new->next = ShellRadius_list;
360 <                ShellRadius_list = ShellRadius_new;
361 <                ShellRadius_new->ShellRadius_arg = strtod (multi_token, NULL);
358 >                shellRadius_new = (struct shellRadius_list *) malloc (sizeof (struct shellRadius_list));
359 >                shellRadius_new->next = shellRadius_list;
360 >                shellRadius_list = shellRadius_new;
361 >                shellRadius_new->shellRadius_arg = strtod (multi_token, NULL);
362                  free (multi_token);
363            
364                  if (multi_next)
365                    {
366                      multi_token = get_multiple_arg_token(multi_next);
367                      multi_next = get_multiple_arg_token_next (multi_next);
368 <                    local_args_info.ShellRadius_given++;
368 >                    local_args_info.shellRadius_given++;
369                    }
370                  else
371                    break;
372                }
373              break;
374            }
375 <          /* (Default) Builds a multi-component random mixed nanoparticle. Mole Fraction must be specified for each componet > 1 in MD file..  */
375 >          /* Builds a multi-component random alloy nanoparticle. A mole Fraction must be specified for each component > 1 in the template file..  */
376            else if (strcmp (long_options[option_index].name, "molFraction") == 0)
377            {
378              local_args_info.molFraction_given++;
# Line 439 | Line 399 | cmdline_parser_internal (int argc, char * const *argv,
399                }
400              break;
401            }
402 <          /* Percentage of vacancies to build.  */
403 <          else if (strcmp (long_options[option_index].name, "vacancyPCT") == 0)
402 >          /* Percentage of atoms to remove from within vacancy range.  */
403 >          else if (strcmp (long_options[option_index].name, "vacancyPercent") == 0)
404            {
405 <            if (local_args_info.vacancyPCT_given)
405 >            if (local_args_info.vacancyPercent_given)
406                {
407 <                fprintf (stderr, "%s: `--vacancyPCT' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
407 >                fprintf (stderr, "%s: `--vacancyPercent' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
408                  goto failure;
409                }
410 <            if (args_info->vacancyPCT_given && ! override)
410 >            if (args_info->vacancyPercent_given && ! override)
411                continue;
412 <            local_args_info.vacancyPCT_given = 1;
413 <            args_info->vacancyPCT_given = 1;
414 <            args_info->vacancyPCT_arg = strtod (optarg, NULL);
412 >            local_args_info.vacancyPercent_given = 1;
413 >            args_info->vacancyPercent_given = 1;
414 >            args_info->vacancyPercent_arg = strtod (optarg, NULL);
415            }
416            /* Radius arround core-shell where vacancies should be located..  */
417 <          else if (strcmp (long_options[option_index].name, "vacancyRadius") == 0)
417 >          else if (strcmp (long_options[option_index].name, "vacancyInnerRadius") == 0)
418            {
419 <            local_args_info.vacancyRadius_given++;
460 <          
461 <            multi_token = get_multiple_arg_token(optarg);
462 <            multi_next = get_multiple_arg_token_next (optarg);
463 <          
464 <            while (1)
419 >            if (local_args_info.vacancyInnerRadius_given)
420                {
421 <                vacancyRadius_new = (struct vacancyRadius_list *) malloc (sizeof (struct vacancyRadius_list));
422 <                vacancyRadius_new->next = vacancyRadius_list;
468 <                vacancyRadius_list = vacancyRadius_new;
469 <                vacancyRadius_new->vacancyRadius_arg = strtod (multi_token, NULL);
470 <                free (multi_token);
471 <          
472 <                if (multi_next)
473 <                  {
474 <                    multi_token = get_multiple_arg_token(multi_next);
475 <                    multi_next = get_multiple_arg_token_next (multi_next);
476 <                    local_args_info.vacancyRadius_given++;
477 <                  }
478 <                else
479 <                  break;
421 >                fprintf (stderr, "%s: `--vacancyInnerRadius' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
422 >                goto failure;
423                }
424 <            break;
424 >            if (args_info->vacancyInnerRadius_given && ! override)
425 >              continue;
426 >            local_args_info.vacancyInnerRadius_given = 1;
427 >            args_info->vacancyInnerRadius_given = 1;
428 >            args_info->vacancyInnerRadius_arg = strtod (optarg, NULL);
429            }
430 +          /* Radius arround core-shell where vacancies should be located..  */
431 +          else if (strcmp (long_options[option_index].name, "vacancyOuterRadius") == 0)
432 +          {
433 +            if (local_args_info.vacancyOuterRadius_given)
434 +              {
435 +                fprintf (stderr, "%s: `--vacancyOuterRadius' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
436 +                goto failure;
437 +              }
438 +            if (args_info->vacancyOuterRadius_given && ! override)
439 +              continue;
440 +            local_args_info.vacancyOuterRadius_given = 1;
441 +            args_info->vacancyOuterRadius_given = 1;
442 +            args_info->vacancyOuterRadius_arg = strtod (optarg, NULL);
443 +          }
444            
445            break;
446          case '?':       /* Invalid option.  */
# Line 493 | Line 454 | cmdline_parser_internal (int argc, char * const *argv,
454      } /* while */
455  
456  
457 <  if (local_args_info.ShellRadius_given && ShellRadius_list)
457 >  if (local_args_info.shellRadius_given && shellRadius_list)
458      {
459 <      struct ShellRadius_list *tmp;
460 <      args_info->ShellRadius_arg = (double *) realloc (args_info->ShellRadius_arg, (args_info->ShellRadius_given + local_args_info.ShellRadius_given) * sizeof (double));
461 <      for (i = (local_args_info.ShellRadius_given - 1); i >= 0; --i)
459 >      struct shellRadius_list *tmp;
460 >      args_info->shellRadius_arg = (double *) realloc (args_info->shellRadius_arg, (args_info->shellRadius_given + local_args_info.shellRadius_given) * sizeof (double));
461 >      for (i = (local_args_info.shellRadius_given - 1); i >= 0; --i)
462          {
463 <          tmp = ShellRadius_list;
464 <          args_info->ShellRadius_arg [i + args_info->ShellRadius_given] = ShellRadius_list->ShellRadius_arg;
465 <          ShellRadius_list = ShellRadius_list->next;
463 >          tmp = shellRadius_list;
464 >          args_info->shellRadius_arg [i + args_info->shellRadius_given] = shellRadius_list->shellRadius_arg;
465 >          shellRadius_list = shellRadius_list->next;
466            free (tmp);
467          }
468      }
# Line 519 | Line 480 | cmdline_parser_internal (int argc, char * const *argv,
480          }
481      }
482    
522  if (local_args_info.vacancyRadius_given && vacancyRadius_list)
523    {
524      struct vacancyRadius_list *tmp;
525      args_info->vacancyRadius_arg = (double *) realloc (args_info->vacancyRadius_arg, (args_info->vacancyRadius_given + local_args_info.vacancyRadius_given) * sizeof (double));
526      for (i = (local_args_info.vacancyRadius_given - 1); i >= 0; --i)
527        {
528          tmp = vacancyRadius_list;
529          args_info->vacancyRadius_arg [i + args_info->vacancyRadius_given] = vacancyRadius_list->vacancyRadius_arg;
530          vacancyRadius_list = vacancyRadius_list->next;
531          free (tmp);
532        }
533    }
534  
483  
484 <  args_info->ShellRadius_given += local_args_info.ShellRadius_given;
485 <  local_args_info.ShellRadius_given = 0;
484 >  args_info->shellRadius_given += local_args_info.shellRadius_given;
485 >  local_args_info.shellRadius_given = 0;
486    args_info->molFraction_given += local_args_info.molFraction_given;
487    local_args_info.molFraction_given = 0;
540  args_info->vacancyRadius_given += local_args_info.vacancyRadius_given;
541  local_args_info.vacancyRadius_given = 0;
488    
489    if (check_required)
490      {
# Line 564 | Line 510 | failure:
510    return 0;
511  
512   failure:
513 <  if (ShellRadius_list)
513 >  if (shellRadius_list)
514      {
515 <      struct ShellRadius_list *tmp;
516 <      while (ShellRadius_list)
515 >      struct shellRadius_list *tmp;
516 >      while (shellRadius_list)
517          {
518 <          tmp = ShellRadius_list;
519 <          ShellRadius_list = ShellRadius_list->next;
518 >          tmp = shellRadius_list;
519 >          shellRadius_list = shellRadius_list->next;
520            free (tmp);
521          }
522      }
# Line 584 | Line 530 | failure:
530            free (tmp);
531          }
532      }
587  if (vacancyRadius_list)
588    {
589      struct vacancyRadius_list *tmp;
590      while (vacancyRadius_list)
591        {
592          tmp = vacancyRadius_list;
593          vacancyRadius_list = vacancyRadius_list->next;
594          free (tmp);
595        }
596    }
533    
534    cmdline_parser_free (&local_args_info);
535    return (EXIT_FAILURE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines