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);
61 if( !myfile.good() ) break;
62 of << line << endl << flush;
65 remove( (fulldir + "/" + nextfile).c_str() );
69 of << "#end" << endl << flush;
75 rename((fulldir + "/rank" + cRank + ".tmp").c_str(),
76 (fulldir + "/rank" + cRank + ".part").c_str());
81 string writeout::getdatfile()
87 if((dp = opendir(fulldir.c_str())) == NULL) {
88 cerr << "Error(" << errno << ") opening " << fulldir << endl;
92 while ((dirp = readdir(dp)) != NULL)
94 myfile = string(dirp->d_name);
95 if(myfile.length() > 3 && myfile.substr(myfile.length()-4) == "part")