--- trunk/mdtools/md_code/StatWriter.cpp 2002/10/31 21:20:49 162 +++ trunk/mdtools/md_code/StatWriter.cpp 2002/11/21 20:33:06 184 @@ -8,40 +8,67 @@ StatWriter::StatWriter( SimInfo* the_entry_plug ){ StatWriter::StatWriter( SimInfo* the_entry_plug ){ - entry_plug = the_entry_plug; - - strcpy( outName, entry_plug->statusName ); - outFile.open(outName, ios::out | ios::trunc ); - - if( !outFile ){ +#ifdef IS_MPI + if(worldRank == TESTWRITE ){ +#endif // is_mpi + + entry_plug = the_entry_plug; - sprintf( painCave.errMsg, - "Could not open \"%s\" for stat output.\n", - outName); - painCave.isFatal = 1; - simError(); + strcpy( outName, entry_plug->statusName ); + + std::cerr << "Opening " << outName << " for stat\n"; + + outFile.open(outName, ios::out | ios::trunc ); + + if( !outFile ){ + + sprintf( painCave.errMsg, + "Could not open \"%s\" for stat output.\n", + outName); + painCave.isFatal = 1; + simError(); + } + + //outFile.setf( ios::scientific ); + outFile << "#time(fs)\ttot_E\tpotential\tkinetic\ttemperature\n"; + + tStats = new Thermo( entry_plug ); + +#ifdef IS_MPI } - - //outFile.setf( ios::scientific ); - outFile << "#time(fs)\ttot_E\tpotential\tkinetic\ttemperature\n"; - - tStats = new Thermo( entry_plug ); +#endif // is_mpi } StatWriter::~StatWriter( ){ - outFile.close(); - delete tStats; +#ifdef IS_MPI + if(worldRank == TESTWRITE ){ +#endif // is_mpi + + outFile.close(); + delete tStats; + +#ifdef IS_MPI + } +#endif // is_mpi } void StatWriter::writeStat( double currentTime ){ - outFile.precision(8); - outFile - << currentTime << "\t" - << tStats->getTotalE() << "\t" - << tStats->getPotential() << "\t" - << tStats->getKinetic() << "\t" - << tStats->getTemperature() << "\n"; - outFile.flush(); +#ifdef IS_MPI + if(worldRank == TESTWRITE ){ +#endif // is_mpi + + outFile.precision(8); + outFile + << currentTime << "\t" + << tStats->getTotalE() << "\t" + << tStats->getPotential() << "\t" + << tStats->getKinetic() << "\t" + << tStats->getTemperature() << "\n"; + outFile.flush(); + +#ifdef IS_MPI + } +#endif // is_mpi }