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