#include <errno.h>
#include <unistd.h>
+#include <boost/filesystem.hpp>
+
using namespace std;
string writeout::tstamp(const long& timestamp)
sprintf(cRank, "%d", rank);
fulldir = wdir + "/" + tstamp(timestamp) + "_" + signature + ".tmp";
- mkdir(fulldir.c_str(), 0775);
+ if (rank==0)
+ mkdir(fulldir.c_str(), 0775);
+ else {
+ while ( ! ( boost::filesystem::exists(fulldir) && boost::filesystem::is_directory(fulldir) ) ) {
+ cerr << "WRITOUT: Waiting for rank 0 to create out directory." << endl << flush;
+ sleep(1);
+ }
+ }
logf.open( (fulldir + "/rank" + cRank + ".log").c_str() );
{
if(fulldir != "") {
for (map<string,ofstream*>::iterator ofit = of.begin(); ofit != of.end(); ++ofit) {
- cout << ofit->first << endl;
if( cRank[0] == '0' ) {
int jobsdone=0;
while(jobsdone<numprocs-1) {
- cout << ofit->first << endl;
- cout << "here" << endl;
string nextfile;
if( (nextfile = getdatfile(ofit->first)) == "" )
sleep(1);
DIR *dp;
struct dirent *dirp;
- cout << "getting:" << subname << endl;
-
if((dp = opendir(fulldir.c_str())) == NULL) {
logf << "Error(" << errno << ") opening " << fulldir << endl;
- cout << "blub" << endl;
+ closedir(dp);
return "";
}
{
myfile = string(dirp->d_name);
- cout << myfile << endl;
-
if(myfile.length() > 3 && myfile.substr(myfile.length()-4) == "part" &&
subname == myfile.substr( myfile.find("-")+1, myfile.rfind(".")-myfile.find("-")-1 ) ) {
- cout << myfile << endl;
+ closedir(dp);
return myfile;
}
}
+ closedir(dp);
return "";
}