--- trunk/OOPSE/libmdtools/ZConsWriter.cpp 2003/08/15 19:24:13 699 +++ trunk/OOPSE/libmdtools/ZConsWriter.cpp 2003/10/28 16:20:28 830 @@ -18,21 +18,20 @@ ZConsWriter::ZConsWriter(const char* filename, vector< if(!output){ sprintf( painCave.errMsg, - "Could not open \"s\" for z constrain output \n", - filename); + "Could not open %s for z constrain output \n", + filename); painCave.isFatal = 1; simError(); } output << "#number of z constrain molecules" << endl; output << "#global Index of molecule\tzPos" << endl; - - parameters = thePara; - writeZPos(); - + output << "#every frame will contain below data" <getMolToProcMap(); - for(int i = 0; i < parameters->size(); i++){ + for(int i = 0; i < (int)(parameters->size()); i++){ globalIndexOfCurMol = (*parameters)[i].zconsIndex; whichNode = MolToProcMap[globalIndexOfCurMol]; if(whichNode == 0){ - for(int j = 0; j < num; j++) - if(index[j] == globalIndexOfCurMol){ - localIndex = j; - break; - } + for(int j = 0; j < num; j++) + if(index[j] == globalIndexOfCurMol){ + localIndex = j; + break; + } - force = fz[localIndex]; - pos = curZPos[localIndex]; - + force = fz[localIndex]; + pos = curZPos[localIndex]; + } else{ status = RequesPosAndForce; MPI_Send(&status, 1, MPI_INT, whichNode, tag, MPI_COMM_WORLD); - MPI_Send(&globalIndexOfCurMol, 1, MPI_INT, whichNode, tag, MPI_COMM_WORLD); - MPI_Recv(&force, 1, MPI_DOUBLE_PRECISION, whichNode, tag, MPI_COMM_WORLD, &ierr); - MPI_Recv(&pos, 1, MPI_DOUBLE_PRECISION, whichNode, tag, MPI_COMM_WORLD, &ierr); + MPI_Send(&globalIndexOfCurMol, 1, MPI_INT, whichNode, tag, MPI_COMM_WORLD); + MPI_Recv(&force, 1, MPI_DOUBLE, whichNode, tag, MPI_COMM_WORLD, &ierr); + MPI_Recv(&pos, 1, MPI_DOUBLE, whichNode, tag, MPI_COMM_WORLD, &ierr); } - output << globalIndexOfCurMol << "\t" << force << "\t" << pos << endl; + output << globalIndexOfCurMol << "\t" << force << "\t" << pos << endl; } //End of Request Loop @@ -124,24 +132,24 @@ void ZConsWriter::writeFZ(double time, int num, int* i switch (status){ - case RequesPosAndForce : + case RequesPosAndForce : - MPI_Recv(&whichMol, 1, MPI_INT, 0, tag, MPI_COMM_WORLD,&ierr); - - for(int i = 0; i < num; i++) - if(index[i] == whichMol){ - localIndex = i; - break; - } - - MPI_Send(&fz[localIndex], 1, MPI_DOUBLE_PRECISION, 0, tag, MPI_COMM_WORLD); - MPI_Send(&curZPos[localIndex], 1, MPI_DOUBLE_PRECISION, 0, tag, MPI_COMM_WORLD); - break; - + MPI_Recv(&whichMol, 1, MPI_INT, 0, tag, MPI_COMM_WORLD,&ierr); + + for(int i = 0; i < num; i++) + if(index[i] == whichMol){ + localIndex = i; + break; + } + + MPI_Send(&fz[localIndex], 1, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD); + MPI_Send(&curZPos[localIndex], 1, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD); + break; + case EndOfRequest : - done = true; - break; + done = true; + break; } } @@ -152,15 +160,18 @@ void ZConsWriter::writeFZ(double time, int num, int* i } +/* + * + */ void ZConsWriter::writeZPos(){ #ifdef IS_MPI if(worldRank == 0){ #endif - output << parameters->size() << endl; + output << parameters->size() << endl; - for(int i =0 ; i < parameters->size(); i++) + for(int i =0 ; i < (int)(parameters->size()); i++) output << (*parameters)[i].zconsIndex << "\t" << (*parameters)[i].zPos << endl; #ifdef IS_MPI