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 2029 by gezelter, Thu Oct 30 18:51:38 2014 UTC

# Line 43 | Line 43 | const char *gengetopt_args_info_help[] = {
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')",
46 +  "  -z, --referenceZ=DOUBLE       Reference z-height of solid surface",
47 +  "  -r, --dropletR=DOUBLE         Droplet radius in angstroms",
48    "\n Group: sequentialProps\n   an option of this group is required",
49 <  "  -d, --density                 selection correlation function",
49 >  "  -c, --com                     selection center of mass",
50 >  "      --ca1                     contact angle of selection (using center of \n                                  mass)",
51 >  "      --ca2                     contact angle of selection (using density \n                                  profile)",
52      0
53   };
54  
55   typedef enum {ARG_NO
56    , ARG_STRING
57    , ARG_INT
58 +  , ARG_DOUBLE
59   } cmdline_parser_arg_type;
60  
61   static
# Line 78 | Line 83 | void clear_given (struct gengetopt_args_info *args_inf
83    args_info->sele1_given = 0 ;
84    args_info->sele2_given = 0 ;
85    args_info->nbins_given = 0 ;
86 <  args_info->density_given = 0 ;
86 >  args_info->referenceZ_given = 0 ;
87 >  args_info->dropletR_given = 0 ;
88 >  args_info->com_given = 0 ;
89 >  args_info->ca1_given = 0 ;
90 >  args_info->ca2_given = 0 ;
91    args_info->sequentialProps_group_counter = 0 ;
92   }
93  
# Line 96 | Line 105 | void clear_args (struct gengetopt_args_info *args_info
105    args_info->sele2_orig = NULL;
106    args_info->nbins_arg = 100;
107    args_info->nbins_orig = NULL;
108 +  args_info->referenceZ_orig = NULL;
109 +  args_info->dropletR_orig = NULL;
110    
111   }
112  
# Line 111 | Line 122 | void init_args_info(struct gengetopt_args_info *args_i
122    args_info->sele1_help = gengetopt_args_info_help[4] ;
123    args_info->sele2_help = gengetopt_args_info_help[5] ;
124    args_info->nbins_help = gengetopt_args_info_help[6] ;
125 <  args_info->density_help = gengetopt_args_info_help[8] ;
125 >  args_info->referenceZ_help = gengetopt_args_info_help[7] ;
126 >  args_info->dropletR_help = gengetopt_args_info_help[8] ;
127 >  args_info->com_help = gengetopt_args_info_help[10] ;
128 >  args_info->ca1_help = gengetopt_args_info_help[11] ;
129 >  args_info->ca2_help = gengetopt_args_info_help[12] ;
130    
131   }
132  
# Line 204 | Line 219 | cmdline_parser_release (struct gengetopt_args_info *ar
219    free_string_field (&(args_info->sele2_arg));
220    free_string_field (&(args_info->sele2_orig));
221    free_string_field (&(args_info->nbins_orig));
222 +  free_string_field (&(args_info->referenceZ_orig));
223 +  free_string_field (&(args_info->dropletR_orig));
224    
225    
226    for (i = 0; i < args_info->inputs_num; ++i)
# Line 253 | Line 270 | cmdline_parser_dump(FILE *outfile, struct gengetopt_ar
270      write_into_file(outfile, "sele2", args_info->sele2_orig, 0);
271    if (args_info->nbins_given)
272      write_into_file(outfile, "nbins", args_info->nbins_orig, 0);
273 <  if (args_info->density_given)
274 <    write_into_file(outfile, "density", 0, 0 );
273 >  if (args_info->referenceZ_given)
274 >    write_into_file(outfile, "referenceZ", args_info->referenceZ_orig, 0);
275 >  if (args_info->dropletR_given)
276 >    write_into_file(outfile, "dropletR", args_info->dropletR_orig, 0);
277 >  if (args_info->com_given)
278 >    write_into_file(outfile, "com", 0, 0 );
279 >  if (args_info->ca1_given)
280 >    write_into_file(outfile, "ca1", 0, 0 );
281 >  if (args_info->ca2_given)
282 >    write_into_file(outfile, "ca2", 0, 0 );
283    
284  
285    i = EXIT_SUCCESS;
# Line 308 | Line 333 | reset_group_sequentialProps(struct gengetopt_args_info
333    if (! args_info->sequentialProps_group_counter)
334      return;
335    
336 <  args_info->density_given = 0 ;
336 >  args_info->com_given = 0 ;
337 >  args_info->ca1_given = 0 ;
338 >  args_info->ca2_given = 0 ;
339  
340    args_info->sequentialProps_group_counter = 0;
341   }
# Line 469 | Line 496 | int update_arg(void *field, char **orig_field,
496    case ARG_INT:
497      if (val) *((int *)field) = strtol (val, &stop_char, 0);
498      break;
499 +  case ARG_DOUBLE:
500 +    if (val) *((double *)field) = strtod (val, &stop_char);
501 +    break;
502    case ARG_STRING:
503      if (val) {
504        string_field = (char **)field;
# Line 484 | Line 514 | int update_arg(void *field, char **orig_field,
514    /* check numeric conversion */
515    switch(arg_type) {
516    case ARG_INT:
517 +  case ARG_DOUBLE:
518      if (val && !(stop_char && *stop_char == '\0')) {
519        fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
520        return 1; /* failure */
# Line 557 | Line 588 | cmdline_parser_internal (
588          { "sele1",      1, NULL, 0 },
589          { "sele2",      1, NULL, 0 },
590          { "nbins",      1, NULL, 'n' },
591 <        { "density",    0, NULL, 'd' },
591 >        { "referenceZ", 1, NULL, 'z' },
592 >        { "dropletR",   1, NULL, 'r' },
593 >        { "com",        0, NULL, 'c' },
594 >        { "ca1",        0, NULL, 0 },
595 >        { "ca2",        0, NULL, 0 },
596          { 0,  0, 0, 0 }
597        };
598  
599 <      c = getopt_long (argc, argv, "hVi:o:n:d", long_options, &option_index);
599 >      c = getopt_long (argc, argv, "hVi:o:n:z:r:c", long_options, &option_index);
600  
601        if (c == -1) break;       /* Exit from `while (1)' loop.  */
602  
# Line 613 | Line 648 | cmdline_parser_internal (
648              goto failure;
649          
650            break;
651 <        case 'd':       /* selection correlation function.  */
651 >        case 'z':       /* Reference z-height of solid surface.  */
652          
653 +        
654 +          if (update_arg( (void *)&(args_info->referenceZ_arg),
655 +               &(args_info->referenceZ_orig), &(args_info->referenceZ_given),
656 +              &(local_args_info.referenceZ_given), optarg, 0, 0, ARG_DOUBLE,
657 +              check_ambiguity, override, 0, 0,
658 +              "referenceZ", 'z',
659 +              additional_error))
660 +            goto failure;
661 +        
662 +          break;
663 +        case 'r':       /* Droplet radius in angstroms.  */
664 +        
665 +        
666 +          if (update_arg( (void *)&(args_info->dropletR_arg),
667 +               &(args_info->dropletR_orig), &(args_info->dropletR_given),
668 +              &(local_args_info.dropletR_given), optarg, 0, 0, ARG_DOUBLE,
669 +              check_ambiguity, override, 0, 0,
670 +              "dropletR", 'r',
671 +              additional_error))
672 +            goto failure;
673 +        
674 +          break;
675 +        case 'c':       /* selection center of mass.  */
676 +        
677            if (args_info->sequentialProps_group_counter && override)
678              reset_group_sequentialProps (args_info);
679            args_info->sequentialProps_group_counter += 1;
680          
681            if (update_arg( 0 ,
682 <               0 , &(args_info->density_given),
683 <              &(local_args_info.density_given), optarg, 0, 0, ARG_NO,
682 >               0 , &(args_info->com_given),
683 >              &(local_args_info.com_given), optarg, 0, 0, ARG_NO,
684                check_ambiguity, override, 0, 0,
685 <              "density", 'd',
685 >              "com", 'c',
686                additional_error))
687              goto failure;
688          
# Line 658 | Line 717 | cmdline_parser_internal (
717                goto failure;
718            
719            }
720 +          /* contact angle of selection (using center of mass).  */
721 +          else if (strcmp (long_options[option_index].name, "ca1") == 0)
722 +          {
723            
724 +            if (args_info->sequentialProps_group_counter && override)
725 +              reset_group_sequentialProps (args_info);
726 +            args_info->sequentialProps_group_counter += 1;
727 +          
728 +            if (update_arg( 0 ,
729 +                 0 , &(args_info->ca1_given),
730 +                &(local_args_info.ca1_given), optarg, 0, 0, ARG_NO,
731 +                check_ambiguity, override, 0, 0,
732 +                "ca1", '-',
733 +                additional_error))
734 +              goto failure;
735 +          
736 +          }
737 +          /* contact angle of selection (using density profile).  */
738 +          else if (strcmp (long_options[option_index].name, "ca2") == 0)
739 +          {
740 +          
741 +            if (args_info->sequentialProps_group_counter && override)
742 +              reset_group_sequentialProps (args_info);
743 +            args_info->sequentialProps_group_counter += 1;
744 +          
745 +            if (update_arg( 0 ,
746 +                 0 , &(args_info->ca2_given),
747 +                &(local_args_info.ca2_given), optarg, 0, 0, ARG_NO,
748 +                check_ambiguity, override, 0, 0,
749 +                "ca2", '-',
750 +                additional_error))
751 +              goto failure;
752 +          
753 +          }
754 +          
755            break;
756          case '?':       /* Invalid option.  */
757            /* `getopt_long' already printed an error message.  */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines