ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/dump2Xyz/Dump2XYZCmd.c
Revision: 1986
Committed: Mon Feb 7 21:11:22 2005 UTC (19 years, 5 months ago) by tim
Content type: text/plain
File size: 13952 byte(s)
Log Message:
update help info for 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 1986 /home/maul/gezelter/tim/bin/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     "Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE);
37     printf("\n");
38 tim 1975 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(" -d, --dipole print the dipole moments (default=off)\n");
44     printf(" -w, --water skip the the waters (default=off)\n");
45     printf(" -m, --periodicBox map to the periodic box (default=off)\n");
46     printf(" -z, --zconstraint replace the atom types of zconstraint \n molecules (default=off)\n");
47     printf(" -r, --rigidbody add a pseudo COM atom to rigidbody \n (default=off)\n");
48     printf(" -t, --watertype replace the atom type of water model \n (default=on)\n");
49     printf(" -g, --ignore=atomtype ignore the atom types\n");
50 tim 1986 printf(" -s, --selection=selection script selection syntax:\n"
51     " select DMPC -- select DMPC molecule\n"
52     " select DMPC.* -- select all atoms and all rigidbodies belong to DMPC molecule(same as above)\n"
53     " select not DMPC -- select all atoms and all rigidbodies do not belong to DMPC molecule\n"
54     " select C* and 4 to 7 -- select stuntdoubles which match C* and which index is between [4, 7)\n"
55     " select 5 -- select stuntdobule whose global index is 5\n"
56     " select within (5.0, HDP or PO4) -- select stuntdoubles which is within 5 A to HDP or PO4\n"
57     " select DMPC.DMPC_RB_*.* --select atoms belong to rigid body inside DMPC molecule \n");
58 tim 1975 printf(" --repeatX=INT The number of images to repeat in the x \n direction (default=`0')\n");
59     printf(" --repeatY=INT The number of images to repeat in the y \n direction (default=`0')\n");
60     printf(" --repeatZ=INT The number of images to repeat in the z \n direction (default=`0')\n");
61 tim 1501 }
62    
63    
64     static char *gengetopt_strdup (const char *s);
65    
66     /* gengetopt_strdup() */
67     /* strdup.c replacement of strdup, which is not standard */
68     char *
69     gengetopt_strdup (const char *s)
70     {
71     char *result = (char*)malloc(strlen(s) + 1);
72     if (result == (char*)0)
73     return (char*)0;
74     strcpy(result, s);
75     return result;
76     }
77    
78     int
79     cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
80     {
81     int c; /* Character of the parsed option. */
82     int i; /* Counter */
83     struct ignore_list
84     {
85     char * ignore_arg;
86     struct ignore_list * next;
87     };
88     struct ignore_list * ignore_list = NULL,* ignore_new = NULL;
89    
90     int missing_required_options = 0;
91    
92     args_info->help_given = 0 ;
93     args_info->version_given = 0 ;
94     args_info->input_given = 0 ;
95     args_info->output_given = 0 ;
96     args_info->frame_given = 0 ;
97     args_info->dipole_given = 0 ;
98     args_info->water_given = 0 ;
99     args_info->periodicBox_given = 0 ;
100     args_info->zconstraint_given = 0 ;
101     args_info->rigidbody_given = 0 ;
102     args_info->watertype_given = 0 ;
103     args_info->ignore_given = 0 ;
104 tim 1975 args_info->selection_given = 0 ;
105 tim 1501 args_info->repeatX_given = 0 ;
106     args_info->repeatY_given = 0 ;
107     args_info->repeatZ_given = 0 ;
108     #define clear_args() { \
109     args_info->input_arg = NULL; \
110     args_info->output_arg = NULL; \
111     args_info->frame_arg = 1 ;\
112     args_info->dipole_flag = 0;\
113     args_info->water_flag = 0;\
114     args_info->periodicBox_flag = 0;\
115     args_info->zconstraint_flag = 0;\
116     args_info->rigidbody_flag = 0;\
117     args_info->watertype_flag = 1;\
118     args_info->ignore_arg = NULL; \
119 tim 1975 args_info->selection_arg = NULL; \
120 tim 1501 args_info->repeatX_arg = 0 ;\
121     args_info->repeatY_arg = 0 ;\
122     args_info->repeatZ_arg = 0 ;\
123     }
124    
125     clear_args();
126    
127     optarg = 0;
128     optind = 1;
129     opterr = 1;
130     optopt = '?';
131    
132     while (1)
133     {
134     int option_index = 0;
135     char *stop_char;
136    
137     static struct option long_options[] = {
138     { "help", 0, NULL, 'h' },
139     { "version", 0, NULL, 'V' },
140     { "input", 1, NULL, 'i' },
141     { "output", 1, NULL, 'o' },
142     { "frame", 1, NULL, 'n' },
143     { "dipole", 0, NULL, 'd' },
144     { "water", 0, NULL, 'w' },
145     { "periodicBox", 0, NULL, 'm' },
146     { "zconstraint", 0, NULL, 'z' },
147     { "rigidbody", 0, NULL, 'r' },
148     { "watertype", 0, NULL, 't' },
149 tim 1975 { "ignore", 1, NULL, 'g' },
150     { "selection", 1, NULL, 's' },
151 tim 1501 { "repeatX", 1, NULL, 0 },
152     { "repeatY", 1, NULL, 0 },
153     { "repeatZ", 1, NULL, 0 },
154     { NULL, 0, NULL, 0 }
155     };
156    
157     stop_char = 0;
158 tim 1975 c = getopt_long (argc, argv, "hVi:o:n:dwmzrtg:s:", long_options, &option_index);
159 tim 1501
160     if (c == -1) break; /* Exit from `while (1)' loop. */
161    
162     switch (c)
163     {
164     case 'h': /* Print help and exit. */
165     clear_args ();
166     cmdline_parser_print_help ();
167     exit (EXIT_SUCCESS);
168    
169     case 'V': /* Print version and exit. */
170     clear_args ();
171     cmdline_parser_print_version ();
172     exit (EXIT_SUCCESS);
173    
174     case 'i': /* input dump file. */
175     if (args_info->input_given)
176     {
177     fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE);
178     clear_args ();
179     exit (EXIT_FAILURE);
180     }
181     args_info->input_given = 1;
182     args_info->input_arg = gengetopt_strdup (optarg);
183     break;
184    
185     case 'o': /* output file name. */
186     if (args_info->output_given)
187     {
188     fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE);
189     clear_args ();
190     exit (EXIT_FAILURE);
191     }
192     args_info->output_given = 1;
193     args_info->output_arg = gengetopt_strdup (optarg);
194     break;
195    
196     case 'n': /* print every n frame. */
197     if (args_info->frame_given)
198     {
199     fprintf (stderr, "%s: `--frame' (`-n') option given more than once\n", CMDLINE_PARSER_PACKAGE);
200     clear_args ();
201     exit (EXIT_FAILURE);
202     }
203     args_info->frame_given = 1;
204     args_info->frame_arg = strtol (optarg,&stop_char,0);
205     break;
206    
207     case 'd': /* print the dipole moments. */
208     if (args_info->dipole_given)
209     {
210     fprintf (stderr, "%s: `--dipole' (`-d') option given more than once\n", CMDLINE_PARSER_PACKAGE);
211     clear_args ();
212     exit (EXIT_FAILURE);
213     }
214     args_info->dipole_given = 1;
215     args_info->dipole_flag = !(args_info->dipole_flag);
216     break;
217    
218     case 'w': /* skip the the waters. */
219     if (args_info->water_given)
220     {
221     fprintf (stderr, "%s: `--water' (`-w') option given more than once\n", CMDLINE_PARSER_PACKAGE);
222     clear_args ();
223     exit (EXIT_FAILURE);
224     }
225     args_info->water_given = 1;
226     args_info->water_flag = !(args_info->water_flag);
227     break;
228    
229     case 'm': /* map to the periodic box. */
230     if (args_info->periodicBox_given)
231     {
232     fprintf (stderr, "%s: `--periodicBox' (`-m') option given more than once\n", CMDLINE_PARSER_PACKAGE);
233     clear_args ();
234     exit (EXIT_FAILURE);
235     }
236     args_info->periodicBox_given = 1;
237     args_info->periodicBox_flag = !(args_info->periodicBox_flag);
238     break;
239    
240     case 'z': /* replace the atom types of zconstraint molecules. */
241     if (args_info->zconstraint_given)
242     {
243     fprintf (stderr, "%s: `--zconstraint' (`-z') option given more than once\n", CMDLINE_PARSER_PACKAGE);
244     clear_args ();
245     exit (EXIT_FAILURE);
246     }
247     args_info->zconstraint_given = 1;
248     args_info->zconstraint_flag = !(args_info->zconstraint_flag);
249     break;
250    
251     case 'r': /* add a pseudo COM atom to rigidbody. */
252     if (args_info->rigidbody_given)
253     {
254     fprintf (stderr, "%s: `--rigidbody' (`-r') option given more than once\n", CMDLINE_PARSER_PACKAGE);
255     clear_args ();
256     exit (EXIT_FAILURE);
257     }
258     args_info->rigidbody_given = 1;
259     args_info->rigidbody_flag = !(args_info->rigidbody_flag);
260     break;
261    
262     case 't': /* replace the atom type of water model. */
263     if (args_info->watertype_given)
264     {
265     fprintf (stderr, "%s: `--watertype' (`-t') option given more than once\n", CMDLINE_PARSER_PACKAGE);
266     clear_args ();
267     exit (EXIT_FAILURE);
268     }
269     args_info->watertype_given = 1;
270     args_info->watertype_flag = !(args_info->watertype_flag);
271     break;
272    
273 tim 1975 case 'g': /* ignore the atom types. */
274 tim 1501 args_info->ignore_given++;
275     ignore_new = (struct ignore_list *) malloc (sizeof (struct ignore_list));
276     ignore_new->next = ignore_list;
277     ignore_list = ignore_new;
278     ignore_new->ignore_arg = gengetopt_strdup (optarg);
279     break;
280    
281 tim 1986 case 's': /* general selection syntax:\n
282     select DMPC -- select DMPC molecule\n \
283     select DMPC.* -- select all atoms and all rigidbodies belong to DMPC molecule\n \
284     select 5 -- select stuntdobule whose global index is 5\n \
285     select within (5.0, HDP or PO4) -- select stuntdoubles which is within 5 A to HDP or PO4\n \
286     select DMPC.DMPC_RB_*.* --select atoms belong to rigid body inside DMPC molecule . */
287 tim 1975 if (args_info->selection_given)
288     {
289     fprintf (stderr, "%s: `--selection' (`-s') option given more than once\n", CMDLINE_PARSER_PACKAGE);
290     clear_args ();
291     exit (EXIT_FAILURE);
292     }
293     args_info->selection_given = 1;
294     args_info->selection_arg = gengetopt_strdup (optarg);
295     break;
296 tim 1501
297 tim 1975
298 tim 1501 case 0: /* Long option with no short option */
299     /* The number of images to repeat in the x direction. */
300     if (strcmp (long_options[option_index].name, "repeatX") == 0)
301     {
302     if (args_info->repeatX_given)
303     {
304     fprintf (stderr, "%s: `--repeatX' option given more than once\n", CMDLINE_PARSER_PACKAGE);
305     clear_args ();
306     exit (EXIT_FAILURE);
307     }
308     args_info->repeatX_given = 1;
309     args_info->repeatX_arg = strtol (optarg,&stop_char,0);
310     break;
311     }
312    
313     /* The number of images to repeat in the y direction. */
314     else if (strcmp (long_options[option_index].name, "repeatY") == 0)
315     {
316     if (args_info->repeatY_given)
317     {
318     fprintf (stderr, "%s: `--repeatY' option given more than once\n", CMDLINE_PARSER_PACKAGE);
319     clear_args ();
320     exit (EXIT_FAILURE);
321     }
322     args_info->repeatY_given = 1;
323     args_info->repeatY_arg = strtol (optarg,&stop_char,0);
324     break;
325     }
326    
327     /* The number of images to repeat in the z direction. */
328     else if (strcmp (long_options[option_index].name, "repeatZ") == 0)
329     {
330     if (args_info->repeatZ_given)
331     {
332     fprintf (stderr, "%s: `--repeatZ' option given more than once\n", CMDLINE_PARSER_PACKAGE);
333     clear_args ();
334     exit (EXIT_FAILURE);
335     }
336     args_info->repeatZ_given = 1;
337     args_info->repeatZ_arg = strtol (optarg,&stop_char,0);
338     break;
339     }
340    
341    
342     case '?': /* Invalid option. */
343     /* `getopt_long' already printed an error message. */
344     exit (EXIT_FAILURE);
345    
346     default: /* bug: option not considered. */
347     fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c);
348     abort ();
349     } /* switch */
350     } /* while */
351    
352    
353     if (! args_info->input_given)
354     {
355     fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE);
356     missing_required_options = 1;
357     }
358     if ( missing_required_options )
359     exit (EXIT_FAILURE);
360    
361     if (args_info->ignore_given)
362     {
363     args_info->ignore_arg = (char * *) malloc (args_info->ignore_given * sizeof (char *));
364     for (i = 0; i < args_info->ignore_given; i++)
365     {
366     args_info->ignore_arg [i] = ignore_list->ignore_arg;
367     ignore_list = ignore_list->next;
368     }
369     }
370    
371     return 0;
372     }