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

Comparing trunk/src/applications/sequentialProps/SequentialPropsCmd.cpp (file contents):
Revision 2024 by gezelter, Thu Oct 16 19:13:51 2014 UTC vs.
Revision 2035 by gezelter, Tue Nov 4 15:31:51 2014 UTC

# Line 42 | Line 42 | const char *gengetopt_args_info_help[] = {
42    "  -o, --output=filename         output file name",
43    "      --sele1=selection script  select first stuntdouble set",
44    "      --sele2=selection script  select second stuntdouble set (if sele2 is not \n                                  set, use script from sele1)",
45 <  "  -n, --nbins=INT               Number of bins  (default=`100')",
45 >  "  -b, --nbins=INT               number of bins (general purpose)  \n                                  (default=`100')",
46 >  "      --nbins_z=INT             number of bins in z axis  (default=`100')",
47 >  "  -z, --referenceZ=DOUBLE       Reference z-height of solid surface",
48 >  "  -r, --dropletR=DOUBLE         Droplet radius in angstroms",
49 >  "      --threshDens=DOUBLE       Threshold Density in g/cm^3",
50    "\n Group: sequentialProps\n   an option of this group is required",
51 <  "  -d, --density                 selection correlation function",
51 >  "  -c, --com                     selection center of mass",
52 >  "      --ca1                     contact angle of selection (using center of \n                                  mass)",
53 >  "      --ca2                     contact angle of selection (using density \n                                  profile)",
54      0
55   };
56  
57   typedef enum {ARG_NO
58    , ARG_STRING
59    , ARG_INT
60 +  , ARG_DOUBLE
61   } cmdline_parser_arg_type;
62  
63   static
# Line 78 | Line 85 | void clear_given (struct gengetopt_args_info *args_inf
85    args_info->sele1_given = 0 ;
86    args_info->sele2_given = 0 ;
87    args_info->nbins_given = 0 ;
88 <  args_info->density_given = 0 ;
88 >  args_info->nbins_z_given = 0 ;
89 >  args_info->referenceZ_given = 0 ;
90 >  args_info->dropletR_given = 0 ;
91 >  args_info->threshDens_given = 0 ;
92 >  args_info->com_given = 0 ;
93 >  args_info->ca1_given = 0 ;
94 >  args_info->ca2_given = 0 ;
95    args_info->sequentialProps_group_counter = 0 ;
96   }
97  
# Line 96 | Line 109 | void clear_args (struct gengetopt_args_info *args_info
109    args_info->sele2_orig = NULL;
110    args_info->nbins_arg = 100;
111    args_info->nbins_orig = NULL;
112 +  args_info->nbins_z_arg = 100;
113 +  args_info->nbins_z_orig = NULL;
114 +  args_info->referenceZ_orig = NULL;
115 +  args_info->dropletR_orig = NULL;
116 +  args_info->threshDens_orig = NULL;
117    
118   }
119  
# Line 111 | Line 129 | void init_args_info(struct gengetopt_args_info *args_i
129    args_info->sele1_help = gengetopt_args_info_help[4] ;
130    args_info->sele2_help = gengetopt_args_info_help[5] ;
131    args_info->nbins_help = gengetopt_args_info_help[6] ;
132 <  args_info->density_help = gengetopt_args_info_help[8] ;
132 >  args_info->nbins_z_help = gengetopt_args_info_help[7] ;
133 >  args_info->referenceZ_help = gengetopt_args_info_help[8] ;
134 >  args_info->dropletR_help = gengetopt_args_info_help[9] ;
135 >  args_info->threshDens_help = gengetopt_args_info_help[10] ;
136 >  args_info->com_help = gengetopt_args_info_help[12] ;
137 >  args_info->ca1_help = gengetopt_args_info_help[13] ;
138 >  args_info->ca2_help = gengetopt_args_info_help[14] ;
139    
140   }
141  
# Line 204 | Line 228 | cmdline_parser_release (struct gengetopt_args_info *ar
228    free_string_field (&(args_info->sele2_arg));
229    free_string_field (&(args_info->sele2_orig));
230    free_string_field (&(args_info->nbins_orig));
231 +  free_string_field (&(args_info->nbins_z_orig));
232 +  free_string_field (&(args_info->referenceZ_orig));
233 +  free_string_field (&(args_info->dropletR_orig));
234 +  free_string_field (&(args_info->threshDens_orig));
235    
236    
237    for (i = 0; i < args_info->inputs_num; ++i)
# Line 253 | Line 281 | cmdline_parser_dump(FILE *outfile, struct gengetopt_ar
281      write_into_file(outfile, "sele2", args_info->sele2_orig, 0);
282    if (args_info->nbins_given)
283      write_into_file(outfile, "nbins", args_info->nbins_orig, 0);
284 <  if (args_info->density_given)
285 <    write_into_file(outfile, "density", 0, 0 );
284 >  if (args_info->nbins_z_given)
285 >    write_into_file(outfile, "nbins_z", args_info->nbins_z_orig, 0);
286 >  if (args_info->referenceZ_given)
287 >    write_into_file(outfile, "referenceZ", args_info->referenceZ_orig, 0);
288 >  if (args_info->dropletR_given)
289 >    write_into_file(outfile, "dropletR", args_info->dropletR_orig, 0);
290 >  if (args_info->threshDens_given)
291 >    write_into_file(outfile, "threshDens", args_info->threshDens_orig, 0);
292 >  if (args_info->com_given)
293 >    write_into_file(outfile, "com", 0, 0 );
294 >  if (args_info->ca1_given)
295 >    write_into_file(outfile, "ca1", 0, 0 );
296 >  if (args_info->ca2_given)
297 >    write_into_file(outfile, "ca2", 0, 0 );
298    
299  
300    i = EXIT_SUCCESS;
# Line 308 | Line 348 | reset_group_sequentialProps(struct gengetopt_args_info
348    if (! args_info->sequentialProps_group_counter)
349      return;
350    
351 <  args_info->density_given = 0 ;
351 >  args_info->com_given = 0 ;
352 >  args_info->ca1_given = 0 ;
353 >  args_info->ca2_given = 0 ;
354  
355    args_info->sequentialProps_group_counter = 0;
356   }
# Line 469 | Line 511 | int update_arg(void *field, char **orig_field,
511    case ARG_INT:
512      if (val) *((int *)field) = strtol (val, &stop_char, 0);
513      break;
514 +  case ARG_DOUBLE:
515 +    if (val) *((double *)field) = strtod (val, &stop_char);
516 +    break;
517    case ARG_STRING:
518      if (val) {
519        string_field = (char **)field;
# Line 484 | Line 529 | int update_arg(void *field, char **orig_field,
529    /* check numeric conversion */
530    switch(arg_type) {
531    case ARG_INT:
532 +  case ARG_DOUBLE:
533      if (val && !(stop_char && *stop_char == '\0')) {
534        fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
535        return 1; /* failure */
# Line 556 | Line 602 | cmdline_parser_internal (
602          { "output",     1, NULL, 'o' },
603          { "sele1",      1, NULL, 0 },
604          { "sele2",      1, NULL, 0 },
605 <        { "nbins",      1, NULL, 'n' },
606 <        { "density",    0, NULL, 'd' },
605 >        { "nbins",      1, NULL, 'b' },
606 >        { "nbins_z",    1, NULL, 0 },
607 >        { "referenceZ", 1, NULL, 'z' },
608 >        { "dropletR",   1, NULL, 'r' },
609 >        { "threshDens", 1, NULL, 0 },
610 >        { "com",        0, NULL, 'c' },
611 >        { "ca1",        0, NULL, 0 },
612 >        { "ca2",        0, NULL, 0 },
613          { 0,  0, 0, 0 }
614        };
615  
616 <      c = getopt_long (argc, argv, "hVi:o:n:d", long_options, &option_index);
616 >      c = getopt_long (argc, argv, "hVi:o:b:z:r:c", long_options, &option_index);
617  
618        if (c == -1) break;       /* Exit from `while (1)' loop.  */
619  
# Line 601 | Line 653 | cmdline_parser_internal (
653              goto failure;
654          
655            break;
656 <        case 'n':       /* Number of bins.  */
656 >        case 'b':       /* number of bins (general purpose).  */
657          
658          
659            if (update_arg( (void *)&(args_info->nbins_arg),
660                 &(args_info->nbins_orig), &(args_info->nbins_given),
661                &(local_args_info.nbins_given), optarg, 0, "100", ARG_INT,
662                check_ambiguity, override, 0, 0,
663 <              "nbins", 'n',
663 >              "nbins", 'b',
664                additional_error))
665              goto failure;
666          
667            break;
668 <        case 'd':       /* selection correlation function.  */
668 >        case 'z':       /* Reference z-height of solid surface.  */
669 >        
670 >        
671 >          if (update_arg( (void *)&(args_info->referenceZ_arg),
672 >               &(args_info->referenceZ_orig), &(args_info->referenceZ_given),
673 >              &(local_args_info.referenceZ_given), optarg, 0, 0, ARG_DOUBLE,
674 >              check_ambiguity, override, 0, 0,
675 >              "referenceZ", 'z',
676 >              additional_error))
677 >            goto failure;
678          
679 +          break;
680 +        case 'r':       /* Droplet radius in angstroms.  */
681 +        
682 +        
683 +          if (update_arg( (void *)&(args_info->dropletR_arg),
684 +               &(args_info->dropletR_orig), &(args_info->dropletR_given),
685 +              &(local_args_info.dropletR_given), optarg, 0, 0, ARG_DOUBLE,
686 +              check_ambiguity, override, 0, 0,
687 +              "dropletR", 'r',
688 +              additional_error))
689 +            goto failure;
690 +        
691 +          break;
692 +        case 'c':       /* selection center of mass.  */
693 +        
694            if (args_info->sequentialProps_group_counter && override)
695              reset_group_sequentialProps (args_info);
696            args_info->sequentialProps_group_counter += 1;
697          
698            if (update_arg( 0 ,
699 <               0 , &(args_info->density_given),
700 <              &(local_args_info.density_given), optarg, 0, 0, ARG_NO,
699 >               0 , &(args_info->com_given),
700 >              &(local_args_info.com_given), optarg, 0, 0, ARG_NO,
701                check_ambiguity, override, 0, 0,
702 <              "density", 'd',
702 >              "com", 'c',
703                additional_error))
704              goto failure;
705          
# Line 658 | Line 734 | cmdline_parser_internal (
734                goto failure;
735            
736            }
737 +          /* number of bins in z axis.  */
738 +          else if (strcmp (long_options[option_index].name, "nbins_z") == 0)
739 +          {
740            
741 +          
742 +            if (update_arg( (void *)&(args_info->nbins_z_arg),
743 +                 &(args_info->nbins_z_orig), &(args_info->nbins_z_given),
744 +                &(local_args_info.nbins_z_given), optarg, 0, "100", ARG_INT,
745 +                check_ambiguity, override, 0, 0,
746 +                "nbins_z", '-',
747 +                additional_error))
748 +              goto failure;
749 +          
750 +          }
751 +          /* Threshold Density in g/cm^3.  */
752 +          else if (strcmp (long_options[option_index].name, "threshDens") == 0)
753 +          {
754 +          
755 +          
756 +            if (update_arg( (void *)&(args_info->threshDens_arg),
757 +                 &(args_info->threshDens_orig), &(args_info->threshDens_given),
758 +                &(local_args_info.threshDens_given), optarg, 0, 0, ARG_DOUBLE,
759 +                check_ambiguity, override, 0, 0,
760 +                "threshDens", '-',
761 +                additional_error))
762 +              goto failure;
763 +          
764 +          }
765 +          /* contact angle of selection (using center of mass).  */
766 +          else if (strcmp (long_options[option_index].name, "ca1") == 0)
767 +          {
768 +          
769 +            if (args_info->sequentialProps_group_counter && override)
770 +              reset_group_sequentialProps (args_info);
771 +            args_info->sequentialProps_group_counter += 1;
772 +          
773 +            if (update_arg( 0 ,
774 +                 0 , &(args_info->ca1_given),
775 +                &(local_args_info.ca1_given), optarg, 0, 0, ARG_NO,
776 +                check_ambiguity, override, 0, 0,
777 +                "ca1", '-',
778 +                additional_error))
779 +              goto failure;
780 +          
781 +          }
782 +          /* contact angle of selection (using density profile).  */
783 +          else if (strcmp (long_options[option_index].name, "ca2") == 0)
784 +          {
785 +          
786 +            if (args_info->sequentialProps_group_counter && override)
787 +              reset_group_sequentialProps (args_info);
788 +            args_info->sequentialProps_group_counter += 1;
789 +          
790 +            if (update_arg( 0 ,
791 +                 0 , &(args_info->ca2_given),
792 +                &(local_args_info.ca2_given), optarg, 0, 0, ARG_NO,
793 +                check_ambiguity, override, 0, 0,
794 +                "ca2", '-',
795 +                additional_error))
796 +              goto failure;
797 +          
798 +          }
799 +          
800            break;
801          case '?':       /* Invalid option.  */
802            /* `getopt_long' already printed an error message.  */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines