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 1052 by gezelter, Tue Sep 26 01:30:32 2006 UTC vs.
Revision 1213 by xsun, Wed Jan 23 21:21:50 2008 UTC

# Line 1 | Line 1
1   /*
2 <  File autogenerated by gengetopt version 2.16
2 >  File autogenerated by gengetopt version 2.19.1
3    generated with the following command:
4 <  gengetopt -F StaticPropsCmd
4 >  gengetopt --file-name=StaticPropsCmd -u
5  
6    The developers of gengetopt consider the fixed text that goes in all
7    gengetopt output files to be in the public domain:
# Line 21 | Line 21
21  
22   #include "StaticPropsCmd.h"
23  
24 + const char *gengetopt_args_info_purpose = "";
25 +
26 + const char *gengetopt_args_info_usage = "Usage: StaticProps [OPTIONS]... [FILES]...";
27 +
28 + const char *gengetopt_args_info_description = "";
29 +
30 + const char *gengetopt_args_info_help[] = {
31 +  "  -h, --help                    Print help and exit",
32 +  "  -V, --version                 Print version and exit",
33 +  "  -i, --input=filename          input dump file",
34 +  "  -o, --output=filename         output file name",
35 +  "  -n, --step=INT                process every n frame  (default=`1')",
36 +  "  -b, --nbins=INT               number of bins (general purpose)  \n                                  (default=`100')",
37 +  "  -x, --nbins_x=INT             number of bins in x axis  (default=`100')",
38 +  "  -y, --nbins_y=INT             number of bins in y axis  (default=`100')",
39 +  "  -a, --nanglebins=INT          number of bins for cos(angle)  (default=`50')",
40 +  "      --length=DOUBLE           maximum length (Defaults to 1/2 smallest length \n                                  of first frame)",
41 +  "  -c, --rcut=DOUBLE             cutoff radius (rcut)",
42 +  "  -z, --zoffset=DOUBLE          Where to set the zero for the slab_density \n                                  calculation  (default=`0')",
43 +  "      --sele1=selection script  select the first stuntdouble set",
44 +  "      --sele2=selection script  select the second stuntdouble set",
45 +  "      --sele3=selection script  select the third stuntdouble set",
46 +  "      --refsele=selection script\n                                select reference (use and only use with --gxyz)",
47 +  "      --molname=STRING          molecule name",
48 +  "      --begin=INT               begin internal index",
49 +  "      --end=INT                 end internal index",
50 +  "      --radius=DOUBLE           nanoparticle radius",
51 +  "\n Group: staticProps\n   an option of this group is required",
52 +  "      --bo                      bond order parameter (--rcut must be specified)",
53 +  "      --bor                     bond order parameter as a function of radius \n                                  (--rcut must be specified)",
54 +  "      --bad                     N(theta) bond angle density within (--rcut must \n                                  be specified)",
55 +  "  -g, --gofr                    g(r)",
56 +  "      --gofz                    g(z)",
57 +  "      --r_theta                 g(r, cos(theta))",
58 +  "      --r_omega                 g(r, cos(omega))",
59 +  "      --theta_omega             g(cos(theta), cos(omega))",
60 +  "      --gxyz                    g(x, y, z)",
61 +  "  -p, --p2                      p2 order parameter (--sele1 and --sele2 must be \n                                  specified)",
62 +  "      --rp2                     rp2 order parameter (--sele1 and --sele2 must \n                                  be specified)",
63 +  "  -s, --scd                     scd order parameter (either --sele1, --sele2, \n                                  --sele3 are specified or --molname, --begin, \n                                  --end are specified)",
64 +  "  -d, --density                 density plot",
65 +  "      --slab_density            slab density",
66 +  "      --hxy                     hxy",
67 +  "      --rho_r                   rho of R",
68 +  "      --hullvol                 hull volume of nanoparticle",
69 +    0
70 + };
71 +
72   static
73   void clear_given (struct gengetopt_args_info *args_info);
74   static
# Line 57 | Line 105 | void clear_given (struct gengetopt_args_info *args_inf
105    args_info->molname_given = 0 ;
106    args_info->begin_given = 0 ;
107    args_info->end_given = 0 ;
108 +  args_info->radius_given = 0 ;
109    args_info->bo_given = 0 ;
110 +  args_info->bor_given = 0 ;
111 +  args_info->bad_given = 0 ;
112    args_info->gofr_given = 0 ;
113 +  args_info->gofz_given = 0 ;
114    args_info->r_theta_given = 0 ;
115    args_info->r_omega_given = 0 ;
116    args_info->theta_omega_given = 0 ;
# Line 69 | Line 121 | void clear_given (struct gengetopt_args_info *args_inf
121    args_info->density_given = 0 ;
122    args_info->slab_density_given = 0 ;
123    args_info->hxy_given = 0 ;
124 +  args_info->rho_r_given = 0 ;
125 +  args_info->hullvol_given = 0 ;
126    args_info->staticProps_group_counter = 0 ;
127   }
128  
# Line 105 | Line 159 | void clear_args (struct gengetopt_args_info *args_info
159    args_info->molname_orig = NULL;
160    args_info->begin_orig = NULL;
161    args_info->end_orig = NULL;
162 +  args_info->radius_orig = NULL;
163 +  
164 + }
165 +
166 + static
167 + void init_args_info(struct gengetopt_args_info *args_info)
168 + {
169 +  args_info->help_help = gengetopt_args_info_help[0] ;
170 +  args_info->version_help = gengetopt_args_info_help[1] ;
171 +  args_info->input_help = gengetopt_args_info_help[2] ;
172 +  args_info->output_help = gengetopt_args_info_help[3] ;
173 +  args_info->step_help = gengetopt_args_info_help[4] ;
174 +  args_info->nbins_help = gengetopt_args_info_help[5] ;
175 +  args_info->nbins_x_help = gengetopt_args_info_help[6] ;
176 +  args_info->nbins_y_help = gengetopt_args_info_help[7] ;
177 +  args_info->nanglebins_help = gengetopt_args_info_help[8] ;
178 +  args_info->length_help = gengetopt_args_info_help[9] ;
179 +  args_info->rcut_help = gengetopt_args_info_help[10] ;
180 +  args_info->zoffset_help = gengetopt_args_info_help[11] ;
181 +  args_info->sele1_help = gengetopt_args_info_help[12] ;
182 +  args_info->sele2_help = gengetopt_args_info_help[13] ;
183 +  args_info->sele3_help = gengetopt_args_info_help[14] ;
184 +  args_info->refsele_help = gengetopt_args_info_help[15] ;
185 +  args_info->molname_help = gengetopt_args_info_help[16] ;
186 +  args_info->begin_help = gengetopt_args_info_help[17] ;
187 +  args_info->end_help = gengetopt_args_info_help[18] ;
188 +  args_info->radius_help = gengetopt_args_info_help[19] ;
189 +  args_info->bo_help = gengetopt_args_info_help[20] ;
190 +  args_info->bor_help = gengetopt_args_info_help[21] ;
191 +  args_info->bad_help = gengetopt_args_info_help[22] ;
192 +  args_info->gofr_help = gengetopt_args_info_help[23] ;
193 +  args_info->gofz_help = gengetopt_args_info_help[24] ;
194 +  args_info->r_theta_help = gengetopt_args_info_help[25] ;
195 +  args_info->r_omega_help = gengetopt_args_info_help[26] ;
196 +  args_info->theta_omega_help = gengetopt_args_info_help[27] ;
197 +  args_info->gxyz_help = gengetopt_args_info_help[28] ;
198 +  args_info->p2_help = gengetopt_args_info_help[29] ;
199 +  args_info->rp2_help = gengetopt_args_info_help[30] ;
200 +  args_info->scd_help = gengetopt_args_info_help[31] ;
201 +  args_info->density_help = gengetopt_args_info_help[32] ;
202 +  args_info->slab_density_help = gengetopt_args_info_help[33] ;
203 +  args_info->hxy_help = gengetopt_args_info_help[34] ;
204 +  args_info->rho_r_help = gengetopt_args_info_help[35] ;
205 +  args_info->hullvol_help = gengetopt_args_info_help[36] ;
206    
207   }
208  
# Line 117 | Line 215 | cmdline_parser_print_help (void)
215   void
216   cmdline_parser_print_help (void)
217   {
218 +  int i = 0;
219    cmdline_parser_print_version ();
220 <  printf("\nUsage: StaticProps [OPTIONS]...\n\n");
221 <  printf("%s\n","  -h, --help                    Print help and exit");
222 <  printf("%s\n","  -V, --version                 Print version and exit");
223 <  printf("%s\n","  -i, --input=filename          input dump file");
224 <  printf("%s\n","  -o, --output=filename         output file name");
225 <  printf("%s\n","  -n, --step=INT                process every n frame  (default=`1')");
226 <  printf("%s\n","  -b, --nbins=INT               number of bins (general purpose)  \n                                  (default=`100')");
227 <  printf("%s\n","  -x, --nbins_x=INT             number of bins in x axis  (default=`100')");
228 <  printf("%s\n","  -y, --nbins_y=INT             number of bins in y axis  (default=`100')");
229 <  printf("%s\n","  -a, --nanglebins=INT          number of bins for cos(angle)  (default=`50')");
230 <  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 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","      --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","  -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","  -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 <  
220 >
221 >  if (strlen(gengetopt_args_info_purpose) > 0)
222 >    printf("\n%s\n", gengetopt_args_info_purpose);
223 >
224 >  printf("\n%s\n\n", gengetopt_args_info_usage);
225 >
226 >  if (strlen(gengetopt_args_info_description) > 0)
227 >    printf("%s\n", gengetopt_args_info_description);
228 >
229 >  while (gengetopt_args_info_help[i])
230 >    printf("%s\n", gengetopt_args_info_help[i++]);
231   }
232  
233   void
# Line 159 | Line 235 | cmdline_parser_init (struct gengetopt_args_info *args_
235   {
236    clear_given (args_info);
237    clear_args (args_info);
238 +  init_args_info (args_info);
239 +
240 +  args_info->inputs = NULL;
241 +  args_info->inputs_num = 0;
242   }
243  
244   static void
245   cmdline_parser_release (struct gengetopt_args_info *args_info)
246   {
247    
248 +  unsigned int i;
249    if (args_info->input_arg)
250      {
251        free (args_info->input_arg); /* free previous argument */
# Line 285 | Line 366 | cmdline_parser_release (struct gengetopt_args_info *ar
366        free (args_info->end_orig); /* free previous argument */
367        args_info->end_orig = 0;
368      }
369 +  if (args_info->radius_orig)
370 +    {
371 +      free (args_info->radius_orig); /* free previous argument */
372 +      args_info->radius_orig = 0;
373 +    }
374    
375 +  for (i = 0; i < args_info->inputs_num; ++i)
376 +    free (args_info->inputs [i]);
377 +  
378 +  if (args_info->inputs_num)
379 +    free (args_info->inputs);
380 +  
381    clear_given (args_info);
382   }
383  
# Line 428 | Line 520 | cmdline_parser_file_save(const char *filename, struct
520        fprintf(outfile, "%s\n", "end");
521      }
522    }
523 +  if (args_info->radius_given) {
524 +    if (args_info->radius_orig) {
525 +      fprintf(outfile, "%s=\"%s\"\n", "radius", args_info->radius_orig);
526 +    } else {
527 +      fprintf(outfile, "%s\n", "radius");
528 +    }
529 +  }
530    if (args_info->bo_given) {
531      fprintf(outfile, "%s\n", "bo");
532    }
533 +  if (args_info->bor_given) {
534 +    fprintf(outfile, "%s\n", "bor");
535 +  }
536 +  if (args_info->bad_given) {
537 +    fprintf(outfile, "%s\n", "bad");
538 +  }
539    if (args_info->gofr_given) {
540      fprintf(outfile, "%s\n", "gofr");
541    }
542 +  if (args_info->gofz_given) {
543 +    fprintf(outfile, "%s\n", "gofz");
544 +  }
545    if (args_info->r_theta_given) {
546      fprintf(outfile, "%s\n", "r_theta");
547    }
# Line 464 | Line 572 | cmdline_parser_file_save(const char *filename, struct
572    if (args_info->hxy_given) {
573      fprintf(outfile, "%s\n", "hxy");
574    }
575 +  if (args_info->rho_r_given) {
576 +    fprintf(outfile, "%s\n", "rho_r");
577 +  }
578 +  if (args_info->hullvol_given) {
579 +    fprintf(outfile, "%s\n", "hullvol");
580 +  }
581    
582    fclose (outfile);
583  
# Line 504 | Line 618 | reset_group_staticProps(struct gengetopt_args_info *ar
618      return;
619    
620    args_info->bo_given = 0 ;
621 +  args_info->bor_given = 0 ;
622 +  args_info->bad_given = 0 ;
623    args_info->gofr_given = 0 ;
624 +  args_info->gofz_given = 0 ;
625    args_info->r_theta_given = 0 ;
626    args_info->r_omega_given = 0 ;
627    args_info->theta_omega_given = 0 ;
# Line 515 | Line 632 | reset_group_staticProps(struct gengetopt_args_info *ar
632    args_info->density_given = 0 ;
633    args_info->slab_density_given = 0 ;
634    args_info->hxy_given = 0 ;
635 +  args_info->rho_r_given = 0 ;
636 +  args_info->hullvol_given = 0 ;
637  
638    args_info->staticProps_group_counter = 0;
639   }
# Line 563 | Line 682 | cmdline_parser_required2 (struct gengetopt_args_info *
682   {
683    int error = 0;
684  
685 +  /* checks for required options */
686    if (! args_info->input_given)
687      {
688        fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : ""));
689        error = 1;
690      }
691 +  
692    if (args_info->staticProps_group_counter == 0)
693      {
694        fprintf (stderr, "%s: %d options of group staticProps were given. One is required.%s\n", prog_name, args_info->staticProps_group_counter, (additional_error ? additional_error : ""));
# Line 575 | Line 696 | cmdline_parser_required2 (struct gengetopt_args_info *
696      }
697    
698  
699 +  /* checks for dependences among options */
700 +
701    return error;
702   }
703  
# Line 621 | Line 744 | cmdline_parser_internal (int argc, char * const *argv,
744          { "molname",    1, NULL, 0 },
745          { "begin",      1, NULL, 0 },
746          { "end",        1, NULL, 0 },
747 +        { "radius",     1, NULL, 0 },
748          { "bo", 0, NULL, 0 },
749 +        { "bor",        0, NULL, 0 },
750 +        { "bad",        0, NULL, 0 },
751          { "gofr",       0, NULL, 'g' },
752 +        { "gofz",       0, NULL, 0 },
753          { "r_theta",    0, NULL, 0 },
754          { "r_omega",    0, NULL, 0 },
755          { "theta_omega",        0, NULL, 0 },
# Line 633 | Line 760 | cmdline_parser_internal (int argc, char * const *argv,
760          { "density",    0, NULL, 'd' },
761          { "slab_density",       0, NULL, 0 },
762          { "hxy",        0, NULL, 0 },
763 +        { "rho_r",      0, NULL, 0 },
764 +        { "hullvol",    0, NULL, 0 },
765          { NULL, 0, NULL, 0 }
766        };
767  
# Line 1049 | Line 1178 | cmdline_parser_internal (int argc, char * const *argv,
1178                free (args_info->end_orig); /* free previous string */
1179              args_info->end_orig = gengetopt_strdup (optarg);
1180            }
1181 <          /* bond order parameter (--rcut must be specified.  */
1181 >          /* nanoparticle radius.  */
1182 >          else if (strcmp (long_options[option_index].name, "radius") == 0)
1183 >          {
1184 >            if (local_args_info.radius_given)
1185 >              {
1186 >                fprintf (stderr, "%s: `--radius' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1187 >                goto failure;
1188 >              }
1189 >            if (args_info->radius_given && ! override)
1190 >              continue;
1191 >            local_args_info.radius_given = 1;
1192 >            args_info->radius_given = 1;
1193 >            args_info->radius_arg = strtod (optarg, &stop_char);
1194 >            if (!(stop_char && *stop_char == '\0')) {
1195 >              fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
1196 >              goto failure;
1197 >            }
1198 >            if (args_info->radius_orig)
1199 >              free (args_info->radius_orig); /* free previous string */
1200 >            args_info->radius_orig = gengetopt_strdup (optarg);
1201 >          }
1202 >          /* bond order parameter (--rcut must be specified).  */
1203            else if (strcmp (long_options[option_index].name, "bo") == 0)
1204            {
1205              if (local_args_info.bo_given)
# Line 1061 | Line 1211 | cmdline_parser_internal (int argc, char * const *argv,
1211                continue;
1212              local_args_info.bo_given = 1;
1213              args_info->bo_given = 1;
1214 +            if (args_info->staticProps_group_counter && override)
1215 +              reset_group_staticProps (args_info);
1216 +            args_info->staticProps_group_counter += 1;
1217 +            break;
1218 +          }
1219 +          /* bond order parameter as a function of radius (--rcut must be specified).  */
1220 +          else if (strcmp (long_options[option_index].name, "bor") == 0)
1221 +          {
1222 +            if (local_args_info.bor_given)
1223 +              {
1224 +                fprintf (stderr, "%s: `--bor' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1225 +                goto failure;
1226 +              }
1227 +            if (args_info->bor_given && ! override)
1228 +              continue;
1229 +            local_args_info.bor_given = 1;
1230 +            args_info->bor_given = 1;
1231 +            if (args_info->staticProps_group_counter && override)
1232 +              reset_group_staticProps (args_info);
1233 +            args_info->staticProps_group_counter += 1;
1234 +            break;
1235 +          }
1236 +          /* N(theta) bond angle density within (--rcut must be specified).  */
1237 +          else if (strcmp (long_options[option_index].name, "bad") == 0)
1238 +          {
1239 +            if (local_args_info.bad_given)
1240 +              {
1241 +                fprintf (stderr, "%s: `--bad' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1242 +                goto failure;
1243 +              }
1244 +            if (args_info->bad_given && ! override)
1245 +              continue;
1246 +            local_args_info.bad_given = 1;
1247 +            args_info->bad_given = 1;
1248              if (args_info->staticProps_group_counter && override)
1249                reset_group_staticProps (args_info);
1250              args_info->staticProps_group_counter += 1;
1251              break;
1252            }
1253 +          /* g(z).  */
1254 +          else if (strcmp (long_options[option_index].name, "gofz") == 0)
1255 +          {
1256 +            if (local_args_info.gofz_given)
1257 +              {
1258 +                fprintf (stderr, "%s: `--gofz' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1259 +                goto failure;
1260 +              }
1261 +            if (args_info->gofz_given && ! override)
1262 +              continue;
1263 +            local_args_info.gofz_given = 1;
1264 +            args_info->gofz_given = 1;
1265 +            if (args_info->staticProps_group_counter && override)
1266 +              reset_group_staticProps (args_info);
1267 +            args_info->staticProps_group_counter += 1;
1268 +            break;
1269 +          }
1270            /* g(r, cos(theta)).  */
1271            else if (strcmp (long_options[option_index].name, "r_theta") == 0)
1272            {
# Line 1185 | Line 1386 | cmdline_parser_internal (int argc, char * const *argv,
1386              args_info->staticProps_group_counter += 1;
1387              break;
1388            }
1389 +          /* rho of R.  */
1390 +          else if (strcmp (long_options[option_index].name, "rho_r") == 0)
1391 +          {
1392 +            if (local_args_info.rho_r_given)
1393 +              {
1394 +                fprintf (stderr, "%s: `--rho_r' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1395 +                goto failure;
1396 +              }
1397 +            if (args_info->rho_r_given && ! override)
1398 +              continue;
1399 +            local_args_info.rho_r_given = 1;
1400 +            args_info->rho_r_given = 1;
1401 +            if (args_info->staticProps_group_counter && override)
1402 +              reset_group_staticProps (args_info);
1403 +            args_info->staticProps_group_counter += 1;
1404 +            break;
1405 +          }
1406 +          /* hull volume of nanoparticle.  */
1407 +          else if (strcmp (long_options[option_index].name, "hullvol") == 0)
1408 +          {
1409 +            if (local_args_info.hullvol_given)
1410 +              {
1411 +                fprintf (stderr, "%s: `--hullvol' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1412 +                goto failure;
1413 +              }
1414 +            if (args_info->hullvol_given && ! override)
1415 +              continue;
1416 +            local_args_info.hullvol_given = 1;
1417 +            args_info->hullvol_given = 1;
1418 +            if (args_info->staticProps_group_counter && override)
1419 +              reset_group_staticProps (args_info);
1420 +            args_info->staticProps_group_counter += 1;
1421 +            break;
1422 +          }
1423            
1424            break;
1425          case '?':       /* Invalid option.  */
# Line 1215 | Line 1450 | cmdline_parser_internal (int argc, char * const *argv,
1450    if ( error )
1451      return (EXIT_FAILURE);
1452  
1453 +  if (optind < argc)
1454 +    {
1455 +      int i = 0 ;
1456 +      int found_prog_name = 0;
1457 +      /* whether program name, i.e., argv[0], is in the remaining args
1458 +         (this may happen with some implementations of getopt,
1459 +          but surely not with the one included by gengetopt) */
1460 +
1461 +      i = optind;
1462 +      while (i < argc)
1463 +        if (argv[i++] == argv[0]) {
1464 +          found_prog_name = 1;
1465 +          break;
1466 +        }
1467 +      i = 0;
1468 +
1469 +      args_info->inputs_num = argc - optind - found_prog_name;
1470 +      args_info->inputs =
1471 +        (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
1472 +      while (optind < argc)
1473 +        if (argv[optind++] != argv[0])
1474 +          args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ;
1475 +    }
1476 +
1477    return 0;
1478  
1479   failure:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines