--- trunk/OOPSE/libmdtools/InitializeFromFile.cpp 2003/07/22 16:41:08 644 +++ trunk/OOPSE/libmdtools/InitializeFromFile.cpp 2003/10/28 16:03:37 829 @@ -1,5 +1,5 @@ #include -#include +#include #include #include @@ -26,7 +26,8 @@ using namespace initFile; #endif // is_mpi -InitializeFromFile :: InitializeFromFile( char *in_name ){ +InitializeFromFile::InitializeFromFile( char *in_name ){ + #ifdef IS_MPI if (worldRank == 0) { #endif @@ -48,7 +49,7 @@ InitializeFromFile :: InitializeFromFile( char *in_nam return; } -InitializeFromFile :: ~InitializeFromFile( ){ +InitializeFromFile::~InitializeFromFile( ){ #ifdef IS_MPI if (worldRank == 0) { #endif @@ -71,18 +72,19 @@ void InitializeFromFile :: readInit( SimInfo* the_simn void InitializeFromFile :: readInit( SimInfo* the_simnfo ){ - int i, j, done, which_node, which_atom; // loop counter + int i, j; + +#ifdef IS_MPI + int done, which_node, which_atom; // loop counter +#endif //is_mpi const int BUFFERSIZE = 2000; // size of the read buffer int n_atoms; // the number of atoms char read_buffer[BUFFERSIZE]; //the line buffer for reading -#ifdef IS_MPI - char send_buffer[BUFFERSIZE]; -#endif char *eof_test; // ptr to see when we reach the end of the file char *parseErr; - int procIndex; + double currTime; double boxMat[9]; double theBoxMat3[3][3]; @@ -102,9 +104,6 @@ void InitializeFromFile :: readInit( SimInfo* the_simn n_atoms = atoi( read_buffer ); - Atom **atoms = simnfo->atoms; - DirectionalAtom* dAtom; - if( n_atoms != simnfo->n_atoms ){ sprintf( painCave.errMsg, "Initialize from File error. %s n_atoms, %d, " @@ -180,16 +179,13 @@ void InitializeFromFile :: readInit( SimInfo* the_simn eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); if( eof_test == NULL ){ sprintf( painCave.errMsg, - "Error reading 1st line of %d \n ",c_in_name); + "Error reading 1st line of %s \n ",c_in_name); haveError = 1; simError(); } n_atoms = atoi( read_buffer ); - Atom **atoms = simnfo->atoms; - DirectionalAtom* dAtom; - // Check to see that the number of atoms in the intial configuration file is the // same as declared in simBass. @@ -323,8 +319,8 @@ char* InitializeFromFile::parseDumpLine(char* readLine char *foo; // the pointer to the current string token - double rx, ry, rz; // position place holders - double vx, vy, vz; // velocity placeholders + double pos[3]; // position place holders + double vel[3]; // velocity placeholders double q[4]; // the quaternions double jx, jy, jz; // angular velocity placeholders; double qSqr, qLength; // needed to normalize the quaternion vector. @@ -332,9 +328,11 @@ char* InitializeFromFile::parseDumpLine(char* readLine Atom **atoms = simnfo->atoms; DirectionalAtom* dAtom; - int j, n_atoms, atomIndex; + int n_atoms, atomIndex; #ifdef IS_MPI + int j; + n_atoms = mpiSim->getTotAtoms(); atomIndex=-1; for (j=0; j < mpiSim->getMyNlocal(); j++) { @@ -377,7 +375,7 @@ char* InitializeFromFile::parseDumpLine(char* readLine c_in_name, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - rx = atof( foo ); + pos[0] = atof( foo ); foo = strtok(NULL, " ,;\t"); if(foo == NULL){ @@ -387,7 +385,7 @@ char* InitializeFromFile::parseDumpLine(char* readLine c_in_name, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - ry = atof( foo ); + pos[1] = atof( foo ); foo = strtok(NULL, " ,;\t"); if(foo == NULL){ @@ -397,7 +395,7 @@ char* InitializeFromFile::parseDumpLine(char* readLine c_in_name, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - rz = atof( foo ); + pos[2] = atof( foo ); // get the velocities @@ -410,7 +408,7 @@ char* InitializeFromFile::parseDumpLine(char* readLine c_in_name, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - vx = atof( foo ); + vel[0] = atof( foo ); foo = strtok(NULL, " ,;\t"); if(foo == NULL){ @@ -420,7 +418,7 @@ char* InitializeFromFile::parseDumpLine(char* readLine c_in_name, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - vy = atof( foo ); + vel[1] = atof( foo ); foo = strtok(NULL, " ,;\t"); if(foo == NULL){ @@ -430,7 +428,7 @@ char* InitializeFromFile::parseDumpLine(char* readLine c_in_name, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - vz = atof( foo ); + vel[2] = atof( foo ); // get the quaternions @@ -531,14 +529,9 @@ char* InitializeFromFile::parseDumpLine(char* readLine } // add the positions and velocities to the atom - - atoms[atomIndex]->setX( rx ); - atoms[atomIndex]->setY( ry ); - atoms[atomIndex]->setZ( rz ); - atoms[atomIndex]->set_vx( vx ); - atoms[atomIndex]->set_vy( vy ); - atoms[atomIndex]->set_vz( vz ); + atoms[atomIndex]->setPos( pos ); + atoms[atomIndex]->setVel( vel ); return NULL; } @@ -548,7 +541,6 @@ char* InitializeFromFile::parseBoxLine(char* readLine, double &time ){ char *foo; // the pointer to the current string token - int j; // set the string tokenizer