1 |
gezelter |
1295 |
/* |
2 |
|
|
File autogenerated by gengetopt version 2.12.1 |
3 |
|
|
generated with the following command: |
4 |
|
|
gengetopt --file-name=shaperCmd |
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 "shaperCmd.h" |
23 |
|
|
|
24 |
|
|
static |
25 |
|
|
void clear_given (struct gengetopt_args_info *args_info); |
26 |
|
|
static |
27 |
|
|
void clear_args (struct gengetopt_args_info *args_info); |
28 |
|
|
|
29 |
|
|
static int |
30 |
|
|
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); |
31 |
|
|
|
32 |
|
|
static char * |
33 |
|
|
gengetopt_strdup (const char *s); |
34 |
|
|
|
35 |
|
|
static |
36 |
|
|
void clear_given (struct gengetopt_args_info *args_info) |
37 |
|
|
{ |
38 |
|
|
args_info->help_given = 0 ; |
39 |
|
|
args_info->version_given = 0 ; |
40 |
|
|
args_info->input_given = 0 ; |
41 |
|
|
args_info->bandwidth_given = 0 ; |
42 |
chrisfen |
1312 |
args_info->tolerance_given = 0 ; |
43 |
gezelter |
1295 |
args_info->charmm_given = 0 ; |
44 |
|
|
args_info->amber_given = 0 ; |
45 |
|
|
args_info->lj_given = 0 ; |
46 |
|
|
args_info->gaff_given = 0 ; |
47 |
|
|
args_info->opls_given = 0 ; |
48 |
|
|
args_info->ForceField_group_counter = 0 ; |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
static |
52 |
|
|
void clear_args (struct gengetopt_args_info *args_info) |
53 |
|
|
{ |
54 |
|
|
args_info->input_arg = NULL; |
55 |
|
|
args_info->bandwidth_arg = 8 ; |
56 |
chrisfen |
1312 |
args_info->tolerance_arg = 0.01 ; |
57 |
gezelter |
1295 |
} |
58 |
|
|
|
59 |
|
|
void |
60 |
|
|
cmdline_parser_print_version (void) |
61 |
|
|
{ |
62 |
|
|
printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); |
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
void |
66 |
|
|
cmdline_parser_print_help (void) |
67 |
|
|
{ |
68 |
|
|
cmdline_parser_print_version (); |
69 |
|
|
printf("\n" |
70 |
|
|
"Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE); |
71 |
|
|
printf("\n"); |
72 |
chrisfen |
1312 |
printf("%s\n"," -h, --help Print help and exit"); |
73 |
|
|
printf("%s\n"," -V, --version Print version and exit"); |
74 |
|
|
printf("%s\n"," -i, --input=filename input file name"); |
75 |
|
|
printf("%s\n"," -b, --bandwidth=INT The step detail for the potential grids - typically \n a power of 2 (default=`8')"); |
76 |
|
|
printf("%s\n"," -t, --tolerance=DOUBLE The tolerance for recognition of spherical harmonic \n terms (default=`0.01')"); |
77 |
gezelter |
1295 |
printf("\n"); |
78 |
|
|
printf(" Group: ForceField A Force Field must be specified\n"); |
79 |
chrisfen |
1312 |
printf("%s\n"," -c, --charmm Use CHARMM 27 parameters"); |
80 |
|
|
printf("%s\n"," -a, --amber Use Amber99 parameters"); |
81 |
|
|
printf("%s\n"," -l, --lj Use Lennard-Jones parameters"); |
82 |
|
|
printf("%s\n"," -g, --gaff Use GAFF parameters"); |
83 |
|
|
printf("%s\n"," -o, --opls Use OPLS/AA parameters"); |
84 |
gezelter |
1295 |
} |
85 |
|
|
|
86 |
|
|
void |
87 |
|
|
cmdline_parser_init (struct gengetopt_args_info *args_info) |
88 |
|
|
{ |
89 |
|
|
clear_given (args_info); |
90 |
|
|
clear_args (args_info); |
91 |
|
|
} |
92 |
|
|
|
93 |
|
|
void |
94 |
|
|
cmdline_parser_free (struct gengetopt_args_info *args_info) |
95 |
|
|
{ |
96 |
|
|
|
97 |
|
|
if (args_info->input_arg) |
98 |
|
|
{ |
99 |
|
|
free (args_info->input_arg); /* free previous argument */ |
100 |
|
|
args_info->input_arg = 0; |
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
clear_given (args_info); |
104 |
|
|
} |
105 |
|
|
|
106 |
|
|
|
107 |
|
|
/* gengetopt_strdup() */ |
108 |
|
|
/* strdup.c replacement of strdup, which is not standard */ |
109 |
|
|
char * |
110 |
|
|
gengetopt_strdup (const char *s) |
111 |
|
|
{ |
112 |
|
|
char *result = NULL; |
113 |
|
|
if (!s) |
114 |
|
|
return result; |
115 |
|
|
|
116 |
|
|
result = (char*)malloc(strlen(s) + 1); |
117 |
|
|
if (result == (char*)0) |
118 |
|
|
return (char*)0; |
119 |
|
|
strcpy(result, s); |
120 |
|
|
return result; |
121 |
|
|
} |
122 |
|
|
|
123 |
|
|
static void |
124 |
|
|
reset_group_ForceField(struct gengetopt_args_info *args_info); |
125 |
|
|
|
126 |
|
|
static void |
127 |
|
|
reset_group_ForceField(struct gengetopt_args_info *args_info) |
128 |
|
|
{ |
129 |
|
|
if (! args_info->ForceField_group_counter) |
130 |
|
|
return; |
131 |
|
|
|
132 |
|
|
args_info->charmm_given = 0 ; |
133 |
|
|
args_info->amber_given = 0 ; |
134 |
|
|
args_info->lj_given = 0 ; |
135 |
|
|
args_info->gaff_given = 0 ; |
136 |
|
|
args_info->opls_given = 0 ; |
137 |
|
|
|
138 |
|
|
args_info->ForceField_group_counter = 0; |
139 |
|
|
} |
140 |
|
|
|
141 |
|
|
int |
142 |
|
|
cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
143 |
|
|
{ |
144 |
|
|
return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); |
145 |
|
|
} |
146 |
|
|
|
147 |
|
|
int |
148 |
|
|
cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
149 |
|
|
{ |
150 |
|
|
int result; |
151 |
|
|
|
152 |
|
|
result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL); |
153 |
|
|
|
154 |
|
|
if (result == EXIT_FAILURE) |
155 |
|
|
{ |
156 |
|
|
cmdline_parser_free (args_info); |
157 |
|
|
exit (EXIT_FAILURE); |
158 |
|
|
} |
159 |
|
|
|
160 |
|
|
return result; |
161 |
|
|
} |
162 |
|
|
|
163 |
|
|
int |
164 |
|
|
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) |
165 |
|
|
{ |
166 |
|
|
int c; /* Character of the parsed option. */ |
167 |
|
|
int error = 0; |
168 |
|
|
struct gengetopt_args_info local_args_info; |
169 |
|
|
|
170 |
|
|
if (initialize) |
171 |
|
|
cmdline_parser_init (args_info); |
172 |
|
|
|
173 |
|
|
cmdline_parser_init (&local_args_info); |
174 |
|
|
|
175 |
|
|
optarg = 0; |
176 |
|
|
optind = 1; |
177 |
|
|
opterr = 1; |
178 |
|
|
optopt = '?'; |
179 |
|
|
|
180 |
|
|
while (1) |
181 |
|
|
{ |
182 |
|
|
int option_index = 0; |
183 |
|
|
char *stop_char; |
184 |
|
|
|
185 |
|
|
static struct option long_options[] = { |
186 |
|
|
{ "help", 0, NULL, 'h' }, |
187 |
|
|
{ "version", 0, NULL, 'V' }, |
188 |
|
|
{ "input", 1, NULL, 'i' }, |
189 |
|
|
{ "bandwidth", 1, NULL, 'b' }, |
190 |
chrisfen |
1312 |
{ "tolerance", 1, NULL, 't' }, |
191 |
gezelter |
1295 |
{ "charmm", 0, NULL, 'c' }, |
192 |
|
|
{ "amber", 0, NULL, 'a' }, |
193 |
|
|
{ "lj", 0, NULL, 'l' }, |
194 |
|
|
{ "gaff", 0, NULL, 'g' }, |
195 |
|
|
{ "opls", 0, NULL, 'o' }, |
196 |
|
|
{ NULL, 0, NULL, 0 } |
197 |
|
|
}; |
198 |
|
|
|
199 |
|
|
stop_char = 0; |
200 |
chrisfen |
1312 |
c = getopt_long (argc, argv, "hVi:b:t:calgo", long_options, &option_index); |
201 |
gezelter |
1295 |
|
202 |
|
|
if (c == -1) break; /* Exit from `while (1)' loop. */ |
203 |
|
|
|
204 |
|
|
switch (c) |
205 |
|
|
{ |
206 |
|
|
case 'h': /* Print help and exit. */ |
207 |
|
|
cmdline_parser_print_help (); |
208 |
|
|
exit (EXIT_SUCCESS); |
209 |
|
|
|
210 |
|
|
case 'V': /* Print version and exit. */ |
211 |
|
|
cmdline_parser_print_version (); |
212 |
|
|
exit (EXIT_SUCCESS); |
213 |
|
|
|
214 |
|
|
case 'i': /* input file name. */ |
215 |
|
|
if (local_args_info.input_given) |
216 |
|
|
{ |
217 |
|
|
fprintf (stderr, "%s: `--input' (`-i') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); |
218 |
|
|
goto failure; |
219 |
|
|
} |
220 |
|
|
if (args_info->input_given && ! override) |
221 |
|
|
continue; |
222 |
|
|
local_args_info.input_given = 1; |
223 |
|
|
args_info->input_given = 1; |
224 |
|
|
if (args_info->input_arg) |
225 |
|
|
free (args_info->input_arg); /* free previous string */ |
226 |
|
|
args_info->input_arg = gengetopt_strdup (optarg); |
227 |
|
|
break; |
228 |
|
|
|
229 |
|
|
case 'b': /* The step detail for the potential grids - typically a power of 2. */ |
230 |
|
|
if (local_args_info.bandwidth_given) |
231 |
|
|
{ |
232 |
|
|
fprintf (stderr, "%s: `--bandwidth' (`-b') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); |
233 |
|
|
goto failure; |
234 |
|
|
} |
235 |
|
|
if (args_info->bandwidth_given && ! override) |
236 |
|
|
continue; |
237 |
|
|
local_args_info.bandwidth_given = 1; |
238 |
|
|
args_info->bandwidth_given = 1; |
239 |
|
|
args_info->bandwidth_arg = strtol (optarg,&stop_char,0); |
240 |
|
|
break; |
241 |
|
|
|
242 |
chrisfen |
1312 |
case 't': /* The tolerance for recognition of spherical harmonic terms. */ |
243 |
|
|
if (local_args_info.tolerance_given) |
244 |
|
|
{ |
245 |
|
|
fprintf (stderr, "%s: `--tolerance' (`-t') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); |
246 |
|
|
goto failure; |
247 |
|
|
} |
248 |
|
|
if (args_info->tolerance_given && ! override) |
249 |
|
|
continue; |
250 |
|
|
local_args_info.tolerance_given = 1; |
251 |
|
|
args_info->tolerance_given = 1; |
252 |
|
|
args_info->tolerance_arg = strtod (optarg, NULL); |
253 |
|
|
break; |
254 |
|
|
|
255 |
gezelter |
1295 |
case 'c': /* Use CHARMM 27 parameters. */ |
256 |
|
|
if (local_args_info.charmm_given) |
257 |
|
|
{ |
258 |
|
|
fprintf (stderr, "%s: `--charmm' (`-c') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); |
259 |
|
|
goto failure; |
260 |
|
|
} |
261 |
|
|
if (args_info->charmm_given && ! override) |
262 |
|
|
continue; |
263 |
|
|
local_args_info.charmm_given = 1; |
264 |
|
|
args_info->charmm_given = 1; |
265 |
|
|
if (args_info->ForceField_group_counter && override) |
266 |
|
|
reset_group_ForceField (args_info); |
267 |
|
|
args_info->ForceField_group_counter += 1; |
268 |
|
|
break; |
269 |
|
|
|
270 |
|
|
case 'a': /* Use Amber99 parameters. */ |
271 |
|
|
if (local_args_info.amber_given) |
272 |
|
|
{ |
273 |
|
|
fprintf (stderr, "%s: `--amber' (`-a') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); |
274 |
|
|
goto failure; |
275 |
|
|
} |
276 |
|
|
if (args_info->amber_given && ! override) |
277 |
|
|
continue; |
278 |
|
|
local_args_info.amber_given = 1; |
279 |
|
|
args_info->amber_given = 1; |
280 |
|
|
if (args_info->ForceField_group_counter && override) |
281 |
|
|
reset_group_ForceField (args_info); |
282 |
|
|
args_info->ForceField_group_counter += 1; |
283 |
|
|
break; |
284 |
|
|
|
285 |
|
|
case 'l': /* Use Lennard-Jones parameters. */ |
286 |
|
|
if (local_args_info.lj_given) |
287 |
|
|
{ |
288 |
|
|
fprintf (stderr, "%s: `--lj' (`-l') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); |
289 |
|
|
goto failure; |
290 |
|
|
} |
291 |
|
|
if (args_info->lj_given && ! override) |
292 |
|
|
continue; |
293 |
|
|
local_args_info.lj_given = 1; |
294 |
|
|
args_info->lj_given = 1; |
295 |
|
|
if (args_info->ForceField_group_counter && override) |
296 |
|
|
reset_group_ForceField (args_info); |
297 |
|
|
args_info->ForceField_group_counter += 1; |
298 |
|
|
break; |
299 |
|
|
|
300 |
|
|
case 'g': /* Use GAFF parameters. */ |
301 |
|
|
if (local_args_info.gaff_given) |
302 |
|
|
{ |
303 |
|
|
fprintf (stderr, "%s: `--gaff' (`-g') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); |
304 |
|
|
goto failure; |
305 |
|
|
} |
306 |
|
|
if (args_info->gaff_given && ! override) |
307 |
|
|
continue; |
308 |
|
|
local_args_info.gaff_given = 1; |
309 |
|
|
args_info->gaff_given = 1; |
310 |
|
|
if (args_info->ForceField_group_counter && override) |
311 |
|
|
reset_group_ForceField (args_info); |
312 |
|
|
args_info->ForceField_group_counter += 1; |
313 |
|
|
break; |
314 |
|
|
|
315 |
|
|
case 'o': /* Use OPLS/AA parameters. */ |
316 |
|
|
if (local_args_info.opls_given) |
317 |
|
|
{ |
318 |
|
|
fprintf (stderr, "%s: `--opls' (`-o') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); |
319 |
|
|
goto failure; |
320 |
|
|
} |
321 |
|
|
if (args_info->opls_given && ! override) |
322 |
|
|
continue; |
323 |
|
|
local_args_info.opls_given = 1; |
324 |
|
|
args_info->opls_given = 1; |
325 |
|
|
if (args_info->ForceField_group_counter && override) |
326 |
|
|
reset_group_ForceField (args_info); |
327 |
|
|
args_info->ForceField_group_counter += 1; |
328 |
|
|
break; |
329 |
|
|
|
330 |
|
|
|
331 |
|
|
case 0: /* Long option with no short option */ |
332 |
|
|
|
333 |
|
|
case '?': /* Invalid option. */ |
334 |
|
|
/* `getopt_long' already printed an error message. */ |
335 |
|
|
goto failure; |
336 |
|
|
|
337 |
|
|
default: /* bug: option not considered. */ |
338 |
|
|
fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); |
339 |
|
|
abort (); |
340 |
|
|
} /* switch */ |
341 |
|
|
} /* while */ |
342 |
|
|
|
343 |
|
|
if ( args_info->ForceField_group_counter != 1) |
344 |
|
|
{ |
345 |
|
|
fprintf (stderr, "%s: %d options of group ForceField were given. One is required.%s\n", CMDLINE_PARSER_PACKAGE, args_info->ForceField_group_counter, (additional_error ? additional_error : "")); |
346 |
|
|
error = 1; |
347 |
|
|
} |
348 |
|
|
|
349 |
|
|
|
350 |
|
|
|
351 |
|
|
if (check_required) |
352 |
|
|
{ |
353 |
|
|
if (! args_info->input_given) |
354 |
|
|
{ |
355 |
|
|
fprintf (stderr, "%s: '--input' ('-i') option required%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); |
356 |
|
|
error = 1; |
357 |
|
|
} |
358 |
|
|
} |
359 |
|
|
|
360 |
|
|
if ( error ) |
361 |
|
|
return (EXIT_FAILURE); |
362 |
|
|
|
363 |
|
|
return 0; |
364 |
|
|
|
365 |
|
|
failure: |
366 |
|
|
cmdline_parser_free (&local_args_info); |
367 |
|
|
return (EXIT_FAILURE); |
368 |
|
|
} |