ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/dump2Xyz/Dump2XYZCmd.c
Revision: 2053
Committed: Fri Feb 18 23:07:32 2005 UTC (19 years, 5 months ago) by tim
Content type: text/plain
File size: 15086 byte(s)
Log Message:
adding LipidTransVisitor, GofXyz is working now

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