| 21 |
|
#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */ |
| 22 |
|
#endif |
| 23 |
|
|
| 24 |
+ |
#ifdef WIN32 |
| 25 |
+ |
#include "utils/wingetopt.h" |
| 26 |
+ |
#else |
| 27 |
|
#include <getopt.h> |
| 28 |
+ |
#endif |
| 29 |
|
|
| 30 |
|
#include "icosahedralBuilderCmd.h" |
| 31 |
|
|
| 39 |
|
" -h, --help Print help and exit", |
| 40 |
|
" -V, --version Print version and exit", |
| 41 |
|
" -o, --output=STRING Output file name", |
| 38 |
– |
" -d, --latticeConstant=DOUBLE Lattice spacing in Angstroms for cubic lattice.", |
| 42 |
|
" -n, --shells=INT Nanoparticle shells", |
| 43 |
+ |
" -d, --latticeConstant=DOUBLE Lattice spacing in Angstroms for cubic lattice.", |
| 44 |
+ |
" -c, --columnAtoms=INT Number of atoms along central column \n (Decahedron only)", |
| 45 |
+ |
" -t, --twinAtoms=INT Number of atoms along twin boundary (Decahedron \n only)", |
| 46 |
+ |
" -p, --truncatedPlanes=INT Number of truncated planes (Curling-stone \n Decahedron only)", |
| 47 |
+ |
"\n Group: clusterShape\n a cluster shape is required", |
| 48 |
+ |
" --ico Create an Icosahedral cluster", |
| 49 |
+ |
" --deca Create a regualar Decahedral cluster", |
| 50 |
+ |
" --ino Create an Ino Decahedral cluster", |
| 51 |
+ |
" --marks Create a Marks Decahedral cluster", |
| 52 |
+ |
" --stone Create a Curling-stone Decahedral cluster", |
| 53 |
|
0 |
| 54 |
|
}; |
| 55 |
|
|
| 80 |
|
args_info->help_given = 0 ; |
| 81 |
|
args_info->version_given = 0 ; |
| 82 |
|
args_info->output_given = 0 ; |
| 70 |
– |
args_info->latticeConstant_given = 0 ; |
| 83 |
|
args_info->shells_given = 0 ; |
| 84 |
+ |
args_info->latticeConstant_given = 0 ; |
| 85 |
+ |
args_info->columnAtoms_given = 0 ; |
| 86 |
+ |
args_info->twinAtoms_given = 0 ; |
| 87 |
+ |
args_info->truncatedPlanes_given = 0 ; |
| 88 |
+ |
args_info->ico_given = 0 ; |
| 89 |
+ |
args_info->deca_given = 0 ; |
| 90 |
+ |
args_info->ino_given = 0 ; |
| 91 |
+ |
args_info->marks_given = 0 ; |
| 92 |
+ |
args_info->stone_given = 0 ; |
| 93 |
+ |
args_info->clusterShape_group_counter = 0 ; |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
static |
| 99 |
|
FIX_UNUSED (args_info); |
| 100 |
|
args_info->output_arg = NULL; |
| 101 |
|
args_info->output_orig = NULL; |
| 80 |
– |
args_info->latticeConstant_orig = NULL; |
| 102 |
|
args_info->shells_orig = NULL; |
| 103 |
+ |
args_info->latticeConstant_orig = NULL; |
| 104 |
+ |
args_info->columnAtoms_orig = NULL; |
| 105 |
+ |
args_info->twinAtoms_orig = NULL; |
| 106 |
+ |
args_info->truncatedPlanes_orig = NULL; |
| 107 |
|
|
| 108 |
|
} |
| 109 |
|
|
| 115 |
|
args_info->help_help = gengetopt_args_info_help[0] ; |
| 116 |
|
args_info->version_help = gengetopt_args_info_help[1] ; |
| 117 |
|
args_info->output_help = gengetopt_args_info_help[2] ; |
| 118 |
< |
args_info->latticeConstant_help = gengetopt_args_info_help[3] ; |
| 119 |
< |
args_info->shells_help = gengetopt_args_info_help[4] ; |
| 118 |
> |
args_info->shells_help = gengetopt_args_info_help[3] ; |
| 119 |
> |
args_info->latticeConstant_help = gengetopt_args_info_help[4] ; |
| 120 |
> |
args_info->columnAtoms_help = gengetopt_args_info_help[5] ; |
| 121 |
> |
args_info->twinAtoms_help = gengetopt_args_info_help[6] ; |
| 122 |
> |
args_info->truncatedPlanes_help = gengetopt_args_info_help[7] ; |
| 123 |
> |
args_info->ico_help = gengetopt_args_info_help[9] ; |
| 124 |
> |
args_info->deca_help = gengetopt_args_info_help[10] ; |
| 125 |
> |
args_info->ino_help = gengetopt_args_info_help[11] ; |
| 126 |
> |
args_info->marks_help = gengetopt_args_info_help[12] ; |
| 127 |
> |
args_info->stone_help = gengetopt_args_info_help[13] ; |
| 128 |
|
|
| 129 |
|
} |
| 130 |
|
|
| 210 |
|
unsigned int i; |
| 211 |
|
free_string_field (&(args_info->output_arg)); |
| 212 |
|
free_string_field (&(args_info->output_orig)); |
| 180 |
– |
free_string_field (&(args_info->latticeConstant_orig)); |
| 213 |
|
free_string_field (&(args_info->shells_orig)); |
| 214 |
+ |
free_string_field (&(args_info->latticeConstant_orig)); |
| 215 |
+ |
free_string_field (&(args_info->columnAtoms_orig)); |
| 216 |
+ |
free_string_field (&(args_info->twinAtoms_orig)); |
| 217 |
+ |
free_string_field (&(args_info->truncatedPlanes_orig)); |
| 218 |
|
|
| 219 |
|
|
| 220 |
|
for (i = 0; i < args_info->inputs_num; ++i) |
| 256 |
|
write_into_file(outfile, "version", 0, 0 ); |
| 257 |
|
if (args_info->output_given) |
| 258 |
|
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); |
| 259 |
|
if (args_info->shells_given) |
| 260 |
|
write_into_file(outfile, "shells", args_info->shells_orig, 0); |
| 261 |
+ |
if (args_info->latticeConstant_given) |
| 262 |
+ |
write_into_file(outfile, "latticeConstant", args_info->latticeConstant_orig, 0); |
| 263 |
+ |
if (args_info->columnAtoms_given) |
| 264 |
+ |
write_into_file(outfile, "columnAtoms", args_info->columnAtoms_orig, 0); |
| 265 |
+ |
if (args_info->twinAtoms_given) |
| 266 |
+ |
write_into_file(outfile, "twinAtoms", args_info->twinAtoms_orig, 0); |
| 267 |
+ |
if (args_info->truncatedPlanes_given) |
| 268 |
+ |
write_into_file(outfile, "truncatedPlanes", args_info->truncatedPlanes_orig, 0); |
| 269 |
+ |
if (args_info->ico_given) |
| 270 |
+ |
write_into_file(outfile, "ico", 0, 0 ); |
| 271 |
+ |
if (args_info->deca_given) |
| 272 |
+ |
write_into_file(outfile, "deca", 0, 0 ); |
| 273 |
+ |
if (args_info->ino_given) |
| 274 |
+ |
write_into_file(outfile, "ino", 0, 0 ); |
| 275 |
+ |
if (args_info->marks_given) |
| 276 |
+ |
write_into_file(outfile, "marks", 0, 0 ); |
| 277 |
+ |
if (args_info->stone_given) |
| 278 |
+ |
write_into_file(outfile, "stone", 0, 0 ); |
| 279 |
|
|
| 280 |
|
|
| 281 |
|
i = EXIT_SUCCESS; |
| 323 |
|
return result; |
| 324 |
|
} |
| 325 |
|
|
| 326 |
+ |
static void |
| 327 |
+ |
reset_group_clusterShape(struct gengetopt_args_info *args_info) |
| 328 |
+ |
{ |
| 329 |
+ |
if (! args_info->clusterShape_group_counter) |
| 330 |
+ |
return; |
| 331 |
+ |
|
| 332 |
+ |
args_info->ico_given = 0 ; |
| 333 |
+ |
args_info->deca_given = 0 ; |
| 334 |
+ |
args_info->ino_given = 0 ; |
| 335 |
+ |
args_info->marks_given = 0 ; |
| 336 |
+ |
args_info->stone_given = 0 ; |
| 337 |
+ |
|
| 338 |
+ |
args_info->clusterShape_group_counter = 0; |
| 339 |
+ |
} |
| 340 |
+ |
|
| 341 |
|
int |
| 342 |
|
cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info) |
| 343 |
|
{ |
| 419 |
|
error = 1; |
| 420 |
|
} |
| 421 |
|
|
| 422 |
+ |
if (args_info->clusterShape_group_counter == 0) |
| 423 |
+ |
{ |
| 424 |
+ |
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 : "")); |
| 425 |
+ |
error = 1; |
| 426 |
+ |
} |
| 427 |
|
|
| 428 |
+ |
|
| 429 |
|
/* checks for dependences among options */ |
| 430 |
|
|
| 431 |
|
return error; |
| 588 |
|
{ "help", 0, NULL, 'h' }, |
| 589 |
|
{ "version", 0, NULL, 'V' }, |
| 590 |
|
{ "output", 1, NULL, 'o' }, |
| 518 |
– |
{ "latticeConstant", 1, NULL, 'd' }, |
| 591 |
|
{ "shells", 1, NULL, 'n' }, |
| 592 |
+ |
{ "latticeConstant", 1, NULL, 'd' }, |
| 593 |
+ |
{ "columnAtoms", 1, NULL, 'c' }, |
| 594 |
+ |
{ "twinAtoms", 1, NULL, 't' }, |
| 595 |
+ |
{ "truncatedPlanes", 1, NULL, 'p' }, |
| 596 |
+ |
{ "ico", 0, NULL, 0 }, |
| 597 |
+ |
{ "deca", 0, NULL, 0 }, |
| 598 |
+ |
{ "ino", 0, NULL, 0 }, |
| 599 |
+ |
{ "marks", 0, NULL, 0 }, |
| 600 |
+ |
{ "stone", 0, NULL, 0 }, |
| 601 |
|
{ 0, 0, 0, 0 } |
| 602 |
|
}; |
| 603 |
|
|
| 604 |
< |
c = getopt_long (argc, argv, "hVo:d:n:", long_options, &option_index); |
| 604 |
> |
c = getopt_long (argc, argv, "hVo:n:d:c:t:p:", long_options, &option_index); |
| 605 |
|
|
| 606 |
|
if (c == -1) break; /* Exit from `while (1)' loop. */ |
| 607 |
|
|
| 629 |
|
goto failure; |
| 630 |
|
|
| 631 |
|
break; |
| 632 |
+ |
case 'n': /* Nanoparticle shells. */ |
| 633 |
+ |
|
| 634 |
+ |
|
| 635 |
+ |
if (update_arg( (void *)&(args_info->shells_arg), |
| 636 |
+ |
&(args_info->shells_orig), &(args_info->shells_given), |
| 637 |
+ |
&(local_args_info.shells_given), optarg, 0, 0, ARG_INT, |
| 638 |
+ |
check_ambiguity, override, 0, 0, |
| 639 |
+ |
"shells", 'n', |
| 640 |
+ |
additional_error)) |
| 641 |
+ |
goto failure; |
| 642 |
+ |
|
| 643 |
+ |
break; |
| 644 |
|
case 'd': /* Lattice spacing in Angstroms for cubic lattice.. */ |
| 645 |
|
|
| 646 |
|
|
| 653 |
|
goto failure; |
| 654 |
|
|
| 655 |
|
break; |
| 656 |
< |
case 'n': /* Nanoparticle shells. */ |
| 656 |
> |
case 'c': /* Number of atoms along central column (Decahedron only). */ |
| 657 |
|
|
| 658 |
|
|
| 659 |
< |
if (update_arg( (void *)&(args_info->shells_arg), |
| 660 |
< |
&(args_info->shells_orig), &(args_info->shells_given), |
| 661 |
< |
&(local_args_info.shells_given), optarg, 0, 0, ARG_INT, |
| 659 |
> |
if (update_arg( (void *)&(args_info->columnAtoms_arg), |
| 660 |
> |
&(args_info->columnAtoms_orig), &(args_info->columnAtoms_given), |
| 661 |
> |
&(local_args_info.columnAtoms_given), optarg, 0, 0, ARG_INT, |
| 662 |
|
check_ambiguity, override, 0, 0, |
| 663 |
< |
"shells", 'n', |
| 663 |
> |
"columnAtoms", 'c', |
| 664 |
|
additional_error)) |
| 665 |
|
goto failure; |
| 666 |
|
|
| 667 |
|
break; |
| 668 |
+ |
case 't': /* Number of atoms along twin boundary (Decahedron only). */ |
| 669 |
+ |
|
| 670 |
+ |
|
| 671 |
+ |
if (update_arg( (void *)&(args_info->twinAtoms_arg), |
| 672 |
+ |
&(args_info->twinAtoms_orig), &(args_info->twinAtoms_given), |
| 673 |
+ |
&(local_args_info.twinAtoms_given), optarg, 0, 0, ARG_INT, |
| 674 |
+ |
check_ambiguity, override, 0, 0, |
| 675 |
+ |
"twinAtoms", 't', |
| 676 |
+ |
additional_error)) |
| 677 |
+ |
goto failure; |
| 678 |
+ |
|
| 679 |
+ |
break; |
| 680 |
+ |
case 'p': /* Number of truncated planes (Curling-stone Decahedron only). */ |
| 681 |
+ |
|
| 682 |
+ |
|
| 683 |
+ |
if (update_arg( (void *)&(args_info->truncatedPlanes_arg), |
| 684 |
+ |
&(args_info->truncatedPlanes_orig), &(args_info->truncatedPlanes_given), |
| 685 |
+ |
&(local_args_info.truncatedPlanes_given), optarg, 0, 0, ARG_INT, |
| 686 |
+ |
check_ambiguity, override, 0, 0, |
| 687 |
+ |
"truncatedPlanes", 'p', |
| 688 |
+ |
additional_error)) |
| 689 |
+ |
goto failure; |
| 690 |
+ |
|
| 691 |
+ |
break; |
| 692 |
|
|
| 693 |
|
case 0: /* Long option with no short option */ |
| 694 |
+ |
/* Create an Icosahedral cluster. */ |
| 695 |
+ |
if (strcmp (long_options[option_index].name, "ico") == 0) |
| 696 |
+ |
{ |
| 697 |
+ |
|
| 698 |
+ |
if (args_info->clusterShape_group_counter && override) |
| 699 |
+ |
reset_group_clusterShape (args_info); |
| 700 |
+ |
args_info->clusterShape_group_counter += 1; |
| 701 |
+ |
|
| 702 |
+ |
if (update_arg( 0 , |
| 703 |
+ |
0 , &(args_info->ico_given), |
| 704 |
+ |
&(local_args_info.ico_given), optarg, 0, 0, ARG_NO, |
| 705 |
+ |
check_ambiguity, override, 0, 0, |
| 706 |
+ |
"ico", '-', |
| 707 |
+ |
additional_error)) |
| 708 |
+ |
goto failure; |
| 709 |
+ |
|
| 710 |
+ |
} |
| 711 |
+ |
/* Create a regualar Decahedral cluster. */ |
| 712 |
+ |
else if (strcmp (long_options[option_index].name, "deca") == 0) |
| 713 |
+ |
{ |
| 714 |
+ |
|
| 715 |
+ |
if (args_info->clusterShape_group_counter && override) |
| 716 |
+ |
reset_group_clusterShape (args_info); |
| 717 |
+ |
args_info->clusterShape_group_counter += 1; |
| 718 |
+ |
|
| 719 |
+ |
if (update_arg( 0 , |
| 720 |
+ |
0 , &(args_info->deca_given), |
| 721 |
+ |
&(local_args_info.deca_given), optarg, 0, 0, ARG_NO, |
| 722 |
+ |
check_ambiguity, override, 0, 0, |
| 723 |
+ |
"deca", '-', |
| 724 |
+ |
additional_error)) |
| 725 |
+ |
goto failure; |
| 726 |
+ |
|
| 727 |
+ |
} |
| 728 |
+ |
/* Create an Ino Decahedral cluster. */ |
| 729 |
+ |
else if (strcmp (long_options[option_index].name, "ino") == 0) |
| 730 |
+ |
{ |
| 731 |
+ |
|
| 732 |
+ |
if (args_info->clusterShape_group_counter && override) |
| 733 |
+ |
reset_group_clusterShape (args_info); |
| 734 |
+ |
args_info->clusterShape_group_counter += 1; |
| 735 |
+ |
|
| 736 |
+ |
if (update_arg( 0 , |
| 737 |
+ |
0 , &(args_info->ino_given), |
| 738 |
+ |
&(local_args_info.ino_given), optarg, 0, 0, ARG_NO, |
| 739 |
+ |
check_ambiguity, override, 0, 0, |
| 740 |
+ |
"ino", '-', |
| 741 |
+ |
additional_error)) |
| 742 |
+ |
goto failure; |
| 743 |
+ |
|
| 744 |
+ |
} |
| 745 |
+ |
/* Create a Marks Decahedral cluster. */ |
| 746 |
+ |
else if (strcmp (long_options[option_index].name, "marks") == 0) |
| 747 |
+ |
{ |
| 748 |
+ |
|
| 749 |
+ |
if (args_info->clusterShape_group_counter && override) |
| 750 |
+ |
reset_group_clusterShape (args_info); |
| 751 |
+ |
args_info->clusterShape_group_counter += 1; |
| 752 |
+ |
|
| 753 |
+ |
if (update_arg( 0 , |
| 754 |
+ |
0 , &(args_info->marks_given), |
| 755 |
+ |
&(local_args_info.marks_given), optarg, 0, 0, ARG_NO, |
| 756 |
+ |
check_ambiguity, override, 0, 0, |
| 757 |
+ |
"marks", '-', |
| 758 |
+ |
additional_error)) |
| 759 |
+ |
goto failure; |
| 760 |
+ |
|
| 761 |
+ |
} |
| 762 |
+ |
/* Create a Curling-stone Decahedral cluster. */ |
| 763 |
+ |
else if (strcmp (long_options[option_index].name, "stone") == 0) |
| 764 |
+ |
{ |
| 765 |
+ |
|
| 766 |
+ |
if (args_info->clusterShape_group_counter && override) |
| 767 |
+ |
reset_group_clusterShape (args_info); |
| 768 |
+ |
args_info->clusterShape_group_counter += 1; |
| 769 |
+ |
|
| 770 |
+ |
if (update_arg( 0 , |
| 771 |
+ |
0 , &(args_info->stone_given), |
| 772 |
+ |
&(local_args_info.stone_given), optarg, 0, 0, ARG_NO, |
| 773 |
+ |
check_ambiguity, override, 0, 0, |
| 774 |
+ |
"stone", '-', |
| 775 |
+ |
additional_error)) |
| 776 |
+ |
goto failure; |
| 777 |
+ |
|
| 778 |
+ |
} |
| 779 |
+ |
|
| 780 |
+ |
break; |
| 781 |
|
case '?': /* Invalid option. */ |
| 782 |
|
/* `getopt_long' already printed an error message. */ |
| 783 |
|
goto failure; |
| 788 |
|
} /* switch */ |
| 789 |
|
} /* while */ |
| 790 |
|
|
| 791 |
+ |
if (args_info->clusterShape_group_counter > 1) |
| 792 |
+ |
{ |
| 793 |
+ |
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 : "")); |
| 794 |
+ |
error = 1; |
| 795 |
+ |
} |
| 796 |
+ |
|
| 797 |
|
|
| 798 |
|
|
| 799 |
|
if (check_required) |