--- trunk/OOPSE/libmdtools/InitializeFromFile.cpp 2003/07/09 22:14:06 586 +++ trunk/OOPSE/libmdtools/InitializeFromFile.cpp 2003/07/22 16:41:08 644 @@ -69,7 +69,7 @@ InitializeFromFile :: ~InitializeFromFile( ){ } -void InitializeFromFile :: read_xyz( SimInfo* the_simnfo ){ +void InitializeFromFile :: readInit( SimInfo* the_simnfo ){ int i, j, done, which_node, which_atom; // loop counter @@ -83,8 +83,9 @@ void InitializeFromFile :: read_xyz( SimInfo* the_simn 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]; simnfo = the_simnfo; @@ -123,16 +124,20 @@ void InitializeFromFile :: read_xyz( SimInfo* the_simn simError(); } - parseErr = parseBoxLine( read_buffer, boxMat ); + parseErr = parseBoxLine( read_buffer, boxMat, currTime ); if( parseErr != NULL ){ strcpy( painCave.errMsg, parseErr ); painCave.isFatal = 1; simError(); } - simnfo->setBoxM( boxMat ); + for(i=0;i<3;i++) + for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; + simnfo->setBoxM( theBoxMat3 ); + simnfo->setTime( currTime ); + for( i=0; i < n_atoms; i++){ eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); @@ -207,7 +212,7 @@ void InitializeFromFile :: read_xyz( SimInfo* the_simn simError(); } - parseErr = parseBoxLine( read_buffer, boxMat ); + parseErr = parseBoxLine( read_buffer, boxMat, currTime ); if( parseErr != NULL ){ strcpy( painCave.errMsg, parseErr ); haveError = 1; @@ -215,6 +220,7 @@ void InitializeFromFile :: read_xyz( SimInfo* the_simn } MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD ); + MPI_Bcast(&currTime, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD ); if(haveError) nodeZeroError(); @@ -269,6 +275,7 @@ void InitializeFromFile :: read_xyz( SimInfo* the_simn } else { MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD); + MPI_Bcast(&currTime, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); done = 0; while (!done) { @@ -301,8 +308,13 @@ void InitializeFromFile :: read_xyz( SimInfo* the_simn // last thing last, enable fatalities. painCave.isEventLoop = 0; - simnfo->setBoxM( boxMat ); + + for(i=0;i<3;i++) + for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; + simnfo->setBoxM( theBoxMat3 ); + simnfo->setTime( currTime ); + #endif } @@ -532,7 +544,8 @@ char* InitializeFromFile::parseDumpLine(char* readLine } -char* InitializeFromFile::parseBoxLine(char* readLine, double boxMat[9]){ +char* InitializeFromFile::parseBoxLine(char* readLine, double boxMat[9], + double &time ){ char *foo; // the pointer to the current string token int j; @@ -540,8 +553,15 @@ char* InitializeFromFile::parseBoxLine(char* readLine, // set the string tokenizer foo = strtok(readLine, " ,;\t"); - // ignore the first token which is the time stamp. + // set the timeToken. + if(foo == NULL){ + sprintf( painCave.errMsg, + "error in reading Time from %s\n", + c_in_name ); + return strdup( painCave.errMsg ); + } + time = atof( foo ); // get the Hx vector