ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/applications/staticProps/StaticPropsCmd.cpp
Revision: 1865
Committed: Wed Apr 17 18:24:08 2013 UTC (12 years ago) by gezelter
File size: 61648 byte(s)
Log Message:
Adding spatial statistics analysers.

File Contents

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

Properties

Name Value
svn:keywords Author Id Revision Date