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 2039 by gezelter, Thu Nov 6 14:31:32 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 >  "      --bufferLength=DOUBLE     Buffer length in angstroms",
51    "\n Group: sequentialProps\n   an option of this group is required",
52 <  "  -d, --density                 selection correlation function",
52 >  "  -c, --com                     selection center of mass",
53 >  "      --ca1                     contact angle of selection (using center of \n                                  mass)",
54 >  "      --ca2                     contact angle of selection (using density \n                                  profile)",
55      0
56   };
57  
58   typedef enum {ARG_NO
59    , ARG_STRING
60    , ARG_INT
61 +  , ARG_DOUBLE
62   } cmdline_parser_arg_type;
63  
64   static
# Line 78 | Line 86 | void clear_given (struct gengetopt_args_info *args_inf
86    args_info->sele1_given = 0 ;
87    args_info->sele2_given = 0 ;
88    args_info->nbins_given = 0 ;
89 <  args_info->density_given = 0 ;
89 >  args_info->nbins_z_given = 0 ;
90 >  args_info->referenceZ_given = 0 ;
91 >  args_info->dropletR_given = 0 ;
92 >  args_info->threshDens_given = 0 ;
93 >  args_info->bufferLength_given = 0 ;
94 >  args_info->com_given = 0 ;
95 >  args_info->ca1_given = 0 ;
96 >  args_info->ca2_given = 0 ;
97    args_info->sequentialProps_group_counter = 0 ;
98   }
99  
# Line 96 | Line 111 | void clear_args (struct gengetopt_args_info *args_info
111    args_info->sele2_orig = NULL;
112    args_info->nbins_arg = 100;
113    args_info->nbins_orig = NULL;
114 +  args_info->nbins_z_arg = 100;
115 +  args_info->nbins_z_orig = NULL;
116 +  args_info->referenceZ_orig = NULL;
117 +  args_info->dropletR_orig = NULL;
118 +  args_info->threshDens_orig = NULL;
119 +  args_info->bufferLength_orig = NULL;
120    
121   }
122  
# Line 111 | Line 132 | void init_args_info(struct gengetopt_args_info *args_i
132    args_info->sele1_help = gengetopt_args_info_help[4] ;
133    args_info->sele2_help = gengetopt_args_info_help[5] ;
134    args_info->nbins_help = gengetopt_args_info_help[6] ;
135 <  args_info->density_help = gengetopt_args_info_help[8] ;
135 >  args_info->nbins_z_help = gengetopt_args_info_help[7] ;
136 >  args_info->referenceZ_help = gengetopt_args_info_help[8] ;
137 >  args_info->dropletR_help = gengetopt_args_info_help[9] ;
138 >  args_info->threshDens_help = gengetopt_args_info_help[10] ;
139 >  args_info->bufferLength_help = gengetopt_args_info_help[11] ;
140 >  args_info->com_help = gengetopt_args_info_help[13] ;
141 >  args_info->ca1_help = gengetopt_args_info_help[14] ;
142 >  args_info->ca2_help = gengetopt_args_info_help[15] ;
143    
144   }
145  
# Line 204 | Line 232 | cmdline_parser_release (struct gengetopt_args_info *ar
232    free_string_field (&(args_info->sele2_arg));
233    free_string_field (&(args_info->sele2_orig));
234    free_string_field (&(args_info->nbins_orig));
235 +  free_string_field (&(args_info->nbins_z_orig));
236 +  free_string_field (&(args_info->referenceZ_orig));
237 +  free_string_field (&(args_info->dropletR_orig));
238 +  free_string_field (&(args_info->threshDens_orig));
239 +  free_string_field (&(args_info->bufferLength_orig));
240    
241    
242    for (i = 0; i < args_info->inputs_num; ++i)
# Line 253 | Line 286 | cmdline_parser_dump(FILE *outfile, struct gengetopt_ar
286      write_into_file(outfile, "sele2", args_info->sele2_orig, 0);
287    if (args_info->nbins_given)
288      write_into_file(outfile, "nbins", args_info->nbins_orig, 0);
289 <  if (args_info->density_given)
290 <    write_into_file(outfile, "density", 0, 0 );
289 >  if (args_info->nbins_z_given)
290 >    write_into_file(outfile, "nbins_z", args_info->nbins_z_orig, 0);
291 >  if (args_info->referenceZ_given)
292 >    write_into_file(outfile, "referenceZ", args_info->referenceZ_orig, 0);
293 >  if (args_info->dropletR_given)
294 >    write_into_file(outfile, "dropletR", args_info->dropletR_orig, 0);
295 >  if (args_info->threshDens_given)
296 >    write_into_file(outfile, "threshDens", args_info->threshDens_orig, 0);
297 >  if (args_info->bufferLength_given)
298 >    write_into_file(outfile, "bufferLength", args_info->bufferLength_orig, 0);
299 >  if (args_info->com_given)
300 >    write_into_file(outfile, "com", 0, 0 );
301 >  if (args_info->ca1_given)
302 >    write_into_file(outfile, "ca1", 0, 0 );
303 >  if (args_info->ca2_given)
304 >    write_into_file(outfile, "ca2", 0, 0 );
305    
306  
307    i = EXIT_SUCCESS;
# Line 308 | Line 355 | reset_group_sequentialProps(struct gengetopt_args_info
355    if (! args_info->sequentialProps_group_counter)
356      return;
357    
358 <  args_info->density_given = 0 ;
358 >  args_info->com_given = 0 ;
359 >  args_info->ca1_given = 0 ;
360 >  args_info->ca2_given = 0 ;
361  
362    args_info->sequentialProps_group_counter = 0;
363   }
# Line 469 | Line 518 | int update_arg(void *field, char **orig_field,
518    case ARG_INT:
519      if (val) *((int *)field) = strtol (val, &stop_char, 0);
520      break;
521 +  case ARG_DOUBLE:
522 +    if (val) *((double *)field) = strtod (val, &stop_char);
523 +    break;
524    case ARG_STRING:
525      if (val) {
526        string_field = (char **)field;
# Line 484 | Line 536 | int update_arg(void *field, char **orig_field,
536    /* check numeric conversion */
537    switch(arg_type) {
538    case ARG_INT:
539 +  case ARG_DOUBLE:
540      if (val && !(stop_char && *stop_char == '\0')) {
541        fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
542        return 1; /* failure */
# Line 556 | Line 609 | cmdline_parser_internal (
609          { "output",     1, NULL, 'o' },
610          { "sele1",      1, NULL, 0 },
611          { "sele2",      1, NULL, 0 },
612 <        { "nbins",      1, NULL, 'n' },
613 <        { "density",    0, NULL, 'd' },
612 >        { "nbins",      1, NULL, 'b' },
613 >        { "nbins_z",    1, NULL, 0 },
614 >        { "referenceZ", 1, NULL, 'z' },
615 >        { "dropletR",   1, NULL, 'r' },
616 >        { "threshDens", 1, NULL, 0 },
617 >        { "bufferLength",       1, NULL, 0 },
618 >        { "com",        0, NULL, 'c' },
619 >        { "ca1",        0, NULL, 0 },
620 >        { "ca2",        0, NULL, 0 },
621          { 0,  0, 0, 0 }
622        };
623  
624 <      c = getopt_long (argc, argv, "hVi:o:n:d", long_options, &option_index);
624 >      c = getopt_long (argc, argv, "hVi:o:b:z:r:c", long_options, &option_index);
625  
626        if (c == -1) break;       /* Exit from `while (1)' loop.  */
627  
# Line 601 | Line 661 | cmdline_parser_internal (
661              goto failure;
662          
663            break;
664 <        case 'n':       /* Number of bins.  */
664 >        case 'b':       /* number of bins (general purpose).  */
665          
666          
667            if (update_arg( (void *)&(args_info->nbins_arg),
668                 &(args_info->nbins_orig), &(args_info->nbins_given),
669                &(local_args_info.nbins_given), optarg, 0, "100", ARG_INT,
670                check_ambiguity, override, 0, 0,
671 <              "nbins", 'n',
671 >              "nbins", 'b',
672                additional_error))
673              goto failure;
674          
675            break;
676 <        case 'd':       /* selection correlation function.  */
676 >        case 'z':       /* Reference z-height of solid surface.  */
677 >        
678 >        
679 >          if (update_arg( (void *)&(args_info->referenceZ_arg),
680 >               &(args_info->referenceZ_orig), &(args_info->referenceZ_given),
681 >              &(local_args_info.referenceZ_given), optarg, 0, 0, ARG_DOUBLE,
682 >              check_ambiguity, override, 0, 0,
683 >              "referenceZ", 'z',
684 >              additional_error))
685 >            goto failure;
686 >        
687 >          break;
688 >        case 'r':       /* Droplet radius in angstroms.  */
689          
690 +        
691 +          if (update_arg( (void *)&(args_info->dropletR_arg),
692 +               &(args_info->dropletR_orig), &(args_info->dropletR_given),
693 +              &(local_args_info.dropletR_given), optarg, 0, 0, ARG_DOUBLE,
694 +              check_ambiguity, override, 0, 0,
695 +              "dropletR", 'r',
696 +              additional_error))
697 +            goto failure;
698 +        
699 +          break;
700 +        case 'c':       /* selection center of mass.  */
701 +        
702            if (args_info->sequentialProps_group_counter && override)
703              reset_group_sequentialProps (args_info);
704            args_info->sequentialProps_group_counter += 1;
705          
706            if (update_arg( 0 ,
707 <               0 , &(args_info->density_given),
708 <              &(local_args_info.density_given), optarg, 0, 0, ARG_NO,
707 >               0 , &(args_info->com_given),
708 >              &(local_args_info.com_given), optarg, 0, 0, ARG_NO,
709                check_ambiguity, override, 0, 0,
710 <              "density", 'd',
710 >              "com", 'c',
711                additional_error))
712              goto failure;
713          
# Line 658 | Line 742 | cmdline_parser_internal (
742                goto failure;
743            
744            }
745 +          /* number of bins in z axis.  */
746 +          else if (strcmp (long_options[option_index].name, "nbins_z") == 0)
747 +          {
748            
749 +          
750 +            if (update_arg( (void *)&(args_info->nbins_z_arg),
751 +                 &(args_info->nbins_z_orig), &(args_info->nbins_z_given),
752 +                &(local_args_info.nbins_z_given), optarg, 0, "100", ARG_INT,
753 +                check_ambiguity, override, 0, 0,
754 +                "nbins_z", '-',
755 +                additional_error))
756 +              goto failure;
757 +          
758 +          }
759 +          /* Threshold Density in g/cm^3.  */
760 +          else if (strcmp (long_options[option_index].name, "threshDens") == 0)
761 +          {
762 +          
763 +          
764 +            if (update_arg( (void *)&(args_info->threshDens_arg),
765 +                 &(args_info->threshDens_orig), &(args_info->threshDens_given),
766 +                &(local_args_info.threshDens_given), optarg, 0, 0, ARG_DOUBLE,
767 +                check_ambiguity, override, 0, 0,
768 +                "threshDens", '-',
769 +                additional_error))
770 +              goto failure;
771 +          
772 +          }
773 +          /* Buffer length in angstroms.  */
774 +          else if (strcmp (long_options[option_index].name, "bufferLength") == 0)
775 +          {
776 +          
777 +          
778 +            if (update_arg( (void *)&(args_info->bufferLength_arg),
779 +                 &(args_info->bufferLength_orig), &(args_info->bufferLength_given),
780 +                &(local_args_info.bufferLength_given), optarg, 0, 0, ARG_DOUBLE,
781 +                check_ambiguity, override, 0, 0,
782 +                "bufferLength", '-',
783 +                additional_error))
784 +              goto failure;
785 +          
786 +          }
787 +          /* contact angle of selection (using center of mass).  */
788 +          else if (strcmp (long_options[option_index].name, "ca1") == 0)
789 +          {
790 +          
791 +            if (args_info->sequentialProps_group_counter && override)
792 +              reset_group_sequentialProps (args_info);
793 +            args_info->sequentialProps_group_counter += 1;
794 +          
795 +            if (update_arg( 0 ,
796 +                 0 , &(args_info->ca1_given),
797 +                &(local_args_info.ca1_given), optarg, 0, 0, ARG_NO,
798 +                check_ambiguity, override, 0, 0,
799 +                "ca1", '-',
800 +                additional_error))
801 +              goto failure;
802 +          
803 +          }
804 +          /* contact angle of selection (using density profile).  */
805 +          else if (strcmp (long_options[option_index].name, "ca2") == 0)
806 +          {
807 +          
808 +            if (args_info->sequentialProps_group_counter && override)
809 +              reset_group_sequentialProps (args_info);
810 +            args_info->sequentialProps_group_counter += 1;
811 +          
812 +            if (update_arg( 0 ,
813 +                 0 , &(args_info->ca2_given),
814 +                &(local_args_info.ca2_given), optarg, 0, 0, ARG_NO,
815 +                check_ambiguity, override, 0, 0,
816 +                "ca2", '-',
817 +                additional_error))
818 +              goto failure;
819 +          
820 +          }
821 +          
822            break;
823          case '?':       /* Invalid option.  */
824            /* `getopt_long' already printed an error message.  */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines