#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() );