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

Comparing trunk/src/applications/staticProps/StaticPropsCmd.c (file contents):
Revision 980 by xsun, Thu Jun 1 18:06:33 2006 UTC vs.
Revision 1052 by gezelter, Tue Sep 26 01:30:32 2006 UTC

# Line 43 | Line 43 | void clear_given (struct gengetopt_args_info *args_inf
43    args_info->input_given = 0 ;
44    args_info->output_given = 0 ;
45    args_info->step_given = 0 ;
46 <  args_info->nrbins_given = 0 ;
46 >  args_info->nbins_given = 0 ;
47    args_info->nbins_x_given = 0 ;
48    args_info->nbins_y_given = 0 ;
49    args_info->nanglebins_given = 0 ;
50    args_info->length_given = 0 ;
51 +  args_info->rcut_given = 0 ;
52    args_info->zoffset_given = 0 ;
53    args_info->sele1_given = 0 ;
54    args_info->sele2_given = 0 ;
# Line 56 | Line 57 | void clear_given (struct gengetopt_args_info *args_inf
57    args_info->molname_given = 0 ;
58    args_info->begin_given = 0 ;
59    args_info->end_given = 0 ;
60 +  args_info->bo_given = 0 ;
61    args_info->gofr_given = 0 ;
62    args_info->r_theta_given = 0 ;
63    args_info->r_omega_given = 0 ;
# Line 79 | Line 81 | void clear_args (struct gengetopt_args_info *args_info
81    args_info->output_orig = NULL;
82    args_info->step_arg = 1;
83    args_info->step_orig = NULL;
84 <  args_info->nrbins_arg = 100;
85 <  args_info->nrbins_orig = NULL;
84 >  args_info->nbins_arg = 100;
85 >  args_info->nbins_orig = NULL;
86    args_info->nbins_x_arg = 100;
87    args_info->nbins_x_orig = NULL;
88    args_info->nbins_y_arg = 100;
# Line 88 | Line 90 | void clear_args (struct gengetopt_args_info *args_info
90    args_info->nanglebins_arg = 50;
91    args_info->nanglebins_orig = NULL;
92    args_info->length_orig = NULL;
93 +  args_info->rcut_orig = NULL;
94    args_info->zoffset_arg = 0;
95    args_info->zoffset_orig = NULL;
96    args_info->sele1_arg = NULL;
# Line 121 | Line 124 | cmdline_parser_print_help (void)
124    printf("%s\n","  -i, --input=filename          input dump file");
125    printf("%s\n","  -o, --output=filename         output file name");
126    printf("%s\n","  -n, --step=INT                process every n frame  (default=`1')");
127 <  printf("%s\n","  -r, --nrbins=INT              number of bins for distance  (default=`100')");
127 >  printf("%s\n","  -b, --nbins=INT               number of bins (general purpose)  \n                                  (default=`100')");
128    printf("%s\n","  -x, --nbins_x=INT             number of bins in x axis  (default=`100')");
129    printf("%s\n","  -y, --nbins_y=INT             number of bins in y axis  (default=`100')");
130    printf("%s\n","  -a, --nanglebins=INT          number of bins for cos(angle)  (default=`50')");
131 <  printf("%s\n","  -l, --length=DOUBLE           maximum length (Defaults to 1/2 smallest length \n                                  of first frame)");
131 >  printf("%s\n","      --length=DOUBLE           maximum length (Defaults to 1/2 smallest length \n                                  of first frame)");
132 >  printf("%s\n","  -c, --rcut=DOUBLE             cutoff radius (rcut)");
133    printf("%s\n","  -z, --zoffset=DOUBLE          Where to set the zero for the slab_density \n                                  calculation  (default=`0')");
134    printf("%s\n","      --sele1=selection script  select the first stuntdouble set");
135    printf("%s\n","      --sele2=selection script  select the second stuntdouble set");
136    printf("%s\n","      --sele3=selection script  select the third stuntdouble set");
137    printf("%s\n","      --refsele=selection script\n                                select reference (use and only use with --gxyz)");
138    printf("%s\n","      --molname=STRING          molecule name");
139 <  printf("%s\n","      --begin=INT               begin interanl index");
139 >  printf("%s\n","      --begin=INT               begin internal index");
140    printf("%s\n","      --end=INT                 end internal index");
141    printf("%s\n","\n Group: staticProps\n   an option of this group is required");
142 <  printf("%s\n","      --gofr                    g(r)");
142 >  printf("%s\n","      --bo                      bond order parameter (--rcut must be specified");
143 >  printf("%s\n","  -g, --gofr                    g(r)");
144    printf("%s\n","      --r_theta                 g(r, cos(theta))");
145    printf("%s\n","      --r_omega                 g(r, cos(omega))");
146    printf("%s\n","      --theta_omega             g(cos(theta), cos(omega))");
147    printf("%s\n","      --gxyz                    g(x, y, z)");
148 <  printf("%s\n","      --p2                      p2 order parameter (--sele1 and --sele2 must be \n                                  specified)");
148 >  printf("%s\n","  -p, --p2                      p2 order parameter (--sele1 and --sele2 must be \n                                  specified)");
149    printf("%s\n","      --rp2                     rp2 order parameter (--sele1 and --sele2 must \n                                  be specified)");
150 <  printf("%s\n","      --scd                     scd order parameter(either --sele1, --sele2, \n                                  --sele3 are specified or --molname, --begin, \n                                  --end are specified)");
151 <  printf("%s\n","      --density                 density plot (--sele1 must be specified)");
152 <  printf("%s\n","      --slab_density            slab density (--sele1 must be specified)");
153 <  printf("%s\n","      --hxy                     hxy (--sele1 must be specified)");
150 >  printf("%s\n","  -s, --scd                     scd order parameter (either --sele1, --sele2, \n                                  --sele3 are specified or --molname, --begin, \n                                  --end are specified)");
151 >  printf("%s\n","  -d, --density                 density plot");
152 >  printf("%s\n","      --slab_density            slab density");
153 >  printf("%s\n","      --hxy                     hxy");
154    
155   }
156  
# Line 185 | Line 190 | cmdline_parser_release (struct gengetopt_args_info *ar
190        free (args_info->step_orig); /* free previous argument */
191        args_info->step_orig = 0;
192      }
193 <  if (args_info->nrbins_orig)
193 >  if (args_info->nbins_orig)
194      {
195 <      free (args_info->nrbins_orig); /* free previous argument */
196 <      args_info->nrbins_orig = 0;
195 >      free (args_info->nbins_orig); /* free previous argument */
196 >      args_info->nbins_orig = 0;
197      }
198    if (args_info->nbins_x_orig)
199      {
# Line 210 | Line 215 | cmdline_parser_release (struct gengetopt_args_info *ar
215        free (args_info->length_orig); /* free previous argument */
216        args_info->length_orig = 0;
217      }
218 +  if (args_info->rcut_orig)
219 +    {
220 +      free (args_info->rcut_orig); /* free previous argument */
221 +      args_info->rcut_orig = 0;
222 +    }
223    if (args_info->zoffset_orig)
224      {
225        free (args_info->zoffset_orig); /* free previous argument */
# Line 320 | Line 330 | cmdline_parser_file_save(const char *filename, struct
330        fprintf(outfile, "%s\n", "step");
331      }
332    }
333 <  if (args_info->nrbins_given) {
334 <    if (args_info->nrbins_orig) {
335 <      fprintf(outfile, "%s=\"%s\"\n", "nrbins", args_info->nrbins_orig);
333 >  if (args_info->nbins_given) {
334 >    if (args_info->nbins_orig) {
335 >      fprintf(outfile, "%s=\"%s\"\n", "nbins", args_info->nbins_orig);
336      } else {
337 <      fprintf(outfile, "%s\n", "nrbins");
337 >      fprintf(outfile, "%s\n", "nbins");
338      }
339    }
340    if (args_info->nbins_x_given) {
# Line 355 | Line 365 | cmdline_parser_file_save(const char *filename, struct
365        fprintf(outfile, "%s\n", "length");
366      }
367    }
368 +  if (args_info->rcut_given) {
369 +    if (args_info->rcut_orig) {
370 +      fprintf(outfile, "%s=\"%s\"\n", "rcut", args_info->rcut_orig);
371 +    } else {
372 +      fprintf(outfile, "%s\n", "rcut");
373 +    }
374 +  }
375    if (args_info->zoffset_given) {
376      if (args_info->zoffset_orig) {
377        fprintf(outfile, "%s=\"%s\"\n", "zoffset", args_info->zoffset_orig);
# Line 410 | Line 427 | cmdline_parser_file_save(const char *filename, struct
427      } else {
428        fprintf(outfile, "%s\n", "end");
429      }
430 +  }
431 +  if (args_info->bo_given) {
432 +    fprintf(outfile, "%s\n", "bo");
433    }
434    if (args_info->gofr_given) {
435      fprintf(outfile, "%s\n", "gofr");
# Line 483 | Line 503 | reset_group_staticProps(struct gengetopt_args_info *ar
503    if (! args_info->staticProps_group_counter)
504      return;
505    
506 +  args_info->bo_given = 0 ;
507    args_info->gofr_given = 0 ;
508    args_info->r_theta_given = 0 ;
509    args_info->r_omega_given = 0 ;
# Line 586 | Line 607 | cmdline_parser_internal (int argc, char * const *argv,
607          { "input",      1, NULL, 'i' },
608          { "output",     1, NULL, 'o' },
609          { "step",       1, NULL, 'n' },
610 <        { "nrbins",     1, NULL, 'r' },
610 >        { "nbins",      1, NULL, 'b' },
611          { "nbins_x",    1, NULL, 'x' },
612          { "nbins_y",    1, NULL, 'y' },
613          { "nanglebins", 1, NULL, 'a' },
614 <        { "length",     1, NULL, 'l' },
614 >        { "length",     1, NULL, 0 },
615 >        { "rcut",       1, NULL, 'c' },
616          { "zoffset",    1, NULL, 'z' },
617          { "sele1",      1, NULL, 0 },
618          { "sele2",      1, NULL, 0 },
# Line 599 | Line 621 | cmdline_parser_internal (int argc, char * const *argv,
621          { "molname",    1, NULL, 0 },
622          { "begin",      1, NULL, 0 },
623          { "end",        1, NULL, 0 },
624 <        { "gofr",       0, NULL, 0 },
624 >        { "bo", 0, NULL, 0 },
625 >        { "gofr",       0, NULL, 'g' },
626          { "r_theta",    0, NULL, 0 },
627          { "r_omega",    0, NULL, 0 },
628          { "theta_omega",        0, NULL, 0 },
629          { "gxyz",       0, NULL, 0 },
630 <        { "p2", 0, NULL, 0 },
630 >        { "p2", 0, NULL, 'p' },
631          { "rp2",        0, NULL, 0 },
632 <        { "scd",        0, NULL, 0 },
633 <        { "density",    0, NULL, 0 },
632 >        { "scd",        0, NULL, 's' },
633 >        { "density",    0, NULL, 'd' },
634          { "slab_density",       0, NULL, 0 },
635          { "hxy",        0, NULL, 0 },
636          { NULL, 0, NULL, 0 }
637        };
638  
639        stop_char = 0;
640 <      c = getopt_long (argc, argv, "hVi:o:n:r:x:y:a:l:z:", long_options, &option_index);
640 >      c = getopt_long (argc, argv, "hVi:o:n:b:x:y:a:c:z:gpsd", long_options, &option_index);
641  
642        if (c == -1) break;       /* Exit from `while (1)' loop.  */
643  
# Line 686 | Line 709 | cmdline_parser_internal (int argc, char * const *argv,
709            args_info->step_orig = gengetopt_strdup (optarg);
710            break;
711  
712 <        case 'r':       /* number of bins for distance.  */
713 <          if (local_args_info.nrbins_given)
712 >        case 'b':       /* number of bins (general purpose).  */
713 >          if (local_args_info.nbins_given)
714              {
715 <              fprintf (stderr, "%s: `--nrbins' (`-r') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
715 >              fprintf (stderr, "%s: `--nbins' (`-b') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
716                goto failure;
717              }
718 <          if (args_info->nrbins_given && ! override)
718 >          if (args_info->nbins_given && ! override)
719              continue;
720 <          local_args_info.nrbins_given = 1;
721 <          args_info->nrbins_given = 1;
722 <          args_info->nrbins_arg = strtol (optarg, &stop_char, 0);
720 >          local_args_info.nbins_given = 1;
721 >          args_info->nbins_given = 1;
722 >          args_info->nbins_arg = strtol (optarg, &stop_char, 0);
723            if (!(stop_char && *stop_char == '\0')) {
724              fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
725              goto failure;
726            }
727 <          if (args_info->nrbins_orig)
728 <            free (args_info->nrbins_orig); /* free previous string */
729 <          args_info->nrbins_orig = gengetopt_strdup (optarg);
727 >          if (args_info->nbins_orig)
728 >            free (args_info->nbins_orig); /* free previous string */
729 >          args_info->nbins_orig = gengetopt_strdup (optarg);
730            break;
731  
732          case 'x':       /* number of bins in x axis.  */
# Line 766 | Line 789 | cmdline_parser_internal (int argc, char * const *argv,
789            args_info->nanglebins_orig = gengetopt_strdup (optarg);
790            break;
791  
792 <        case 'l':       /* maximum length (Defaults to 1/2 smallest length of first frame).  */
793 <          if (local_args_info.length_given)
792 >        case 'c':       /* cutoff radius (rcut).  */
793 >          if (local_args_info.rcut_given)
794              {
795 <              fprintf (stderr, "%s: `--length' (`-l') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
795 >              fprintf (stderr, "%s: `--rcut' (`-c') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
796                goto failure;
797              }
798 <          if (args_info->length_given && ! override)
798 >          if (args_info->rcut_given && ! override)
799              continue;
800 <          local_args_info.length_given = 1;
801 <          args_info->length_given = 1;
802 <          args_info->length_arg = strtod (optarg, &stop_char);
800 >          local_args_info.rcut_given = 1;
801 >          args_info->rcut_given = 1;
802 >          args_info->rcut_arg = strtod (optarg, &stop_char);
803            if (!(stop_char && *stop_char == '\0')) {
804              fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
805              goto failure;
806            }
807 <          if (args_info->length_orig)
808 <            free (args_info->length_orig); /* free previous string */
809 <          args_info->length_orig = gengetopt_strdup (optarg);
807 >          if (args_info->rcut_orig)
808 >            free (args_info->rcut_orig); /* free previous string */
809 >          args_info->rcut_orig = gengetopt_strdup (optarg);
810            break;
811  
812          case 'z':       /* Where to set the zero for the slab_density calculation.  */
# Line 806 | Line 829 | cmdline_parser_internal (int argc, char * const *argv,
829            args_info->zoffset_orig = gengetopt_strdup (optarg);
830            break;
831  
832 +        case 'g':       /* g(r).  */
833 +          if (local_args_info.gofr_given)
834 +            {
835 +              fprintf (stderr, "%s: `--gofr' (`-g') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
836 +              goto failure;
837 +            }
838 +          if (args_info->gofr_given && ! override)
839 +            continue;
840 +          local_args_info.gofr_given = 1;
841 +          args_info->gofr_given = 1;
842 +          if (args_info->staticProps_group_counter && override)
843 +            reset_group_staticProps (args_info);
844 +          args_info->staticProps_group_counter += 1;
845 +          break;
846  
847 +        case 'p':       /* p2 order parameter (--sele1 and --sele2 must be specified).  */
848 +          if (local_args_info.p2_given)
849 +            {
850 +              fprintf (stderr, "%s: `--p2' (`-p') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
851 +              goto failure;
852 +            }
853 +          if (args_info->p2_given && ! override)
854 +            continue;
855 +          local_args_info.p2_given = 1;
856 +          args_info->p2_given = 1;
857 +          if (args_info->staticProps_group_counter && override)
858 +            reset_group_staticProps (args_info);
859 +          args_info->staticProps_group_counter += 1;
860 +          break;
861 +
862 +        case 's':       /* scd order parameter (either --sele1, --sele2, --sele3 are specified or --molname, --begin, --end are specified).  */
863 +          if (local_args_info.scd_given)
864 +            {
865 +              fprintf (stderr, "%s: `--scd' (`-s') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
866 +              goto failure;
867 +            }
868 +          if (args_info->scd_given && ! override)
869 +            continue;
870 +          local_args_info.scd_given = 1;
871 +          args_info->scd_given = 1;
872 +          if (args_info->staticProps_group_counter && override)
873 +            reset_group_staticProps (args_info);
874 +          args_info->staticProps_group_counter += 1;
875 +          break;
876 +
877 +        case 'd':       /* density plot.  */
878 +          if (local_args_info.density_given)
879 +            {
880 +              fprintf (stderr, "%s: `--density' (`-d') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
881 +              goto failure;
882 +            }
883 +          if (args_info->density_given && ! override)
884 +            continue;
885 +          local_args_info.density_given = 1;
886 +          args_info->density_given = 1;
887 +          if (args_info->staticProps_group_counter && override)
888 +            reset_group_staticProps (args_info);
889 +          args_info->staticProps_group_counter += 1;
890 +          break;
891 +
892 +
893          case 0: /* Long option with no short option */
894 +          /* maximum length (Defaults to 1/2 smallest length of first frame).  */
895 +          if (strcmp (long_options[option_index].name, "length") == 0)
896 +          {
897 +            if (local_args_info.length_given)
898 +              {
899 +                fprintf (stderr, "%s: `--length' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
900 +                goto failure;
901 +              }
902 +            if (args_info->length_given && ! override)
903 +              continue;
904 +            local_args_info.length_given = 1;
905 +            args_info->length_given = 1;
906 +            args_info->length_arg = strtod (optarg, &stop_char);
907 +            if (!(stop_char && *stop_char == '\0')) {
908 +              fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
909 +              goto failure;
910 +            }
911 +            if (args_info->length_orig)
912 +              free (args_info->length_orig); /* free previous string */
913 +            args_info->length_orig = gengetopt_strdup (optarg);
914 +          }
915            /* select the first stuntdouble set.  */
916 <          if (strcmp (long_options[option_index].name, "sele1") == 0)
916 >          else if (strcmp (long_options[option_index].name, "sele1") == 0)
917            {
918              if (local_args_info.sele1_given)
919                {
# Line 903 | Line 1007 | cmdline_parser_internal (int argc, char * const *argv,
1007                free (args_info->molname_orig); /* free previous string */
1008              args_info->molname_orig = gengetopt_strdup (optarg);
1009            }
1010 <          /* begin interanl index.  */
1010 >          /* begin internal index.  */
1011            else if (strcmp (long_options[option_index].name, "begin") == 0)
1012            {
1013              if (local_args_info.begin_given)
# Line 945 | Line 1049 | cmdline_parser_internal (int argc, char * const *argv,
1049                free (args_info->end_orig); /* free previous string */
1050              args_info->end_orig = gengetopt_strdup (optarg);
1051            }
1052 <          /* g(r).  */
1053 <          else if (strcmp (long_options[option_index].name, "gofr") == 0)
1052 >          /* bond order parameter (--rcut must be specified.  */
1053 >          else if (strcmp (long_options[option_index].name, "bo") == 0)
1054            {
1055 <            if (local_args_info.gofr_given)
1055 >            if (local_args_info.bo_given)
1056                {
1057 <                fprintf (stderr, "%s: `--gofr' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1057 >                fprintf (stderr, "%s: `--bo' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1058                  goto failure;
1059                }
1060 <            if (args_info->gofr_given && ! override)
1060 >            if (args_info->bo_given && ! override)
1061                continue;
1062 <            local_args_info.gofr_given = 1;
1063 <            args_info->gofr_given = 1;
1062 >            local_args_info.bo_given = 1;
1063 >            args_info->bo_given = 1;
1064              if (args_info->staticProps_group_counter && override)
1065                reset_group_staticProps (args_info);
1066              args_info->staticProps_group_counter += 1;
# Line 1030 | Line 1134 | cmdline_parser_internal (int argc, char * const *argv,
1134              args_info->staticProps_group_counter += 1;
1135              break;
1136            }
1033          /* p2 order parameter (--sele1 and --sele2 must be specified).  */
1034          else if (strcmp (long_options[option_index].name, "p2") == 0)
1035          {
1036            if (local_args_info.p2_given)
1037              {
1038                fprintf (stderr, "%s: `--p2' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1039                goto failure;
1040              }
1041            if (args_info->p2_given && ! override)
1042              continue;
1043            local_args_info.p2_given = 1;
1044            args_info->p2_given = 1;
1045            if (args_info->staticProps_group_counter && override)
1046              reset_group_staticProps (args_info);
1047            args_info->staticProps_group_counter += 1;
1048            break;
1049          }
1137            /* rp2 order parameter (--sele1 and --sele2 must be specified).  */
1138            else if (strcmp (long_options[option_index].name, "rp2") == 0)
1139            {
# Line 1064 | Line 1151 | cmdline_parser_internal (int argc, char * const *argv,
1151              args_info->staticProps_group_counter += 1;
1152              break;
1153            }
1154 <          /* scd order parameter(either --sele1, --sele2, --sele3 are specified or --molname, --begin, --end are specified).  */
1068 <          else if (strcmp (long_options[option_index].name, "scd") == 0)
1069 <          {
1070 <            if (local_args_info.scd_given)
1071 <              {
1072 <                fprintf (stderr, "%s: `--scd' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1073 <                goto failure;
1074 <              }
1075 <            if (args_info->scd_given && ! override)
1076 <              continue;
1077 <            local_args_info.scd_given = 1;
1078 <            args_info->scd_given = 1;
1079 <            if (args_info->staticProps_group_counter && override)
1080 <              reset_group_staticProps (args_info);
1081 <            args_info->staticProps_group_counter += 1;
1082 <            break;
1083 <          }
1084 <          /* density plot (--sele1 must be specified).  */
1085 <          else if (strcmp (long_options[option_index].name, "density") == 0)
1086 <          {
1087 <            if (local_args_info.density_given)
1088 <              {
1089 <                fprintf (stderr, "%s: `--density' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1090 <                goto failure;
1091 <              }
1092 <            if (args_info->density_given && ! override)
1093 <              continue;
1094 <            local_args_info.density_given = 1;
1095 <            args_info->density_given = 1;
1096 <            if (args_info->staticProps_group_counter && override)
1097 <              reset_group_staticProps (args_info);
1098 <            args_info->staticProps_group_counter += 1;
1099 <            break;
1100 <          }
1101 <          /* slab density (--sele1 must be specified).  */
1154 >          /* slab density.  */
1155            else if (strcmp (long_options[option_index].name, "slab_density") == 0)
1156            {
1157              if (local_args_info.slab_density_given)
# Line 1115 | Line 1168 | cmdline_parser_internal (int argc, char * const *argv,
1168              args_info->staticProps_group_counter += 1;
1169              break;
1170            }
1171 <          /* hxy (--sele1 must be specified).  */
1171 >          /* hxy.  */
1172            else if (strcmp (long_options[option_index].name, "hxy") == 0)
1173            {
1174              if (local_args_info.hxy_given)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines