- if(fulldir != "")
- {
- if( cRank[0] == '0' )
- {
- int jobsdone=0;
- while(jobsdone<numprocs-1)
- {
- string nextfile;
- if( (nextfile=getdatfile()) == "" ) sleep(1);
- else
- {
- logf << "collecting " << nextfile << endl;
-
- ifstream myfile( (fulldir + "/" + nextfile).c_str() );
- while(true){
- string line;
- getline(myfile, line);
- if( !myfile.good() ) break;
- of << line << endl << flush;
- }
- myfile.close();
- remove( (fulldir + "/" + nextfile).c_str() );
- jobsdone++;
- }
+ if(fulldir != "") {
+ for (map<string,ofstream*>::iterator ofit = of.begin(); ofit != of.end(); ++ofit) {
+ if( cRank[0] == '0' ) {
+ int jobsdone=0;
+ while(jobsdone<numprocs-1) {
+ string nextfile;
+ if( (nextfile = getdatfile(ofit->first)) == "" )
+ sleep(1);
+ else {
+ logf << "collecting " << nextfile << endl;
+
+ ifstream myfile( (fulldir + "/" + nextfile).c_str() );
+ while(true) {
+ string line;
+ getline(myfile, line);
+ if( !myfile.good() ) break;
+ *ofit->second << line << endl << flush;