--- trunk/OOPSE/libmdtools/InitializeFromFile.cpp 2004/04/15 16:18:26 1113 +++ trunk/OOPSE/libmdtools/InitializeFromFile.cpp 2004/04/22 21:33:55 1131 @@ -16,8 +16,8 @@ #ifdef IS_MPI #include #include "mpiSimulation.hpp" -#define TAKE_THIS_TAG_CHAR 0 -#define TAKE_THIS_TAG_INT 1 +#define TAKE_THIS_TAG_CHAR 3134 +#define TAKE_THIS_TAG_INT 3135 namespace initFile{ void nodeZeroError( void ); @@ -175,7 +175,9 @@ void InitializeFromFile :: readInit( SimInfo* the_simn int *MolToProcMap = mpiSim->getMolToProcMap(); int localIndex; int nCurObj; + int nItems; + nTotObjs = simnfo->getTotIntegrableObjects(); haveError = 0; if (worldRank == 0) { @@ -187,12 +189,12 @@ void InitializeFromFile :: readInit( SimInfo* the_simn simError(); } - nTotObjs = atoi( read_buffer ); + nItems = atoi( read_buffer ); // Check to see that the number of integrable objects in the intial configuration file is the // same as declared in simBass. - if( nTotObjs != simnfo->getTotIntegrableObjects()){ + if( nTotObjs != nItems){ sprintf( painCave.errMsg, "Initialize from File error. %s n_atoms, %d, " "does not match the BASS file's n_atoms, %d.\n", @@ -218,6 +220,7 @@ void InitializeFromFile :: readInit( SimInfo* the_simn MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, 0, MPI_COMM_WORLD); + parseErr = parseCommentLine( read_buffer, simnfo); if( parseErr != NULL ){ @@ -255,7 +258,7 @@ void InitializeFromFile :: readInit( SimInfo* the_simn if(haveError) nodeZeroError(); - parseDumpLine(read_buffer, integrableObjects[i]); + parseDumpLine(read_buffer, integrableObjects[j]); } @@ -264,10 +267,10 @@ void InitializeFromFile :: readInit( SimInfo* the_simn else{ //molecule belongs to slave nodes - MPI_Recv(&nCurObj, 1, MPI_INT, 0, + MPI_Recv(&nCurObj, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); - - for(j=0; j < integrableObjects.size(); j++){ + + for(j=0; j < nCurObj; j++){ eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); if(eof_test == NULL){ @@ -284,7 +287,7 @@ void InitializeFromFile :: readInit( SimInfo* the_simn MPI_Send(read_buffer, BUFFERSIZE, MPI_CHAR, which_node, TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD); - + } } @@ -294,6 +297,17 @@ void InitializeFromFile :: readInit( SimInfo* the_simn } else{ //actions taken at slave nodes + + MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, 0, MPI_COMM_WORLD); + + parseErr = parseCommentLine( read_buffer, simnfo); + + if( parseErr != NULL ){ + strcpy( painCave.errMsg, parseErr ); + haveError = 1; + simError(); + } + for (i=0 ; i < mpiSim->getTotNmol(); i++) { which_node = MolToProcMap[i]; @@ -312,8 +326,8 @@ void InitializeFromFile :: readInit( SimInfo* the_simn nCurObj = integrableObjects.size(); - MPI_Recv(&nCurObj, 1, MPI_INT, 0, - TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); + MPI_Send(&nCurObj, 1, MPI_INT, 0, + TAKE_THIS_TAG_INT, MPI_COMM_WORLD); for(j = 0; j < integrableObjects.size(); j++){ @@ -617,7 +631,7 @@ char* InitializeFromFile::parseCommentLine(char* readL //push eta into SimInfo::properties which can be //retrieved by integrator later - //entry_plug->setBoxM( theBoxMat3 ); + DoubleArrayData* etaValue = new DoubleArrayData(); etaValue->setID(ETAVALUE_ID); etaValue->setData(eta, 9);