add_library(lat_paraq paraq.cpp)
+add_library(lat_progress progress.cpp)
+
add_executable(neigh_test neigh_test.cpp)
target_link_libraries(neigh_test lat_neigh)
\ No newline at end of file
--- /dev/null
+#include "progress.h"
+
+progress::progress(int a_realsteps, int a_progsteps)
+{
+ laststep = 0;
+ realsteps = a_realsteps;
+ progsteps = a_progsteps;
+}
+
+bool progress::madeStep(int realStep)
+{
+ if( (double)(realStep+1)*progsteps/realsteps >= laststep+1 ) {
+ laststep++;
+ return true;
+ }
+ else
+ return false;
+}
--- /dev/null
+#ifndef PROGRESS_H
+#define PROGRESS_H
+
+class progress
+{
+ public:
+ progress(int a_realsteps, int a_progsteps=100);
+ bool madeStep( int realStep );
+
+ private:
+ int realsteps;
+ int progsteps;
+ int laststep;
+};
+
+#endif
if(rank>0) of.open( (fulldir + "/rank" + cRank + ".tmp").c_str() );
else of.open( (fulldir + "/" + signature + ".dat").c_str() );
+ logf.open( (fulldir + "/rank" + cRank + ".log").c_str() );
+
+ logf << "[ " << timestring() << " ] Log starts here." << endl;
+
buf = of.rdbuf();
+ logbuf = logf.rdbuf();
}
else{
buf = cout.rdbuf();
+ logbuf = cerr.rdbuf();
}
out = new ostream(buf);
+ log = new ostream(logbuf);
+}
+
+string writeout::timestring()
+{
+ time_t rawtime;
+ string timestring;
+ time( &rawtime );
+ timestring = asctime( localtime( &rawtime ) );
+ return timestring.substr(0, timestring.size()-1);;
}
writeout::~writeout()
(fulldir + "/rank" + cRank + ".part").c_str());
}
}
+ logf << "[ " << timestring() << " ] Log ends here." << endl;
+ logf.close();
}
string writeout::getdatfile()
#include <fstream>
using namespace std;
-
+
class writeout
{
public:
writeout(const string& wdir, const string& signature,
const int& rank, const int& procs, const long& timestamp=0);
ostream *out;
+ ostream *log;
~writeout();
private:
ofstream of;
+ ofstream logf;
streambuf *buf;
+ streambuf *logbuf;
string fulldir;
char cRank[20];
string tstamp(const long& timestamp);
int numprocs;
string getdatfile();
+ string timestring();
};
#endif