diff --git a/src/engine.c b/src/engine.c index 1d4ad74a7115cead171152f9da890c47785b7705..cb4a0a5eee4dfdaf6e0d057bffac3bb1d6c1f374 100644 --- a/src/engine.c +++ b/src/engine.c @@ -3742,6 +3742,7 @@ void engine_step(struct engine *e) { e->step += 1; engine_current_step = e->step; e->step_props = engine_step_prop_none; + e->stf_this_timestep = 0; /* When restarting, move everyone to the current time. */ if (e->restarting) engine_drift_all(e, /*drift_mpole=*/1); @@ -3973,7 +3974,7 @@ void engine_check_for_dumps(struct engine *e) { case output_snapshot: /* Do we want a corresponding VELOCIraptor output? */ - if (with_stf && e->snapshot_invoke_stf) { + if (with_stf && e->snapshot_invoke_stf && !e->stf_this_timestep) { #ifdef HAVE_VELOCIRAPTOR velociraptor_invoke(e, /*linked_with_snap=*/1); @@ -3994,7 +3995,7 @@ void engine_check_for_dumps(struct engine *e) { #endif /* Free the memory allocated for VELOCIraptor i/o. */ - if (with_stf && e->snapshot_invoke_stf) { + if (with_stf && e->snapshot_invoke_stf && !e->stf_this_timestep) { #ifdef HAVE_VELOCIRAPTOR swift_free("gpart_group_data", e->s->gpart_group_data); e->s->gpart_group_data = NULL; @@ -4019,8 +4020,10 @@ void engine_check_for_dumps(struct engine *e) { #ifdef HAVE_VELOCIRAPTOR /* Unleash the raptor! */ - velociraptor_invoke(e, /*linked_with_snap=*/0); - e->step_props |= engine_step_prop_stf; + if (!e->stf_this_timestep) { + velociraptor_invoke(e, /*linked_with_snap=*/0); + e->step_props |= engine_step_prop_stf; + } /* ... and find the next output time */ engine_compute_next_stf_time(e); @@ -4989,6 +4992,7 @@ void engine_init(struct engine *e, struct space *s, struct swift_params *params, e->chemistry = chemistry; e->fof_properties = fof_properties; e->parameter_file = params; + e->stf_this_timestep = 0; #ifdef WITH_MPI e->cputime_last_step = 0; e->last_repartition = 0; @@ -5441,16 +5445,6 @@ void engine_config(int restart, int fof, struct engine *e, "Scale-factor of first stf output (%e) must be after the " "simulation start a=%e.", e->a_first_stf_output, e->cosmology->a_begin); - - if ((e->snapshot_invoke_stf && e->output_list_stf && - e->output_list_snapshots) && - (output_list_check_duplicates(e->output_list_snapshots, - e->output_list_stf))) - error("Cannot have duplicate time entries between " - "StructureFinding:output_list and " - "Snapshots:output_list when Snapshots:invoke_stf " - "is selected."); - } if (e->policy & engine_policy_fof) { diff --git a/src/engine.h b/src/engine.h index 8296933561b5f7664904d439ec6ca20f1e37a4b8..84397a6dbd1c78669c1440d7d597cd04db316c9d 100644 --- a/src/engine.h +++ b/src/engine.h @@ -471,6 +471,9 @@ struct engine { /* Label of the run */ char run_name[PARSER_MAX_LINE_SIZE]; + + /* Has there been an stf this timestep? */ + int stf_this_timestep; }; /* Function prototypes, engine.c. */ diff --git a/src/outputlist.c b/src/outputlist.c index 7e742a07c388007de4895318a1369a2ae4eadacd..8e2a2624197a4ea1e689c68625c97fdb6f2bf43b 100644 --- a/src/outputlist.c +++ b/src/outputlist.c @@ -314,20 +314,3 @@ void output_list_struct_restore(struct output_list *list, FILE *stream) { restart_read_blocks(list->times, list->size, sizeof(double), stream, NULL, "times"); } - -/** - * @brief Check if there are duplicate times between two output lists - * - * @param list_a The first #output_list. - * @param list_b THe second #output_list. - */ -int output_list_check_duplicates(const struct output_list *list_a, - const struct output_list *list_b) { - - for (size_t ind_a=0; ind_a < list_a->size; ind_a++) { - for (size_t ind_b=0; ind_b < list_a->size; ind_b++) { - if (list_a->times[ind_a] == list_b->times[ind_b]) return 1; - } - } - return 0; -} diff --git a/src/velociraptor_interface.c b/src/velociraptor_interface.c index a7a5876e936a4bc70d609d3523397a660fffcba4..6e73836f23a0978bda65207a10ab77ad85a5a599 100644 --- a/src/velociraptor_interface.c +++ b/src/velociraptor_interface.c @@ -606,6 +606,8 @@ void velociraptor_invoke(struct engine *e, const int linked_with_snap) { /* Increase output counter (if not linked with snapshots) */ if (!linked_with_snap) e->stf_output_count++; + /* Record we have ran stf this timestep */ + e->stf_this_timestep = 1; #else error("SWIFT not configure to run with VELOCIraptor."); #endif /* HAVE_VELOCIRAPTOR */