From d3c230dcc7edf196462d30b6320b0f23b9ed401f Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Mon, 5 Sep 2016 16:14:41 +0100
Subject: [PATCH] Redirect the output of SWIFT to a output file

---
 examples/CoolingBox/run.sh |  2 +-
 examples/main.c            | 22 +++++++++++-----------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/examples/CoolingBox/run.sh b/examples/CoolingBox/run.sh
index 18ece8fd3e..c78eec9da6 100755
--- a/examples/CoolingBox/run.sh
+++ b/examples/CoolingBox/run.sh
@@ -5,6 +5,6 @@ echo "Generating initial conditions for the cooling box example..."
 
 python makeIC.py 10
 
-../swift -s -t 1 coolingBox.yml -C
+../swift -s -t 1 coolingBox.yml -C 2>&1 | tee output.log
 
 python energy_plot.py 0
diff --git a/examples/main.c b/examples/main.c
index 5bbb6ad616..14c95dd3ec 100644
--- a/examples/main.c
+++ b/examples/main.c
@@ -330,17 +330,6 @@ int main(int argc, char *argv[]) {
   struct hydro_props hydro_properties;
   hydro_props_init(&hydro_properties, params);
 
-  /* Initialise the external potential properties */
-  struct external_potential potential;
-  if (with_external_gravity)
-    potential_init(params, &prog_const, &us, &potential);
-  if (with_external_gravity && myrank == 0) potential_print(&potential);
-
-  /* Initialise the cooling function properties */
-  struct cooling_data cooling;
-  if (with_cooling) cooling_init(params, &us, &prog_const, &cooling);
-  if (with_cooling && myrank == 0) cooling_print(&cooling);
-
   /* Read particles and space information from (GADGET) ICs */
   char ICfileName[200] = "";
   parser_get_param_string(params, "InitialConditions:file_name", ICfileName);
@@ -443,6 +432,17 @@ int main(int argc, char *argv[]) {
     message("nr of cells at depth %i is %i.", data[0], data[1]);
   }
 
+  /* Initialise the external potential properties */
+  struct external_potential potential;
+  if (with_external_gravity)
+    potential_init(params, &prog_const, &us, &potential);
+  if (with_external_gravity && myrank == 0) potential_print(&potential);
+
+  /* Initialise the cooling function properties */
+  struct cooling_data cooling;
+  if (with_cooling) cooling_init(params, &us, &prog_const, &cooling);
+  if (with_cooling && myrank == 0) cooling_print(&cooling);
+  
   /* Construct the engine policy */
   int engine_policies = ENGINE_POLICY | engine_policy_steal;
   if (with_drift_all) engine_policies |= engine_policy_drift_all;
-- 
GitLab