| 8 | 
  | 
 | 
| 9 | 
  | 
StatWriter::StatWriter( SimInfo* the_entry_plug ){ | 
| 10 | 
  | 
 | 
| 11 | 
< | 
  entry_plug = the_entry_plug; | 
| 12 | 
< | 
   | 
| 13 | 
< | 
  strcpy( outName, entry_plug->statusName ); | 
| 14 | 
< | 
  outFile.open(outName, ios::out | ios::trunc ); | 
| 15 | 
< | 
   | 
| 16 | 
< | 
  if( !outFile ){ | 
| 11 | 
> | 
#ifdef IS_MPI | 
| 12 | 
> | 
  if(worldRank == TESTWRITE ){ | 
| 13 | 
> | 
#endif // is_mpi | 
| 14 | 
> | 
 | 
| 15 | 
> | 
    entry_plug = the_entry_plug; | 
| 16 | 
  | 
     | 
| 17 | 
< | 
    sprintf( painCave.errMsg, | 
| 18 | 
< | 
             "Could not open \"%s\" for stat output.\n", | 
| 19 | 
< | 
             outName); | 
| 20 | 
< | 
    painCave.isFatal = 1; | 
| 21 | 
< | 
    simError(); | 
| 17 | 
> | 
    strcpy( outName, entry_plug->statusName ); | 
| 18 | 
> | 
     | 
| 19 | 
> | 
    std::cerr << "Opening " << outName << " for stat\n"; | 
| 20 | 
> | 
 | 
| 21 | 
> | 
    outFile.open(outName, ios::out | ios::trunc ); | 
| 22 | 
> | 
     | 
| 23 | 
> | 
    if( !outFile ){ | 
| 24 | 
> | 
       | 
| 25 | 
> | 
      sprintf( painCave.errMsg, | 
| 26 | 
> | 
               "Could not open \"%s\" for stat output.\n", | 
| 27 | 
> | 
               outName); | 
| 28 | 
> | 
      painCave.isFatal = 1; | 
| 29 | 
> | 
      simError(); | 
| 30 | 
> | 
    } | 
| 31 | 
> | 
     | 
| 32 | 
> | 
    //outFile.setf( ios::scientific ); | 
| 33 | 
> | 
    outFile << "#time(fs)\ttot_E\tpotential\tkinetic\ttemperature\n"; | 
| 34 | 
> | 
     | 
| 35 | 
> | 
    tStats = new Thermo( entry_plug ); | 
| 36 | 
> | 
 | 
| 37 | 
> | 
#ifdef IS_MPI | 
| 38 | 
  | 
  } | 
| 39 | 
< | 
   | 
| 25 | 
< | 
  //outFile.setf( ios::scientific ); | 
| 26 | 
< | 
  outFile << "#time(fs)\ttot_E\tpotential\tkinetic\ttemperature\n"; | 
| 27 | 
< | 
   | 
| 28 | 
< | 
  tStats = new Thermo( entry_plug ); | 
| 39 | 
> | 
#endif // is_mpi | 
| 40 | 
  | 
} | 
| 41 | 
  | 
 | 
| 42 | 
  | 
StatWriter::~StatWriter( ){ | 
| 43 | 
  | 
 | 
| 44 | 
< | 
  outFile.close(); | 
| 45 | 
< | 
  delete tStats; | 
| 44 | 
> | 
#ifdef IS_MPI | 
| 45 | 
> | 
  if(worldRank == TESTWRITE ){ | 
| 46 | 
> | 
#endif // is_mpi | 
| 47 | 
> | 
 | 
| 48 | 
> | 
    outFile.close(); | 
| 49 | 
> | 
    delete tStats; | 
| 50 | 
> | 
 | 
| 51 | 
> | 
#ifdef IS_MPI | 
| 52 | 
> | 
  } | 
| 53 | 
> | 
#endif // is_mpi | 
| 54 | 
  | 
} | 
| 55 | 
  | 
 | 
| 56 | 
  | 
void StatWriter::writeStat( double currentTime ){ | 
| 57 | 
  | 
 | 
| 58 | 
< | 
  outFile.precision(8); | 
| 59 | 
< | 
  outFile | 
| 60 | 
< | 
    << currentTime << "\t" | 
| 61 | 
< | 
    << tStats->getTotalE() << "\t" | 
| 62 | 
< | 
    << tStats->getPotential() << "\t" | 
| 63 | 
< | 
    << tStats->getKinetic() << "\t" | 
| 64 | 
< | 
    << tStats->getTemperature() << "\n"; | 
| 65 | 
< | 
  outFile.flush(); | 
| 58 | 
> | 
#ifdef IS_MPI | 
| 59 | 
> | 
  if(worldRank == TESTWRITE ){ | 
| 60 | 
> | 
#endif // is_mpi | 
| 61 | 
> | 
 | 
| 62 | 
> | 
    outFile.precision(8); | 
| 63 | 
> | 
    outFile | 
| 64 | 
> | 
      << currentTime << "\t" | 
| 65 | 
> | 
      << tStats->getTotalE() << "\t" | 
| 66 | 
> | 
      << tStats->getPotential() << "\t" | 
| 67 | 
> | 
      << tStats->getKinetic() << "\t" | 
| 68 | 
> | 
      << tStats->getTemperature() << "\n"; | 
| 69 | 
> | 
    outFile.flush(); | 
| 70 | 
> | 
 | 
| 71 | 
> | 
#ifdef IS_MPI | 
| 72 | 
> | 
  } | 
| 73 | 
> | 
#endif // is_mpi | 
| 74 | 
  | 
} |