15 string writeout::tstamp(const long& timestamp)
 
  18   if(!timestamp) sstr << time (NULL);
 
  19   else sstr << timestamp;
 
  23 writeout::writeout(const string& wdir, const string& signature, 
 
  24                    const int& rank, const int& procs, const long& timestamp)
 
  28     sprintf(cRank, "%d", rank);
 
  29     fulldir = wdir + "/" + tstamp(timestamp) + "_" + signature;
 
  30     mkdir( fulldir.c_str(),  0775);
 
  32     if(rank>0) of.open( (fulldir + "/rank" + cRank + ".tmp").c_str() );
 
  33     else of.open( (fulldir + "/" + signature + ".dat").c_str() );
 
  40   out = new ostream(buf);
 
  50           while(jobsdone<numprocs-1)
 
  53               if( (nextfile=getdatfile()) == "" ) sleep(1);
 
  56                   cerr << "collecting " << nextfile << endl;
 
  58                   ifstream myfile( (fulldir + "/" + nextfile).c_str() );
 
  61                     getline(myfile, line);
 
  62                     if( !myfile.good() ) break;
 
  63                     of << line << endl << flush;
 
  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")