ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/dump2Xyz/Dump2XYZCmd.c
Revision: 2240
Committed: Thu May 26 22:45:00 2005 UTC (19 years, 1 month ago) by tim
Content type: text/plain
File size: 13071 byte(s)
Log Message:
adding AtomNameVisitor to convert atom name to its base name; wrappingvisitor
now wrap back to the center of the mass; adding P2OrderParameter into StaticProps

File Contents

# Content
1 /*
2 File autogenerated by gengetopt version 2.11
3 generated with the following command:
4 /home/maul/gezelter/tim/bin/gengetopt -i Dump2XYZ.ggo -F Dump2XYZCmd
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
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15
16 /* If we use autoconf. */
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20
21 #include "getopt.h"
22
23 #include "Dump2XYZCmd.h"
24
25 void
26 cmdline_parser_print_version (void)
27 {
28 printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
29 }
30
31 void
32 cmdline_parser_print_help (void)
33 {
34 cmdline_parser_print_version ();
35 printf("\n"
36 "Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE);
37 printf("\n");
38 printf(" -h, --help Print help and exit\n");
39 printf(" -V, --version Print version and exit\n");
40 printf(" -i, --input=filename input dump file\n");
41 printf(" -o, --output=filename output file name\n");
42 printf(" -n, --frame=INT print every n frame (default=`1')\n");
43 printf(" -w, --water skip the the waters (default=off)\n");
44 printf(" -m, --periodicBox map to the periodic box (default=off)\n");
45 printf(" -z, --zconstraint replace the atom types of zconstraint \n molecules (default=off)\n");
46 printf(" -r, --rigidbody add a pseudo COM atom to rigidbody \n (default=off)\n");
47 printf(" -t, --watertype replace the atom type of water model \n (default=on)\n");
48 printf(" -b, --basetype using base atom type (default=off)\n");
49 printf(" -s, --selection=selection script general selection syntax\n");
50 printf(" --originsele=selection script select origin\n");
51 printf(" --refsele=selection script select reference\n");
52 printf(" --repeatX=INT The number of images to repeat in the x \n direction (default=`0')\n");
53 printf(" --repeatY=INT The number of images to repeat in the y \n direction (default=`0')\n");
54 printf(" --repeatZ=INT The number of images to repeat in the z \n direction (default=`0')\n");
55 }
56
57
58 static char *gengetopt_strdup (const char *s);
59
60 /* gengetopt_strdup() */
61 /* strdup.c replacement of strdup, which is not standard */
62 char *
63 gengetopt_strdup (const char *s)
64 {
65 char *result = (char*)malloc(strlen(s) + 1);
66 if (result == (char*)0)
67 return (char*)0;
68 strcpy(result, s);
69 return result;
70 }
71
72 int
73 cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
74 {
75 int c; /* Character of the parsed option. */
76 int missing_required_options = 0;
77
78 args_info->help_given = 0 ;
79 args_info->version_given = 0 ;
80 args_info->input_given = 0 ;
81 args_info->output_given = 0 ;
82 args_info->frame_given = 0 ;
83 args_info->water_given = 0 ;
84 args_info->periodicBox_given = 0 ;
85 args_info->zconstraint_given = 0 ;
86 args_info->rigidbody_given = 0 ;
87 args_info->watertype_given = 0 ;
88 args_info->basetype_given = 0 ;
89 args_info->selection_given = 0 ;
90 args_info->originsele_given = 0 ;
91 args_info->refsele_given = 0 ;
92 args_info->repeatX_given = 0 ;
93 args_info->repeatY_given = 0 ;
94 args_info->repeatZ_given = 0 ;
95 #define clear_args() { \
96 args_info->input_arg = NULL; \
97 args_info->output_arg = NULL; \
98 args_info->frame_arg = 1 ;\
99 args_info->water_flag = 0;\
100 args_info->periodicBox_flag = 0;\
101 args_info->zconstraint_flag = 0;\
102 args_info->rigidbody_flag = 0;\
103 args_info->watertype_flag = 1;\
104 args_info->basetype_flag = 0;\
105 args_info->selection_arg = NULL; \
106 args_info->originsele_arg = NULL; \
107 args_info->refsele_arg = NULL; \
108 args_info->repeatX_arg = 0 ;\
109 args_info->repeatY_arg = 0 ;\
110 args_info->repeatZ_arg = 0 ;\
111 }
112
113 clear_args();
114
115 optarg = 0;
116 optind = 1;
117 opterr = 1;
118 optopt = '?';
119
120 while (1)
121 {
122 int option_index = 0;
123 char *stop_char;
124
125 static struct option long_options[] = {
126 { "help", 0, NULL, 'h' },
127 { "version", 0, NULL, 'V' },
128 { "input", 1, NULL, 'i' },
129 { "output", 1, NULL, 'o' },
130 { "frame", 1, NULL, 'n' },
131 { "water", 0, NULL, 'w' },
132 { "periodicBox", 0, NULL, 'm' },
133 { "zconstraint", 0, NULL, 'z' },
134 { "rigidbody", 0, NULL, 'r' },
135 { "watertype", 0, NULL, 't' },
136 { "basetype", 0, NULL, 'b' },
137 { "selection", 1, NULL, 's' },
138 { "originsele", 1, NULL, 0 },
139 { "refsele", 1, NULL, 0 },
140 { "repeatX", 1, NULL, 0 },
141 { "repeatY", 1, NULL, 0 },
142 { "repeatZ", 1, NULL, 0 },
143 { NULL, 0, NULL, 0 }
144 };
145
146 stop_char = 0;
147 c = getopt_long (argc, argv, "hVi:o:n:wmzrtbs:", long_options, &option_index);
148
149 if (c == -1) break; /* Exit from `while (1)' loop. */
150
151 switch (c)
152 {
153 case 'h': /* Print help and exit. */
154 clear_args ();
155 cmdline_parser_print_help ();
156 exit (EXIT_SUCCESS);
157
158 case 'V': /* Print version and exit. */
159 clear_args ();
160 cmdline_parser_print_version ();
161 exit (EXIT_SUCCESS);
162
163 case 'i': /* input dump file. */
164 if (args_info->input_given)
165 {
166 fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE);
167 clear_args ();
168 exit (EXIT_FAILURE);
169 }
170 args_info->input_given = 1;
171 args_info->input_arg = gengetopt_strdup (optarg);
172 break;
173
174 case 'o': /* output file name. */
175 if (args_info->output_given)
176 {
177 fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE);
178 clear_args ();
179 exit (EXIT_FAILURE);
180 }
181 args_info->output_given = 1;
182 args_info->output_arg = gengetopt_strdup (optarg);
183 break;
184
185 case 'n': /* print every n frame. */
186 if (args_info->frame_given)
187 {
188 fprintf (stderr, "%s: `--frame' (`-n') option given more than once\n", CMDLINE_PARSER_PACKAGE);
189 clear_args ();
190 exit (EXIT_FAILURE);
191 }
192 args_info->frame_given = 1;
193 args_info->frame_arg = strtol (optarg,&stop_char,0);
194 break;
195
196 case 'w': /* skip the the waters. */
197 if (args_info->water_given)
198 {
199 fprintf (stderr, "%s: `--water' (`-w') option given more than once\n", CMDLINE_PARSER_PACKAGE);
200 clear_args ();
201 exit (EXIT_FAILURE);
202 }
203 args_info->water_given = 1;
204 args_info->water_flag = !(args_info->water_flag);
205 break;
206
207 case 'm': /* map to the periodic box. */
208 if (args_info->periodicBox_given)
209 {
210 fprintf (stderr, "%s: `--periodicBox' (`-m') option given more than once\n", CMDLINE_PARSER_PACKAGE);
211 clear_args ();
212 exit (EXIT_FAILURE);
213 }
214 args_info->periodicBox_given = 1;
215 args_info->periodicBox_flag = !(args_info->periodicBox_flag);
216 break;
217
218 case 'z': /* replace the atom types of zconstraint molecules. */
219 if (args_info->zconstraint_given)
220 {
221 fprintf (stderr, "%s: `--zconstraint' (`-z') option given more than once\n", CMDLINE_PARSER_PACKAGE);
222 clear_args ();
223 exit (EXIT_FAILURE);
224 }
225 args_info->zconstraint_given = 1;
226 args_info->zconstraint_flag = !(args_info->zconstraint_flag);
227 break;
228
229 case 'r': /* add a pseudo COM atom to rigidbody. */
230 if (args_info->rigidbody_given)
231 {
232 fprintf (stderr, "%s: `--rigidbody' (`-r') option given more than once\n", CMDLINE_PARSER_PACKAGE);
233 clear_args ();
234 exit (EXIT_FAILURE);
235 }
236 args_info->rigidbody_given = 1;
237 args_info->rigidbody_flag = !(args_info->rigidbody_flag);
238 break;
239
240 case 't': /* replace the atom type of water model. */
241 if (args_info->watertype_given)
242 {
243 fprintf (stderr, "%s: `--watertype' (`-t') option given more than once\n", CMDLINE_PARSER_PACKAGE);
244 clear_args ();
245 exit (EXIT_FAILURE);
246 }
247 args_info->watertype_given = 1;
248 args_info->watertype_flag = !(args_info->watertype_flag);
249 break;
250
251 case 'b': /* using base atom type. */
252 if (args_info->basetype_given)
253 {
254 fprintf (stderr, "%s: `--basetype' (`-b') option given more than once\n", CMDLINE_PARSER_PACKAGE);
255 clear_args ();
256 exit (EXIT_FAILURE);
257 }
258 args_info->basetype_given = 1;
259 args_info->basetype_flag = !(args_info->basetype_flag);
260 break;
261
262 case 's': /* general selection syntax. */
263 if (args_info->selection_given)
264 {
265 fprintf (stderr, "%s: `--selection' (`-s') option given more than once\n", CMDLINE_PARSER_PACKAGE);
266 clear_args ();
267 exit (EXIT_FAILURE);
268 }
269 args_info->selection_given = 1;
270 args_info->selection_arg = gengetopt_strdup (optarg);
271 break;
272
273
274 case 0: /* Long option with no short option */
275 /* select origin. */
276 if (strcmp (long_options[option_index].name, "originsele") == 0)
277 {
278 if (args_info->originsele_given)
279 {
280 fprintf (stderr, "%s: `--originsele' option given more than once\n", CMDLINE_PARSER_PACKAGE);
281 clear_args ();
282 exit (EXIT_FAILURE);
283 }
284 args_info->originsele_given = 1;
285 args_info->originsele_arg = gengetopt_strdup (optarg);
286 break;
287 }
288
289 /* select reference. */
290 else if (strcmp (long_options[option_index].name, "refsele") == 0)
291 {
292 if (args_info->refsele_given)
293 {
294 fprintf (stderr, "%s: `--refsele' option given more than once\n", CMDLINE_PARSER_PACKAGE);
295 clear_args ();
296 exit (EXIT_FAILURE);
297 }
298 args_info->refsele_given = 1;
299 args_info->refsele_arg = gengetopt_strdup (optarg);
300 break;
301 }
302
303 /* The number of images to repeat in the x direction. */
304 else if (strcmp (long_options[option_index].name, "repeatX") == 0)
305 {
306 if (args_info->repeatX_given)
307 {
308 fprintf (stderr, "%s: `--repeatX' option given more than once\n", CMDLINE_PARSER_PACKAGE);
309 clear_args ();
310 exit (EXIT_FAILURE);
311 }
312 args_info->repeatX_given = 1;
313 args_info->repeatX_arg = strtol (optarg,&stop_char,0);
314 break;
315 }
316
317 /* The number of images to repeat in the y direction. */
318 else if (strcmp (long_options[option_index].name, "repeatY") == 0)
319 {
320 if (args_info->repeatY_given)
321 {
322 fprintf (stderr, "%s: `--repeatY' option given more than once\n", CMDLINE_PARSER_PACKAGE);
323 clear_args ();
324 exit (EXIT_FAILURE);
325 }
326 args_info->repeatY_given = 1;
327 args_info->repeatY_arg = strtol (optarg,&stop_char,0);
328 break;
329 }
330
331 /* The number of images to repeat in the z direction. */
332 else if (strcmp (long_options[option_index].name, "repeatZ") == 0)
333 {
334 if (args_info->repeatZ_given)
335 {
336 fprintf (stderr, "%s: `--repeatZ' option given more than once\n", CMDLINE_PARSER_PACKAGE);
337 clear_args ();
338 exit (EXIT_FAILURE);
339 }
340 args_info->repeatZ_given = 1;
341 args_info->repeatZ_arg = strtol (optarg,&stop_char,0);
342 break;
343 }
344
345
346 case '?': /* Invalid option. */
347 /* `getopt_long' already printed an error message. */
348 exit (EXIT_FAILURE);
349
350 default: /* bug: option not considered. */
351 fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c);
352 abort ();
353 } /* switch */
354 } /* while */
355
356
357 if (! args_info->input_given)
358 {
359 fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE);
360 missing_required_options = 1;
361 }
362 if ( missing_required_options )
363 exit (EXIT_FAILURE);
364
365 return 0;
366 }