ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/InitializeFromFile.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/InitializeFromFile.cpp (file contents):
Revision 447 by mmeineke, Thu Apr 3 20:21:54 2003 UTC vs.
Revision 586 by mmeineke, Wed Jul 9 22:14:06 2003 UTC

# Line 69 | Line 69 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
69   }
70  
71  
72 < void InitializeFromFile :: read_xyz( SimInfo* the_entry_plug ){
72 > void InitializeFromFile :: read_xyz( SimInfo* the_simnfo ){
73  
74    int i, j, done, which_node, which_atom; // loop counter
75  
# Line 83 | Line 83 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
83    char *eof_test; // ptr to see when we reach the end of the file
84    char *parseErr;
85    int procIndex;
86 +  double boxMat[9];
87 +  
88  
89 <  entry_plug = the_entry_plug;
89 >  simnfo = the_simnfo;
90  
91  
92   #ifndef IS_MPI
# Line 99 | Line 101 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
101  
102    n_atoms = atoi( read_buffer );
103  
104 <  Atom **atoms = entry_plug->atoms;
104 >  Atom **atoms = simnfo->atoms;
105    DirectionalAtom* dAtom;
106  
107 <  if( n_atoms != entry_plug->n_atoms ){
107 >  if( n_atoms != simnfo->n_atoms ){
108      sprintf( painCave.errMsg,
109               "Initialize from File error. %s n_atoms, %d, "
110               "does not match the BASS file's n_atoms, %d.\n",
111 <             c_in_name, n_atoms, entry_plug->n_atoms );
111 >             c_in_name, n_atoms, simnfo->n_atoms );
112      painCave.isFatal = 1;
113      simError();
114    }
115    
116 <  //read and toss the comment line
116 >  //read the box mat from the comment line
117    
118    eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file);
119    if(eof_test == NULL){
# Line 121 | Line 123 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
123      simError();
124    }
125  
126 +  parseErr = parseBoxLine( read_buffer, boxMat );
127 +  if( parseErr != NULL ){
128 +    strcpy( painCave.errMsg, parseErr );
129 +    painCave.isFatal = 1;
130 +    simError();
131 +  }
132 +
133 +  simnfo->setBoxM( boxMat );
134 +
135 +
136    for( i=0; i < n_atoms; i++){
137      
138      eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file);
# Line 140 | Line 152 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
152        strcpy( painCave.errMsg, parseErr );
153        painCave.isFatal = 1;
154        simError();
155 <    }    
155 >    }
156    }
157  
158  
# Line 170 | Line 182 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
182      
183      n_atoms = atoi( read_buffer );
184      
185 <    Atom **atoms = entry_plug->atoms;
185 >    Atom **atoms = simnfo->atoms;
186      DirectionalAtom* dAtom;
187  
188      // Check to see that the number of atoms in the intial configuration file is the
# Line 180 | Line 192 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
192        sprintf( painCave.errMsg,
193                 "Initialize from File error. %s n_atoms, %d, "
194                 "does not match the BASS file's n_atoms, %d.\n",
195 <               c_in_name, n_atoms, entry_plug->n_atoms );
195 >               c_in_name, n_atoms, simnfo->n_atoms );
196        haveError= 1;
197        simError();
198      }
199      
200 <    //read and toss the comment line
200 >    //read the boxMat from the comment line
201      
202      eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file);
203      if(eof_test == NULL){
204        sprintf( painCave.errMsg,
205                 "error in reading commment in %s\n", c_in_name);
206 <      haveError= 1;
206 >      haveError = 1;
207 >      simError();
208 >    }
209 >    
210 >    parseErr = parseBoxLine( read_buffer, boxMat );
211 >    if( parseErr != NULL ){
212 >      strcpy( painCave.errMsg, parseErr );
213 >      haveError = 1;
214        simError();
215      }
216 +
217 +    MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD );
218    
219      if(haveError) nodeZeroError();
220  
# Line 247 | Line 268 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
268      
269    } else {
270      
271 +    MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD);
272 +
273      done = 0;
274      while (!done) {
275  
# Line 278 | Line 301 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
301      
302   // last  thing last, enable  fatalities.
303    painCave.isEventLoop = 0;
304 +  simnfo->setBoxM( boxMat );
305 +
306    
307   #endif
308   }
# Line 292 | Line 317 | char* InitializeFromFile::parseDumpLine(char* readLine
317    double jx, jy, jz; // angular velocity placeholders;
318    double qSqr, qLength; // needed to normalize the quaternion vector.
319    
320 <  Atom **atoms = entry_plug->atoms;
320 >  Atom **atoms = simnfo->atoms;
321    DirectionalAtom* dAtom;
322    
323    int j, n_atoms, atomIndex;
# Line 311 | Line 336 | char* InitializeFromFile::parseDumpLine(char* readLine
336      return strdup( painCave.errMsg );
337    }  
338   #else
339 <  n_atoms = entry_plug->n_atoms;
339 >  n_atoms = simnfo->n_atoms;
340    atomIndex = globalIndex;
341   #endif // is_mpi
342  
# Line 507 | Line 532 | char* InitializeFromFile::parseDumpLine(char* readLine
532   }
533  
534  
535 + char* InitializeFromFile::parseBoxLine(char* readLine, double boxMat[9]){
536 +
537 +  char *foo; // the pointer to the current string token
538 +  int j;
539 +
540 +  // set the string tokenizer
541 +  
542 +  foo = strtok(readLine, " ,;\t");
543 +  // ignore the first token which is the time stamp.
544 +
545 +
546 +  // get the Hx vector
547 +
548 +  foo = strtok(NULL, " ,;\t");
549 +  if(foo == NULL){
550 +    sprintf( painCave.errMsg,
551 +             "error in reading Hx[0] from %s\n",
552 +             c_in_name );
553 +    return strdup( painCave.errMsg );
554 +  }
555 +  boxMat[0] = atof( foo );
556 +  
557 +  foo = strtok(NULL, " ,;\t");
558 +  if(foo == NULL){
559 +    sprintf( painCave.errMsg,
560 +             "error in reading Hx[1] from %s\n",
561 +             c_in_name );
562 +    return strdup( painCave.errMsg );
563 +  }
564 +  boxMat[1] = atof( foo );
565 +    
566 +  foo = strtok(NULL, " ,;\t");
567 +  if(foo == NULL){
568 +    sprintf( painCave.errMsg,
569 +             "error in reading Hx[2] from %s\n",
570 +             c_in_name );
571 +    return strdup( painCave.errMsg );
572 +  }
573 +  boxMat[2] = atof( foo );    
574 +
575 +  // get the Hy vector
576 +
577 +  foo = strtok(NULL, " ,;\t");
578 +  if(foo == NULL){
579 +    sprintf( painCave.errMsg,
580 +             "error in reading Hy[0] from %s\n",
581 +             c_in_name );
582 +    return strdup( painCave.errMsg );
583 +  }
584 +  boxMat[3] = atof( foo );
585 +  
586 +  foo = strtok(NULL, " ,;\t");
587 +  if(foo == NULL){
588 +    sprintf( painCave.errMsg,
589 +             "error in reading Hy[1] from %s\n",
590 +             c_in_name );
591 +    return strdup( painCave.errMsg );
592 +  }
593 +  boxMat[4] = atof( foo );
594 +    
595 +  foo = strtok(NULL, " ,;\t");
596 +  if(foo == NULL){
597 +    sprintf( painCave.errMsg,
598 +             "error in reading Hy[2] from %s\n",
599 +             c_in_name );
600 +    return strdup( painCave.errMsg );
601 +  }
602 +  boxMat[5] = atof( foo );    
603 +
604 +  // get the Hz vector
605 +
606 +  foo = strtok(NULL, " ,;\t");
607 +  if(foo == NULL){
608 +    sprintf( painCave.errMsg,
609 +             "error in reading Hz[0] from %s\n",
610 +             c_in_name );
611 +    return strdup( painCave.errMsg );
612 +  }
613 +  boxMat[6] = atof( foo );
614 +  
615 +  foo = strtok(NULL, " ,;\t");
616 +  if(foo == NULL){
617 +    sprintf( painCave.errMsg,
618 +             "error in reading Hz[1] from %s\n",
619 +             c_in_name );
620 +    return strdup( painCave.errMsg );
621 +  }
622 +  boxMat[7] = atof( foo );
623 +    
624 +  foo = strtok(NULL, " ,;\t");
625 +  if(foo == NULL){
626 +    sprintf( painCave.errMsg,
627 +             "error in reading Hz[2] from %s\n",
628 +             c_in_name );
629 +    return strdup( painCave.errMsg );
630 +  }
631 +  boxMat[8] = atof( foo );    
632 +
633 +  return NULL;
634 + }
635 +
636 +
637   #ifdef IS_MPI
638  
639   // a couple of functions to let us escape the read loop

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines