1 |
/* |
2 |
File autogenerated by gengetopt version 2.22.4 |
3 |
generated with the following command: |
4 |
gengetopt -F DynamicPropsCmd -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 |
#ifndef FIX_UNUSED |
21 |
#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */ |
22 |
#endif |
23 |
|
24 |
#include <getopt.h> |
25 |
|
26 |
#include "DynamicPropsCmd.h" |
27 |
|
28 |
const char *gengetopt_args_info_purpose = ""; |
29 |
|
30 |
const char *gengetopt_args_info_usage = "Usage: DynamicProps [OPTIONS]... [FILES]..."; |
31 |
|
32 |
const char *gengetopt_args_info_description = ""; |
33 |
|
34 |
const char *gengetopt_args_info_help[] = { |
35 |
" -h, --help Print help and exit", |
36 |
" -V, --version Print version and exit", |
37 |
" -i, --input=filename input dump file", |
38 |
" -o, --output=filename output file name", |
39 |
" --sele1=selection script select first stuntdouble set", |
40 |
" --sele2=selection script select second stuntdouble set (if sele2 is not \n set, use script from sele1)", |
41 |
" --order=INT Lengendre Polynomial Order", |
42 |
" -m, --memory=memory specification\n Available memory (defaults to 2G) \n (default=`2G')", |
43 |
"\n Group: dynamicProps\n an option of this group is required", |
44 |
" -r, --rcorr rmsd", |
45 |
" -v, --vcorr velocity correlation function", |
46 |
" -d, --dcorr dipole correlation function", |
47 |
" -l, --lcorr Lengendre correlation function", |
48 |
" --r_rcorr Radial rmsd", |
49 |
" --thetacorr Angular rmsd", |
50 |
" --drcorr Directional rmsd for particles with unit \n vectors", |
51 |
" --helfandEcorr Helfand moment for thermal conductvity", |
52 |
" --stresscorr Stress tensor correlation function", |
53 |
0 |
54 |
}; |
55 |
|
56 |
typedef enum {ARG_NO |
57 |
, ARG_STRING |
58 |
, ARG_INT |
59 |
} cmdline_parser_arg_type; |
60 |
|
61 |
static |
62 |
void clear_given (struct gengetopt_args_info *args_info); |
63 |
static |
64 |
void clear_args (struct gengetopt_args_info *args_info); |
65 |
|
66 |
static int |
67 |
cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info, |
68 |
struct cmdline_parser_params *params, const char *additional_error); |
69 |
|
70 |
static int |
71 |
cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error); |
72 |
|
73 |
static char * |
74 |
gengetopt_strdup (const char *s); |
75 |
|
76 |
static |
77 |
void clear_given (struct gengetopt_args_info *args_info) |
78 |
{ |
79 |
args_info->help_given = 0 ; |
80 |
args_info->version_given = 0 ; |
81 |
args_info->input_given = 0 ; |
82 |
args_info->output_given = 0 ; |
83 |
args_info->sele1_given = 0 ; |
84 |
args_info->sele2_given = 0 ; |
85 |
args_info->order_given = 0 ; |
86 |
args_info->memory_given = 0 ; |
87 |
args_info->rcorr_given = 0 ; |
88 |
args_info->vcorr_given = 0 ; |
89 |
args_info->dcorr_given = 0 ; |
90 |
args_info->lcorr_given = 0 ; |
91 |
args_info->r_rcorr_given = 0 ; |
92 |
args_info->thetacorr_given = 0 ; |
93 |
args_info->drcorr_given = 0 ; |
94 |
args_info->helfandEcorr_given = 0 ; |
95 |
args_info->stresscorr_given = 0 ; |
96 |
args_info->dynamicProps_group_counter = 0 ; |
97 |
} |
98 |
|
99 |
static |
100 |
void clear_args (struct gengetopt_args_info *args_info) |
101 |
{ |
102 |
FIX_UNUSED (args_info); |
103 |
args_info->input_arg = NULL; |
104 |
args_info->input_orig = NULL; |
105 |
args_info->output_arg = NULL; |
106 |
args_info->output_orig = NULL; |
107 |
args_info->sele1_arg = NULL; |
108 |
args_info->sele1_orig = NULL; |
109 |
args_info->sele2_arg = NULL; |
110 |
args_info->sele2_orig = NULL; |
111 |
args_info->order_orig = NULL; |
112 |
args_info->memory_arg = gengetopt_strdup ("2G"); |
113 |
args_info->memory_orig = NULL; |
114 |
|
115 |
} |
116 |
|
117 |
static |
118 |
void init_args_info(struct gengetopt_args_info *args_info) |
119 |
{ |
120 |
|
121 |
|
122 |
args_info->help_help = gengetopt_args_info_help[0] ; |
123 |
args_info->version_help = gengetopt_args_info_help[1] ; |
124 |
args_info->input_help = gengetopt_args_info_help[2] ; |
125 |
args_info->output_help = gengetopt_args_info_help[3] ; |
126 |
args_info->sele1_help = gengetopt_args_info_help[4] ; |
127 |
args_info->sele2_help = gengetopt_args_info_help[5] ; |
128 |
args_info->order_help = gengetopt_args_info_help[6] ; |
129 |
args_info->memory_help = gengetopt_args_info_help[7] ; |
130 |
args_info->rcorr_help = gengetopt_args_info_help[9] ; |
131 |
args_info->vcorr_help = gengetopt_args_info_help[10] ; |
132 |
args_info->dcorr_help = gengetopt_args_info_help[11] ; |
133 |
args_info->lcorr_help = gengetopt_args_info_help[12] ; |
134 |
args_info->r_rcorr_help = gengetopt_args_info_help[13] ; |
135 |
args_info->thetacorr_help = gengetopt_args_info_help[14] ; |
136 |
args_info->drcorr_help = gengetopt_args_info_help[15] ; |
137 |
args_info->helfandEcorr_help = gengetopt_args_info_help[16] ; |
138 |
args_info->stresscorr_help = gengetopt_args_info_help[17] ; |
139 |
|
140 |
} |
141 |
|
142 |
void |
143 |
cmdline_parser_print_version (void) |
144 |
{ |
145 |
printf ("%s %s\n", |
146 |
(strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE), |
147 |
CMDLINE_PARSER_VERSION); |
148 |
} |
149 |
|
150 |
static void print_help_common(void) { |
151 |
cmdline_parser_print_version (); |
152 |
|
153 |
if (strlen(gengetopt_args_info_purpose) > 0) |
154 |
printf("\n%s\n", gengetopt_args_info_purpose); |
155 |
|
156 |
if (strlen(gengetopt_args_info_usage) > 0) |
157 |
printf("\n%s\n", gengetopt_args_info_usage); |
158 |
|
159 |
printf("\n"); |
160 |
|
161 |
if (strlen(gengetopt_args_info_description) > 0) |
162 |
printf("%s\n\n", gengetopt_args_info_description); |
163 |
} |
164 |
|
165 |
void |
166 |
cmdline_parser_print_help (void) |
167 |
{ |
168 |
int i = 0; |
169 |
print_help_common(); |
170 |
while (gengetopt_args_info_help[i]) |
171 |
printf("%s\n", gengetopt_args_info_help[i++]); |
172 |
} |
173 |
|
174 |
void |
175 |
cmdline_parser_init (struct gengetopt_args_info *args_info) |
176 |
{ |
177 |
clear_given (args_info); |
178 |
clear_args (args_info); |
179 |
init_args_info (args_info); |
180 |
|
181 |
args_info->inputs = 0; |
182 |
args_info->inputs_num = 0; |
183 |
} |
184 |
|
185 |
void |
186 |
cmdline_parser_params_init(struct cmdline_parser_params *params) |
187 |
{ |
188 |
if (params) |
189 |
{ |
190 |
params->override = 0; |
191 |
params->initialize = 1; |
192 |
params->check_required = 1; |
193 |
params->check_ambiguity = 0; |
194 |
params->print_errors = 1; |
195 |
} |
196 |
} |
197 |
|
198 |
struct cmdline_parser_params * |
199 |
cmdline_parser_params_create(void) |
200 |
{ |
201 |
struct cmdline_parser_params *params = |
202 |
(struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params)); |
203 |
cmdline_parser_params_init(params); |
204 |
return params; |
205 |
} |
206 |
|
207 |
static void |
208 |
free_string_field (char **s) |
209 |
{ |
210 |
if (*s) |
211 |
{ |
212 |
free (*s); |
213 |
*s = 0; |
214 |
} |
215 |
} |
216 |
|
217 |
|
218 |
static void |
219 |
cmdline_parser_release (struct gengetopt_args_info *args_info) |
220 |
{ |
221 |
unsigned int i; |
222 |
free_string_field (&(args_info->input_arg)); |
223 |
free_string_field (&(args_info->input_orig)); |
224 |
free_string_field (&(args_info->output_arg)); |
225 |
free_string_field (&(args_info->output_orig)); |
226 |
free_string_field (&(args_info->sele1_arg)); |
227 |
free_string_field (&(args_info->sele1_orig)); |
228 |
free_string_field (&(args_info->sele2_arg)); |
229 |
free_string_field (&(args_info->sele2_orig)); |
230 |
free_string_field (&(args_info->order_orig)); |
231 |
free_string_field (&(args_info->memory_arg)); |
232 |
free_string_field (&(args_info->memory_orig)); |
233 |
|
234 |
|
235 |
for (i = 0; i < args_info->inputs_num; ++i) |
236 |
free (args_info->inputs [i]); |
237 |
|
238 |
if (args_info->inputs_num) |
239 |
free (args_info->inputs); |
240 |
|
241 |
clear_given (args_info); |
242 |
} |
243 |
|
244 |
|
245 |
static void |
246 |
write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[]) |
247 |
{ |
248 |
FIX_UNUSED (values); |
249 |
if (arg) { |
250 |
fprintf(outfile, "%s=\"%s\"\n", opt, arg); |
251 |
} else { |
252 |
fprintf(outfile, "%s\n", opt); |
253 |
} |
254 |
} |
255 |
|
256 |
|
257 |
int |
258 |
cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) |
259 |
{ |
260 |
int i = 0; |
261 |
|
262 |
if (!outfile) |
263 |
{ |
264 |
fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE); |
265 |
return EXIT_FAILURE; |
266 |
} |
267 |
|
268 |
if (args_info->help_given) |
269 |
write_into_file(outfile, "help", 0, 0 ); |
270 |
if (args_info->version_given) |
271 |
write_into_file(outfile, "version", 0, 0 ); |
272 |
if (args_info->input_given) |
273 |
write_into_file(outfile, "input", args_info->input_orig, 0); |
274 |
if (args_info->output_given) |
275 |
write_into_file(outfile, "output", args_info->output_orig, 0); |
276 |
if (args_info->sele1_given) |
277 |
write_into_file(outfile, "sele1", args_info->sele1_orig, 0); |
278 |
if (args_info->sele2_given) |
279 |
write_into_file(outfile, "sele2", args_info->sele2_orig, 0); |
280 |
if (args_info->order_given) |
281 |
write_into_file(outfile, "order", args_info->order_orig, 0); |
282 |
if (args_info->memory_given) |
283 |
write_into_file(outfile, "memory", args_info->memory_orig, 0); |
284 |
if (args_info->rcorr_given) |
285 |
write_into_file(outfile, "rcorr", 0, 0 ); |
286 |
if (args_info->vcorr_given) |
287 |
write_into_file(outfile, "vcorr", 0, 0 ); |
288 |
if (args_info->dcorr_given) |
289 |
write_into_file(outfile, "dcorr", 0, 0 ); |
290 |
if (args_info->lcorr_given) |
291 |
write_into_file(outfile, "lcorr", 0, 0 ); |
292 |
if (args_info->r_rcorr_given) |
293 |
write_into_file(outfile, "r_rcorr", 0, 0 ); |
294 |
if (args_info->thetacorr_given) |
295 |
write_into_file(outfile, "thetacorr", 0, 0 ); |
296 |
if (args_info->drcorr_given) |
297 |
write_into_file(outfile, "drcorr", 0, 0 ); |
298 |
if (args_info->helfandEcorr_given) |
299 |
write_into_file(outfile, "helfandEcorr", 0, 0 ); |
300 |
if (args_info->stresscorr_given) |
301 |
write_into_file(outfile, "stresscorr", 0, 0 ); |
302 |
|
303 |
|
304 |
i = EXIT_SUCCESS; |
305 |
return i; |
306 |
} |
307 |
|
308 |
int |
309 |
cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) |
310 |
{ |
311 |
FILE *outfile; |
312 |
int i = 0; |
313 |
|
314 |
outfile = fopen(filename, "w"); |
315 |
|
316 |
if (!outfile) |
317 |
{ |
318 |
fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); |
319 |
return EXIT_FAILURE; |
320 |
} |
321 |
|
322 |
i = cmdline_parser_dump(outfile, args_info); |
323 |
fclose (outfile); |
324 |
|
325 |
return i; |
326 |
} |
327 |
|
328 |
void |
329 |
cmdline_parser_free (struct gengetopt_args_info *args_info) |
330 |
{ |
331 |
cmdline_parser_release (args_info); |
332 |
} |
333 |
|
334 |
/** @brief replacement of strdup, which is not standard */ |
335 |
char * |
336 |
gengetopt_strdup (const char *s) |
337 |
{ |
338 |
char *result = 0; |
339 |
if (!s) |
340 |
return result; |
341 |
|
342 |
result = (char*)malloc(strlen(s) + 1); |
343 |
if (result == (char*)0) |
344 |
return (char*)0; |
345 |
strcpy(result, s); |
346 |
return result; |
347 |
} |
348 |
|
349 |
static void |
350 |
reset_group_dynamicProps(struct gengetopt_args_info *args_info) |
351 |
{ |
352 |
if (! args_info->dynamicProps_group_counter) |
353 |
return; |
354 |
|
355 |
args_info->rcorr_given = 0 ; |
356 |
args_info->vcorr_given = 0 ; |
357 |
args_info->dcorr_given = 0 ; |
358 |
args_info->lcorr_given = 0 ; |
359 |
args_info->r_rcorr_given = 0 ; |
360 |
args_info->thetacorr_given = 0 ; |
361 |
args_info->drcorr_given = 0 ; |
362 |
args_info->helfandEcorr_given = 0 ; |
363 |
args_info->stresscorr_given = 0 ; |
364 |
|
365 |
args_info->dynamicProps_group_counter = 0; |
366 |
} |
367 |
|
368 |
int |
369 |
cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info) |
370 |
{ |
371 |
return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); |
372 |
} |
373 |
|
374 |
int |
375 |
cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, |
376 |
struct cmdline_parser_params *params) |
377 |
{ |
378 |
int result; |
379 |
result = cmdline_parser_internal (argc, argv, args_info, params, 0); |
380 |
|
381 |
if (result == EXIT_FAILURE) |
382 |
{ |
383 |
cmdline_parser_free (args_info); |
384 |
exit (EXIT_FAILURE); |
385 |
} |
386 |
|
387 |
return result; |
388 |
} |
389 |
|
390 |
int |
391 |
cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
392 |
{ |
393 |
int result; |
394 |
struct cmdline_parser_params params; |
395 |
|
396 |
params.override = override; |
397 |
params.initialize = initialize; |
398 |
params.check_required = check_required; |
399 |
params.check_ambiguity = 0; |
400 |
params.print_errors = 1; |
401 |
|
402 |
result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0); |
403 |
|
404 |
if (result == EXIT_FAILURE) |
405 |
{ |
406 |
cmdline_parser_free (args_info); |
407 |
exit (EXIT_FAILURE); |
408 |
} |
409 |
|
410 |
return result; |
411 |
} |
412 |
|
413 |
int |
414 |
cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) |
415 |
{ |
416 |
int result = EXIT_SUCCESS; |
417 |
|
418 |
if (cmdline_parser_required2(args_info, prog_name, 0) > 0) |
419 |
result = EXIT_FAILURE; |
420 |
|
421 |
if (result == EXIT_FAILURE) |
422 |
{ |
423 |
cmdline_parser_free (args_info); |
424 |
exit (EXIT_FAILURE); |
425 |
} |
426 |
|
427 |
return result; |
428 |
} |
429 |
|
430 |
int |
431 |
cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) |
432 |
{ |
433 |
int error = 0; |
434 |
FIX_UNUSED (additional_error); |
435 |
|
436 |
/* checks for required options */ |
437 |
if (! args_info->input_given) |
438 |
{ |
439 |
fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : "")); |
440 |
error = 1; |
441 |
} |
442 |
|
443 |
if (args_info->dynamicProps_group_counter == 0) |
444 |
{ |
445 |
fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required%s.\n", prog_name, args_info->dynamicProps_group_counter, (additional_error ? additional_error : "")); |
446 |
error = 1; |
447 |
} |
448 |
|
449 |
|
450 |
/* checks for dependences among options */ |
451 |
|
452 |
return error; |
453 |
} |
454 |
|
455 |
|
456 |
static char *package_name = 0; |
457 |
|
458 |
/** |
459 |
* @brief updates an option |
460 |
* @param field the generic pointer to the field to update |
461 |
* @param orig_field the pointer to the orig field |
462 |
* @param field_given the pointer to the number of occurrence of this option |
463 |
* @param prev_given the pointer to the number of occurrence already seen |
464 |
* @param value the argument for this option (if null no arg was specified) |
465 |
* @param possible_values the possible values for this option (if specified) |
466 |
* @param default_value the default value (in case the option only accepts fixed values) |
467 |
* @param arg_type the type of this option |
468 |
* @param check_ambiguity @see cmdline_parser_params.check_ambiguity |
469 |
* @param override @see cmdline_parser_params.override |
470 |
* @param no_free whether to free a possible previous value |
471 |
* @param multiple_option whether this is a multiple option |
472 |
* @param long_opt the corresponding long option |
473 |
* @param short_opt the corresponding short option (or '-' if none) |
474 |
* @param additional_error possible further error specification |
475 |
*/ |
476 |
static |
477 |
int update_arg(void *field, char **orig_field, |
478 |
unsigned int *field_given, unsigned int *prev_given, |
479 |
char *value, const char *possible_values[], |
480 |
const char *default_value, |
481 |
cmdline_parser_arg_type arg_type, |
482 |
int check_ambiguity, int override, |
483 |
int no_free, int multiple_option, |
484 |
const char *long_opt, char short_opt, |
485 |
const char *additional_error) |
486 |
{ |
487 |
char *stop_char = 0; |
488 |
const char *val = value; |
489 |
int found; |
490 |
char **string_field; |
491 |
FIX_UNUSED (field); |
492 |
|
493 |
stop_char = 0; |
494 |
found = 0; |
495 |
|
496 |
if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) |
497 |
{ |
498 |
if (short_opt != '-') |
499 |
fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", |
500 |
package_name, long_opt, short_opt, |
501 |
(additional_error ? additional_error : "")); |
502 |
else |
503 |
fprintf (stderr, "%s: `--%s' option given more than once%s\n", |
504 |
package_name, long_opt, |
505 |
(additional_error ? additional_error : "")); |
506 |
return 1; /* failure */ |
507 |
} |
508 |
|
509 |
FIX_UNUSED (default_value); |
510 |
|
511 |
if (field_given && *field_given && ! override) |
512 |
return 0; |
513 |
if (prev_given) |
514 |
(*prev_given)++; |
515 |
if (field_given) |
516 |
(*field_given)++; |
517 |
if (possible_values) |
518 |
val = possible_values[found]; |
519 |
|
520 |
switch(arg_type) { |
521 |
case ARG_INT: |
522 |
if (val) *((int *)field) = strtol (val, &stop_char, 0); |
523 |
break; |
524 |
case ARG_STRING: |
525 |
if (val) { |
526 |
string_field = (char **)field; |
527 |
if (!no_free && *string_field) |
528 |
free (*string_field); /* free previous string */ |
529 |
*string_field = gengetopt_strdup (val); |
530 |
} |
531 |
break; |
532 |
default: |
533 |
break; |
534 |
}; |
535 |
|
536 |
/* check numeric conversion */ |
537 |
switch(arg_type) { |
538 |
case ARG_INT: |
539 |
if (val && !(stop_char && *stop_char == '\0')) { |
540 |
fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val); |
541 |
return 1; /* failure */ |
542 |
} |
543 |
break; |
544 |
default: |
545 |
; |
546 |
}; |
547 |
|
548 |
/* store the original value */ |
549 |
switch(arg_type) { |
550 |
case ARG_NO: |
551 |
break; |
552 |
default: |
553 |
if (value && orig_field) { |
554 |
if (no_free) { |
555 |
*orig_field = value; |
556 |
} else { |
557 |
if (*orig_field) |
558 |
free (*orig_field); /* free previous string */ |
559 |
*orig_field = gengetopt_strdup (value); |
560 |
} |
561 |
} |
562 |
}; |
563 |
|
564 |
return 0; /* OK */ |
565 |
} |
566 |
|
567 |
|
568 |
int |
569 |
cmdline_parser_internal ( |
570 |
int argc, char **argv, struct gengetopt_args_info *args_info, |
571 |
struct cmdline_parser_params *params, const char *additional_error) |
572 |
{ |
573 |
int c; /* Character of the parsed option. */ |
574 |
|
575 |
int error = 0; |
576 |
struct gengetopt_args_info local_args_info; |
577 |
|
578 |
int override; |
579 |
int initialize; |
580 |
int check_required; |
581 |
int check_ambiguity; |
582 |
|
583 |
package_name = argv[0]; |
584 |
|
585 |
override = params->override; |
586 |
initialize = params->initialize; |
587 |
check_required = params->check_required; |
588 |
check_ambiguity = params->check_ambiguity; |
589 |
|
590 |
if (initialize) |
591 |
cmdline_parser_init (args_info); |
592 |
|
593 |
cmdline_parser_init (&local_args_info); |
594 |
|
595 |
optarg = 0; |
596 |
optind = 0; |
597 |
opterr = params->print_errors; |
598 |
optopt = '?'; |
599 |
|
600 |
while (1) |
601 |
{ |
602 |
int option_index = 0; |
603 |
|
604 |
static struct option long_options[] = { |
605 |
{ "help", 0, NULL, 'h' }, |
606 |
{ "version", 0, NULL, 'V' }, |
607 |
{ "input", 1, NULL, 'i' }, |
608 |
{ "output", 1, NULL, 'o' }, |
609 |
{ "sele1", 1, NULL, 0 }, |
610 |
{ "sele2", 1, NULL, 0 }, |
611 |
{ "order", 1, NULL, 0 }, |
612 |
{ "memory", 1, NULL, 'm' }, |
613 |
{ "rcorr", 0, NULL, 'r' }, |
614 |
{ "vcorr", 0, NULL, 'v' }, |
615 |
{ "dcorr", 0, NULL, 'd' }, |
616 |
{ "lcorr", 0, NULL, 'l' }, |
617 |
{ "r_rcorr", 0, NULL, 0 }, |
618 |
{ "thetacorr", 0, NULL, 0 }, |
619 |
{ "drcorr", 0, NULL, 0 }, |
620 |
{ "helfandEcorr", 0, NULL, 0 }, |
621 |
{ "stresscorr", 0, NULL, 0 }, |
622 |
{ 0, 0, 0, 0 } |
623 |
}; |
624 |
|
625 |
c = getopt_long (argc, argv, "hVi:o:m:rvdl", long_options, &option_index); |
626 |
|
627 |
if (c == -1) break; /* Exit from `while (1)' loop. */ |
628 |
|
629 |
switch (c) |
630 |
{ |
631 |
case 'h': /* Print help and exit. */ |
632 |
cmdline_parser_print_help (); |
633 |
cmdline_parser_free (&local_args_info); |
634 |
exit (EXIT_SUCCESS); |
635 |
|
636 |
case 'V': /* Print version and exit. */ |
637 |
cmdline_parser_print_version (); |
638 |
cmdline_parser_free (&local_args_info); |
639 |
exit (EXIT_SUCCESS); |
640 |
|
641 |
case 'i': /* input dump file. */ |
642 |
|
643 |
|
644 |
if (update_arg( (void *)&(args_info->input_arg), |
645 |
&(args_info->input_orig), &(args_info->input_given), |
646 |
&(local_args_info.input_given), optarg, 0, 0, ARG_STRING, |
647 |
check_ambiguity, override, 0, 0, |
648 |
"input", 'i', |
649 |
additional_error)) |
650 |
goto failure; |
651 |
|
652 |
break; |
653 |
case 'o': /* output file name. */ |
654 |
|
655 |
|
656 |
if (update_arg( (void *)&(args_info->output_arg), |
657 |
&(args_info->output_orig), &(args_info->output_given), |
658 |
&(local_args_info.output_given), optarg, 0, 0, ARG_STRING, |
659 |
check_ambiguity, override, 0, 0, |
660 |
"output", 'o', |
661 |
additional_error)) |
662 |
goto failure; |
663 |
|
664 |
break; |
665 |
case 'm': /* Available memory (defaults to 2G). */ |
666 |
|
667 |
|
668 |
if (update_arg( (void *)&(args_info->memory_arg), |
669 |
&(args_info->memory_orig), &(args_info->memory_given), |
670 |
&(local_args_info.memory_given), optarg, 0, "2G", ARG_STRING, |
671 |
check_ambiguity, override, 0, 0, |
672 |
"memory", 'm', |
673 |
additional_error)) |
674 |
goto failure; |
675 |
|
676 |
break; |
677 |
case 'r': /* rmsd. */ |
678 |
|
679 |
if (args_info->dynamicProps_group_counter && override) |
680 |
reset_group_dynamicProps (args_info); |
681 |
args_info->dynamicProps_group_counter += 1; |
682 |
|
683 |
if (update_arg( 0 , |
684 |
0 , &(args_info->rcorr_given), |
685 |
&(local_args_info.rcorr_given), optarg, 0, 0, ARG_NO, |
686 |
check_ambiguity, override, 0, 0, |
687 |
"rcorr", 'r', |
688 |
additional_error)) |
689 |
goto failure; |
690 |
|
691 |
break; |
692 |
case 'v': /* velocity correlation function. */ |
693 |
|
694 |
if (args_info->dynamicProps_group_counter && override) |
695 |
reset_group_dynamicProps (args_info); |
696 |
args_info->dynamicProps_group_counter += 1; |
697 |
|
698 |
if (update_arg( 0 , |
699 |
0 , &(args_info->vcorr_given), |
700 |
&(local_args_info.vcorr_given), optarg, 0, 0, ARG_NO, |
701 |
check_ambiguity, override, 0, 0, |
702 |
"vcorr", 'v', |
703 |
additional_error)) |
704 |
goto failure; |
705 |
|
706 |
break; |
707 |
case 'd': /* dipole correlation function. */ |
708 |
|
709 |
if (args_info->dynamicProps_group_counter && override) |
710 |
reset_group_dynamicProps (args_info); |
711 |
args_info->dynamicProps_group_counter += 1; |
712 |
|
713 |
if (update_arg( 0 , |
714 |
0 , &(args_info->dcorr_given), |
715 |
&(local_args_info.dcorr_given), optarg, 0, 0, ARG_NO, |
716 |
check_ambiguity, override, 0, 0, |
717 |
"dcorr", 'd', |
718 |
additional_error)) |
719 |
goto failure; |
720 |
|
721 |
break; |
722 |
case 'l': /* Lengendre correlation function. */ |
723 |
|
724 |
if (args_info->dynamicProps_group_counter && override) |
725 |
reset_group_dynamicProps (args_info); |
726 |
args_info->dynamicProps_group_counter += 1; |
727 |
|
728 |
if (update_arg( 0 , |
729 |
0 , &(args_info->lcorr_given), |
730 |
&(local_args_info.lcorr_given), optarg, 0, 0, ARG_NO, |
731 |
check_ambiguity, override, 0, 0, |
732 |
"lcorr", 'l', |
733 |
additional_error)) |
734 |
goto failure; |
735 |
|
736 |
break; |
737 |
|
738 |
case 0: /* Long option with no short option */ |
739 |
/* select first stuntdouble set. */ |
740 |
if (strcmp (long_options[option_index].name, "sele1") == 0) |
741 |
{ |
742 |
|
743 |
|
744 |
if (update_arg( (void *)&(args_info->sele1_arg), |
745 |
&(args_info->sele1_orig), &(args_info->sele1_given), |
746 |
&(local_args_info.sele1_given), optarg, 0, 0, ARG_STRING, |
747 |
check_ambiguity, override, 0, 0, |
748 |
"sele1", '-', |
749 |
additional_error)) |
750 |
goto failure; |
751 |
|
752 |
} |
753 |
/* select second stuntdouble set (if sele2 is not set, use script from sele1). */ |
754 |
else if (strcmp (long_options[option_index].name, "sele2") == 0) |
755 |
{ |
756 |
|
757 |
|
758 |
if (update_arg( (void *)&(args_info->sele2_arg), |
759 |
&(args_info->sele2_orig), &(args_info->sele2_given), |
760 |
&(local_args_info.sele2_given), optarg, 0, 0, ARG_STRING, |
761 |
check_ambiguity, override, 0, 0, |
762 |
"sele2", '-', |
763 |
additional_error)) |
764 |
goto failure; |
765 |
|
766 |
} |
767 |
/* Lengendre Polynomial Order. */ |
768 |
else if (strcmp (long_options[option_index].name, "order") == 0) |
769 |
{ |
770 |
|
771 |
|
772 |
if (update_arg( (void *)&(args_info->order_arg), |
773 |
&(args_info->order_orig), &(args_info->order_given), |
774 |
&(local_args_info.order_given), optarg, 0, 0, ARG_INT, |
775 |
check_ambiguity, override, 0, 0, |
776 |
"order", '-', |
777 |
additional_error)) |
778 |
goto failure; |
779 |
|
780 |
} |
781 |
/* Radial rmsd. */ |
782 |
else if (strcmp (long_options[option_index].name, "r_rcorr") == 0) |
783 |
{ |
784 |
|
785 |
if (args_info->dynamicProps_group_counter && override) |
786 |
reset_group_dynamicProps (args_info); |
787 |
args_info->dynamicProps_group_counter += 1; |
788 |
|
789 |
if (update_arg( 0 , |
790 |
0 , &(args_info->r_rcorr_given), |
791 |
&(local_args_info.r_rcorr_given), optarg, 0, 0, ARG_NO, |
792 |
check_ambiguity, override, 0, 0, |
793 |
"r_rcorr", '-', |
794 |
additional_error)) |
795 |
goto failure; |
796 |
|
797 |
} |
798 |
/* Angular rmsd. */ |
799 |
else if (strcmp (long_options[option_index].name, "thetacorr") == 0) |
800 |
{ |
801 |
|
802 |
if (args_info->dynamicProps_group_counter && override) |
803 |
reset_group_dynamicProps (args_info); |
804 |
args_info->dynamicProps_group_counter += 1; |
805 |
|
806 |
if (update_arg( 0 , |
807 |
0 , &(args_info->thetacorr_given), |
808 |
&(local_args_info.thetacorr_given), optarg, 0, 0, ARG_NO, |
809 |
check_ambiguity, override, 0, 0, |
810 |
"thetacorr", '-', |
811 |
additional_error)) |
812 |
goto failure; |
813 |
|
814 |
} |
815 |
/* Directional rmsd for particles with unit vectors. */ |
816 |
else if (strcmp (long_options[option_index].name, "drcorr") == 0) |
817 |
{ |
818 |
|
819 |
if (args_info->dynamicProps_group_counter && override) |
820 |
reset_group_dynamicProps (args_info); |
821 |
args_info->dynamicProps_group_counter += 1; |
822 |
|
823 |
if (update_arg( 0 , |
824 |
0 , &(args_info->drcorr_given), |
825 |
&(local_args_info.drcorr_given), optarg, 0, 0, ARG_NO, |
826 |
check_ambiguity, override, 0, 0, |
827 |
"drcorr", '-', |
828 |
additional_error)) |
829 |
goto failure; |
830 |
|
831 |
} |
832 |
/* Helfand moment for thermal conductvity. */ |
833 |
else if (strcmp (long_options[option_index].name, "helfandEcorr") == 0) |
834 |
{ |
835 |
|
836 |
if (args_info->dynamicProps_group_counter && override) |
837 |
reset_group_dynamicProps (args_info); |
838 |
args_info->dynamicProps_group_counter += 1; |
839 |
|
840 |
if (update_arg( 0 , |
841 |
0 , &(args_info->helfandEcorr_given), |
842 |
&(local_args_info.helfandEcorr_given), optarg, 0, 0, ARG_NO, |
843 |
check_ambiguity, override, 0, 0, |
844 |
"helfandEcorr", '-', |
845 |
additional_error)) |
846 |
goto failure; |
847 |
|
848 |
} |
849 |
/* Stress tensor correlation function. */ |
850 |
else if (strcmp (long_options[option_index].name, "stresscorr") == 0) |
851 |
{ |
852 |
|
853 |
if (args_info->dynamicProps_group_counter && override) |
854 |
reset_group_dynamicProps (args_info); |
855 |
args_info->dynamicProps_group_counter += 1; |
856 |
|
857 |
if (update_arg( 0 , |
858 |
0 , &(args_info->stresscorr_given), |
859 |
&(local_args_info.stresscorr_given), optarg, 0, 0, ARG_NO, |
860 |
check_ambiguity, override, 0, 0, |
861 |
"stresscorr", '-', |
862 |
additional_error)) |
863 |
goto failure; |
864 |
|
865 |
} |
866 |
|
867 |
break; |
868 |
case '?': /* Invalid option. */ |
869 |
/* `getopt_long' already printed an error message. */ |
870 |
goto failure; |
871 |
|
872 |
default: /* bug: option not considered. */ |
873 |
fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); |
874 |
abort (); |
875 |
} /* switch */ |
876 |
} /* while */ |
877 |
|
878 |
if (args_info->dynamicProps_group_counter > 1) |
879 |
{ |
880 |
fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required%s.\n", argv[0], args_info->dynamicProps_group_counter, (additional_error ? additional_error : "")); |
881 |
error = 1; |
882 |
} |
883 |
|
884 |
|
885 |
|
886 |
if (check_required) |
887 |
{ |
888 |
error += cmdline_parser_required2 (args_info, argv[0], additional_error); |
889 |
} |
890 |
|
891 |
cmdline_parser_release (&local_args_info); |
892 |
|
893 |
if ( error ) |
894 |
return (EXIT_FAILURE); |
895 |
|
896 |
if (optind < argc) |
897 |
{ |
898 |
int i = 0 ; |
899 |
int found_prog_name = 0; |
900 |
/* whether program name, i.e., argv[0], is in the remaining args |
901 |
(this may happen with some implementations of getopt, |
902 |
but surely not with the one included by gengetopt) */ |
903 |
|
904 |
i = optind; |
905 |
while (i < argc) |
906 |
if (argv[i++] == argv[0]) { |
907 |
found_prog_name = 1; |
908 |
break; |
909 |
} |
910 |
i = 0; |
911 |
|
912 |
args_info->inputs_num = argc - optind - found_prog_name; |
913 |
args_info->inputs = |
914 |
(char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ; |
915 |
while (optind < argc) |
916 |
if (argv[optind++] != argv[0]) |
917 |
args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ; |
918 |
} |
919 |
|
920 |
return 0; |
921 |
|
922 |
failure: |
923 |
|
924 |
cmdline_parser_release (&local_args_info); |
925 |
return (EXIT_FAILURE); |
926 |
} |