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

Comparing trunk/OOPSE/libmdtools/DumpReader.cpp (file contents):
Revision 1118 by tim, Mon Apr 19 03:52:27 2004 UTC vs.
Revision 1268 by tim, Fri Jun 11 17:16:21 2004 UTC

# Line 84 | Line 84 | void DumpReader::scanFile( void ){
84  
85   void DumpReader::scanFile( void ){
86  
87 <  int vectorSize;
88 <  int i, j, k;
87 >  int i, j;
88    int lineNum = 0;
89    char readBuffer[2000];
91  char* foo;
90    fpos_t *currPos;
93  double time;
91  
95
96
92   #ifdef IS_MPI
93    if( worldRank == 0 ){
94   #endif // is_mpi
# Line 112 | Line 107 | void DumpReader::scanFile( void ){
107        painCave.isFatal = 1;
108        simError();
109      }
115    framePos.push_back(currPos);
110  
111      while( !feof( inFile ) ){
112 +      
113 +      framePos.push_back(currPos);
114  
115        i = atoi(readBuffer);
116        
# Line 149 | Line 145 | void DumpReader::scanFile( void ){
145        currPos = new fpos_t;
146        fgetpos( inFile, currPos );
147        fgets( readBuffer, sizeof( readBuffer ), inFile );
152      framePos.push_back(currPos);
148        lineNum++;
149      }
150      
# Line 176 | Line 171 | void DumpReader :: readSet( int whichFrame ){
171  
172   void DumpReader :: readSet( int whichFrame ){
173  
174 <   int i, j;
174 >  int i;
175 >  unsigned int j;
176  
177   #ifdef IS_MPI
178    int done, which_node, which_atom; // loop counter
# Line 198 | Line 194 | void DumpReader :: readSet( int whichFrame ){
194    eof_test = fgets(read_buffer, sizeof(read_buffer), inFile);
195    if( eof_test == NULL ){
196      sprintf( painCave.errMsg,
197 <             "InitializeFromFile error: error reading 1st line of \"%s\"\n",
197 >             "DumpReader error: error reading 1st line of \"%s\"\n",
198               inFileName.c_str() );
199      painCave.isFatal = 1;
200      simError();
# Line 208 | Line 204 | void DumpReader :: readSet( int whichFrame ){
204  
205    if( nTotObjs != simnfo->getTotIntegrableObjects() ){
206      sprintf( painCave.errMsg,
207 <             "Initialize from File error. %s n_atoms, %d, "
207 >             "DumpReader error. %s n_atoms, %d, "
208               "does not match the BASS file's n_atoms, %d.\n",
209               inFileName.c_str(), nTotObjs, simnfo->getTotIntegrableObjects());
210      painCave.isFatal = 1;
# Line 273 | Line 269 | void DumpReader :: readSet( int whichFrame ){
269    int *MolToProcMap = mpiSim->getMolToProcMap();
270    int localIndex;
271    int nCurObj;
272 +  int nitems;
273  
274 +  nTotObjs = simnfo->getTotIntegrableObjects();
275    haveError = 0;
276    if (worldRank == 0) {
277       fsetpos(inFile,  framePos[whichFrame]);
# Line 286 | Line 284 | void DumpReader :: readSet( int whichFrame ){
284        simError();
285      }
286  
287 <    nTotObjs = atoi( read_buffer );
287 >    nitems = atoi( read_buffer );
288  
289      // Check to see that the number of integrable objects  in the intial configuration file is the
290      // same as declared in simBass.
291  
292 <    if( nTotObjs != simnfo->getTotIntegrableObjects()){
292 >    if( nTotObjs != nitems){
293        sprintf( painCave.errMsg,
294 <               "Initialize from File error. %s n_atoms, %d, "
294 >               "DumpReadererror. %s n_atoms, %d, "
295                 "does not match the BASS file's n_atoms, %d.\n",
296                 inFileName.c_str(), nTotObjs, simnfo->getTotIntegrableObjects());
297        haveError= 1;
# Line 325 | Line 323 | void DumpReader :: readSet( int whichFrame ){
323        simError();
324      }
325  
326 <    for (i=0 ; i < mpiSim->getTotNmol(); i++) {
326 >    for (i=0 ; i < mpiSim->getNMolGlobal(); i++) {
327        which_node = MolToProcMap[i];
328        if(which_node == 0){
329         //molecules belong to master node
# Line 354 | Line 352 | void DumpReader :: readSet( int whichFrame ){
352            
353            if(haveError) nodeZeroError();
354  
355 <          parseDumpLine(read_buffer, integrableObjects[i]);
355 >          parseDumpLine(read_buffer, integrableObjects[j]);
356            
357         }
358  
# Line 363 | Line 361 | void DumpReader :: readSet( int whichFrame ){
361        else{
362        //molecule belongs to slave nodes
363  
364 <        MPI_Recv(&nCurObj, 1, MPI_INT, 0,
364 >        MPI_Recv(&nCurObj, 1, MPI_INT, which_node,
365                 TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus);
366        
367 <       for(j=0; j < integrableObjects.size(); j++){
367 >       for(j=0; j < nCurObj; j++){
368          
369            eof_test = fgets(read_buffer, sizeof(read_buffer), inFile);
370            if(eof_test == NULL){
# Line 393 | Line 391 | void DumpReader :: readSet( int whichFrame ){
391    }
392    else{
393    //actions taken at slave nodes
394 <    for (i=0 ; i < mpiSim->getTotNmol(); i++) {
394 >    MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, 0, MPI_COMM_WORLD);
395 >
396 >    parseErr = parseCommentLine( read_buffer, simnfo);
397 >
398 >    if( parseErr != NULL ){
399 >      strcpy( painCave.errMsg, parseErr );
400 >      haveError = 1;
401 >      simError();
402 >    }
403 >  
404 >    for (i=0 ; i < mpiSim->getNMolGlobal(); i++) {
405        which_node = MolToProcMap[i];
406        
407        if(which_node == worldRank){
# Line 411 | Line 419 | void DumpReader :: readSet( int whichFrame ){
419  
420          nCurObj = integrableObjects.size();
421          
422 <        MPI_Recv(&nCurObj, 1, MPI_INT, 0,
423 <                        TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus);
422 >        MPI_Send(&nCurObj, 1, MPI_INT, 0,
423 >                        TAKE_THIS_TAG_INT, MPI_COMM_WORLD);
424  
425          for(j = 0; j < integrableObjects.size(); j++){
426  
# Line 456 | Line 464 | char* DumpReader::parseDumpLine(char* readLine, StuntD
464  
465    if( strcmp( foo, sd->getType() ) ){
466      sprintf( painCave.errMsg,
467 <             "Initialize from file error.  Does not"
467 >             "DumpReader error.  Does not"
468               " match the BASS atom %s.\n",
469               sd->getType() );
470      return strdup( painCave.errMsg );
# Line 603 | Line 611 | char* DumpReader::parseDumpLine(char* readLine, StuntD
611      // check that the quaternion vector is normalized
612  
613      qSqr = (q[0] * q[0]) + (q[1] * q[1]) + (q[2] * q[2]) + (q[3] * q[3]);
614 +
615 +    if (fabs(qSqr) < 1e-6) {
616 +      sprintf(painCave.errMsg,
617 +          "initial quaternion error (q0^2 + q1^2 + q2^2 + q3^2 ~ 0).\n");
618 +       return strdup(painCave.errMsg);
619 +    }
620  
621      qLength = sqrt( qSqr );
622      q[0] = q[0] / qLength;
# Line 732 | Line 746 | void DumpReader::nodeZeroError( void ){
746    int j, myStatus;
747  
748    myStatus = 0;
749 <  for (j = 0; j < mpiSim->getNumberProcessors(); j++) {
749 >  for (j = 0; j < mpiSim->getNProcessors(); j++) {
750      MPI_Send( &myStatus, 1, MPI_INT, j,
751                TAKE_THIS_TAG_INT, MPI_COMM_WORLD);
752    }
# Line 748 | Line 762 | void DumpReader::anonymousNodeDie( void ){
762    MPI_Finalize();
763    exit (0);
764   }
765 < #endif
765 > #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines