From c95bca4cf55f46e9450c063307a25b3fc1432f96 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Tue, 15 Sep 2015 11:34:58 +0200
Subject: [PATCH] Different file names for thread output

Former-commit-id: 3f25f51ba835dc02cebf25b5b0dd74747e4aa115
---
 examples/test.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/examples/test.c b/examples/test.c
index 8b808cc60a..8ee735a57f 100644
--- a/examples/test.c
+++ b/examples/test.c
@@ -565,6 +565,7 @@ int main(int argc, char *argv[]) {
   float dt_max = 0.0f;
   ticks tic;
   int nr_nodes = 1, myrank = 0, grid[3] = {1, 1, 1};
+  FILE *file_thread;
 
 /* Choke on FP-exceptions. */
 // feenableexcept( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW );
@@ -899,16 +900,16 @@ int main(int argc, char *argv[]) {
 #endif
 
   /* Dump the task data. */
-  FILE *file = fopen("thread_info.dat", "w");
 #ifdef WITH_MPI
+  file_thread = fopen("thread_info_MPI.dat", "w");
   for (j = 0; j < nr_nodes; j++) {
     MPI_Barrier(MPI_COMM_WORLD);
     if (j == myrank) {
-      fprintf(file, " %03i 0 0 0 0 %lli 0 0 0 0\n", myrank, e.tic_step);
+      fprintf(file_thread, " %03i 0 0 0 0 %lli 0 0 0 0\n", myrank, e.tic_step);
       for (k = 0; k < e.sched.nr_tasks; k++)
         if (!e.sched.tasks[k].skip && !e.sched.tasks[k].implicit)
           fprintf(
-              file, " %03i %i %i %i %i %lli %lli %i %i %i\n", myrank,
+              file_thread, " %03i %i %i %i %i %lli %lli %i %i %i\n", myrank,
               e.sched.tasks[k].rid, e.sched.tasks[k].type,
               e.sched.tasks[k].subtype, (e.sched.tasks[k].cj == NULL),
               e.sched.tasks[k].tic, e.sched.tasks[k].toc,
@@ -919,16 +920,18 @@ int main(int argc, char *argv[]) {
       sleep(1);
     }
   }
+  fclose(file_thread);
 #else
+  file_thread = fopen("thread_info.dat", "w");
   for (k = 0; k < e.sched.nr_tasks; k++)
     if (!e.sched.tasks[k].skip && !e.sched.tasks[k].implicit)
-      fprintf(file, " %i %i %i %i %lli %lli %i %i\n", e.sched.tasks[k].rid,
+      fprintf(file_thread, " %i %i %i %i %lli %lli %i %i\n", e.sched.tasks[k].rid,
               e.sched.tasks[k].type, e.sched.tasks[k].subtype,
               (e.sched.tasks[k].cj == NULL), e.sched.tasks[k].tic,
               e.sched.tasks[k].toc, e.sched.tasks[k].ci->count,
               (e.sched.tasks[k].cj == NULL) ? 0 : e.sched.tasks[k].cj->count);
+  fclose(file_thread);
 #endif
-  fclose(file);
 
 /* Write final output. */
 #if defined(WITH_MPI)
-- 
GitLab