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

Comparing:
trunk/src/applications/staticProps/StaticPropsCmd.c (file contents), Revision 929 by gezelter, Tue Apr 11 15:33:27 2006 UTC vs.
trunk/src/applications/staticProps/StaticPropsCmd.cpp (file contents), Revision 1795 by gezelter, Fri Sep 7 18:13:55 2012 UTC

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

Comparing:
trunk/src/applications/staticProps/StaticPropsCmd.c (property svn:keywords), Revision 929 by gezelter, Tue Apr 11 15:33:27 2006 UTC vs.
trunk/src/applications/staticProps/StaticPropsCmd.cpp (property svn:keywords), Revision 1795 by gezelter, Fri Sep 7 18:13:55 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines