From b9124e9e4ea21fce1c3136e04800c028c71eb94d Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Mon, 6 Aug 2018 17:36:23 +0200
Subject: [PATCH] Make the STF dump follow the same pattern as the other dumps.
 A drift_all will have to be added one day.

---
 src/engine.c | 31 ++++++++++++++-----------------
 src/engine.h |  1 -
 2 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/src/engine.c b/src/engine.c
index 94a142b9eb..5a616317d9 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -4851,19 +4851,20 @@ void engine_step(struct engine *e) {
   if (e->ti_end_min >= e->ti_next_snapshot && e->ti_next_snapshot > 0)
     dump_snapshot = 1;
 
-  /* Store information before attempting extra dump-related drifts */
-  integertime_t ti_current = e->ti_current;
-  timebin_t max_active_bin = e->max_active_bin;
-  double time = e->time;
-
   /* Do we want to perform structure finding? */
+  int run_stf = 0;
   if ((e->policy & engine_policy_structure_finding)) {
-    if(e->stf_output_freq_format == STEPS && e->step%e->deltaStepSTF == 0) 
-      e->run_stf = 1;
+    if(e->stf_output_freq_format == STEPS && e->step % e->deltaStepSTF == 0)
+      run_stf = 1;
     else if(e->stf_output_freq_format == TIME && e->ti_end_min >= e->ti_nextSTF && e->ti_nextSTF > 0)
-      e->run_stf = 1; 
+      run_stf = 1;
   }
 
+  /* Store information before attempting extra dump-related drifts */
+  integertime_t ti_current = e->ti_current;
+  timebin_t max_active_bin = e->max_active_bin;
+  double time = e->time;
+
   /* Write some form of output */
   if (dump_snapshot && save_stats) {
 
@@ -4975,13 +4976,14 @@ void engine_step(struct engine *e) {
   }
 
   /* Perform structure finding? */
-  if (e->run_stf) {
-    //velociraptor_invoke(e);
+  if (run_stf) {
+
+    // MATTHIEU: Add a drift_all here. And check the order with the order i/o options.
+
+    velociraptor_invoke(e);
     
     /* ... and find the next output time */
     if(e->stf_output_freq_format == TIME) engine_compute_next_stf_time(e);
-    
-    e->run_stf = 0;
   }
 
   /* Restore the information we stored */
@@ -5873,11 +5875,6 @@ void engine_config(int restart, struct engine *e, struct swift_params *params,
   e->restart_next = 0;
   e->restart_dt = 0;
   e->timeFirstSTFOutput = 0;
-  e->deltaTimeSTF = 0;
-  e->deltaStepSTF = 0;
-  e->stf_output_freq_format = 0;
-  e->ti_nextSTF = 0;
-  e->run_stf = 0;
   engine_rank = nodeID;
 
   /* Initialise VELOCIraptor. */
diff --git a/src/engine.h b/src/engine.h
index f6526e7c5f..9e44ab3a73 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -225,7 +225,6 @@ struct engine {
   int snapshot_output_count;
 
   /* Structure finding information */
-  int run_stf;
   int stf_output_freq_format;
   double a_first_stf;
   double timeFirstSTFOutput;
-- 
GitLab