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

Comparing branches/development/src/applications/nanoparticleBuilder/icosahedralBuilderCmd.cpp (file contents):
Revision 1861 by gezelter, Tue Apr 9 16:14:15 2013 UTC vs.
Revision 1862 by gezelter, Fri Apr 12 20:45:04 2013 UTC

# Line 35 | Line 35 | const char *gengetopt_args_info_help[] = {
35    "  -h, --help                    Print help and exit",
36    "  -V, --version                 Print version and exit",
37    "  -o, --output=STRING           Output file name",
38  "  -d, --latticeConstant=DOUBLE  Lattice spacing in Angstroms for cubic lattice.",
38    "  -n, --shells=INT              Nanoparticle shells",
39 +  "  -d, --latticeConstant=DOUBLE  Lattice spacing in Angstroms for cubic lattice.",
40 +  "  -c, --columnAtoms=INT         Number of atoms along central column \n                                  (Decahedron only)",
41 +  "  -t, --twinAtoms=INT           Number of atoms along twin boundary (Decahedron \n                                  only)",
42 +  "  -p, --truncatedPlanes=INT     Number of truncated planes (Curling-stone \n                                  Decahedron only)",
43 +  "\n Group: clusterShape\n   a cluster shape is required",
44 +  "      --ico                     Create an Icosahedral cluster",
45 +  "      --deca                    Create a regualar Decahedral cluster",
46 +  "      --ino                     Create an Ino Decahedral cluster",
47 +  "      --marks                   Create a Marks Decahedral cluster",
48 +  "      --stone                   Create a Curling-stone Decahedral cluster",
49      0
50   };
51  
# Line 67 | Line 76 | void clear_given (struct gengetopt_args_info *args_inf
76    args_info->help_given = 0 ;
77    args_info->version_given = 0 ;
78    args_info->output_given = 0 ;
70  args_info->latticeConstant_given = 0 ;
79    args_info->shells_given = 0 ;
80 +  args_info->latticeConstant_given = 0 ;
81 +  args_info->columnAtoms_given = 0 ;
82 +  args_info->twinAtoms_given = 0 ;
83 +  args_info->truncatedPlanes_given = 0 ;
84 +  args_info->ico_given = 0 ;
85 +  args_info->deca_given = 0 ;
86 +  args_info->ino_given = 0 ;
87 +  args_info->marks_given = 0 ;
88 +  args_info->stone_given = 0 ;
89 +  args_info->clusterShape_group_counter = 0 ;
90   }
91  
92   static
# Line 77 | Line 95 | void clear_args (struct gengetopt_args_info *args_info
95    FIX_UNUSED (args_info);
96    args_info->output_arg = NULL;
97    args_info->output_orig = NULL;
80  args_info->latticeConstant_orig = NULL;
98    args_info->shells_orig = NULL;
99 +  args_info->latticeConstant_orig = NULL;
100 +  args_info->columnAtoms_orig = NULL;
101 +  args_info->twinAtoms_orig = NULL;
102 +  args_info->truncatedPlanes_orig = NULL;
103    
104   }
105  
# Line 90 | Line 111 | void init_args_info(struct gengetopt_args_info *args_i
111    args_info->help_help = gengetopt_args_info_help[0] ;
112    args_info->version_help = gengetopt_args_info_help[1] ;
113    args_info->output_help = gengetopt_args_info_help[2] ;
114 <  args_info->latticeConstant_help = gengetopt_args_info_help[3] ;
115 <  args_info->shells_help = gengetopt_args_info_help[4] ;
114 >  args_info->shells_help = gengetopt_args_info_help[3] ;
115 >  args_info->latticeConstant_help = gengetopt_args_info_help[4] ;
116 >  args_info->columnAtoms_help = gengetopt_args_info_help[5] ;
117 >  args_info->twinAtoms_help = gengetopt_args_info_help[6] ;
118 >  args_info->truncatedPlanes_help = gengetopt_args_info_help[7] ;
119 >  args_info->ico_help = gengetopt_args_info_help[9] ;
120 >  args_info->deca_help = gengetopt_args_info_help[10] ;
121 >  args_info->ino_help = gengetopt_args_info_help[11] ;
122 >  args_info->marks_help = gengetopt_args_info_help[12] ;
123 >  args_info->stone_help = gengetopt_args_info_help[13] ;
124    
125   }
126  
# Line 177 | Line 206 | cmdline_parser_release (struct gengetopt_args_info *ar
206    unsigned int i;
207    free_string_field (&(args_info->output_arg));
208    free_string_field (&(args_info->output_orig));
180  free_string_field (&(args_info->latticeConstant_orig));
209    free_string_field (&(args_info->shells_orig));
210 +  free_string_field (&(args_info->latticeConstant_orig));
211 +  free_string_field (&(args_info->columnAtoms_orig));
212 +  free_string_field (&(args_info->twinAtoms_orig));
213 +  free_string_field (&(args_info->truncatedPlanes_orig));
214    
215    
216    for (i = 0; i < args_info->inputs_num; ++i)
# Line 220 | Line 252 | cmdline_parser_dump(FILE *outfile, struct gengetopt_ar
252      write_into_file(outfile, "version", 0, 0 );
253    if (args_info->output_given)
254      write_into_file(outfile, "output", args_info->output_orig, 0);
223  if (args_info->latticeConstant_given)
224    write_into_file(outfile, "latticeConstant", args_info->latticeConstant_orig, 0);
255    if (args_info->shells_given)
256      write_into_file(outfile, "shells", args_info->shells_orig, 0);
257 +  if (args_info->latticeConstant_given)
258 +    write_into_file(outfile, "latticeConstant", args_info->latticeConstant_orig, 0);
259 +  if (args_info->columnAtoms_given)
260 +    write_into_file(outfile, "columnAtoms", args_info->columnAtoms_orig, 0);
261 +  if (args_info->twinAtoms_given)
262 +    write_into_file(outfile, "twinAtoms", args_info->twinAtoms_orig, 0);
263 +  if (args_info->truncatedPlanes_given)
264 +    write_into_file(outfile, "truncatedPlanes", args_info->truncatedPlanes_orig, 0);
265 +  if (args_info->ico_given)
266 +    write_into_file(outfile, "ico", 0, 0 );
267 +  if (args_info->deca_given)
268 +    write_into_file(outfile, "deca", 0, 0 );
269 +  if (args_info->ino_given)
270 +    write_into_file(outfile, "ino", 0, 0 );
271 +  if (args_info->marks_given)
272 +    write_into_file(outfile, "marks", 0, 0 );
273 +  if (args_info->stone_given)
274 +    write_into_file(outfile, "stone", 0, 0 );
275    
276  
277    i = EXIT_SUCCESS;
# Line 271 | Line 319 | gengetopt_strdup (const char *s)
319    return result;
320   }
321  
322 + static void
323 + reset_group_clusterShape(struct gengetopt_args_info *args_info)
324 + {
325 +  if (! args_info->clusterShape_group_counter)
326 +    return;
327 +  
328 +  args_info->ico_given = 0 ;
329 +  args_info->deca_given = 0 ;
330 +  args_info->ino_given = 0 ;
331 +  args_info->marks_given = 0 ;
332 +  args_info->stone_given = 0 ;
333 +
334 +  args_info->clusterShape_group_counter = 0;
335 + }
336 +
337   int
338   cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
339   {
# Line 352 | Line 415 | cmdline_parser_required2 (struct gengetopt_args_info *
415        error = 1;
416      }
417    
418 +  if (args_info->clusterShape_group_counter == 0)
419 +    {
420 +      fprintf (stderr, "%s: %d options of group clusterShape were given. One is required%s.\n", prog_name, args_info->clusterShape_group_counter, (additional_error ? additional_error : ""));
421 +      error = 1;
422 +    }
423    
424 +
425    /* checks for dependences among options */
426  
427    return error;
# Line 515 | Line 584 | cmdline_parser_internal (
584          { "help",       0, NULL, 'h' },
585          { "version",    0, NULL, 'V' },
586          { "output",     1, NULL, 'o' },
518        { "latticeConstant",    1, NULL, 'd' },
587          { "shells",     1, NULL, 'n' },
588 +        { "latticeConstant",    1, NULL, 'd' },
589 +        { "columnAtoms",        1, NULL, 'c' },
590 +        { "twinAtoms",  1, NULL, 't' },
591 +        { "truncatedPlanes",    1, NULL, 'p' },
592 +        { "ico",        0, NULL, 0 },
593 +        { "deca",       0, NULL, 0 },
594 +        { "ino",        0, NULL, 0 },
595 +        { "marks",      0, NULL, 0 },
596 +        { "stone",      0, NULL, 0 },
597          { 0,  0, 0, 0 }
598        };
599  
600 <      c = getopt_long (argc, argv, "hVo:d:n:", long_options, &option_index);
600 >      c = getopt_long (argc, argv, "hVo:n:d:c:t:p:", long_options, &option_index);
601  
602        if (c == -1) break;       /* Exit from `while (1)' loop.  */
603  
# Line 548 | Line 625 | cmdline_parser_internal (
625              goto failure;
626          
627            break;
628 +        case 'n':       /* Nanoparticle shells.  */
629 +        
630 +        
631 +          if (update_arg( (void *)&(args_info->shells_arg),
632 +               &(args_info->shells_orig), &(args_info->shells_given),
633 +              &(local_args_info.shells_given), optarg, 0, 0, ARG_INT,
634 +              check_ambiguity, override, 0, 0,
635 +              "shells", 'n',
636 +              additional_error))
637 +            goto failure;
638 +        
639 +          break;
640          case 'd':       /* Lattice spacing in Angstroms for cubic lattice..  */
641          
642          
# Line 560 | Line 649 | cmdline_parser_internal (
649              goto failure;
650          
651            break;
652 <        case 'n':       /* Nanoparticle shells.  */
652 >        case 'c':       /* Number of atoms along central column (Decahedron only).  */
653          
654          
655 <          if (update_arg( (void *)&(args_info->shells_arg),
656 <               &(args_info->shells_orig), &(args_info->shells_given),
657 <              &(local_args_info.shells_given), optarg, 0, 0, ARG_INT,
655 >          if (update_arg( (void *)&(args_info->columnAtoms_arg),
656 >               &(args_info->columnAtoms_orig), &(args_info->columnAtoms_given),
657 >              &(local_args_info.columnAtoms_given), optarg, 0, 0, ARG_INT,
658                check_ambiguity, override, 0, 0,
659 <              "shells", 'n',
659 >              "columnAtoms", 'c',
660                additional_error))
661              goto failure;
662          
663            break;
664 +        case 't':       /* Number of atoms along twin boundary (Decahedron only).  */
665 +        
666 +        
667 +          if (update_arg( (void *)&(args_info->twinAtoms_arg),
668 +               &(args_info->twinAtoms_orig), &(args_info->twinAtoms_given),
669 +              &(local_args_info.twinAtoms_given), optarg, 0, 0, ARG_INT,
670 +              check_ambiguity, override, 0, 0,
671 +              "twinAtoms", 't',
672 +              additional_error))
673 +            goto failure;
674 +        
675 +          break;
676 +        case 'p':       /* Number of truncated planes (Curling-stone Decahedron only).  */
677 +        
678 +        
679 +          if (update_arg( (void *)&(args_info->truncatedPlanes_arg),
680 +               &(args_info->truncatedPlanes_orig), &(args_info->truncatedPlanes_given),
681 +              &(local_args_info.truncatedPlanes_given), optarg, 0, 0, ARG_INT,
682 +              check_ambiguity, override, 0, 0,
683 +              "truncatedPlanes", 'p',
684 +              additional_error))
685 +            goto failure;
686 +        
687 +          break;
688  
689          case 0: /* Long option with no short option */
690 +          /* Create an Icosahedral cluster.  */
691 +          if (strcmp (long_options[option_index].name, "ico") == 0)
692 +          {
693 +          
694 +            if (args_info->clusterShape_group_counter && override)
695 +              reset_group_clusterShape (args_info);
696 +            args_info->clusterShape_group_counter += 1;
697 +          
698 +            if (update_arg( 0 ,
699 +                 0 , &(args_info->ico_given),
700 +                &(local_args_info.ico_given), optarg, 0, 0, ARG_NO,
701 +                check_ambiguity, override, 0, 0,
702 +                "ico", '-',
703 +                additional_error))
704 +              goto failure;
705 +          
706 +          }
707 +          /* Create a regualar Decahedral cluster.  */
708 +          else if (strcmp (long_options[option_index].name, "deca") == 0)
709 +          {
710 +          
711 +            if (args_info->clusterShape_group_counter && override)
712 +              reset_group_clusterShape (args_info);
713 +            args_info->clusterShape_group_counter += 1;
714 +          
715 +            if (update_arg( 0 ,
716 +                 0 , &(args_info->deca_given),
717 +                &(local_args_info.deca_given), optarg, 0, 0, ARG_NO,
718 +                check_ambiguity, override, 0, 0,
719 +                "deca", '-',
720 +                additional_error))
721 +              goto failure;
722 +          
723 +          }
724 +          /* Create an Ino Decahedral cluster.  */
725 +          else if (strcmp (long_options[option_index].name, "ino") == 0)
726 +          {
727 +          
728 +            if (args_info->clusterShape_group_counter && override)
729 +              reset_group_clusterShape (args_info);
730 +            args_info->clusterShape_group_counter += 1;
731 +          
732 +            if (update_arg( 0 ,
733 +                 0 , &(args_info->ino_given),
734 +                &(local_args_info.ino_given), optarg, 0, 0, ARG_NO,
735 +                check_ambiguity, override, 0, 0,
736 +                "ino", '-',
737 +                additional_error))
738 +              goto failure;
739 +          
740 +          }
741 +          /* Create a Marks Decahedral cluster.  */
742 +          else if (strcmp (long_options[option_index].name, "marks") == 0)
743 +          {
744 +          
745 +            if (args_info->clusterShape_group_counter && override)
746 +              reset_group_clusterShape (args_info);
747 +            args_info->clusterShape_group_counter += 1;
748 +          
749 +            if (update_arg( 0 ,
750 +                 0 , &(args_info->marks_given),
751 +                &(local_args_info.marks_given), optarg, 0, 0, ARG_NO,
752 +                check_ambiguity, override, 0, 0,
753 +                "marks", '-',
754 +                additional_error))
755 +              goto failure;
756 +          
757 +          }
758 +          /* Create a Curling-stone Decahedral cluster.  */
759 +          else if (strcmp (long_options[option_index].name, "stone") == 0)
760 +          {
761 +          
762 +            if (args_info->clusterShape_group_counter && override)
763 +              reset_group_clusterShape (args_info);
764 +            args_info->clusterShape_group_counter += 1;
765 +          
766 +            if (update_arg( 0 ,
767 +                 0 , &(args_info->stone_given),
768 +                &(local_args_info.stone_given), optarg, 0, 0, ARG_NO,
769 +                check_ambiguity, override, 0, 0,
770 +                "stone", '-',
771 +                additional_error))
772 +              goto failure;
773 +          
774 +          }
775 +          
776 +          break;
777          case '?':       /* Invalid option.  */
778            /* `getopt_long' already printed an error message.  */
779            goto failure;
# Line 584 | Line 784 | cmdline_parser_internal (
784          } /* switch */
785      } /* while */
786  
787 +  if (args_info->clusterShape_group_counter > 1)
788 +    {
789 +      fprintf (stderr, "%s: %d options of group clusterShape were given. One is required%s.\n", argv[0], args_info->clusterShape_group_counter, (additional_error ? additional_error : ""));
790 +      error = 1;
791 +    }
792 +  
793  
794  
795    if (check_required)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines