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