diff --git a/examples/main.c b/examples/main.c index 773accc461fa26c819f0b603e7de689fa50e6cc6..257ffb9c82c52a21a645508b05330fdfef6d7a37 100644 --- a/examples/main.c +++ b/examples/main.c @@ -943,6 +943,9 @@ int main(int argc, char *argv[]) { engine_dump_snapshot(&e); engine_print_stats(&e); + /* Is there a dump before the end of the first time-step? */ + engine_check_for_dumps(&e); + #ifdef HAVE_VELOCIRAPTOR /* Call VELOCIraptor for the first time after the first snapshot dump. */ // if (e.policy & engine_policy_structure_finding) { diff --git a/src/engine.c b/src/engine.c index 9d5ae94f045b8a174bc7b486fbd9788170d81b6e..65fcc2751c71f7e48016e786567ba956dbe06a06 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2746,8 +2746,7 @@ void engine_link_gravity_tasks(struct engine *e) { /* Get a pointer to the task. */ struct task *t = &sched->tasks[k]; - if(t->type == task_type_none) - continue; + if (t->type == task_type_none) continue; /* Get the cells we act on */ struct cell *ci = t->ci; @@ -4844,6 +4843,21 @@ void engine_step(struct engine *e) { /* Create a restart file if needed. */ engine_dump_restarts(e, 0, e->restart_onexit && engine_is_done(e)); + engine_check_for_dumps(e); + + TIMER_TOC2(timer_step); + + clocks_gettime(&time2); + e->wallclock_time = (float)clocks_diff(&time1, &time2); + +#ifdef SWIFT_DEBUG_TASKS + /* Time in ticks at the end of this step. */ + e->toc_step = getticks(); +#endif +} + +void engine_check_for_dumps(struct engine *e) { + /* Save some statistics ? */ int save_stats = 0; if (e->ti_end_min > e->ti_next_stats && e->ti_next_stats > 0) save_stats = 1; @@ -4997,16 +5011,6 @@ void engine_step(struct engine *e) { e->ti_current = ti_current; e->max_active_bin = max_active_bin; e->time = time; - - TIMER_TOC2(timer_step); - - clocks_gettime(&time2); - e->wallclock_time = (float)clocks_diff(&time1, &time2); - -#ifdef SWIFT_DEBUG_TASKS - /* Time in ticks at the end of this step. */ - e->toc_step = getticks(); -#endif } /** diff --git a/src/engine.h b/src/engine.h index cfd656712bdea84484101cf7e83795f795200f5f..65cb7f22a715d01c745268948c796db3a1f735ab 100644 --- a/src/engine.h +++ b/src/engine.h @@ -382,6 +382,7 @@ void engine_drift_all(struct engine *e); void engine_drift_top_multipoles(struct engine *e); void engine_reconstruct_multipoles(struct engine *e); void engine_print_stats(struct engine *e); +void engine_check_for_dumps(struct engine *e); void engine_dump_snapshot(struct engine *e); void engine_init_output_lists(struct engine *e, struct swift_params *params); void engine_init(struct engine *e, struct space *s, struct swift_params *params,