ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/utils/sysBuild.cpp
Revision: 495
Committed: Mon Apr 14 19:52:00 2003 UTC (21 years, 5 months ago) by mmeineke
File size: 3182 byte(s)
Log Message:
 working on a system builder

File Contents

# User Rev Content
1 mmeineke 495 #include <cstdlib>
2     #include <cstdio>
3     #include <cstring>
4    
5    
6     #include "simError.h"
7    
8     // quick case asignments
9    
10     #define BILAYER 1
11    
12    
13     char* program_name;
14     void usage(void);
15    
16    
17     int main( int argc, char* argv[]){
18    
19     int i,j,k;
20     int sysType;
21     int done, have_prefix, isRandom;
22     char current_flag;
23     char* out_prefix;
24     char* in_name;
25    
26     // initialize simError
27     initSimError();
28    
29    
30     program_name = argv[0]; /*save the program name in case we need it*/
31     sysType = -1;
32     have_prefix = 0;
33     isRandom = 0;
34     in_name = NULL;
35     for( i = 1; i < argc; i++){
36    
37     if(argv[i][0] =='-'){
38    
39     // parse the option
40    
41     if(argv[i][1] == '-' ){
42    
43     // parse long word options
44    
45     if( !strcmp( argv[i], "--bilayer" ) ){
46     if( sysType > 0 ){
47     sprintf( painCave.errMsg,
48     "You cannot specify more than one system to build.\n" );
49     painCave.isFatal = 0;
50     simError();
51     usage();
52     }
53     sysType = BILAYER;
54     }
55    
56     else{
57     sprintf( painCave.errMsg,
58     "Invalid option \"%s\"\n", argv[i] );
59     painCave.isFatal = 0;
60     simError();
61     usage();
62     }
63     }
64    
65     else{
66    
67     // parse single character options
68    
69     done =0;
70     j = 1;
71     current_flag = argv[i][j];
72     while( (current_flag != '\0') && (!done) ){
73    
74     switch(current_flag){
75    
76     case 'o':
77     // -o <prefix> => the output prefix.
78    
79     i++;
80     out_prefix = argv[i];
81     have_prefix = 1;
82     done = 1;
83     break;
84    
85     case 'h':
86     // -h => give the usage
87    
88     usage();
89     break;
90    
91     case 'r':
92     // toggle random
93    
94     isRandom = 1;;
95     break;
96    
97     default:
98     sprintf(painCave.errMsg,
99     "Bad option \"-%s\"\n", current_flag);
100     painCave.isFatal = 0;
101     simError();
102     usage();
103     }
104     j++;
105     current_flag = argv[i][j];
106     }
107     }
108     }
109    
110     else{
111    
112     if( in_name != NULL ){
113     sprintf( painCave.errMsg,
114     "Error at \"%s\", program does not support\n"
115     "more than one input file.\n"
116     "\n",
117     argv[i]);
118     painCave.isFatal = 0;
119     simError();
120     usage();
121     }
122    
123     in_name = argv[i];
124     }
125     }
126    
127     if(in_name == NULL){
128     usage();
129     }
130    
131    
132    
133    
134    
135    
136    
137    
138     return 0;
139     }
140    
141    
142     /***************************************************************************
143     * prints out the usage for the command line arguments, then exits.
144     ***************************************************************************/
145    
146     void usage(){
147     (void)fprintf(stdout,
148     "The proper usage is: %s [options] <input bass>\n"
149     "\n"
150     "Options:\n"
151     "\n"
152     " short:\n"
153     " ------\n"
154     " -h Display this message\n"
155     " -o <prefix> The output prefix\n"
156     " -r toggle the random option\n"
157     "\n"
158     " long:\n"
159     " -----\n"
160     " --bilayer Tries to build a basic bilayer with the specified number\n"
161     " of lipids in the input bass file. The bilayer will be\n"
162     " surrounded by the number of solvent molecules given\n"
163     " in the bass file.\n"
164     " -note: combined with \"-r\" the simulation will start in\n"
165     " an FCC lattice with randomly assigned latice\n"
166     " for all atoms involved.\n"
167     "\n"
168     "\n",
169     program_name);
170     exit(8);
171     }