ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/staticProps/StaticPropsCmd.c
Revision: 1526
Committed: Wed Nov 24 17:40:12 2010 UTC (14 years, 5 months ago) by kstocke1
Content type: text/plain
File size: 53823 byte(s)
Log Message:
Completed SMIPD to Langevin Hull integrator name change


File Contents

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

Properties

Name Value
svn:keywords Author Id Revision Date