ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/tcProps/tcProps.c
(Generate patch)

Comparing trunk/tcProps/tcProps.c (file contents):
Revision 1052 by mmeineke, Fri Feb 13 22:13:06 2004 UTC vs.
Revision 1080 by mmeineke, Wed Mar 3 15:16:15 2004 UTC

# Line 2 | Line 2
2  
3   #include <stdio.h>
4   #include <stdlib.h>
5 + #include <string.h>
6  
7  
8   #include "params.h"
9   #include "tcProps.h"
10   #include "readWrite.h"
11 + #include "scdCorr.h"
12 + #include "directorHead.h"
13 + #include "directorWhole.h"
14 + #include "rmsd.h"
15 + #include "gofz.h"
16  
17  
18 + #define VERSION_MAJOR 0
19 + #define VERSION_MINOR 1
20 +
21 + char *programName; /*the name of the program */
22 + void usage(void);
23 +
24   int main( int argC, char *argV[] ){
25  
26    // list of 'a priori' constants
27  
28 <  const int nLipAtoms = 19;
29 <  const int nBonds = 18;
30 <  const int nLipids = NLIPIDS;
31 <  const int nSSD = NSSD;
32 <  const int nAtoms = nLipAtoms * nLipids + nSSD;
28 >  const int nLipAtoms = NL_ATOMS;
29 >  const int nBonds    = NBONDS;
30 >  const int nLipids   = NLIPIDS;
31 >  const int nSSD      = NSSD;
32 >  const int nAtoms    = nLipAtoms * nLipids + nSSD;
33  
34    // different needed variables
35    
36    struct atomCoord atoms[nAtoms];
37    int i,j,k;
38 <  char* inName;
39 <  int nFrames;
38 >  
39 >  char* outPrefix; // the output prefix
40 >  char currentFlag; // used in parsing the flags
41 >  int done = 0; // multipurpose boolean
42 >  int havePrefix; // boolean for the output prefix  
43 >  int haveMaxLength;
44 >  char* conversionCheck;
45 >  int conversionError;
46 >  int optionError;
47 >  char* pair1;
48 >  char* pair2;
49 >  int scdCorr;
50 >  double startTime;
51 >  double maxLength;
52 >  int directorHead, directorWhole, doRMSD, doGofz;
53 >  enum atomNames rmsdType;
54  
55    // system initialization
56    
57    isScanned = 0;
58 +  fileOpen = 0;
59 +  nFrames = 0;
60 +  frameTimes = NULL;
61  
62 +  outPrefix = NULL;
63 +  inName = NULL;
64 +  
65 +  haveMaxLength = 0;
66 +  conversionError = 0;
67 +  optionError = 0;
68 +  havePrefix = 0;
69 +  scdCorr = 0;
70 +  startTime = 0.0;
71 +  directorHead = 0;
72 +  directorWhole = 0;
73 +  doRMSD = 0;
74 +  doGofz = 0;
75 +  
76  
77 +  // parse the command line
78 +
79 +  programName = argV[0]; /*save the program name in case we need it*/
80 +
81 +  for( i = 1; i < argC; i++){
82 +    
83 +    if(argV[i][0] =='-'){
84 +
85 +      // parse the option
86 +      
87 +      if(argV[i][1] == '-' ){
88 +
89 +        // parse long word options
90 +        
91 +        if( !strcmp( argV[i], "--rmsd" ) ){
92 +
93 +          doRMSD = 1;
94 +          i++;
95 +          if( i>=argC ){
96 +            fprintf( stderr,
97 +                     "\n"
98 +                     "not enough arguments for --rmsd\n");
99 +            usage();
100 +            exit(0);
101 +          }      
102 +          pair1 = argV[i];
103 +
104 +          if( !strcmp(pair1, "HEAD") )    rmsdType = HEAD;
105 +          else if( !strcmp(pair1, "CH") ) rmsdType = CH;
106 +          else if( !strcmp(pair1, "CH2") )rmsdType = CH2;
107 +          else if( !strcmp(pair1, "CH3") )rmsdType = CH3;
108 +          else if( !strcmp(pair1, "SSD") )rmsdType = SSD;
109 +          else if( !strcmp(pair1, "COM") )rmsdType = COM;
110 +          else{
111 +            fprintf( stderr,
112 +                     "Unrecognized rmsd atom type \"%s\"\n",
113 +                     pair1 );
114 +            exit(0);
115 +          }
116 +
117 +        }
118 +
119 +        else if( !strcmp( argV[i], "--gofrTheta" ) ){
120 +          
121 +          i++;
122 +          if( i>=argC ){
123 +            fprintf( stderr,
124 +                     "\n"
125 +                     "not enough arguments for --gofrTheta\n");
126 +            usage();
127 +            exit(0);
128 +          }      
129 +          pair1 = argV[i];
130 +
131 +          i++;
132 +          if( i>=argC ){
133 +            fprintf( stderr,
134 +                     "\n"
135 +                     "not enough arguments for --gofrTheta\n");
136 +            usage();
137 +            exit(0);
138 +          }      
139 +          pair2 = argV[i];
140 +
141 +        }
142 +
143 +        else if( !strcmp( argV[i], "--gofrOmega" ) ){
144 +          
145 +          i++;
146 +          if( i>=argC ){
147 +            fprintf( stderr,
148 +                     "\n"
149 +                     "not enough arguments for --gofrOmega\n");
150 +            usage();
151 +            exit(0);
152 +          }      
153 +          pair1 = argV[i];
154 +
155 +          i++;
156 +          if( i>=argC ){
157 +            fprintf( stderr,
158 +                     "\n"
159 +                     "not enough arguments for --gofrOmega\n");
160 +            usage();
161 +            exit(0);
162 +          }      
163 +          pair2 = argV[i];
164 +
165 +        }
166 +
167 +        else if( !strcmp( argV[i], "--version") ){
168 +          
169 +          printf("\n"
170 +                 "tcProps version %d.%d\n"
171 +                 "\n",
172 +                 VERSION_MAJOR, VERSION_MINOR );
173 +          exit(0);
174 +          
175 +        }
176 +
177 +        else if( !strcmp( argV[i], "--help") ){
178 +          
179 +          usage();
180 +          exit(0);
181 +        }
182 +        
183 +        // anything else is an error
184 +
185 +        else{
186 +          fprintf( stderr,
187 +                   "Invalid option \"%s\"\n", argV[i] );
188 +          usage();
189 +          exit(0);
190 +        }
191 +      }
192 +      
193 +      else{
194 +        
195 +        // parse single character options
196 +        
197 +        done =0;
198 +        j = 1;
199 +        currentFlag = argV[i][j];
200 +        while( (currentFlag != '\0') && (!done) ){
201 +          
202 +          switch(currentFlag){
203 +
204 +          case 'o':
205 +            // -o <prefix> => the output prefix.
206 +
207 +            j++;
208 +            currentFlag = argV[i][j];
209 +              
210 +            if( currentFlag != '\0' ) optionError = 1;
211 +            
212 +            if( optionError ){
213 +              fprintf( stderr,
214 +                       "\n"
215 +                       "The -o flag should end an option sequence.\n"
216 +                       "   example: -r <outname> *NOT* -or <outname>\n" );
217 +              usage();
218 +              exit(0);
219 +            }
220 +              
221 +            i++;
222 +            if( i>=argC ){
223 +              fprintf( stderr,
224 +                       "\n"
225 +                       "not enough arguments for -o\n");
226 +              usage();
227 +              exit(0);
228 +            }    
229 +            
230 +            outPrefix = argV[i];
231 +            if( outPrefix[0] == '-' ) optionError = 1;
232 +                
233 +            if( optionError ){
234 +              fprintf( stderr,
235 +                       "\n"
236 +                       "\"%s\" is not a valid out prefix/name.\n"
237 +                       "Out prefix/name should not begin with a dash.\n",
238 +                       outPrefix );
239 +              usage();
240 +              exit(0);
241 +            }
242 +            
243 +            havePrefix = 1;
244 +            done = 1;
245 +            break;
246 +
247 +          case 'l':
248 +            // -l <double>    set <double> to the maxLength
249 +
250 +            haveMaxLength = 1;
251 +            j++;
252 +            currentFlag = argV[i][j];
253 +              
254 +            if( currentFlag != '\0' ) optionError = 1;
255 +            
256 +            if( optionError ){
257 +              fprintf( stderr,
258 +                       "\n"
259 +                       "The -l flag should end an option sequence.\n"
260 +                       "   example: -sl <double> *NOT* -ls <double>\n" );
261 +              usage();
262 +              exit(0);
263 +            }
264 +
265 +            i++;
266 +            if( i>=argC ){
267 +              fprintf( stderr,
268 +                       "\n"
269 +                       "not enough arguments for -l\n");
270 +              usage();
271 +              exit(0);
272 +            }    
273 +
274 +            maxLength = atof( argV[i] );
275 +            
276 +            done = 1;
277 +
278 +            break;
279 +
280 +          case 't':
281 +            // -t <double>    set <double> to the startTime
282 +
283 +            j++;
284 +            currentFlag = argV[i][j];
285 +              
286 +            if( currentFlag != '\0' ) optionError = 1;
287 +            
288 +            if( optionError ){
289 +              fprintf( stderr,
290 +                       "\n"
291 +                       "The -t flag should end an option sequence.\n"
292 +                       "   example: -st <double> *NOT* -ts <double>\n" );
293 +              usage();
294 +              exit(0);
295 +            }
296 +
297 +            i++;
298 +            if( i>=argC ){
299 +              fprintf( stderr,
300 +                       "\n"
301 +                       "not enough arguments for -t\n");
302 +              usage();
303 +              exit(0);
304 +            }    
305 +
306 +            startTime = atof( argV[i] );
307 +            done = 1;
308 +            break;
309 +
310 +          case 's':
311 +            // -s turn on Scd corr
312 +
313 +            scdCorr = 1;
314 +            break;
315 +
316 +          case 'h':
317 +            // -h turn on director head
318 +
319 +            directorHead = 1;
320 +            break;
321 +
322 +          case 'w':
323 +            // -w turn on director head
324 +
325 +            directorWhole = 1;
326 +            break;
327 +
328 +          case 'g':
329 +            // -g turn on gofZ
330 +
331 +            doGofz = 1;
332 +            break;
333 +
334 +
335 +          default:
336 +
337 +            fprintf( stderr,
338 +                    "\n"
339 +                    "Bad option \"-%c\"\n", currentFlag);
340 +            usage();
341 +            exit(0);
342 +          }
343 +          j++;
344 +          currentFlag = argV[i][j];
345 +        }
346 +      }
347 +    }
348 +
349 +    else{
350 +      
351 +      if( inName != NULL ){
352 +        fprintf( stderr,
353 +                 "Error at \"%s\", program does not currently support\n"
354 +                 "more than one input dump file.\n"
355 +                 "\n",
356 +                 argV[i]);
357 +        usage();
358 +        exit(0);
359 +      }
360 +      
361 +      inName = argV[i];
362 +      
363 +    }
364 +  }  
365 +  
366 +  if( inName == NULL ){
367 +    fprintf( stderr,
368 +             "Error, dump file is needed to run.\n" );
369 +    usage();
370 +    exit(0);
371 +  }
372 +
373 +  if( outPrefix == NULL )
374 +    outPrefix = inName;
375 +
376 +
377    // initialize the arrays
378  
379    for(i=0;i<nLipids;i++){
380  
381      atoms[nLipAtoms*i+0].type = HEAD;
382 +    atoms[nLipAtoms*i+0].mass = 72;
383      atoms[nLipAtoms*i+0].u[0] = 0.0;
384      atoms[nLipAtoms*i+0].u[1] = 0.0;
385      atoms[nLipAtoms*i+0].u[2] = 1.0;
386      
387 +    
388  
389      atoms[nLipAtoms*i+1].type = CH2;
390 +    atoms[nLipAtoms*i+1].mass = 14.03;
391  
392      atoms[nLipAtoms*i+2].type = CH;
393 +    atoms[nLipAtoms*i+2].mass = 13.02;
394  
395      atoms[nLipAtoms*i+3].type = CH2;
396 +    atoms[nLipAtoms*i+3].mass = 14.03;
397  
398      atoms[nLipAtoms*i+4].type = CH2;
399 +    atoms[nLipAtoms*i+4].mass = 14.03;
400  
401      atoms[nLipAtoms*i+5].type = CH2;
402 +    atoms[nLipAtoms*i+5].mass = 14.03;
403  
404      atoms[nLipAtoms*i+6].type = CH2;
405 +    atoms[nLipAtoms*i+6].mass = 14.03;
406  
407      atoms[nLipAtoms*i+7].type = CH2;
408 +    atoms[nLipAtoms*i+7].mass = 14.03;
409  
410      atoms[nLipAtoms*i+8].type = CH2;
411 +    atoms[nLipAtoms*i+8].mass = 14.03;
412  
413      atoms[nLipAtoms*i+9].type = CH2;
414 +    atoms[nLipAtoms*i+9].mass = 14.03;
415  
416      atoms[nLipAtoms*i+10].type = CH3;
417 +    atoms[nLipAtoms*i+10].mass = 15.04;
418  
419      atoms[nLipAtoms*i+11].type = CH2;
420 +    atoms[nLipAtoms*i+11].mass = 14.03;
421  
422      atoms[nLipAtoms*i+12].type = CH2;
423 +    atoms[nLipAtoms*i+12].mass = 14.03;
424  
425 <    atoms[nLipAtoms*i+13].type = CH2;
425 >    atoms[nLipAtoms*i+13].type = CH2;    
426 >    atoms[nLipAtoms*i+13].mass = 14.03;
427  
428      atoms[nLipAtoms*i+14].type = CH2;
429 +    atoms[nLipAtoms*i+14].mass = 14.03;
430    
431      atoms[nLipAtoms*i+15].type = CH2;
432 +    atoms[nLipAtoms*i+15].mass = 14.03;
433    
434      atoms[nLipAtoms*i+16].type = CH2;
435 +    atoms[nLipAtoms*i+16].mass = 14.03;
436    
437      atoms[nLipAtoms*i+17].type = CH2;
438 +    atoms[nLipAtoms*i+17].mass = 14.03;
439    
440      atoms[nLipAtoms*i+18].type = CH3;
441 +    atoms[nLipAtoms*i+18].mass = 15.04;
442    }
443    
444    for(i=(nLipAtoms*nLipids);i<nAtoms;i++){
445      atoms[i].type = SSD;
446 +    atoms[i].mass = 18.03;
447      atoms[i].u[0] = 0.0;
448      atoms[i].u[1] = 0.0;
449      atoms[i].u[2] = 1.0;
# Line 87 | Line 451 | int main( int argC, char *argV[] ){
451  
452    // read and set the frames
453    
454 <  nFrames = setFrames( inName );
454 >  openFile();
455 >
456 >  fprintf( stdout,
457 >           "\n"
458 >           "Counting the number of frames in \"%s\"...",
459 >           inName );
460 >  fflush(stdout);
461 >
462 >  setFrames();
463    
464 +  fprintf( stdout,
465 +           "done.\n"
466 +           "nFrames = %d.\n",
467 +           nFrames );
468 +  fflush(stdout);
469 +
470 +  if(scdCorr){
471 +
472 +    fprintf ( stdout,
473 +              "Calculating the Scd correlation\n" );
474 +    fflush( stdout );
475 +    
476 +    calcScdCorr( startTime, atoms, outPrefix );
477 +  }
478 +
479 +  if(directorHead){
480 +
481 +    fprintf ( stdout,
482 +              "Calculating the Head director\n" );
483 +    fflush( stdout );
484 +    
485 +    calcDirHeadCorr( startTime, atoms, outPrefix );
486 +  }
487 +
488 +  if(directorWhole){
489 +
490 +    fprintf ( stdout,
491 +              "Calculating the bilayer director\n" );
492 +    fflush( stdout );
493 +    
494 +    calcDirWholeCorr( startTime, atoms, outPrefix );
495 +  }
496 +
497 +  if(doRMSD){
498 +
499 +    fprintf ( stdout,
500 +              "Calculating the RMSD\n" );
501 +    fflush( stdout );
502 +    
503 +    rmsd( rmsdType, startTime, outPrefix );
504 +  }
505 +
506 +  if(doGofz){
507 +
508 +    fprintf ( stdout,
509 +              "Calculating the gofZ\n" );
510 +    fflush( stdout );
511 +    
512 +    calcGofz( startTime, atoms, outPrefix );
513 +  }
514 +  
515 +
516 +  closeFile();
517 +
518 + }
519 +
520 +
521 + /***************************************************************************
522 + * prints out the usage for the command line arguments, then exits.
523 + ***************************************************************************/
524 +
525 + void usage(){
526 +  (void)fprintf(stdout,
527 +                "\n"
528 +                "The proper usage is: %s [options] <input_file>\n"
529 +                "\n"
530 +                "Options:\n"
531 +                "\n"
532 +                "   short:\n"
533 +                "   ------\n"
534 +                "   -o <name>       The output prefix\n"
535 +                "   -t <time>       Set the start time for correlations\n"
536 +                "   -l <maxLength>  set the maximum value of r\n"
537 +                "                     *Defaults to 1/2 smallest length of first frame.\n"
538 +                "   -s              Calculate the Scd chain correlation.\n"
539 +                "   -h              Calculate the directors for the head groups\n"
540 +                "   -w              Calculate the director from the bilayers\n"
541 +                "   -g              Calculate the gofz profile\n"
542 +                "\n"
543 +                "   long:\n"
544 +                "   -----\n"
545 +                "   --rmsd <atom1>                 rmsd for atom1\n"
546 +                "   --gofrTheta <atom1> <atom2>    g(r, theta) for atom1 and atom2\n"
547 +                "   --gofrOmega <atom1> <atom2>    g(r, omega) for atom1 and atom2\n"
548 +                "   --version                      displays the version number\n"
549 +                "   --help                         displays this help message.\n"
550 +                
551 +                "\n"
552 +                "\n",
553 +                programName);
554 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines