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

Comparing trunk/tcProps/readWrite.c (file contents):
Revision 1058 by mmeineke, Wed Feb 18 21:20:51 2004 UTC vs.
Revision 1080 by mmeineke, Wed Mar 3 15:16:15 2004 UTC

# Line 17 | Line 17 | FILE* inFile;
17   int nFrames;
18   double *frameTimes;
19   FILE* inFile;
20 + char* inName;
21  
21
22   struct linkedPos{
23    
24    fpos_t *myPos;
# Line 39 | Line 39 | void openFile( char* inName ){
39   void setU( double q[4], double u[3] );
40   void normalizeQ( double q[4] );
41  
42 < void openFile( char* inName ){
42 > void openFile( void ){
43    
44 <  inFile = fopen(inName);
44 >  inFile = fopen(inName, "r");
45    if(inFile ==NULL){
46      fprintf(stderr,
47              "Error opening file \"%s\"\n",
# Line 59 | Line 59 | int setFrames( void ){
59    fileOpen = 0;
60   }
61  
62 < int setFrames( void ){
62 > void setFrames( void ){
63  
64    int i,j,k;
65    struct linkedPos* headPos;
# Line 81 | Line 81 | int setFrames( void ){
81    nFrames = 0;
82    headPos = (struct linkedPos*)malloc(sizeof(struct linkedPos));
83    currPos = headPos;
84 +
85 +  currPT = (fpos_t *)malloc(sizeof(fpos_t));
86 +  fgetpos(inFile, currPT);
87 +  
88 +  fgets( readBuffer, sizeof( readBuffer ), inFile );
89 +  lineNum++;
90 +  if( feof( inFile ) ){
91 +    fprintf( stderr,
92 +             "File \"%s\" ended unexpectedly at line %d\n",
93 +             inName,
94 +             lineNum );
95 +    exit(0);
96 +  }
97 +
98    while( !feof( inFile ) ){
99  
86    currPT = (fpos_t *)malloc(sizeof(fpos_t));
87    fgetpos(inFile, currPT);
88    
89    fgets( readBuffer, sizeof( readBuffer ), inFile );
90    lineNum++;
91    if( feof( inFile ) ){
92      fprintf( stderr,
93               "File \"%s\" ended unexpectedly at line %d\n",
94               inName,
95               lineNum );
96      exit(0);
97    }
98    
100      currPos->next = (struct linkedPos*)malloc(sizeof(struct linkedPos));
101      currPos = currPos->next;
102      currPos->myPos = currPT;      
# Line 229 | Line 230 | int setFrames( void ){
230          exit(0);
231        }
232      }
233 +
234 +    currPT = (fpos_t *)malloc(sizeof(fpos_t));
235 +    fgetpos(inFile, currPT);
236 +    
237 +    fgets( readBuffer, sizeof( readBuffer ), inFile );
238 +    lineNum++;
239    }
240    
241    // allocate the static position array
# Line 303 | Line 310 | void readFrame(int theFrame, struct atomCoord* atoms,
310    if( !fileOpen ){
311      
312      fprintf( stderr,
313 <             "File is closed, cannot read frame %d.\n"
313 >             "File is closed, cannot read frame %d.\n",
314               theFrame );
315      exit(0);
316    }
# Line 311 | Line 318 | void readFrame(int theFrame, struct atomCoord* atoms,
318    // access the frame
319    
320    framePos = posArray[theFrame].myPos;
321 <  fsetPos( inFile, framePos );
321 >  fsetpos( inFile, framePos );
322  
323    for(j=0;j<3;j++){
324      for(k=0;k<3;k++){
# Line 370 | Line 377 | void parseDumpLine( char readLine[BUFFER_SIZE], int i,
377  
378   void parseDumpLine( char readLine[BUFFER_SIZE], int i,
379                      struct atomCoord* atoms ){
380 +  
381 +  const int nLipAtoms = NL_ATOMS;
382 +  const int nBonds    = NBONDS;
383 +  const int nLipids   = NLIPIDS;
384 +  const int nSSD      = NSSD;
385 +  const int nAtoms    = nLipAtoms * nLipids + nSSD;
386 +
387    char* foo;
388    double q[4];
389  
# Line 384 | Line 398 | void parseDumpLine( char readLine[BUFFER_SIZE], int i,
398    case HEAD:
399      if( strcmp(foo, "HEAD") ){
400        fprintf( stderr,
401 <               "Atom %s does not match master array type \"HEAD\".\n"
401 >               "Atom %s does not match master array type \"HEAD\".\n",
402                 foo );
403        exit(0);
404      }
# Line 393 | Line 407 | void parseDumpLine( char readLine[BUFFER_SIZE], int i,
407    case CH:
408      if( strcmp(foo, "CH") ){
409        fprintf( stderr,
410 <               "Atom %s does not match master array type \"CH\".\n"
410 >               "Atom %s does not match master array type \"CH\".\n",
411                 foo );
412        exit(0);
413      }
# Line 402 | Line 416 | void parseDumpLine( char readLine[BUFFER_SIZE], int i,
416    case CH2:
417      if( strcmp(foo, "CH2") ){
418        fprintf( stderr,
419 <               "Atom %s does not match master array type \"CH2\".\n"
419 >               "Atom %s does not match master array type \"CH2\".\n",
420                 foo );
421        exit(0);
422      }
# Line 411 | Line 425 | void parseDumpLine( char readLine[BUFFER_SIZE], int i,
425    case CH3:
426      if( strcmp(foo, "CH3") ){
427        fprintf( stderr,
428 <               "Atom %s does not match master array type \"CH3\".\n"
428 >               "Atom %s does not match master array type \"CH3\".\n",
429                 foo );
430        exit(0);
431      }
# Line 420 | Line 434 | void parseDumpLine( char readLine[BUFFER_SIZE], int i,
434    case SSD:
435      if( strcmp(foo, "SSD") ){
436        fprintf( stderr,
437 <               "Atom %s does not match master array type \"SSD\".\n"
437 >               "Atom %s does not match master array type \"SSD\".\n",
438                 foo );
439        exit(0);
440      }
# Line 505 | Line 519 | void parseDumpLine( char readLine[BUFFER_SIZE], int i,
519        
520      foo = strtok(NULL, " ,;\t");
521      if(foo == NULL){
522 <      sprintf(painCave.errMsg,
523 <              "error in reading quaternion 0 from %s\n"
524 <              "natoms  = %d, i = %d\n",
525 <              inName, nAtoms, i );
522 >      fprintf( stderr,
523 >               "error in reading quaternion 0 from %s\n"
524 >               "natoms  = %d, i = %d\n",
525 >               inName, nAtoms, i );
526        exit(0);
527      }
528      q[0] = atof( foo );
# Line 555 | Line 569 | void setU( double the_q[4], double u[3] ){
569    double q0Sqr, q1Sqr, q2Sqr, q3Sqr;
570    double A[3][3];
571    double rb[3];
572 +  int i,j,k;
573  
574    // initialize the axis
575  
# Line 604 | Line 619 | void normalizeQ( double q[4] ){
619    for(i=0;i<4;i++)
620      q[i] /= qSqr;
621   }
622 +
623 + double scanSmallestZ(int startFrame){
624 +  double smallest;
625 +  int i;
626 +  
627 +  smallest = posArray[startFrame].Hmat[2][2];
628 +  for(i=startFrame;i<nFrames;i++)
629 +    smallest =
630 +      (smallest<posArray[i].Hmat[2][2])? smallest : posArray[i].Hmat[2][2];
631 +
632 +  return smallest;
633 + }
634 +  
635        

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines