Skip to content
Snippets Groups Projects
Commit 6d37bce8 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Append thread output files to program output

parent 82a68b84
No related branches found
No related tags found
No related merge requests found
...@@ -604,8 +604,31 @@ void cluster(string config_file, string data_file, string output_path) { ...@@ -604,8 +604,31 @@ void cluster(string config_file, string data_file, string output_path) {
delete[] am_2; delete[] am_2;
} // jxi488 loop } // jxi488 loop
for (int ri=0; ri<ompnumthreads; ri++) { for (int ri = 0; ri < ompnumthreads; ri++) {
// Giovanni, please add here in this loop code to reopen the temporary files, reread them and append them respectively to the global output and tppoan, before closing them // Giovanni, please add here in this loop code to reopen the temporary files, reread them and append them respectively to the global output and tppoan, before closing them
string partial_file_name = output_path + "/c_OCLU_" + to_string(ri);
printf("Copying ASCII output of thread %d of %d... ", ri, ompnumthreads);
FILE *partial_output = fopen(partial_file_name.c_str(), "r");
char c = fgetc(partial_output);
while (c != EOF) {
fputc(c, output);
c = fgetc(partial_output);
}
fclose(partial_output);
remove(partial_file_name.c_str());
printf("done.\n");
partial_file_name = output_path + "/c_TPPOAN_" + to_string(ri);
printf("Copying binary output of thread %d of %d... ", ri, ompnumthreads);
fstream partial_tppoan;
partial_tppoan.open((output_path + "/c_TPPOAN_" + to_string(ri)).c_str(), ios::in | ios::binary);
c = partial_tppoan.get();
while(!partial_tppoan.eof()) {
tppoan.put(c);
c = partial_tppoan.get();
}
partial_tppoan.close();
remove(partial_file_name.c_str());
printf("done.\n");
} }
tppoan.close(); tppoan.close();
} else { // In case TPPOAN could not be opened. Should never happen. } else { // In case TPPOAN could not be opened. Should never happen.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment