ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/md_code/StatWriter.cpp
(Generate patch)

Comparing trunk/mdtools/md_code/StatWriter.cpp (file contents):
Revision 162 by mmeineke, Thu Oct 31 21:20:49 2002 UTC vs.
Revision 261 by chuckv, Mon Feb 3 21:15:59 2003 UTC

# Line 9 | Line 9 | StatWriter::StatWriter( SimInfo* the_entry_plug ){
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 ){
12 >
13 > #ifdef IS_MPI
14 >  if(worldRank == 0 ){
15 > #endif // is_mpi
16 >
17 >    strcpy( outName, entry_plug->statusName );
18      
19 <    sprintf( painCave.errMsg,
20 <             "Could not open \"%s\" for stat output.\n",
21 <             outName);
22 <    painCave.isFatal = 1;
23 <    simError();
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 >
36 >
37 > #ifdef IS_MPI
38    }
39 <  
40 <  //outFile.setf( ios::scientific );
41 <  outFile << "#time(fs)\ttot_E\tpotential\tkinetic\ttemperature\n";
42 <  
39 >
40 >  sprintf( checkPointMsg,
41 >           "Sucessfully opened output file for stating.\n");
42 >  MPIcheckPoint();
43 > #endif // is_mpi
44 >
45    tStats = new Thermo( entry_plug );
46   }
47  
48   StatWriter::~StatWriter( ){
49  
50 <  outFile.close();
51 <  delete tStats;
50 > #ifdef IS_MPI
51 >  if(worldRank == 0 ){
52 > #endif // is_mpi
53 >
54 >    outFile.close();
55 >    delete tStats;
56 >
57 > #ifdef IS_MPI
58 >  }
59 > #endif // is_mpi
60   }
61  
62   void StatWriter::writeStat( double currentTime ){
63  
64 <  outFile.precision(8);
65 <  outFile
66 <    << currentTime << "\t"
67 <    << tStats->getTotalE() << "\t"
68 <    << tStats->getPotential() << "\t"
69 <    << tStats->getKinetic() << "\t"
70 <    << tStats->getTemperature() << "\n";
71 <  outFile.flush();
64 >  double totE, potE, kinE, temp;
65 >
66 >  totE = tStats->getTotalE();
67 >  potE = tStats->getPotential();
68 >  kinE = tStats->getKinetic();
69 >  temp = tStats->getTemperature();
70 >
71 > #ifdef IS_MPI
72 >  if(worldRank == 0 ){
73 > #endif // is_mpi
74 >
75 >    outFile.precision(8);
76 >    outFile
77 >      << currentTime << "\t"
78 >      << totE << "\t"
79 >      << potE << "\t"
80 >      << kinE << "\t"
81 >      << temp << "\n";
82 >    outFile.flush();
83 >
84 > #ifdef IS_MPI
85 >  }
86 > #endif // is_mpi
87   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines