15 string writeout::tstamp()
22 writeout::writeout(const string& wdir, const string& signature,
23 const int& rank, const int& procs)
27 sprintf(cRank, "%d", rank);
28 fulldir = wdir + "/" + tstamp() + "_" + signature;
29 mkdir( fulldir.c_str(), 0775);
31 if(rank>0) of.open( (fulldir + "/rank" + cRank + ".tmp").c_str() );
32 else of.open( (fulldir + "/" + signature + ".dat").c_str() );
39 out = new ostream(buf);
49 while(jobsdone<numprocs-1)
52 if( (nextfile=getdatfile()) == "" ) sleep(1);
55 cerr << "collecting " << nextfile << endl;
57 ifstream myfile( (fulldir + "/" + nextfile).c_str() );
60 getline(myfile, line);
66 remove( (fulldir + "/" + nextfile).c_str() );
70 of << "#end" << endl << flush;
76 rename((fulldir + "/rank" + cRank + ".tmp").c_str(),
77 (fulldir + "/rank" + cRank + ".part").c_str());
82 string writeout::getdatfile()
88 if((dp = opendir(fulldir.c_str())) == NULL) {
89 cerr << "Error(" << errno << ") opening " << fulldir << endl;
93 while ((dirp = readdir(dp)) != NULL)
95 myfile = string(dirp->d_name);
96 if(myfile.length() > 3 && myfile.substr(myfile.length()-4) == "part")