ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/SHAPES/shaperCmd.c
Revision: 1295
Committed: Thu Jun 24 15:31:52 2004 UTC (20 years ago) by gezelter
Content type: text/plain
File size: 10920 byte(s)
Log Message:
renamed forcer, modified factorial, fixed makefile

File Contents

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