--- trunk/src/io/DumpWriter.cpp 2005/11/08 13:32:27 721 +++ trunk/src/io/DumpWriter.cpp 2006/05/17 21:51:42 963 @@ -57,8 +57,8 @@ namespace oopse { Globals* simParams = info->getSimParams(); needCompression_ = simParams->getCompressDumpFile(); - needForceVector_ = simParams->getDumpForceVector(); - + needForceVector_ = simParams->getOutputForceVector(); + createDumpFile_ = true; #ifdef HAVE_LIBZ if (needCompression_) { filename_ += ".gz"; @@ -71,7 +71,7 @@ namespace oopse { if (worldRank == 0) { #endif // is_mpi - + dumpFile_ = createOStream(filename_); if (!dumpFile_) { @@ -100,8 +100,8 @@ namespace oopse { eorFilename_ = filename_.substr(0, filename_.rfind(".")) + ".eor"; needCompression_ = simParams->getCompressDumpFile(); - needForceVector_ = simParams->getDumpForceVector(); - + needForceVector_ = simParams->getOutputForceVector(); + createDumpFile_ = true; #ifdef HAVE_LIBZ if (needCompression_) { filename_ += ".gz"; @@ -114,7 +114,7 @@ namespace oopse { if (worldRank == 0) { #endif // is_mpi - + dumpFile_ = createOStream(filename_); if (!dumpFile_) { @@ -133,7 +133,55 @@ namespace oopse { #endif // is_mpi + } + + DumpWriter::DumpWriter(SimInfo* info, const std::string& filename, bool writeDumpFile) + : info_(info), filename_(filename){ + + Globals* simParams = info->getSimParams(); + eorFilename_ = filename_.substr(0, filename_.rfind(".")) + ".eor"; + + needCompression_ = simParams->getCompressDumpFile(); + needForceVector_ = simParams->getOutputForceVector(); + +#ifdef HAVE_LIBZ + if (needCompression_) { + filename_ += ".gz"; + eorFilename_ += ".gz"; + } +#endif + +#ifdef IS_MPI + + if (worldRank == 0) { +#endif // is_mpi + + createDumpFile_ = writeDumpFile; + if (createDumpFile_) { + dumpFile_ = createOStream(filename_); + + if (!dumpFile_) { + sprintf(painCave.errMsg, "Could not open \"%s\" for dump output.\n", + filename_.c_str()); + painCave.isFatal = 1; + simError(); + } + } +#ifdef IS_MPI + } + + sprintf(checkPointMsg, "Sucessfully opened output file for dumping.\n"); + MPIcheckPoint(); + +#endif // is_mpi + + } + + + + + DumpWriter::~DumpWriter() { @@ -141,9 +189,9 @@ namespace oopse { if (worldRank == 0) { #endif // is_mpi - - delete dumpFile_; - + if (createDumpFile_){ + delete dumpFile_; + } #ifdef IS_MPI } @@ -154,10 +202,10 @@ namespace oopse { void DumpWriter::writeCommentLine(std::ostream& os, Snapshot* s) { - double currentTime; + RealType currentTime; Mat3x3d hmat; - double chi; - double integralOfChiDt; + RealType chi; + RealType integralOfChiDt; Mat3x3d eta; currentTime = s->getTime(); @@ -173,7 +221,7 @@ namespace oopse { //write out additional parameters, such as chi and eta - os << chi << "\t" << integralOfChiDt << "\t;"; + os << chi << "\t" << integralOfChiDt << ";\t"; os << eta(0, 0) << "\t" << eta(1, 0) << "\t" << eta(2, 0) << ";\t" << eta(0, 1) << "\t" << eta(1, 1) << "\t" << eta(2, 1) << ";\t" @@ -299,7 +347,7 @@ namespace oopse { int myPotato; int nProc; int which_node; - double atomData[19]; + RealType atomData[19]; int isDirectional; char MPIatomTypeString[MINIBUFFERSIZE]; int msgLen; // the length of message actually recieved at master nodes @@ -374,11 +422,11 @@ namespace oopse { myPotato++; - MPI_Recv(atomData, 19, MPI_DOUBLE, which_node, myPotato, + MPI_Recv(atomData, 19, MPI_REALTYPE, which_node, myPotato, MPI_COMM_WORLD, &istatus); myPotato++; - MPI_Get_count(&istatus, MPI_DOUBLE, &msgLen); + MPI_Get_count(&istatus, MPI_REALTYPE, &msgLen); if (msgLen == 13 || msgLen == 19) isDirectional = 1; @@ -678,16 +726,16 @@ namespace oopse { myPotato++; if (isDirectional && needForceVector_) { - MPI_Send(atomData, 19, MPI_DOUBLE, 0, myPotato, + MPI_Send(atomData, 19, MPI_REALTYPE, 0, myPotato, MPI_COMM_WORLD); } else if (isDirectional) { - MPI_Send(atomData, 13, MPI_DOUBLE, 0, myPotato, + MPI_Send(atomData, 13, MPI_REALTYPE, 0, myPotato, MPI_COMM_WORLD); } else if (needForceVector_) { - MPI_Send(atomData, 12, MPI_DOUBLE, 0, myPotato, + MPI_Send(atomData, 12, MPI_REALTYPE, 0, myPotato, MPI_COMM_WORLD); } else { - MPI_Send(atomData, 6, MPI_DOUBLE, 0, myPotato, + MPI_Send(atomData, 6, MPI_REALTYPE, 0, myPotato, MPI_COMM_WORLD); }