--- trunk/OOPSE/libmdtools/DumpReader.cpp 2003/10/16 19:16:24 804 +++ trunk/OOPSE/libmdtools/DumpReader.cpp 2004/04/12 20:32:20 1097 @@ -1,10 +1,11 @@ +#define _LARGEFILE_SOURCE64 #define _FILE_OFFSET_BITS 64 #include #include #include -#include +#include #include #include @@ -33,7 +34,7 @@ DumpReader :: DumpReader( char *in_name ){ using namespace dumpRead; -DumpReader :: DumpReader( char *in_name ){ +DumpReader :: DumpReader(const char *in_name ){ isScanned = false; headFP = new FilePos; @@ -221,14 +222,13 @@ void DumpReader :: readSet( int whichFrame ){ double time; fpos_t *framePos; + framePos = frameStart[whichFrame]->getPos(); #ifndef IS_MPI - framePos = frameStart[whichFrame]->getPos(); - + fsetpos(inFile, framePos); - eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); if( eof_test == NULL ){ sprintf( painCave.errMsg, @@ -316,7 +316,7 @@ void DumpReader :: readSet( int whichFrame ){ haveError = 0; if (worldRank == 0) { - + fsetpos(inFile, framePos); eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); if( eof_test == NULL ){ sprintf( painCave.errMsg, @@ -465,10 +465,10 @@ char* DumpReader::parseDumpLine(char* readLine, int gl char *foo; // the pointer to the current string token - double pos[3]; // position place holders - double vel[3]; // velocity placeholders - double q[4]; // the quaternions - double jx, jy, jz; // angular velocity placeholders; + double pos[3]; // position place holders + double vel[3]; // velocity placeholders + double q[4]; // the quaternions + double ji[3]; // angular velocity placeholders; double qSqr, qLength; // needed to normalize the quaternion vector. Atom **atoms = simnfo->atoms; @@ -497,17 +497,17 @@ char* DumpReader::parseDumpLine(char* readLine, int gl // set the string tokenizer foo = strtok(readLine, " ,;\t"); - + atoms[atomIndex]->setType(foo); // check the atom name to the current atom - if( strcmp( foo, atoms[atomIndex]->getType() ) ){ - sprintf( painCave.errMsg, - "Initialize from file error. Atom %s at index %d " - "in file %s does not" - " match the BASS atom %s.\n", - foo, atomIndex, inName, atoms[atomIndex]->getType() ); - return strdup( painCave.errMsg ); - } + //if( strcmp( foo, atoms[atomIndex]->getType() ) ){ + // sprintf( painCave.errMsg, + // "Initialize from file error. Atom %s at index %d " + // "in file %s does not" + // " match the BASS atom %s.\n", + // foo, atomIndex, inName, atoms[atomIndex]->getType() ); + // return strdup( painCave.errMsg ); + //} // get the positions @@ -629,7 +629,7 @@ char* DumpReader::parseDumpLine(char* readLine, int gl inName, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - jx = atof( foo ); + ji[0] = atof( foo ); foo = strtok(NULL, " ,;\t"); if(foo == NULL){ @@ -639,7 +639,7 @@ char* DumpReader::parseDumpLine(char* readLine, int gl inName, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - jy = atof(foo ); + ji[1] = atof(foo ); foo = strtok(NULL, " ,;\t"); if(foo == NULL){ @@ -649,7 +649,7 @@ char* DumpReader::parseDumpLine(char* readLine, int gl inName, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - jz = atof( foo ); + ji[2] = atof( foo ); dAtom = ( DirectionalAtom* )atoms[atomIndex]; @@ -667,9 +667,7 @@ char* DumpReader::parseDumpLine(char* readLine, int gl // add the angular velocities - dAtom->setJx( jx ); - dAtom->setJy( jy ); - dAtom->setJz( jz ); + dAtom->setJ( ji ); } // add the positions and velocities to the atom @@ -686,6 +684,8 @@ char* DumpReader::parseCommentLine(char* readLine, dou char *foo; // the pointer to the current string token int j; + double chi, integralOfChidt; + double eta[9]; // set the string tokenizer @@ -784,8 +784,62 @@ char* DumpReader::parseCommentLine(char* readLine, dou return strdup( painCave.errMsg ); } boxMat[8] = atof( foo ); + + return NULL; + //get chi and integralOfChidt, they should appear by pair + foo = strtok(NULL, " ,;\t\n"); + if(foo != NULL){ + chi = atof(foo); + + foo = strtok(NULL, " ,;\t\n"); + if(foo == NULL){ + sprintf( painCave.errMsg, + "chi and integralOfChidt should appear by pair in %s\n", inName ); + return strdup( painCave.errMsg ); + } + integralOfChidt = atof( foo ); + + //push chi and integralOfChidt into SimInfo::properties which can be + //retrieved by integrator later + DoubleData* chiValue = new DoubleData(); + chiValue->setID(CHIVALUE_ID); + chiValue->setData(chi); + simnfo->addProperty(chiValue); + + DoubleData* integralOfChidtValue = new DoubleData(); + integralOfChidtValue->setID(INTEGRALOFCHIDT_ID); + integralOfChidtValue->setData(integralOfChidt); + simnfo->addProperty(integralOfChidtValue); + + } + else + return NULL; + + //get eta + for(int i = 0 ; i < 9; i++){ + foo = strtok(NULL, " ,;\t"); + if(foo == NULL){ + sprintf( painCave.errMsg, + "error in reading eta[%d] from %s\n", i, inName ); + return strdup( painCave.errMsg ); + } + eta[i] = atof( foo ); + } + + //push eta into SimInfo::properties which can be + //retrieved by integrator later + //simnfo->setBoxM( theBoxMat3 ); + DoubleArrayData* etaValue = new DoubleArrayData(); + etaValue->setID(ETAVALUE_ID); + etaValue->setData(eta, 9); + simnfo->addProperty(etaValue); + + return NULL; + + + }