ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/dump2Xyz/Dump2XYZCmd.c
Revision: 2749
Committed: Wed May 10 01:44:48 2006 UTC (18 years, 2 months ago) by tim
Content type: text/plain
File size: 13848 byte(s)
Log Message:
adding a gay-berne switch to Dump2XYZ

File Contents

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