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

Comparing trunk/src/applications/staticProps/StaticPropsCmd.c (file contents):
Revision 1091 by chuckv, Fri Nov 10 18:45:29 2006 UTC vs.
Revision 1513 by gezelter, Tue Oct 19 18:40:54 2010 UTC

# Line 1 | Line 1
1   /*
2 <  File autogenerated by gengetopt version 2.15
2 >  File autogenerated by gengetopt version 2.22
3    generated with the following command:
4 <  gengetopt -i StaticProps.ggo -F StaticPropsCmd
4 >  gengetopt -F 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 +  "      --nbins_z=INT             number of bins in z axis  (default=`100')",
40 +  "  -a, --nanglebins=INT          number of bins for cos(angle)  (default=`50')",
41 +  "  -c, --rcut=DOUBLE             cutoff radius (rcut)",
42 +  "      --dz=DOUBLE               slab width (dz)",
43 +  "      --length=DOUBLE           maximum length (Defaults to 1/2 smallest length \n                                  of first frame)",
44 +  "      --zlength=DOUBLE          maximum length (Defaults to 1/2 smallest length \n                                  of first frame)",
45 +  "  -z, --zoffset=DOUBLE          Where to set the zero for the slab_density \n                                  calculation  (default=`0')",
46 +  "      --sele1=selection script  select the first stuntdouble set",
47 +  "      --sele2=selection script  select the second stuntdouble set",
48 +  "      --sele3=selection script  select the third stuntdouble set",
49 +  "      --refsele=selection script\n                                select reference (use and only use with --gxyz)",
50 +  "      --comsele=selection script\n                                select stunt doubles for center-of-mass \n                                  reference point",
51 +  "      --molname=STRING          molecule name",
52 +  "      --begin=INT               begin internal index",
53 +  "      --end=INT                 end internal index",
54 +  "      --radius=DOUBLE           nanoparticle radius",
55 +  "\n Group: staticProps\n   an option of this group is required",
56 +  "      --bo                      bond order parameter (--rcut must be specified)",
57 +  "      --bor                     bond order parameter as a function of radius \n                                  (--rcut must be specified)",
58 +  "      --bad                     N(theta) bond angle density within (--rcut must \n                                  be specified)",
59 +  "      --count                   count of molecules matching selection criteria \n                                  (and associated statistics)",
60 +  "  -g, --gofr                    g(r)",
61 +  "      --gofz                    g(z)",
62 +  "      --r_theta                 g(r, cos(theta))",
63 +  "      --r_omega                 g(r, cos(omega))",
64 +  "      --r_z                     g(r, z)",
65 +  "      --theta_omega             g(cos(theta), cos(omega))",
66 +  "      --gxyz                    g(x, y, z)",
67 +  "      --twodgofr                2D g(r) (Slab width --dz must be specified)",
68 +  "  -p, --p2                      p2 order parameter (--sele1 and --sele2 must be \n                                  specified)",
69 +  "      --rp2                     rp2 order parameter (--sele1 and --sele2 must \n                                  be specified)",
70 +  "  -s, --scd                     scd order parameter (either --sele1, --sele2, \n                                  --sele3 are specified or --molname, --begin, \n                                  --end are specified)",
71 +  "  -d, --density                 density plot",
72 +  "      --slab_density            slab density",
73 +  "      --p_angle                 p(cos(theta))",
74 +  "      --hxy                     hxy",
75 +  "      --rho_r                   rho of R",
76 +  "      --hullvol                 hull volume of nanoparticle",
77 +    0
78 + };
79 +
80 + typedef enum {ARG_NO
81 +  , ARG_STRING
82 +  , ARG_INT
83 +  , ARG_DOUBLE
84 + } cmdline_parser_arg_type;
85 +
86   static
87   void clear_given (struct gengetopt_args_info *args_info);
88   static
89   void clear_args (struct gengetopt_args_info *args_info);
90  
91   static int
92 < cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error);
92 > cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
93 >                        struct cmdline_parser_params *params, const char *additional_error);
94  
95   static int
96   cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
# Line 46 | Line 109 | void clear_given (struct gengetopt_args_info *args_inf
109    args_info->nbins_given = 0 ;
110    args_info->nbins_x_given = 0 ;
111    args_info->nbins_y_given = 0 ;
112 +  args_info->nbins_z_given = 0 ;
113    args_info->nanglebins_given = 0 ;
50  args_info->length_given = 0 ;
114    args_info->rcut_given = 0 ;
115 +  args_info->dz_given = 0 ;
116 +  args_info->length_given = 0 ;
117 +  args_info->zlength_given = 0 ;
118    args_info->zoffset_given = 0 ;
119    args_info->sele1_given = 0 ;
120    args_info->sele2_given = 0 ;
121    args_info->sele3_given = 0 ;
122    args_info->refsele_given = 0 ;
123 +  args_info->comsele_given = 0 ;
124    args_info->molname_given = 0 ;
125    args_info->begin_given = 0 ;
126    args_info->end_given = 0 ;
127    args_info->radius_given = 0 ;
128    args_info->bo_given = 0 ;
129 +  args_info->bor_given = 0 ;
130 +  args_info->bad_given = 0 ;
131 +  args_info->count_given = 0 ;
132    args_info->gofr_given = 0 ;
133 +  args_info->gofz_given = 0 ;
134    args_info->r_theta_given = 0 ;
135    args_info->r_omega_given = 0 ;
136 +  args_info->r_z_given = 0 ;
137    args_info->theta_omega_given = 0 ;
138    args_info->gxyz_given = 0 ;
139 +  args_info->twodgofr_given = 0 ;
140    args_info->p2_given = 0 ;
141    args_info->rp2_given = 0 ;
142    args_info->scd_given = 0 ;
143    args_info->density_given = 0 ;
144    args_info->slab_density_given = 0 ;
145 +  args_info->p_angle_given = 0 ;
146    args_info->hxy_given = 0 ;
147    args_info->rho_r_given = 0 ;
148 +  args_info->hullvol_given = 0 ;
149    args_info->staticProps_group_counter = 0 ;
150   }
151  
# Line 89 | Line 164 | void clear_args (struct gengetopt_args_info *args_info
164    args_info->nbins_x_orig = NULL;
165    args_info->nbins_y_arg = 100;
166    args_info->nbins_y_orig = NULL;
167 +  args_info->nbins_z_arg = 100;
168 +  args_info->nbins_z_orig = NULL;
169    args_info->nanglebins_arg = 50;
170    args_info->nanglebins_orig = NULL;
94  args_info->length_orig = NULL;
171    args_info->rcut_orig = NULL;
172 +  args_info->dz_orig = NULL;
173 +  args_info->length_orig = NULL;
174 +  args_info->zlength_orig = NULL;
175    args_info->zoffset_arg = 0;
176    args_info->zoffset_orig = NULL;
177    args_info->sele1_arg = NULL;
# Line 103 | Line 182 | void clear_args (struct gengetopt_args_info *args_info
182    args_info->sele3_orig = NULL;
183    args_info->refsele_arg = NULL;
184    args_info->refsele_orig = NULL;
185 +  args_info->comsele_arg = NULL;
186 +  args_info->comsele_orig = NULL;
187    args_info->molname_arg = NULL;
188    args_info->molname_orig = NULL;
189    args_info->begin_orig = NULL;
# Line 111 | Line 192 | void clear_args (struct gengetopt_args_info *args_info
192    
193   }
194  
195 + static
196 + void init_args_info(struct gengetopt_args_info *args_info)
197 + {
198 +
199 +
200 +  args_info->help_help = gengetopt_args_info_help[0] ;
201 +  args_info->version_help = gengetopt_args_info_help[1] ;
202 +  args_info->input_help = gengetopt_args_info_help[2] ;
203 +  args_info->output_help = gengetopt_args_info_help[3] ;
204 +  args_info->step_help = gengetopt_args_info_help[4] ;
205 +  args_info->nbins_help = gengetopt_args_info_help[5] ;
206 +  args_info->nbins_x_help = gengetopt_args_info_help[6] ;
207 +  args_info->nbins_y_help = gengetopt_args_info_help[7] ;
208 +  args_info->nbins_z_help = gengetopt_args_info_help[8] ;
209 +  args_info->nanglebins_help = gengetopt_args_info_help[9] ;
210 +  args_info->rcut_help = gengetopt_args_info_help[10] ;
211 +  args_info->dz_help = gengetopt_args_info_help[11] ;
212 +  args_info->length_help = gengetopt_args_info_help[12] ;
213 +  args_info->zlength_help = gengetopt_args_info_help[13] ;
214 +  args_info->zoffset_help = gengetopt_args_info_help[14] ;
215 +  args_info->sele1_help = gengetopt_args_info_help[15] ;
216 +  args_info->sele2_help = gengetopt_args_info_help[16] ;
217 +  args_info->sele3_help = gengetopt_args_info_help[17] ;
218 +  args_info->refsele_help = gengetopt_args_info_help[18] ;
219 +  args_info->comsele_help = gengetopt_args_info_help[19] ;
220 +  args_info->molname_help = gengetopt_args_info_help[20] ;
221 +  args_info->begin_help = gengetopt_args_info_help[21] ;
222 +  args_info->end_help = gengetopt_args_info_help[22] ;
223 +  args_info->radius_help = gengetopt_args_info_help[23] ;
224 +  args_info->bo_help = gengetopt_args_info_help[25] ;
225 +  args_info->bor_help = gengetopt_args_info_help[26] ;
226 +  args_info->bad_help = gengetopt_args_info_help[27] ;
227 +  args_info->count_help = gengetopt_args_info_help[28] ;
228 +  args_info->gofr_help = gengetopt_args_info_help[29] ;
229 +  args_info->gofz_help = gengetopt_args_info_help[30] ;
230 +  args_info->r_theta_help = gengetopt_args_info_help[31] ;
231 +  args_info->r_omega_help = gengetopt_args_info_help[32] ;
232 +  args_info->r_z_help = gengetopt_args_info_help[33] ;
233 +  args_info->theta_omega_help = gengetopt_args_info_help[34] ;
234 +  args_info->gxyz_help = gengetopt_args_info_help[35] ;
235 +  args_info->twodgofr_help = gengetopt_args_info_help[36] ;
236 +  args_info->p2_help = gengetopt_args_info_help[37] ;
237 +  args_info->rp2_help = gengetopt_args_info_help[38] ;
238 +  args_info->scd_help = gengetopt_args_info_help[39] ;
239 +  args_info->density_help = gengetopt_args_info_help[40] ;
240 +  args_info->slab_density_help = gengetopt_args_info_help[41] ;
241 +  args_info->p_angle_help = gengetopt_args_info_help[42] ;
242 +  args_info->hxy_help = gengetopt_args_info_help[43] ;
243 +  args_info->rho_r_help = gengetopt_args_info_help[44] ;
244 +  args_info->hullvol_help = gengetopt_args_info_help[45] ;
245 +  
246 + }
247 +
248   void
249   cmdline_parser_print_version (void)
250   {
251    printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
252   }
253  
254 + static void print_help_common(void) {
255 +  cmdline_parser_print_version ();
256 +
257 +  if (strlen(gengetopt_args_info_purpose) > 0)
258 +    printf("\n%s\n", gengetopt_args_info_purpose);
259 +
260 +  if (strlen(gengetopt_args_info_usage) > 0)
261 +    printf("\n%s\n", gengetopt_args_info_usage);
262 +
263 +  printf("\n");
264 +
265 +  if (strlen(gengetopt_args_info_description) > 0)
266 +    printf("%s\n", gengetopt_args_info_description);
267 + }
268 +
269   void
270   cmdline_parser_print_help (void)
271   {
272 <  cmdline_parser_print_version ();
273 <  printf("\nUsage: StaticProps [OPTIONS]...\n\n");
274 <  printf("%s\n","  -h, --help                    Print help and exit");
275 <  printf("%s\n","  -V, --version                 Print version and exit");
127 <  printf("%s\n","  -i, --input=filename          input dump file");
128 <  printf("%s\n","  -o, --output=filename         output file name");
129 <  printf("%s\n","  -n, --step=INT                process every n frame  (default=`1')");
130 <  printf("%s\n","  -b, --nbins=INT               number of bins (general purpose)  \n                                  (default=`100')");
131 <  printf("%s\n","  -x, --nbins_x=INT             number of bins in x axis  (default=`100')");
132 <  printf("%s\n","  -y, --nbins_y=INT             number of bins in y axis  (default=`100')");
133 <  printf("%s\n","  -a, --nanglebins=INT          number of bins for cos(angle)  (default=`50')");
134 <  printf("%s\n","      --length=DOUBLE           maximum length (Defaults to 1/2 smallest length \n                                  of first frame)");
135 <  printf("%s\n","  -c, --rcut=DOUBLE             cutoff radius (rcut)");
136 <  printf("%s\n","  -z, --zoffset=DOUBLE          Where to set the zero for the slab_density \n                                  calculation  (default=`0')");
137 <  printf("%s\n","      --sele1=selection script  select the first stuntdouble set");
138 <  printf("%s\n","      --sele2=selection script  select the second stuntdouble set");
139 <  printf("%s\n","      --sele3=selection script  select the third stuntdouble set");
140 <  printf("%s\n","      --refsele=selection script\n                                select reference (use and only use with --gxyz)");
141 <  printf("%s\n","      --molname=STRING          molecule name");
142 <  printf("%s\n","      --begin=INT               begin internal index");
143 <  printf("%s\n","      --end=INT                 end internal index");
144 <  printf("%s\n","      --radius=DOUBLE           nanoparticle radius");
145 <  printf("%s\n","\n Group: staticProps\n   an option of this group is required");
146 <  printf("%s\n","      --bo                      bond order parameter (--rcut must be specified");
147 <  printf("%s\n","  -g, --gofr                    g(r)");
148 <  printf("%s\n","      --r_theta                 g(r, cos(theta))");
149 <  printf("%s\n","      --r_omega                 g(r, cos(omega))");
150 <  printf("%s\n","      --theta_omega             g(cos(theta), cos(omega))");
151 <  printf("%s\n","      --gxyz                    g(x, y, z)");
152 <  printf("%s\n","  -p, --p2                      p2 order parameter (--sele1 and --sele2 must be \n                                  specified)");
153 <  printf("%s\n","      --rp2                     rp2 order parameter (--sele1 and --sele2 must \n                                  be specified)");
154 <  printf("%s\n","  -s, --scd                     scd order parameter (either --sele1, --sele2, \n                                  --sele3 are specified or --molname, --begin, \n                                  --end are specified)");
155 <  printf("%s\n","  -d, --density                 density plot");
156 <  printf("%s\n","      --slab_density            slab density");
157 <  printf("%s\n","      --hxy                     hxy");
158 <  printf("%s\n","      --rho_r                   rho of R");
159 <  
272 >  int i = 0;
273 >  print_help_common();
274 >  while (gengetopt_args_info_help[i])
275 >    printf("%s\n", gengetopt_args_info_help[i++]);
276   }
277  
278   void
# Line 164 | Line 280 | cmdline_parser_init (struct gengetopt_args_info *args_
280   {
281    clear_given (args_info);
282    clear_args (args_info);
283 +  init_args_info (args_info);
284 +
285 +  args_info->inputs = NULL;
286 +  args_info->inputs_num = 0;
287   }
288  
289 + void
290 + cmdline_parser_params_init(struct cmdline_parser_params *params)
291 + {
292 +  if (params)
293 +    {
294 +      params->override = 0;
295 +      params->initialize = 1;
296 +      params->check_required = 1;
297 +      params->check_ambiguity = 0;
298 +      params->print_errors = 1;
299 +    }
300 + }
301 +
302 + struct cmdline_parser_params *
303 + cmdline_parser_params_create(void)
304 + {
305 +  struct cmdline_parser_params *params =
306 +    (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
307 +  cmdline_parser_params_init(params);  
308 +  return params;
309 + }
310 +
311   static void
312 < cmdline_parser_release (struct gengetopt_args_info *args_info)
312 > free_string_field (char **s)
313   {
314 <  
173 <  if (args_info->input_arg)
314 >  if (*s)
315      {
316 <      free (args_info->input_arg); /* free previous argument */
317 <      args_info->input_arg = 0;
316 >      free (*s);
317 >      *s = 0;
318      }
319 <  if (args_info->input_orig)
319 > }
320 >
321 >
322 > static void
323 > cmdline_parser_release (struct gengetopt_args_info *args_info)
324 > {
325 >  unsigned int i;
326 >  free_string_field (&(args_info->input_arg));
327 >  free_string_field (&(args_info->input_orig));
328 >  free_string_field (&(args_info->output_arg));
329 >  free_string_field (&(args_info->output_orig));
330 >  free_string_field (&(args_info->step_orig));
331 >  free_string_field (&(args_info->nbins_orig));
332 >  free_string_field (&(args_info->nbins_x_orig));
333 >  free_string_field (&(args_info->nbins_y_orig));
334 >  free_string_field (&(args_info->nbins_z_orig));
335 >  free_string_field (&(args_info->nanglebins_orig));
336 >  free_string_field (&(args_info->rcut_orig));
337 >  free_string_field (&(args_info->dz_orig));
338 >  free_string_field (&(args_info->length_orig));
339 >  free_string_field (&(args_info->zlength_orig));
340 >  free_string_field (&(args_info->zoffset_orig));
341 >  free_string_field (&(args_info->sele1_arg));
342 >  free_string_field (&(args_info->sele1_orig));
343 >  free_string_field (&(args_info->sele2_arg));
344 >  free_string_field (&(args_info->sele2_orig));
345 >  free_string_field (&(args_info->sele3_arg));
346 >  free_string_field (&(args_info->sele3_orig));
347 >  free_string_field (&(args_info->refsele_arg));
348 >  free_string_field (&(args_info->refsele_orig));
349 >  free_string_field (&(args_info->comsele_arg));
350 >  free_string_field (&(args_info->comsele_orig));
351 >  free_string_field (&(args_info->molname_arg));
352 >  free_string_field (&(args_info->molname_orig));
353 >  free_string_field (&(args_info->begin_orig));
354 >  free_string_field (&(args_info->end_orig));
355 >  free_string_field (&(args_info->radius_orig));
356 >  
357 >  
358 >  for (i = 0; i < args_info->inputs_num; ++i)
359 >    free (args_info->inputs [i]);
360 >
361 >  if (args_info->inputs_num)
362 >    free (args_info->inputs);
363 >
364 >  clear_given (args_info);
365 > }
366 >
367 >
368 > static void
369 > write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
370 > {
371 >  if (arg) {
372 >    fprintf(outfile, "%s=\"%s\"\n", opt, arg);
373 >  } else {
374 >    fprintf(outfile, "%s\n", opt);
375 >  }
376 > }
377 >
378 >
379 > int
380 > cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
381 > {
382 >  int i = 0;
383 >
384 >  if (!outfile)
385      {
386 <      free (args_info->input_orig); /* free previous argument */
387 <      args_info->input_orig = 0;
386 >      fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
387 >      return EXIT_FAILURE;
388      }
389 <  if (args_info->output_arg)
390 <    {
391 <      free (args_info->output_arg); /* free previous argument */
392 <      args_info->output_arg = 0;
393 <    }
394 <  if (args_info->output_orig)
395 <    {
396 <      free (args_info->output_orig); /* free previous argument */
397 <      args_info->output_orig = 0;
398 <    }
399 <  if (args_info->step_orig)
400 <    {
401 <      free (args_info->step_orig); /* free previous argument */
402 <      args_info->step_orig = 0;
403 <    }
404 <  if (args_info->nbins_orig)
405 <    {
406 <      free (args_info->nbins_orig); /* free previous argument */
407 <      args_info->nbins_orig = 0;
408 <    }
409 <  if (args_info->nbins_x_orig)
410 <    {
411 <      free (args_info->nbins_x_orig); /* free previous argument */
412 <      args_info->nbins_x_orig = 0;
413 <    }
414 <  if (args_info->nbins_y_orig)
415 <    {
416 <      free (args_info->nbins_y_orig); /* free previous argument */
417 <      args_info->nbins_y_orig = 0;
418 <    }
419 <  if (args_info->nanglebins_orig)
420 <    {
421 <      free (args_info->nanglebins_orig); /* free previous argument */
422 <      args_info->nanglebins_orig = 0;
423 <    }
424 <  if (args_info->length_orig)
425 <    {
426 <      free (args_info->length_orig); /* free previous argument */
427 <      args_info->length_orig = 0;
428 <    }
429 <  if (args_info->rcut_orig)
430 <    {
431 <      free (args_info->rcut_orig); /* free previous argument */
432 <      args_info->rcut_orig = 0;
433 <    }
434 <  if (args_info->zoffset_orig)
435 <    {
436 <      free (args_info->zoffset_orig); /* free previous argument */
437 <      args_info->zoffset_orig = 0;
438 <    }
439 <  if (args_info->sele1_arg)
440 <    {
441 <      free (args_info->sele1_arg); /* free previous argument */
442 <      args_info->sele1_arg = 0;
443 <    }
444 <  if (args_info->sele1_orig)
445 <    {
446 <      free (args_info->sele1_orig); /* free previous argument */
447 <      args_info->sele1_orig = 0;
448 <    }
449 <  if (args_info->sele2_arg)
450 <    {
451 <      free (args_info->sele2_arg); /* free previous argument */
452 <      args_info->sele2_arg = 0;
453 <    }
454 <  if (args_info->sele2_orig)
455 <    {
456 <      free (args_info->sele2_orig); /* free previous argument */
457 <      args_info->sele2_orig = 0;
458 <    }
459 <  if (args_info->sele3_arg)
460 <    {
461 <      free (args_info->sele3_arg); /* free previous argument */
462 <      args_info->sele3_arg = 0;
463 <    }
464 <  if (args_info->sele3_orig)
465 <    {
466 <      free (args_info->sele3_orig); /* free previous argument */
467 <      args_info->sele3_orig = 0;
468 <    }
469 <  if (args_info->refsele_arg)
470 <    {
471 <      free (args_info->refsele_arg); /* free previous argument */
472 <      args_info->refsele_arg = 0;
473 <    }
474 <  if (args_info->refsele_orig)
475 <    {
476 <      free (args_info->refsele_orig); /* free previous argument */
477 <      args_info->refsele_orig = 0;
478 <    }
479 <  if (args_info->molname_arg)
274 <    {
275 <      free (args_info->molname_arg); /* free previous argument */
276 <      args_info->molname_arg = 0;
277 <    }
278 <  if (args_info->molname_orig)
279 <    {
280 <      free (args_info->molname_orig); /* free previous argument */
281 <      args_info->molname_orig = 0;
282 <    }
283 <  if (args_info->begin_orig)
284 <    {
285 <      free (args_info->begin_orig); /* free previous argument */
286 <      args_info->begin_orig = 0;
287 <    }
288 <  if (args_info->end_orig)
289 <    {
290 <      free (args_info->end_orig); /* free previous argument */
291 <      args_info->end_orig = 0;
292 <    }
293 <  if (args_info->radius_orig)
294 <    {
295 <      free (args_info->radius_orig); /* free previous argument */
296 <      args_info->radius_orig = 0;
297 <    }
389 >
390 >  if (args_info->help_given)
391 >    write_into_file(outfile, "help", 0, 0 );
392 >  if (args_info->version_given)
393 >    write_into_file(outfile, "version", 0, 0 );
394 >  if (args_info->input_given)
395 >    write_into_file(outfile, "input", args_info->input_orig, 0);
396 >  if (args_info->output_given)
397 >    write_into_file(outfile, "output", args_info->output_orig, 0);
398 >  if (args_info->step_given)
399 >    write_into_file(outfile, "step", args_info->step_orig, 0);
400 >  if (args_info->nbins_given)
401 >    write_into_file(outfile, "nbins", args_info->nbins_orig, 0);
402 >  if (args_info->nbins_x_given)
403 >    write_into_file(outfile, "nbins_x", args_info->nbins_x_orig, 0);
404 >  if (args_info->nbins_y_given)
405 >    write_into_file(outfile, "nbins_y", args_info->nbins_y_orig, 0);
406 >  if (args_info->nbins_z_given)
407 >    write_into_file(outfile, "nbins_z", args_info->nbins_z_orig, 0);
408 >  if (args_info->nanglebins_given)
409 >    write_into_file(outfile, "nanglebins", args_info->nanglebins_orig, 0);
410 >  if (args_info->rcut_given)
411 >    write_into_file(outfile, "rcut", args_info->rcut_orig, 0);
412 >  if (args_info->dz_given)
413 >    write_into_file(outfile, "dz", args_info->dz_orig, 0);
414 >  if (args_info->length_given)
415 >    write_into_file(outfile, "length", args_info->length_orig, 0);
416 >  if (args_info->zlength_given)
417 >    write_into_file(outfile, "zlength", args_info->zlength_orig, 0);
418 >  if (args_info->zoffset_given)
419 >    write_into_file(outfile, "zoffset", args_info->zoffset_orig, 0);
420 >  if (args_info->sele1_given)
421 >    write_into_file(outfile, "sele1", args_info->sele1_orig, 0);
422 >  if (args_info->sele2_given)
423 >    write_into_file(outfile, "sele2", args_info->sele2_orig, 0);
424 >  if (args_info->sele3_given)
425 >    write_into_file(outfile, "sele3", args_info->sele3_orig, 0);
426 >  if (args_info->refsele_given)
427 >    write_into_file(outfile, "refsele", args_info->refsele_orig, 0);
428 >  if (args_info->comsele_given)
429 >    write_into_file(outfile, "comsele", args_info->comsele_orig, 0);
430 >  if (args_info->molname_given)
431 >    write_into_file(outfile, "molname", args_info->molname_orig, 0);
432 >  if (args_info->begin_given)
433 >    write_into_file(outfile, "begin", args_info->begin_orig, 0);
434 >  if (args_info->end_given)
435 >    write_into_file(outfile, "end", args_info->end_orig, 0);
436 >  if (args_info->radius_given)
437 >    write_into_file(outfile, "radius", args_info->radius_orig, 0);
438 >  if (args_info->bo_given)
439 >    write_into_file(outfile, "bo", 0, 0 );
440 >  if (args_info->bor_given)
441 >    write_into_file(outfile, "bor", 0, 0 );
442 >  if (args_info->bad_given)
443 >    write_into_file(outfile, "bad", 0, 0 );
444 >  if (args_info->count_given)
445 >    write_into_file(outfile, "count", 0, 0 );
446 >  if (args_info->gofr_given)
447 >    write_into_file(outfile, "gofr", 0, 0 );
448 >  if (args_info->gofz_given)
449 >    write_into_file(outfile, "gofz", 0, 0 );
450 >  if (args_info->r_theta_given)
451 >    write_into_file(outfile, "r_theta", 0, 0 );
452 >  if (args_info->r_omega_given)
453 >    write_into_file(outfile, "r_omega", 0, 0 );
454 >  if (args_info->r_z_given)
455 >    write_into_file(outfile, "r_z", 0, 0 );
456 >  if (args_info->theta_omega_given)
457 >    write_into_file(outfile, "theta_omega", 0, 0 );
458 >  if (args_info->gxyz_given)
459 >    write_into_file(outfile, "gxyz", 0, 0 );
460 >  if (args_info->twodgofr_given)
461 >    write_into_file(outfile, "twodgofr", 0, 0 );
462 >  if (args_info->p2_given)
463 >    write_into_file(outfile, "p2", 0, 0 );
464 >  if (args_info->rp2_given)
465 >    write_into_file(outfile, "rp2", 0, 0 );
466 >  if (args_info->scd_given)
467 >    write_into_file(outfile, "scd", 0, 0 );
468 >  if (args_info->density_given)
469 >    write_into_file(outfile, "density", 0, 0 );
470 >  if (args_info->slab_density_given)
471 >    write_into_file(outfile, "slab_density", 0, 0 );
472 >  if (args_info->p_angle_given)
473 >    write_into_file(outfile, "p_angle", 0, 0 );
474 >  if (args_info->hxy_given)
475 >    write_into_file(outfile, "hxy", 0, 0 );
476 >  if (args_info->rho_r_given)
477 >    write_into_file(outfile, "rho_r", 0, 0 );
478 >  if (args_info->hullvol_given)
479 >    write_into_file(outfile, "hullvol", 0, 0 );
480    
481 <  clear_given (args_info);
481 >
482 >  i = EXIT_SUCCESS;
483 >  return i;
484   }
485  
486   int
# Line 313 | Line 497 | cmdline_parser_file_save(const char *filename, struct
497        return EXIT_FAILURE;
498      }
499  
500 <  if (args_info->help_given) {
317 <    fprintf(outfile, "%s\n", "help");
318 <  }
319 <  if (args_info->version_given) {
320 <    fprintf(outfile, "%s\n", "version");
321 <  }
322 <  if (args_info->input_given) {
323 <    if (args_info->input_orig) {
324 <      fprintf(outfile, "%s=\"%s\"\n", "input", args_info->input_orig);
325 <    } else {
326 <      fprintf(outfile, "%s\n", "input");
327 <    }
328 <  }
329 <  if (args_info->output_given) {
330 <    if (args_info->output_orig) {
331 <      fprintf(outfile, "%s=\"%s\"\n", "output", args_info->output_orig);
332 <    } else {
333 <      fprintf(outfile, "%s\n", "output");
334 <    }
335 <  }
336 <  if (args_info->step_given) {
337 <    if (args_info->step_orig) {
338 <      fprintf(outfile, "%s=\"%s\"\n", "step", args_info->step_orig);
339 <    } else {
340 <      fprintf(outfile, "%s\n", "step");
341 <    }
342 <  }
343 <  if (args_info->nbins_given) {
344 <    if (args_info->nbins_orig) {
345 <      fprintf(outfile, "%s=\"%s\"\n", "nbins", args_info->nbins_orig);
346 <    } else {
347 <      fprintf(outfile, "%s\n", "nbins");
348 <    }
349 <  }
350 <  if (args_info->nbins_x_given) {
351 <    if (args_info->nbins_x_orig) {
352 <      fprintf(outfile, "%s=\"%s\"\n", "nbins_x", args_info->nbins_x_orig);
353 <    } else {
354 <      fprintf(outfile, "%s\n", "nbins_x");
355 <    }
356 <  }
357 <  if (args_info->nbins_y_given) {
358 <    if (args_info->nbins_y_orig) {
359 <      fprintf(outfile, "%s=\"%s\"\n", "nbins_y", args_info->nbins_y_orig);
360 <    } else {
361 <      fprintf(outfile, "%s\n", "nbins_y");
362 <    }
363 <  }
364 <  if (args_info->nanglebins_given) {
365 <    if (args_info->nanglebins_orig) {
366 <      fprintf(outfile, "%s=\"%s\"\n", "nanglebins", args_info->nanglebins_orig);
367 <    } else {
368 <      fprintf(outfile, "%s\n", "nanglebins");
369 <    }
370 <  }
371 <  if (args_info->length_given) {
372 <    if (args_info->length_orig) {
373 <      fprintf(outfile, "%s=\"%s\"\n", "length", args_info->length_orig);
374 <    } else {
375 <      fprintf(outfile, "%s\n", "length");
376 <    }
377 <  }
378 <  if (args_info->rcut_given) {
379 <    if (args_info->rcut_orig) {
380 <      fprintf(outfile, "%s=\"%s\"\n", "rcut", args_info->rcut_orig);
381 <    } else {
382 <      fprintf(outfile, "%s\n", "rcut");
383 <    }
384 <  }
385 <  if (args_info->zoffset_given) {
386 <    if (args_info->zoffset_orig) {
387 <      fprintf(outfile, "%s=\"%s\"\n", "zoffset", args_info->zoffset_orig);
388 <    } else {
389 <      fprintf(outfile, "%s\n", "zoffset");
390 <    }
391 <  }
392 <  if (args_info->sele1_given) {
393 <    if (args_info->sele1_orig) {
394 <      fprintf(outfile, "%s=\"%s\"\n", "sele1", args_info->sele1_orig);
395 <    } else {
396 <      fprintf(outfile, "%s\n", "sele1");
397 <    }
398 <  }
399 <  if (args_info->sele2_given) {
400 <    if (args_info->sele2_orig) {
401 <      fprintf(outfile, "%s=\"%s\"\n", "sele2", args_info->sele2_orig);
402 <    } else {
403 <      fprintf(outfile, "%s\n", "sele2");
404 <    }
405 <  }
406 <  if (args_info->sele3_given) {
407 <    if (args_info->sele3_orig) {
408 <      fprintf(outfile, "%s=\"%s\"\n", "sele3", args_info->sele3_orig);
409 <    } else {
410 <      fprintf(outfile, "%s\n", "sele3");
411 <    }
412 <  }
413 <  if (args_info->refsele_given) {
414 <    if (args_info->refsele_orig) {
415 <      fprintf(outfile, "%s=\"%s\"\n", "refsele", args_info->refsele_orig);
416 <    } else {
417 <      fprintf(outfile, "%s\n", "refsele");
418 <    }
419 <  }
420 <  if (args_info->molname_given) {
421 <    if (args_info->molname_orig) {
422 <      fprintf(outfile, "%s=\"%s\"\n", "molname", args_info->molname_orig);
423 <    } else {
424 <      fprintf(outfile, "%s\n", "molname");
425 <    }
426 <  }
427 <  if (args_info->begin_given) {
428 <    if (args_info->begin_orig) {
429 <      fprintf(outfile, "%s=\"%s\"\n", "begin", args_info->begin_orig);
430 <    } else {
431 <      fprintf(outfile, "%s\n", "begin");
432 <    }
433 <  }
434 <  if (args_info->end_given) {
435 <    if (args_info->end_orig) {
436 <      fprintf(outfile, "%s=\"%s\"\n", "end", args_info->end_orig);
437 <    } else {
438 <      fprintf(outfile, "%s\n", "end");
439 <    }
440 <  }
441 <  if (args_info->radius_given) {
442 <    if (args_info->radius_orig) {
443 <      fprintf(outfile, "%s=\"%s\"\n", "radius", args_info->radius_orig);
444 <    } else {
445 <      fprintf(outfile, "%s\n", "radius");
446 <    }
447 <  }
448 <  if (args_info->bo_given) {
449 <    fprintf(outfile, "%s\n", "bo");
450 <  }
451 <  if (args_info->gofr_given) {
452 <    fprintf(outfile, "%s\n", "gofr");
453 <  }
454 <  if (args_info->r_theta_given) {
455 <    fprintf(outfile, "%s\n", "r_theta");
456 <  }
457 <  if (args_info->r_omega_given) {
458 <    fprintf(outfile, "%s\n", "r_omega");
459 <  }
460 <  if (args_info->theta_omega_given) {
461 <    fprintf(outfile, "%s\n", "theta_omega");
462 <  }
463 <  if (args_info->gxyz_given) {
464 <    fprintf(outfile, "%s\n", "gxyz");
465 <  }
466 <  if (args_info->p2_given) {
467 <    fprintf(outfile, "%s\n", "p2");
468 <  }
469 <  if (args_info->rp2_given) {
470 <    fprintf(outfile, "%s\n", "rp2");
471 <  }
472 <  if (args_info->scd_given) {
473 <    fprintf(outfile, "%s\n", "scd");
474 <  }
475 <  if (args_info->density_given) {
476 <    fprintf(outfile, "%s\n", "density");
477 <  }
478 <  if (args_info->slab_density_given) {
479 <    fprintf(outfile, "%s\n", "slab_density");
480 <  }
481 <  if (args_info->hxy_given) {
482 <    fprintf(outfile, "%s\n", "hxy");
483 <  }
484 <  if (args_info->rho_r_given) {
485 <    fprintf(outfile, "%s\n", "rho_r");
486 <  }
487 <  
500 >  i = cmdline_parser_dump(outfile, args_info);
501    fclose (outfile);
502  
490  i = EXIT_SUCCESS;
503    return i;
504   }
505  
# Line 497 | Line 509 | cmdline_parser_free (struct gengetopt_args_info *args_
509    cmdline_parser_release (args_info);
510   }
511  
512 <
501 < /* gengetopt_strdup() */
502 < /* strdup.c replacement of strdup, which is not standard */
512 > /** @brief replacement of strdup, which is not standard */
513   char *
514   gengetopt_strdup (const char *s)
515   {
# Line 515 | Line 525 | static void
525   }
526  
527   static void
518 reset_group_staticProps(struct gengetopt_args_info *args_info);
519
520 static void
528   reset_group_staticProps(struct gengetopt_args_info *args_info)
529   {
530    if (! args_info->staticProps_group_counter)
531      return;
532    
533    args_info->bo_given = 0 ;
534 +  args_info->bor_given = 0 ;
535 +  args_info->bad_given = 0 ;
536 +  args_info->count_given = 0 ;
537    args_info->gofr_given = 0 ;
538 +  args_info->gofz_given = 0 ;
539    args_info->r_theta_given = 0 ;
540    args_info->r_omega_given = 0 ;
541 +  args_info->r_z_given = 0 ;
542    args_info->theta_omega_given = 0 ;
543    args_info->gxyz_given = 0 ;
544 +  args_info->twodgofr_given = 0 ;
545    args_info->p2_given = 0 ;
546    args_info->rp2_given = 0 ;
547    args_info->scd_given = 0 ;
548    args_info->density_given = 0 ;
549    args_info->slab_density_given = 0 ;
550 +  args_info->p_angle_given = 0 ;
551    args_info->hxy_given = 0 ;
552    args_info->rho_r_given = 0 ;
553 +  args_info->hullvol_given = 0 ;
554  
555    args_info->staticProps_group_counter = 0;
556   }
# Line 547 | Line 562 | int
562   }
563  
564   int
565 + cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info,
566 +                   struct cmdline_parser_params *params)
567 + {
568 +  int result;
569 +  result = cmdline_parser_internal (argc, argv, args_info, params, NULL);
570 +
571 +  if (result == EXIT_FAILURE)
572 +    {
573 +      cmdline_parser_free (args_info);
574 +      exit (EXIT_FAILURE);
575 +    }
576 +  
577 +  return result;
578 + }
579 +
580 + int
581   cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
582   {
583    int result;
584 +  struct cmdline_parser_params params;
585 +  
586 +  params.override = override;
587 +  params.initialize = initialize;
588 +  params.check_required = check_required;
589 +  params.check_ambiguity = 0;
590 +  params.print_errors = 1;
591  
592 <  result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL);
592 >  result = cmdline_parser_internal (argc, argv, args_info, &params, NULL);
593  
594    if (result == EXIT_FAILURE)
595      {
# Line 584 | Line 622 | cmdline_parser_required2 (struct gengetopt_args_info *
622   {
623    int error = 0;
624  
625 +  /* checks for required options */
626    if (! args_info->input_given)
627      {
628        fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : ""));
629        error = 1;
630      }
631 +  
632    if (args_info->staticProps_group_counter == 0)
633      {
634        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 596 | Line 636 | cmdline_parser_required2 (struct gengetopt_args_info *
636      }
637    
638  
639 +  /* checks for dependences among options */
640 +
641    return error;
642   }
643  
644 +
645 + static char *package_name = 0;
646 +
647 + /**
648 + * @brief updates an option
649 + * @param field the generic pointer to the field to update
650 + * @param orig_field the pointer to the orig field
651 + * @param field_given the pointer to the number of occurrence of this option
652 + * @param prev_given the pointer to the number of occurrence already seen
653 + * @param value the argument for this option (if null no arg was specified)
654 + * @param possible_values the possible values for this option (if specified)
655 + * @param default_value the default value (in case the option only accepts fixed values)
656 + * @param arg_type the type of this option
657 + * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
658 + * @param override @see cmdline_parser_params.override
659 + * @param no_free whether to free a possible previous value
660 + * @param multiple_option whether this is a multiple option
661 + * @param long_opt the corresponding long option
662 + * @param short_opt the corresponding short option (or '-' if none)
663 + * @param additional_error possible further error specification
664 + */
665 + static
666 + int update_arg(void *field, char **orig_field,
667 +               unsigned int *field_given, unsigned int *prev_given,
668 +               char *value, char *possible_values[], const char *default_value,
669 +               cmdline_parser_arg_type arg_type,
670 +               int check_ambiguity, int override,
671 +               int no_free, int multiple_option,
672 +               const char *long_opt, char short_opt,
673 +               const char *additional_error)
674 + {
675 +  char *stop_char = 0;
676 +  const char *val = value;
677 +  int found;
678 +  char **string_field;
679 +
680 +  stop_char = 0;
681 +  found = 0;
682 +
683 +  if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
684 +    {
685 +      if (short_opt != '-')
686 +        fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
687 +               package_name, long_opt, short_opt,
688 +               (additional_error ? additional_error : ""));
689 +      else
690 +        fprintf (stderr, "%s: `--%s' option given more than once%s\n",
691 +               package_name, long_opt,
692 +               (additional_error ? additional_error : ""));
693 +      return 1; /* failure */
694 +    }
695 +
696 +    
697 +  if (field_given && *field_given && ! override)
698 +    return 0;
699 +  if (prev_given)
700 +    (*prev_given)++;
701 +  if (field_given)
702 +    (*field_given)++;
703 +  if (possible_values)
704 +    val = possible_values[found];
705 +
706 +  switch(arg_type) {
707 +  case ARG_INT:
708 +    if (val) *((int *)field) = strtol (val, &stop_char, 0);
709 +    break;
710 +  case ARG_DOUBLE:
711 +    if (val) *((double *)field) = strtod (val, &stop_char);
712 +    break;
713 +  case ARG_STRING:
714 +    if (val) {
715 +      string_field = (char **)field;
716 +      if (!no_free && *string_field)
717 +        free (*string_field); /* free previous string */
718 +      *string_field = gengetopt_strdup (val);
719 +    }
720 +    break;
721 +  default:
722 +    break;
723 +  };
724 +
725 +  /* check numeric conversion */
726 +  switch(arg_type) {
727 +  case ARG_INT:
728 +  case ARG_DOUBLE:
729 +    if (val && !(stop_char && *stop_char == '\0')) {
730 +      fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
731 +      return 1; /* failure */
732 +    }
733 +    break;
734 +  default:
735 +    ;
736 +  };
737 +
738 +  /* store the original value */
739 +  switch(arg_type) {
740 +  case ARG_NO:
741 +    break;
742 +  default:
743 +    if (value && orig_field) {
744 +      if (no_free) {
745 +        *orig_field = value;
746 +      } else {
747 +        if (*orig_field)
748 +          free (*orig_field); /* free previous string */
749 +        *orig_field = gengetopt_strdup (value);
750 +      }
751 +    }
752 +  };
753 +
754 +  return 0; /* OK */
755 + }
756 +
757 +
758   int
759 < cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error)
759 > cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
760 >                        struct cmdline_parser_params *params, const char *additional_error)
761   {
762    int c;        /* Character of the parsed option.  */
763  
764    int error = 0;
765    struct gengetopt_args_info local_args_info;
766 +  
767 +  int override;
768 +  int initialize;
769 +  int check_required;
770 +  int check_ambiguity;
771 +  
772 +  package_name = argv[0];
773 +  
774 +  override = params->override;
775 +  initialize = params->initialize;
776 +  check_required = params->check_required;
777 +  check_ambiguity = params->check_ambiguity;
778  
779    if (initialize)
780      cmdline_parser_init (args_info);
# Line 613 | Line 782 | cmdline_parser_internal (int argc, char * const *argv,
782    cmdline_parser_init (&local_args_info);
783  
784    optarg = 0;
785 <  optind = 1;
786 <  opterr = 1;
785 >  optind = 0;
786 >  opterr = params->print_errors;
787    optopt = '?';
788  
789    while (1)
790      {
791        int option_index = 0;
623      char *stop_char;
792  
793        static struct option long_options[] = {
794          { "help",       0, NULL, 'h' },
# Line 631 | Line 799 | cmdline_parser_internal (int argc, char * const *argv,
799          { "nbins",      1, NULL, 'b' },
800          { "nbins_x",    1, NULL, 'x' },
801          { "nbins_y",    1, NULL, 'y' },
802 +        { "nbins_z",    1, NULL, 0 },
803          { "nanglebins", 1, NULL, 'a' },
635        { "length",     1, NULL, 0 },
804          { "rcut",       1, NULL, 'c' },
805 +        { "dz", 1, NULL, 0 },
806 +        { "length",     1, NULL, 0 },
807 +        { "zlength",    1, NULL, 0 },
808          { "zoffset",    1, NULL, 'z' },
809          { "sele1",      1, NULL, 0 },
810          { "sele2",      1, NULL, 0 },
811          { "sele3",      1, NULL, 0 },
812          { "refsele",    1, NULL, 0 },
813 +        { "comsele",    1, NULL, 0 },
814          { "molname",    1, NULL, 0 },
815          { "begin",      1, NULL, 0 },
816          { "end",        1, NULL, 0 },
817          { "radius",     1, NULL, 0 },
818          { "bo", 0, NULL, 0 },
819 +        { "bor",        0, NULL, 0 },
820 +        { "bad",        0, NULL, 0 },
821 +        { "count",      0, NULL, 0 },
822          { "gofr",       0, NULL, 'g' },
823 +        { "gofz",       0, NULL, 0 },
824          { "r_theta",    0, NULL, 0 },
825          { "r_omega",    0, NULL, 0 },
826 +        { "r_z",        0, NULL, 0 },
827          { "theta_omega",        0, NULL, 0 },
828          { "gxyz",       0, NULL, 0 },
829 +        { "twodgofr",   0, NULL, 0 },
830          { "p2", 0, NULL, 'p' },
831          { "rp2",        0, NULL, 0 },
832          { "scd",        0, NULL, 's' },
833          { "density",    0, NULL, 'd' },
834          { "slab_density",       0, NULL, 0 },
835 +        { "p_angle",    0, NULL, 0 },
836          { "hxy",        0, NULL, 0 },
837          { "rho_r",      0, NULL, 0 },
838 +        { "hullvol",    0, NULL, 0 },
839          { NULL, 0, NULL, 0 }
840        };
841  
662      stop_char = 0;
842        c = getopt_long (argc, argv, "hVi:o:n:b:x:y:a:c:z:gpsd", long_options, &option_index);
843  
844        if (c == -1) break;       /* Exit from `while (1)' loop.  */
# Line 677 | Line 856 | cmdline_parser_internal (int argc, char * const *argv,
856            exit (EXIT_SUCCESS);
857  
858          case 'i':       /* input dump file.  */
859 <          if (local_args_info.input_given)
860 <            {
861 <              fprintf (stderr, "%s: `--input' (`-i') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
862 <              goto failure;
863 <            }
864 <          if (args_info->input_given && ! override)
865 <            continue;
866 <          local_args_info.input_given = 1;
867 <          args_info->input_given = 1;
868 <          if (args_info->input_arg)
690 <            free (args_info->input_arg); /* free previous string */
691 <          args_info->input_arg = gengetopt_strdup (optarg);
692 <          if (args_info->input_orig)
693 <            free (args_info->input_orig); /* free previous string */
694 <          args_info->input_orig = gengetopt_strdup (optarg);
859 >        
860 >        
861 >          if (update_arg( (void *)&(args_info->input_arg),
862 >               &(args_info->input_orig), &(args_info->input_given),
863 >              &(local_args_info.input_given), optarg, 0, 0, ARG_STRING,
864 >              check_ambiguity, override, 0, 0,
865 >              "input", 'i',
866 >              additional_error))
867 >            goto failure;
868 >        
869            break;
696
870          case 'o':       /* output file name.  */
871 <          if (local_args_info.output_given)
872 <            {
873 <              fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
874 <              goto failure;
875 <            }
876 <          if (args_info->output_given && ! override)
877 <            continue;
878 <          local_args_info.output_given = 1;
879 <          args_info->output_given = 1;
880 <          if (args_info->output_arg)
708 <            free (args_info->output_arg); /* free previous string */
709 <          args_info->output_arg = gengetopt_strdup (optarg);
710 <          if (args_info->output_orig)
711 <            free (args_info->output_orig); /* free previous string */
712 <          args_info->output_orig = gengetopt_strdup (optarg);
871 >        
872 >        
873 >          if (update_arg( (void *)&(args_info->output_arg),
874 >               &(args_info->output_orig), &(args_info->output_given),
875 >              &(local_args_info.output_given), optarg, 0, 0, ARG_STRING,
876 >              check_ambiguity, override, 0, 0,
877 >              "output", 'o',
878 >              additional_error))
879 >            goto failure;
880 >        
881            break;
714
882          case 'n':       /* process every n frame.  */
883 <          if (local_args_info.step_given)
884 <            {
885 <              fprintf (stderr, "%s: `--step' (`-n') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
886 <              goto failure;
887 <            }
888 <          if (args_info->step_given && ! override)
889 <            continue;
890 <          local_args_info.step_given = 1;
724 <          args_info->step_given = 1;
725 <          args_info->step_arg = strtol (optarg, &stop_char, 0);
726 <          if (!(stop_char && *stop_char == '\0')) {
727 <            fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
883 >        
884 >        
885 >          if (update_arg( (void *)&(args_info->step_arg),
886 >               &(args_info->step_orig), &(args_info->step_given),
887 >              &(local_args_info.step_given), optarg, 0, "1", ARG_INT,
888 >              check_ambiguity, override, 0, 0,
889 >              "step", 'n',
890 >              additional_error))
891              goto failure;
892 <          }
730 <          if (args_info->step_orig)
731 <            free (args_info->step_orig); /* free previous string */
732 <          args_info->step_orig = gengetopt_strdup (optarg);
892 >        
893            break;
734
894          case 'b':       /* number of bins (general purpose).  */
895 <          if (local_args_info.nbins_given)
896 <            {
897 <              fprintf (stderr, "%s: `--nbins' (`-b') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
898 <              goto failure;
899 <            }
900 <          if (args_info->nbins_given && ! override)
901 <            continue;
902 <          local_args_info.nbins_given = 1;
744 <          args_info->nbins_given = 1;
745 <          args_info->nbins_arg = strtol (optarg, &stop_char, 0);
746 <          if (!(stop_char && *stop_char == '\0')) {
747 <            fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
895 >        
896 >        
897 >          if (update_arg( (void *)&(args_info->nbins_arg),
898 >               &(args_info->nbins_orig), &(args_info->nbins_given),
899 >              &(local_args_info.nbins_given), optarg, 0, "100", ARG_INT,
900 >              check_ambiguity, override, 0, 0,
901 >              "nbins", 'b',
902 >              additional_error))
903              goto failure;
904 <          }
750 <          if (args_info->nbins_orig)
751 <            free (args_info->nbins_orig); /* free previous string */
752 <          args_info->nbins_orig = gengetopt_strdup (optarg);
904 >        
905            break;
754
906          case 'x':       /* number of bins in x axis.  */
907 <          if (local_args_info.nbins_x_given)
908 <            {
909 <              fprintf (stderr, "%s: `--nbins_x' (`-x') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
910 <              goto failure;
911 <            }
912 <          if (args_info->nbins_x_given && ! override)
913 <            continue;
914 <          local_args_info.nbins_x_given = 1;
764 <          args_info->nbins_x_given = 1;
765 <          args_info->nbins_x_arg = strtol (optarg, &stop_char, 0);
766 <          if (!(stop_char && *stop_char == '\0')) {
767 <            fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
907 >        
908 >        
909 >          if (update_arg( (void *)&(args_info->nbins_x_arg),
910 >               &(args_info->nbins_x_orig), &(args_info->nbins_x_given),
911 >              &(local_args_info.nbins_x_given), optarg, 0, "100", ARG_INT,
912 >              check_ambiguity, override, 0, 0,
913 >              "nbins_x", 'x',
914 >              additional_error))
915              goto failure;
916 <          }
770 <          if (args_info->nbins_x_orig)
771 <            free (args_info->nbins_x_orig); /* free previous string */
772 <          args_info->nbins_x_orig = gengetopt_strdup (optarg);
916 >        
917            break;
774
918          case 'y':       /* number of bins in y axis.  */
919 <          if (local_args_info.nbins_y_given)
920 <            {
921 <              fprintf (stderr, "%s: `--nbins_y' (`-y') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
922 <              goto failure;
923 <            }
924 <          if (args_info->nbins_y_given && ! override)
925 <            continue;
926 <          local_args_info.nbins_y_given = 1;
784 <          args_info->nbins_y_given = 1;
785 <          args_info->nbins_y_arg = strtol (optarg, &stop_char, 0);
786 <          if (!(stop_char && *stop_char == '\0')) {
787 <            fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
919 >        
920 >        
921 >          if (update_arg( (void *)&(args_info->nbins_y_arg),
922 >               &(args_info->nbins_y_orig), &(args_info->nbins_y_given),
923 >              &(local_args_info.nbins_y_given), optarg, 0, "100", ARG_INT,
924 >              check_ambiguity, override, 0, 0,
925 >              "nbins_y", 'y',
926 >              additional_error))
927              goto failure;
928 <          }
790 <          if (args_info->nbins_y_orig)
791 <            free (args_info->nbins_y_orig); /* free previous string */
792 <          args_info->nbins_y_orig = gengetopt_strdup (optarg);
928 >        
929            break;
794
930          case 'a':       /* number of bins for cos(angle).  */
931 <          if (local_args_info.nanglebins_given)
932 <            {
933 <              fprintf (stderr, "%s: `--nanglebins' (`-a') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
934 <              goto failure;
935 <            }
936 <          if (args_info->nanglebins_given && ! override)
937 <            continue;
938 <          local_args_info.nanglebins_given = 1;
804 <          args_info->nanglebins_given = 1;
805 <          args_info->nanglebins_arg = strtol (optarg, &stop_char, 0);
806 <          if (!(stop_char && *stop_char == '\0')) {
807 <            fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
931 >        
932 >        
933 >          if (update_arg( (void *)&(args_info->nanglebins_arg),
934 >               &(args_info->nanglebins_orig), &(args_info->nanglebins_given),
935 >              &(local_args_info.nanglebins_given), optarg, 0, "50", ARG_INT,
936 >              check_ambiguity, override, 0, 0,
937 >              "nanglebins", 'a',
938 >              additional_error))
939              goto failure;
940 <          }
810 <          if (args_info->nanglebins_orig)
811 <            free (args_info->nanglebins_orig); /* free previous string */
812 <          args_info->nanglebins_orig = gengetopt_strdup (optarg);
940 >        
941            break;
814
942          case 'c':       /* cutoff radius (rcut).  */
943 <          if (local_args_info.rcut_given)
944 <            {
945 <              fprintf (stderr, "%s: `--rcut' (`-c') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
946 <              goto failure;
947 <            }
948 <          if (args_info->rcut_given && ! override)
949 <            continue;
950 <          local_args_info.rcut_given = 1;
824 <          args_info->rcut_given = 1;
825 <          args_info->rcut_arg = strtod (optarg, &stop_char);
826 <          if (!(stop_char && *stop_char == '\0')) {
827 <            fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
943 >        
944 >        
945 >          if (update_arg( (void *)&(args_info->rcut_arg),
946 >               &(args_info->rcut_orig), &(args_info->rcut_given),
947 >              &(local_args_info.rcut_given), optarg, 0, 0, ARG_DOUBLE,
948 >              check_ambiguity, override, 0, 0,
949 >              "rcut", 'c',
950 >              additional_error))
951              goto failure;
952 <          }
830 <          if (args_info->rcut_orig)
831 <            free (args_info->rcut_orig); /* free previous string */
832 <          args_info->rcut_orig = gengetopt_strdup (optarg);
952 >        
953            break;
834
954          case 'z':       /* Where to set the zero for the slab_density calculation.  */
955 <          if (local_args_info.zoffset_given)
956 <            {
957 <              fprintf (stderr, "%s: `--zoffset' (`-z') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
958 <              goto failure;
959 <            }
960 <          if (args_info->zoffset_given && ! override)
961 <            continue;
962 <          local_args_info.zoffset_given = 1;
844 <          args_info->zoffset_given = 1;
845 <          args_info->zoffset_arg = strtod (optarg, &stop_char);
846 <          if (!(stop_char && *stop_char == '\0')) {
847 <            fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
955 >        
956 >        
957 >          if (update_arg( (void *)&(args_info->zoffset_arg),
958 >               &(args_info->zoffset_orig), &(args_info->zoffset_given),
959 >              &(local_args_info.zoffset_given), optarg, 0, "0", ARG_DOUBLE,
960 >              check_ambiguity, override, 0, 0,
961 >              "zoffset", 'z',
962 >              additional_error))
963              goto failure;
964 <          }
850 <          if (args_info->zoffset_orig)
851 <            free (args_info->zoffset_orig); /* free previous string */
852 <          args_info->zoffset_orig = gengetopt_strdup (optarg);
964 >        
965            break;
854
966          case 'g':       /* g(r).  */
967 <          if (local_args_info.gofr_given)
857 <            {
858 <              fprintf (stderr, "%s: `--gofr' (`-g') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
859 <              goto failure;
860 <            }
861 <          if (args_info->gofr_given && ! override)
862 <            continue;
863 <          local_args_info.gofr_given = 1;
864 <          args_info->gofr_given = 1;
967 >        
968            if (args_info->staticProps_group_counter && override)
969              reset_group_staticProps (args_info);
970            args_info->staticProps_group_counter += 1;
971 +        
972 +          if (update_arg( 0 ,
973 +               0 , &(args_info->gofr_given),
974 +              &(local_args_info.gofr_given), optarg, 0, 0, ARG_NO,
975 +              check_ambiguity, override, 0, 0,
976 +              "gofr", 'g',
977 +              additional_error))
978 +            goto failure;
979 +        
980            break;
869
981          case 'p':       /* p2 order parameter (--sele1 and --sele2 must be specified).  */
982 <          if (local_args_info.p2_given)
872 <            {
873 <              fprintf (stderr, "%s: `--p2' (`-p') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
874 <              goto failure;
875 <            }
876 <          if (args_info->p2_given && ! override)
877 <            continue;
878 <          local_args_info.p2_given = 1;
879 <          args_info->p2_given = 1;
982 >        
983            if (args_info->staticProps_group_counter && override)
984              reset_group_staticProps (args_info);
985            args_info->staticProps_group_counter += 1;
986 +        
987 +          if (update_arg( 0 ,
988 +               0 , &(args_info->p2_given),
989 +              &(local_args_info.p2_given), optarg, 0, 0, ARG_NO,
990 +              check_ambiguity, override, 0, 0,
991 +              "p2", 'p',
992 +              additional_error))
993 +            goto failure;
994 +        
995            break;
884
996          case 's':       /* scd order parameter (either --sele1, --sele2, --sele3 are specified or --molname, --begin, --end are specified).  */
997 <          if (local_args_info.scd_given)
887 <            {
888 <              fprintf (stderr, "%s: `--scd' (`-s') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
889 <              goto failure;
890 <            }
891 <          if (args_info->scd_given && ! override)
892 <            continue;
893 <          local_args_info.scd_given = 1;
894 <          args_info->scd_given = 1;
997 >        
998            if (args_info->staticProps_group_counter && override)
999              reset_group_staticProps (args_info);
1000            args_info->staticProps_group_counter += 1;
1001 <          break;
1002 <
1001 >        
1002 >          if (update_arg( 0 ,
1003 >               0 , &(args_info->scd_given),
1004 >              &(local_args_info.scd_given), optarg, 0, 0, ARG_NO,
1005 >              check_ambiguity, override, 0, 0,
1006 >              "scd", 's',
1007 >              additional_error))
1008 >            goto failure;
1009 >        
1010 >          break;
1011          case 'd':       /* density plot.  */
1012 <          if (local_args_info.density_given)
902 <            {
903 <              fprintf (stderr, "%s: `--density' (`-d') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
904 <              goto failure;
905 <            }
906 <          if (args_info->density_given && ! override)
907 <            continue;
908 <          local_args_info.density_given = 1;
909 <          args_info->density_given = 1;
1012 >        
1013            if (args_info->staticProps_group_counter && override)
1014              reset_group_staticProps (args_info);
1015            args_info->staticProps_group_counter += 1;
1016 +        
1017 +          if (update_arg( 0 ,
1018 +               0 , &(args_info->density_given),
1019 +              &(local_args_info.density_given), optarg, 0, 0, ARG_NO,
1020 +              check_ambiguity, override, 0, 0,
1021 +              "density", 'd',
1022 +              additional_error))
1023 +            goto failure;
1024 +        
1025            break;
1026  
915
1027          case 0: /* Long option with no short option */
1028 +          /* number of bins in z axis.  */
1029 +          if (strcmp (long_options[option_index].name, "nbins_z") == 0)
1030 +          {
1031 +          
1032 +          
1033 +            if (update_arg( (void *)&(args_info->nbins_z_arg),
1034 +                 &(args_info->nbins_z_orig), &(args_info->nbins_z_given),
1035 +                &(local_args_info.nbins_z_given), optarg, 0, "100", ARG_INT,
1036 +                check_ambiguity, override, 0, 0,
1037 +                "nbins_z", '-',
1038 +                additional_error))
1039 +              goto failure;
1040 +          
1041 +          }
1042 +          /* slab width (dz).  */
1043 +          else if (strcmp (long_options[option_index].name, "dz") == 0)
1044 +          {
1045 +          
1046 +          
1047 +            if (update_arg( (void *)&(args_info->dz_arg),
1048 +                 &(args_info->dz_orig), &(args_info->dz_given),
1049 +                &(local_args_info.dz_given), optarg, 0, 0, ARG_DOUBLE,
1050 +                check_ambiguity, override, 0, 0,
1051 +                "dz", '-',
1052 +                additional_error))
1053 +              goto failure;
1054 +          
1055 +          }
1056            /* maximum length (Defaults to 1/2 smallest length of first frame).  */
1057 <          if (strcmp (long_options[option_index].name, "length") == 0)
1057 >          else if (strcmp (long_options[option_index].name, "length") == 0)
1058            {
1059 <            if (local_args_info.length_given)
1060 <              {
1061 <                fprintf (stderr, "%s: `--length' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1062 <                goto failure;
1063 <              }
1064 <            if (args_info->length_given && ! override)
1065 <              continue;
1066 <            local_args_info.length_given = 1;
928 <            args_info->length_given = 1;
929 <            args_info->length_arg = strtod (optarg, &stop_char);
930 <            if (!(stop_char && *stop_char == '\0')) {
931 <              fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
1059 >          
1060 >          
1061 >            if (update_arg( (void *)&(args_info->length_arg),
1062 >                 &(args_info->length_orig), &(args_info->length_given),
1063 >                &(local_args_info.length_given), optarg, 0, 0, ARG_DOUBLE,
1064 >                check_ambiguity, override, 0, 0,
1065 >                "length", '-',
1066 >                additional_error))
1067                goto failure;
1068 <            }
934 <            if (args_info->length_orig)
935 <              free (args_info->length_orig); /* free previous string */
936 <            args_info->length_orig = gengetopt_strdup (optarg);
1068 >          
1069            }
1070 +          /* maximum length (Defaults to 1/2 smallest length of first frame).  */
1071 +          else if (strcmp (long_options[option_index].name, "zlength") == 0)
1072 +          {
1073 +          
1074 +          
1075 +            if (update_arg( (void *)&(args_info->zlength_arg),
1076 +                 &(args_info->zlength_orig), &(args_info->zlength_given),
1077 +                &(local_args_info.zlength_given), optarg, 0, 0, ARG_DOUBLE,
1078 +                check_ambiguity, override, 0, 0,
1079 +                "zlength", '-',
1080 +                additional_error))
1081 +              goto failure;
1082 +          
1083 +          }
1084            /* select the first stuntdouble set.  */
1085            else if (strcmp (long_options[option_index].name, "sele1") == 0)
1086            {
1087 <            if (local_args_info.sele1_given)
1088 <              {
1089 <                fprintf (stderr, "%s: `--sele1' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1090 <                goto failure;
1091 <              }
1092 <            if (args_info->sele1_given && ! override)
1093 <              continue;
1094 <            local_args_info.sele1_given = 1;
1095 <            args_info->sele1_given = 1;
1096 <            if (args_info->sele1_arg)
951 <              free (args_info->sele1_arg); /* free previous string */
952 <            args_info->sele1_arg = gengetopt_strdup (optarg);
953 <            if (args_info->sele1_orig)
954 <              free (args_info->sele1_orig); /* free previous string */
955 <            args_info->sele1_orig = gengetopt_strdup (optarg);
1087 >          
1088 >          
1089 >            if (update_arg( (void *)&(args_info->sele1_arg),
1090 >                 &(args_info->sele1_orig), &(args_info->sele1_given),
1091 >                &(local_args_info.sele1_given), optarg, 0, 0, ARG_STRING,
1092 >                check_ambiguity, override, 0, 0,
1093 >                "sele1", '-',
1094 >                additional_error))
1095 >              goto failure;
1096 >          
1097            }
1098            /* select the second stuntdouble set.  */
1099            else if (strcmp (long_options[option_index].name, "sele2") == 0)
1100            {
1101 <            if (local_args_info.sele2_given)
1102 <              {
1103 <                fprintf (stderr, "%s: `--sele2' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1104 <                goto failure;
1105 <              }
1106 <            if (args_info->sele2_given && ! override)
1107 <              continue;
1108 <            local_args_info.sele2_given = 1;
1109 <            args_info->sele2_given = 1;
1110 <            if (args_info->sele2_arg)
970 <              free (args_info->sele2_arg); /* free previous string */
971 <            args_info->sele2_arg = gengetopt_strdup (optarg);
972 <            if (args_info->sele2_orig)
973 <              free (args_info->sele2_orig); /* free previous string */
974 <            args_info->sele2_orig = gengetopt_strdup (optarg);
1101 >          
1102 >          
1103 >            if (update_arg( (void *)&(args_info->sele2_arg),
1104 >                 &(args_info->sele2_orig), &(args_info->sele2_given),
1105 >                &(local_args_info.sele2_given), optarg, 0, 0, ARG_STRING,
1106 >                check_ambiguity, override, 0, 0,
1107 >                "sele2", '-',
1108 >                additional_error))
1109 >              goto failure;
1110 >          
1111            }
1112            /* select the third stuntdouble set.  */
1113            else if (strcmp (long_options[option_index].name, "sele3") == 0)
1114            {
1115 <            if (local_args_info.sele3_given)
1116 <              {
1117 <                fprintf (stderr, "%s: `--sele3' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1118 <                goto failure;
1119 <              }
1120 <            if (args_info->sele3_given && ! override)
1121 <              continue;
1122 <            local_args_info.sele3_given = 1;
1123 <            args_info->sele3_given = 1;
1124 <            if (args_info->sele3_arg)
989 <              free (args_info->sele3_arg); /* free previous string */
990 <            args_info->sele3_arg = gengetopt_strdup (optarg);
991 <            if (args_info->sele3_orig)
992 <              free (args_info->sele3_orig); /* free previous string */
993 <            args_info->sele3_orig = gengetopt_strdup (optarg);
1115 >          
1116 >          
1117 >            if (update_arg( (void *)&(args_info->sele3_arg),
1118 >                 &(args_info->sele3_orig), &(args_info->sele3_given),
1119 >                &(local_args_info.sele3_given), optarg, 0, 0, ARG_STRING,
1120 >                check_ambiguity, override, 0, 0,
1121 >                "sele3", '-',
1122 >                additional_error))
1123 >              goto failure;
1124 >          
1125            }
1126            /* select reference (use and only use with --gxyz).  */
1127            else if (strcmp (long_options[option_index].name, "refsele") == 0)
1128            {
1129 <            if (local_args_info.refsele_given)
1130 <              {
1131 <                fprintf (stderr, "%s: `--refsele' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1132 <                goto failure;
1133 <              }
1134 <            if (args_info->refsele_given && ! override)
1135 <              continue;
1136 <            local_args_info.refsele_given = 1;
1137 <            args_info->refsele_given = 1;
1138 <            if (args_info->refsele_arg)
1008 <              free (args_info->refsele_arg); /* free previous string */
1009 <            args_info->refsele_arg = gengetopt_strdup (optarg);
1010 <            if (args_info->refsele_orig)
1011 <              free (args_info->refsele_orig); /* free previous string */
1012 <            args_info->refsele_orig = gengetopt_strdup (optarg);
1129 >          
1130 >          
1131 >            if (update_arg( (void *)&(args_info->refsele_arg),
1132 >                 &(args_info->refsele_orig), &(args_info->refsele_given),
1133 >                &(local_args_info.refsele_given), optarg, 0, 0, ARG_STRING,
1134 >                check_ambiguity, override, 0, 0,
1135 >                "refsele", '-',
1136 >                additional_error))
1137 >              goto failure;
1138 >          
1139            }
1140 +          /* select stunt doubles for center-of-mass reference point.  */
1141 +          else if (strcmp (long_options[option_index].name, "comsele") == 0)
1142 +          {
1143 +          
1144 +          
1145 +            if (update_arg( (void *)&(args_info->comsele_arg),
1146 +                 &(args_info->comsele_orig), &(args_info->comsele_given),
1147 +                &(local_args_info.comsele_given), optarg, 0, 0, ARG_STRING,
1148 +                check_ambiguity, override, 0, 0,
1149 +                "comsele", '-',
1150 +                additional_error))
1151 +              goto failure;
1152 +          
1153 +          }
1154            /* molecule name.  */
1155            else if (strcmp (long_options[option_index].name, "molname") == 0)
1156            {
1157 <            if (local_args_info.molname_given)
1158 <              {
1159 <                fprintf (stderr, "%s: `--molname' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1160 <                goto failure;
1161 <              }
1162 <            if (args_info->molname_given && ! override)
1163 <              continue;
1164 <            local_args_info.molname_given = 1;
1165 <            args_info->molname_given = 1;
1166 <            if (args_info->molname_arg)
1027 <              free (args_info->molname_arg); /* free previous string */
1028 <            args_info->molname_arg = gengetopt_strdup (optarg);
1029 <            if (args_info->molname_orig)
1030 <              free (args_info->molname_orig); /* free previous string */
1031 <            args_info->molname_orig = gengetopt_strdup (optarg);
1157 >          
1158 >          
1159 >            if (update_arg( (void *)&(args_info->molname_arg),
1160 >                 &(args_info->molname_orig), &(args_info->molname_given),
1161 >                &(local_args_info.molname_given), optarg, 0, 0, ARG_STRING,
1162 >                check_ambiguity, override, 0, 0,
1163 >                "molname", '-',
1164 >                additional_error))
1165 >              goto failure;
1166 >          
1167            }
1168            /* begin internal index.  */
1169            else if (strcmp (long_options[option_index].name, "begin") == 0)
1170            {
1171 <            if (local_args_info.begin_given)
1172 <              {
1173 <                fprintf (stderr, "%s: `--begin' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1174 <                goto failure;
1175 <              }
1176 <            if (args_info->begin_given && ! override)
1177 <              continue;
1178 <            local_args_info.begin_given = 1;
1044 <            args_info->begin_given = 1;
1045 <            args_info->begin_arg = strtol (optarg, &stop_char, 0);
1046 <            if (!(stop_char && *stop_char == '\0')) {
1047 <              fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
1171 >          
1172 >          
1173 >            if (update_arg( (void *)&(args_info->begin_arg),
1174 >                 &(args_info->begin_orig), &(args_info->begin_given),
1175 >                &(local_args_info.begin_given), optarg, 0, 0, ARG_INT,
1176 >                check_ambiguity, override, 0, 0,
1177 >                "begin", '-',
1178 >                additional_error))
1179                goto failure;
1180 <            }
1050 <            if (args_info->begin_orig)
1051 <              free (args_info->begin_orig); /* free previous string */
1052 <            args_info->begin_orig = gengetopt_strdup (optarg);
1180 >          
1181            }
1182            /* end internal index.  */
1183            else if (strcmp (long_options[option_index].name, "end") == 0)
1184            {
1185 <            if (local_args_info.end_given)
1186 <              {
1187 <                fprintf (stderr, "%s: `--end' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1188 <                goto failure;
1189 <              }
1190 <            if (args_info->end_given && ! override)
1191 <              continue;
1192 <            local_args_info.end_given = 1;
1065 <            args_info->end_given = 1;
1066 <            args_info->end_arg = strtol (optarg, &stop_char, 0);
1067 <            if (!(stop_char && *stop_char == '\0')) {
1068 <              fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
1185 >          
1186 >          
1187 >            if (update_arg( (void *)&(args_info->end_arg),
1188 >                 &(args_info->end_orig), &(args_info->end_given),
1189 >                &(local_args_info.end_given), optarg, 0, 0, ARG_INT,
1190 >                check_ambiguity, override, 0, 0,
1191 >                "end", '-',
1192 >                additional_error))
1193                goto failure;
1194 <            }
1071 <            if (args_info->end_orig)
1072 <              free (args_info->end_orig); /* free previous string */
1073 <            args_info->end_orig = gengetopt_strdup (optarg);
1194 >          
1195            }
1196            /* nanoparticle radius.  */
1197            else if (strcmp (long_options[option_index].name, "radius") == 0)
1198            {
1199 <            if (local_args_info.radius_given)
1200 <              {
1201 <                fprintf (stderr, "%s: `--radius' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1202 <                goto failure;
1203 <              }
1204 <            if (args_info->radius_given && ! override)
1205 <              continue;
1206 <            local_args_info.radius_given = 1;
1086 <            args_info->radius_given = 1;
1087 <            args_info->radius_arg = strtod (optarg, &stop_char);
1088 <            if (!(stop_char && *stop_char == '\0')) {
1089 <              fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
1199 >          
1200 >          
1201 >            if (update_arg( (void *)&(args_info->radius_arg),
1202 >                 &(args_info->radius_orig), &(args_info->radius_given),
1203 >                &(local_args_info.radius_given), optarg, 0, 0, ARG_DOUBLE,
1204 >                check_ambiguity, override, 0, 0,
1205 >                "radius", '-',
1206 >                additional_error))
1207                goto failure;
1208 <            }
1092 <            if (args_info->radius_orig)
1093 <              free (args_info->radius_orig); /* free previous string */
1094 <            args_info->radius_orig = gengetopt_strdup (optarg);
1208 >          
1209            }
1210 <          /* bond order parameter (--rcut must be specified.  */
1210 >          /* bond order parameter (--rcut must be specified).  */
1211            else if (strcmp (long_options[option_index].name, "bo") == 0)
1212            {
1213 <            if (local_args_info.bo_given)
1100 <              {
1101 <                fprintf (stderr, "%s: `--bo' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1102 <                goto failure;
1103 <              }
1104 <            if (args_info->bo_given && ! override)
1105 <              continue;
1106 <            local_args_info.bo_given = 1;
1107 <            args_info->bo_given = 1;
1213 >          
1214              if (args_info->staticProps_group_counter && override)
1215                reset_group_staticProps (args_info);
1216              args_info->staticProps_group_counter += 1;
1217 <            break;
1217 >          
1218 >            if (update_arg( 0 ,
1219 >                 0 , &(args_info->bo_given),
1220 >                &(local_args_info.bo_given), optarg, 0, 0, ARG_NO,
1221 >                check_ambiguity, override, 0, 0,
1222 >                "bo", '-',
1223 >                additional_error))
1224 >              goto failure;
1225 >          
1226            }
1227 +          /* bond order parameter as a function of radius (--rcut must be specified).  */
1228 +          else if (strcmp (long_options[option_index].name, "bor") == 0)
1229 +          {
1230 +          
1231 +            if (args_info->staticProps_group_counter && override)
1232 +              reset_group_staticProps (args_info);
1233 +            args_info->staticProps_group_counter += 1;
1234 +          
1235 +            if (update_arg( 0 ,
1236 +                 0 , &(args_info->bor_given),
1237 +                &(local_args_info.bor_given), optarg, 0, 0, ARG_NO,
1238 +                check_ambiguity, override, 0, 0,
1239 +                "bor", '-',
1240 +                additional_error))
1241 +              goto failure;
1242 +          
1243 +          }
1244 +          /* N(theta) bond angle density within (--rcut must be specified).  */
1245 +          else if (strcmp (long_options[option_index].name, "bad") == 0)
1246 +          {
1247 +          
1248 +            if (args_info->staticProps_group_counter && override)
1249 +              reset_group_staticProps (args_info);
1250 +            args_info->staticProps_group_counter += 1;
1251 +          
1252 +            if (update_arg( 0 ,
1253 +                 0 , &(args_info->bad_given),
1254 +                &(local_args_info.bad_given), optarg, 0, 0, ARG_NO,
1255 +                check_ambiguity, override, 0, 0,
1256 +                "bad", '-',
1257 +                additional_error))
1258 +              goto failure;
1259 +          
1260 +          }
1261 +          /* count of molecules matching selection criteria (and associated statistics).  */
1262 +          else if (strcmp (long_options[option_index].name, "count") == 0)
1263 +          {
1264 +          
1265 +            if (args_info->staticProps_group_counter && override)
1266 +              reset_group_staticProps (args_info);
1267 +            args_info->staticProps_group_counter += 1;
1268 +          
1269 +            if (update_arg( 0 ,
1270 +                 0 , &(args_info->count_given),
1271 +                &(local_args_info.count_given), optarg, 0, 0, ARG_NO,
1272 +                check_ambiguity, override, 0, 0,
1273 +                "count", '-',
1274 +                additional_error))
1275 +              goto failure;
1276 +          
1277 +          }
1278 +          /* g(z).  */
1279 +          else if (strcmp (long_options[option_index].name, "gofz") == 0)
1280 +          {
1281 +          
1282 +            if (args_info->staticProps_group_counter && override)
1283 +              reset_group_staticProps (args_info);
1284 +            args_info->staticProps_group_counter += 1;
1285 +          
1286 +            if (update_arg( 0 ,
1287 +                 0 , &(args_info->gofz_given),
1288 +                &(local_args_info.gofz_given), optarg, 0, 0, ARG_NO,
1289 +                check_ambiguity, override, 0, 0,
1290 +                "gofz", '-',
1291 +                additional_error))
1292 +              goto failure;
1293 +          
1294 +          }
1295            /* g(r, cos(theta)).  */
1296            else if (strcmp (long_options[option_index].name, "r_theta") == 0)
1297            {
1298 <            if (local_args_info.r_theta_given)
1117 <              {
1118 <                fprintf (stderr, "%s: `--r_theta' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1119 <                goto failure;
1120 <              }
1121 <            if (args_info->r_theta_given && ! override)
1122 <              continue;
1123 <            local_args_info.r_theta_given = 1;
1124 <            args_info->r_theta_given = 1;
1298 >          
1299              if (args_info->staticProps_group_counter && override)
1300                reset_group_staticProps (args_info);
1301              args_info->staticProps_group_counter += 1;
1302 <            break;
1302 >          
1303 >            if (update_arg( 0 ,
1304 >                 0 , &(args_info->r_theta_given),
1305 >                &(local_args_info.r_theta_given), optarg, 0, 0, ARG_NO,
1306 >                check_ambiguity, override, 0, 0,
1307 >                "r_theta", '-',
1308 >                additional_error))
1309 >              goto failure;
1310 >          
1311            }
1312            /* g(r, cos(omega)).  */
1313            else if (strcmp (long_options[option_index].name, "r_omega") == 0)
1314            {
1315 <            if (local_args_info.r_omega_given)
1134 <              {
1135 <                fprintf (stderr, "%s: `--r_omega' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1136 <                goto failure;
1137 <              }
1138 <            if (args_info->r_omega_given && ! override)
1139 <              continue;
1140 <            local_args_info.r_omega_given = 1;
1141 <            args_info->r_omega_given = 1;
1315 >          
1316              if (args_info->staticProps_group_counter && override)
1317                reset_group_staticProps (args_info);
1318              args_info->staticProps_group_counter += 1;
1319 <            break;
1319 >          
1320 >            if (update_arg( 0 ,
1321 >                 0 , &(args_info->r_omega_given),
1322 >                &(local_args_info.r_omega_given), optarg, 0, 0, ARG_NO,
1323 >                check_ambiguity, override, 0, 0,
1324 >                "r_omega", '-',
1325 >                additional_error))
1326 >              goto failure;
1327 >          
1328            }
1329 +          /* g(r, z).  */
1330 +          else if (strcmp (long_options[option_index].name, "r_z") == 0)
1331 +          {
1332 +          
1333 +            if (args_info->staticProps_group_counter && override)
1334 +              reset_group_staticProps (args_info);
1335 +            args_info->staticProps_group_counter += 1;
1336 +          
1337 +            if (update_arg( 0 ,
1338 +                 0 , &(args_info->r_z_given),
1339 +                &(local_args_info.r_z_given), optarg, 0, 0, ARG_NO,
1340 +                check_ambiguity, override, 0, 0,
1341 +                "r_z", '-',
1342 +                additional_error))
1343 +              goto failure;
1344 +          
1345 +          }
1346            /* g(cos(theta), cos(omega)).  */
1347            else if (strcmp (long_options[option_index].name, "theta_omega") == 0)
1348            {
1349 <            if (local_args_info.theta_omega_given)
1151 <              {
1152 <                fprintf (stderr, "%s: `--theta_omega' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1153 <                goto failure;
1154 <              }
1155 <            if (args_info->theta_omega_given && ! override)
1156 <              continue;
1157 <            local_args_info.theta_omega_given = 1;
1158 <            args_info->theta_omega_given = 1;
1349 >          
1350              if (args_info->staticProps_group_counter && override)
1351                reset_group_staticProps (args_info);
1352              args_info->staticProps_group_counter += 1;
1353 <            break;
1353 >          
1354 >            if (update_arg( 0 ,
1355 >                 0 , &(args_info->theta_omega_given),
1356 >                &(local_args_info.theta_omega_given), optarg, 0, 0, ARG_NO,
1357 >                check_ambiguity, override, 0, 0,
1358 >                "theta_omega", '-',
1359 >                additional_error))
1360 >              goto failure;
1361 >          
1362            }
1363            /* g(x, y, z).  */
1364            else if (strcmp (long_options[option_index].name, "gxyz") == 0)
1365            {
1366 <            if (local_args_info.gxyz_given)
1168 <              {
1169 <                fprintf (stderr, "%s: `--gxyz' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1170 <                goto failure;
1171 <              }
1172 <            if (args_info->gxyz_given && ! override)
1173 <              continue;
1174 <            local_args_info.gxyz_given = 1;
1175 <            args_info->gxyz_given = 1;
1366 >          
1367              if (args_info->staticProps_group_counter && override)
1368                reset_group_staticProps (args_info);
1369              args_info->staticProps_group_counter += 1;
1370 <            break;
1370 >          
1371 >            if (update_arg( 0 ,
1372 >                 0 , &(args_info->gxyz_given),
1373 >                &(local_args_info.gxyz_given), optarg, 0, 0, ARG_NO,
1374 >                check_ambiguity, override, 0, 0,
1375 >                "gxyz", '-',
1376 >                additional_error))
1377 >              goto failure;
1378 >          
1379            }
1380 +          /* 2D g(r) (Slab width --dz must be specified).  */
1381 +          else if (strcmp (long_options[option_index].name, "twodgofr") == 0)
1382 +          {
1383 +          
1384 +            if (args_info->staticProps_group_counter && override)
1385 +              reset_group_staticProps (args_info);
1386 +            args_info->staticProps_group_counter += 1;
1387 +          
1388 +            if (update_arg( 0 ,
1389 +                 0 , &(args_info->twodgofr_given),
1390 +                &(local_args_info.twodgofr_given), optarg, 0, 0, ARG_NO,
1391 +                check_ambiguity, override, 0, 0,
1392 +                "twodgofr", '-',
1393 +                additional_error))
1394 +              goto failure;
1395 +          
1396 +          }
1397            /* rp2 order parameter (--sele1 and --sele2 must be specified).  */
1398            else if (strcmp (long_options[option_index].name, "rp2") == 0)
1399            {
1400 <            if (local_args_info.rp2_given)
1185 <              {
1186 <                fprintf (stderr, "%s: `--rp2' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1187 <                goto failure;
1188 <              }
1189 <            if (args_info->rp2_given && ! override)
1190 <              continue;
1191 <            local_args_info.rp2_given = 1;
1192 <            args_info->rp2_given = 1;
1400 >          
1401              if (args_info->staticProps_group_counter && override)
1402                reset_group_staticProps (args_info);
1403              args_info->staticProps_group_counter += 1;
1404 <            break;
1404 >          
1405 >            if (update_arg( 0 ,
1406 >                 0 , &(args_info->rp2_given),
1407 >                &(local_args_info.rp2_given), optarg, 0, 0, ARG_NO,
1408 >                check_ambiguity, override, 0, 0,
1409 >                "rp2", '-',
1410 >                additional_error))
1411 >              goto failure;
1412 >          
1413            }
1414            /* slab density.  */
1415            else if (strcmp (long_options[option_index].name, "slab_density") == 0)
1416            {
1417 <            if (local_args_info.slab_density_given)
1202 <              {
1203 <                fprintf (stderr, "%s: `--slab_density' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1204 <                goto failure;
1205 <              }
1206 <            if (args_info->slab_density_given && ! override)
1207 <              continue;
1208 <            local_args_info.slab_density_given = 1;
1209 <            args_info->slab_density_given = 1;
1417 >          
1418              if (args_info->staticProps_group_counter && override)
1419                reset_group_staticProps (args_info);
1420              args_info->staticProps_group_counter += 1;
1421 <            break;
1421 >          
1422 >            if (update_arg( 0 ,
1423 >                 0 , &(args_info->slab_density_given),
1424 >                &(local_args_info.slab_density_given), optarg, 0, 0, ARG_NO,
1425 >                check_ambiguity, override, 0, 0,
1426 >                "slab_density", '-',
1427 >                additional_error))
1428 >              goto failure;
1429 >          
1430            }
1431 +          /* p(cos(theta)).  */
1432 +          else if (strcmp (long_options[option_index].name, "p_angle") == 0)
1433 +          {
1434 +          
1435 +            if (args_info->staticProps_group_counter && override)
1436 +              reset_group_staticProps (args_info);
1437 +            args_info->staticProps_group_counter += 1;
1438 +          
1439 +            if (update_arg( 0 ,
1440 +                 0 , &(args_info->p_angle_given),
1441 +                &(local_args_info.p_angle_given), optarg, 0, 0, ARG_NO,
1442 +                check_ambiguity, override, 0, 0,
1443 +                "p_angle", '-',
1444 +                additional_error))
1445 +              goto failure;
1446 +          
1447 +          }
1448            /* hxy.  */
1449            else if (strcmp (long_options[option_index].name, "hxy") == 0)
1450            {
1451 <            if (local_args_info.hxy_given)
1219 <              {
1220 <                fprintf (stderr, "%s: `--hxy' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1221 <                goto failure;
1222 <              }
1223 <            if (args_info->hxy_given && ! override)
1224 <              continue;
1225 <            local_args_info.hxy_given = 1;
1226 <            args_info->hxy_given = 1;
1451 >          
1452              if (args_info->staticProps_group_counter && override)
1453                reset_group_staticProps (args_info);
1454              args_info->staticProps_group_counter += 1;
1455 <            break;
1455 >          
1456 >            if (update_arg( 0 ,
1457 >                 0 , &(args_info->hxy_given),
1458 >                &(local_args_info.hxy_given), optarg, 0, 0, ARG_NO,
1459 >                check_ambiguity, override, 0, 0,
1460 >                "hxy", '-',
1461 >                additional_error))
1462 >              goto failure;
1463 >          
1464            }
1465            /* rho of R.  */
1466            else if (strcmp (long_options[option_index].name, "rho_r") == 0)
1467            {
1468 <            if (local_args_info.rho_r_given)
1236 <              {
1237 <                fprintf (stderr, "%s: `--rho_r' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
1238 <                goto failure;
1239 <              }
1240 <            if (args_info->rho_r_given && ! override)
1241 <              continue;
1242 <            local_args_info.rho_r_given = 1;
1243 <            args_info->rho_r_given = 1;
1468 >          
1469              if (args_info->staticProps_group_counter && override)
1470                reset_group_staticProps (args_info);
1471              args_info->staticProps_group_counter += 1;
1472 <            break;
1472 >          
1473 >            if (update_arg( 0 ,
1474 >                 0 , &(args_info->rho_r_given),
1475 >                &(local_args_info.rho_r_given), optarg, 0, 0, ARG_NO,
1476 >                check_ambiguity, override, 0, 0,
1477 >                "rho_r", '-',
1478 >                additional_error))
1479 >              goto failure;
1480 >          
1481            }
1482 +          /* hull volume of nanoparticle.  */
1483 +          else if (strcmp (long_options[option_index].name, "hullvol") == 0)
1484 +          {
1485            
1486 +            if (args_info->staticProps_group_counter && override)
1487 +              reset_group_staticProps (args_info);
1488 +            args_info->staticProps_group_counter += 1;
1489 +          
1490 +            if (update_arg( 0 ,
1491 +                 0 , &(args_info->hullvol_given),
1492 +                &(local_args_info.hullvol_given), optarg, 0, 0, ARG_NO,
1493 +                check_ambiguity, override, 0, 0,
1494 +                "hullvol", '-',
1495 +                additional_error))
1496 +              goto failure;
1497 +          
1498 +          }
1499 +          
1500            break;
1501          case '?':       /* Invalid option.  */
1502            /* `getopt_long' already printed an error message.  */
# Line 1276 | Line 1526 | cmdline_parser_internal (int argc, char * const *argv,
1526    if ( error )
1527      return (EXIT_FAILURE);
1528  
1529 +  if (optind < argc)
1530 +    {
1531 +      int i = 0 ;
1532 +      int found_prog_name = 0;
1533 +      /* whether program name, i.e., argv[0], is in the remaining args
1534 +         (this may happen with some implementations of getopt,
1535 +          but surely not with the one included by gengetopt) */
1536 +
1537 +      i = optind;
1538 +      while (i < argc)
1539 +        if (argv[i++] == argv[0]) {
1540 +          found_prog_name = 1;
1541 +          break;
1542 +        }
1543 +      i = 0;
1544 +
1545 +      args_info->inputs_num = argc - optind - found_prog_name;
1546 +      args_info->inputs =
1547 +        (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
1548 +      while (optind < argc)
1549 +        if (argv[optind++] != argv[0])
1550 +          args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ;
1551 +    }
1552 +
1553    return 0;
1554  
1555   failure:

Comparing trunk/src/applications/staticProps/StaticPropsCmd.c (property svn:keywords):
Revision 1091 by chuckv, Fri Nov 10 18:45:29 2006 UTC vs.
Revision 1513 by gezelter, Tue Oct 19 18:40:54 2010 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines