diff --git a/src/engine.c b/src/engine.c index 184abee389de0cf5ff21b46aef14e1b22d04d0f2..001bd824fbdf1d06f1627d97048586aa875b2e89 100644 --- a/src/engine.c +++ b/src/engine.c @@ -6443,8 +6443,8 @@ void engine_print_policy(struct engine *e) { void engine_compute_next_snapshot_time(struct engine *e) { /* Do outputlist file case */ if (e->outputlist_snapshots) { - outputlist_read_next_time(e->outputlist_snapshots, e, - "snapshots", &e->ti_next_snapshot); + outputlist_read_next_time(e->outputlist_snapshots, e, "snapshots", + &e->ti_next_snapshot); return; } @@ -6499,7 +6499,6 @@ void engine_compute_next_snapshot_time(struct engine *e) { } } - /** * @brief Computes the next time (on the time line) for a statistics dump * @@ -6508,8 +6507,8 @@ void engine_compute_next_snapshot_time(struct engine *e) { void engine_compute_next_statistics_time(struct engine *e) { /* Do outputlist file case */ if (e->outputlist_stats) { - outputlist_read_next_time(e->outputlist_stats, e, - "stats", &e->ti_next_stats); + outputlist_read_next_time(e->outputlist_stats, e, "stats", + &e->ti_next_stats); return; } @@ -6558,7 +6557,7 @@ void engine_compute_next_statistics_time(struct engine *e) { next_statistics_time); } else { const double next_statistics_time = - e->ti_next_stats * e->time_base + e->time_begin; + e->ti_next_stats * e->time_base + e->time_begin; if (e->verbose) message("Next output time for stats set to t=%e.", next_statistics_time); @@ -6574,8 +6573,7 @@ void engine_compute_next_statistics_time(struct engine *e) { void engine_compute_next_stf_time(struct engine *e) { /* Do outputlist file case */ if (e->outputlist_stf) { - outputlist_read_next_time(e->outputlist_stf, e, - "stf", &e->ti_nextSTF); + outputlist_read_next_time(e->outputlist_stf, e, "stf", &e->ti_nextSTF); return; } @@ -6636,9 +6634,9 @@ void engine_compute_next_stf_time(struct engine *e) { void engine_init_outputlists(struct engine *e, struct swift_params *params) { /* Deal with snapshots */ double snaps_time_first; - outputlist_init(&e->outputlist_snapshots, e, "Snapshots", &e->delta_time_snapshot, - &snaps_time_first); - + outputlist_init(&e->outputlist_snapshots, e, "Snapshots", + &e->delta_time_snapshot, &snaps_time_first); + if (e->policy & engine_policy_cosmology) e->a_first_snapshot = snaps_time_first; else @@ -6646,8 +6644,8 @@ void engine_init_outputlists(struct engine *e, struct swift_params *params) { /* Deal with stats */ double stats_time_first; - outputlist_init(&e->outputlist_stats, e, "Statistics", &e->delta_time_statistics, - &stats_time_first); + outputlist_init(&e->outputlist_stats, e, "Statistics", + &e->delta_time_statistics, &stats_time_first); if (e->policy & engine_policy_cosmology) e->a_first_statistics = stats_time_first; @@ -6657,13 +6655,12 @@ void engine_init_outputlists(struct engine *e, struct swift_params *params) { /* Deal with stf */ double stf_time_first; outputlist_init(&e->outputlist_stf, e, "StructureFinding", &e->deltaTimeSTF, - &stf_time_first); + &stf_time_first); if (e->policy & engine_policy_cosmology) e->a_first_stf = stf_time_first; else e->timeFirstSTFOutput = stats_time_first; - } /** @@ -6856,8 +6853,7 @@ void engine_struct_dump(struct engine *e, FILE *stream) { if (e->outputlist_snapshots) outputlist_struct_dump(e->outputlist_snapshots, stream); if (e->outputlist_stats) outputlist_struct_dump(e->outputlist_stats, stream); - if (e->outputlist_stf) - outputlist_struct_dump(e->outputlist_stf, stream); + if (e->outputlist_stf) outputlist_struct_dump(e->outputlist_stf, stream); } /** @@ -6955,21 +6951,21 @@ void engine_struct_restore(struct engine *e, FILE *stream) { if (e->outputlist_snapshots) { struct outputlist *outputlist_snapshots = - (struct outputlist *) malloc(sizeof(struct outputlist)); + (struct outputlist *)malloc(sizeof(struct outputlist)); outputlist_struct_restore(outputlist_snapshots, stream); e->outputlist_snapshots = outputlist_snapshots; } if (e->outputlist_stats) { struct outputlist *outputlist_stats = - (struct outputlist *) malloc(sizeof(struct outputlist)); + (struct outputlist *)malloc(sizeof(struct outputlist)); outputlist_struct_restore(outputlist_stats, stream); e->outputlist_stats = outputlist_stats; } if (e->outputlist_stf) { struct outputlist *outputlist_stf = - (struct outputlist *) malloc(sizeof(struct outputlist)); + (struct outputlist *)malloc(sizeof(struct outputlist)); outputlist_struct_restore(outputlist_stf, stream); e->outputlist_stf = outputlist_stf; } diff --git a/src/engine.h b/src/engine.h index 4604bf1ab84152b9a6aa9f1fc396bfd80d867276..edc2c0f9f107bfe7cf5832d2ed4db48661032b45 100644 --- a/src/engine.h +++ b/src/engine.h @@ -249,7 +249,7 @@ struct engine { /* Outputlist for the stats */ struct outputlist *outputlist_stats; - + /* Integer time of the next statistics dump */ integertime_t ti_next_stats; diff --git a/src/outputlist.c b/src/outputlist.c index d0ad000ccdb4bd731ecaa9448af912ff0be058a7..a8831951c50d6d978faca55e1f8c83a695d179a9 100644 --- a/src/outputlist.c +++ b/src/outputlist.c @@ -24,8 +24,8 @@ #include "outputlist.h" /* Local includes. */ -#include "engine.h" #include "cosmology.h" +#include "engine.h" #include "error.h" #include "restart.h" @@ -120,7 +120,6 @@ void outputlist_read_file(struct outputlist *outputlist, const char *filename, fclose(file); } - /** * @brief Read the next time for an output * @@ -129,7 +128,8 @@ void outputlist_read_file(struct outputlist *outputlist, const char *filename, * @param name The name of the output (e.g. 'stats', 'snapshots', 'stf') * @param ti_next updated to the next output time */ -void outputlist_read_next_time(struct outputlist *t, const struct engine *e, const char* name, integertime_t *ti_next) { +void outputlist_read_next_time(struct outputlist *t, const struct engine *e, + const char *name, integertime_t *ti_next) { int is_cosmo = e->policy & engine_policy_cosmology; /* Find upper-bound on last output */ @@ -161,8 +161,7 @@ void outputlist_read_next_time(struct outputlist *t, const struct engine *e, con } /* Deal with last statistics */ - if (*ti_next >= max_nr_timesteps || ind == t->size || - time >= time_end) { + if (*ti_next >= max_nr_timesteps || ind == t->size || time >= time_end) { *ti_next = -1; if (e->verbose) message("No further output time for %s.", name); } else { @@ -172,14 +171,11 @@ void outputlist_read_next_time(struct outputlist *t, const struct engine *e, con const double next_time = exp(*ti_next * e->time_base) * e->cosmology->a_begin; if (e->verbose) - message("Next output time for %s set to a=%e.", - name, next_time); + message("Next output time for %s set to a=%e.", name, next_time); } else { - const double next_time = - *ti_next * e->time_base + e->time_begin; + const double next_time = *ti_next * e->time_base + e->time_begin; if (e->verbose) - message("Next output time for %s set to t=%e.", - name, next_time); + message("Next output time for %s set to t=%e.", name, next_time); } } } @@ -191,10 +187,11 @@ void outputlist_read_next_time(struct outputlist *t, const struct engine *e, con * @param e The #engine * @param name The name of the section in params * @param delta_time updated to the initial delta time - * @param time_first updated to the time of first output (scale factor or cosmic time) + * @param time_first updated to the time of first output (scale factor or cosmic + * time) */ -void outputlist_init(struct outputlist **list, const struct engine *e, char* name, - double *delta_time, double *time_first) { +void outputlist_init(struct outputlist **list, const struct engine *e, + char *name, double *delta_time, double *time_first) { struct swift_params *params = e->parameter_file; /* get cosmo */ @@ -204,8 +201,7 @@ void outputlist_init(struct outputlist **list, const struct engine *e, char* nam /* Read output on/off */ char param_name[PARSER_MAX_LINE_SIZE]; sprintf(param_name, "%s:output_list_on", name); - int outputlist_on = - parser_get_opt_param_int(params, param_name, 0); + int outputlist_on = parser_get_opt_param_int(params, param_name, 0); /* Read outputlist for snapshots */ if (outputlist_on) { @@ -231,7 +227,6 @@ void outputlist_init(struct outputlist **list, const struct engine *e, char* nam *time_first = (*list)->times[0]; } } - } /** diff --git a/src/outputlist.h b/src/outputlist.h index 2d9528736b0d4116869ccaaef82a100f7bdae450..dac27e829a34b02c6ab6323ff391a9f9bfa02029 100644 --- a/src/outputlist.h +++ b/src/outputlist.h @@ -36,7 +36,6 @@ enum output_list_type { OUTPUTLIST_SCALE_FACTOR, }; - /** * @brief the array containing the output times */ @@ -54,9 +53,10 @@ struct outputlist { void outputlist_read_file(struct outputlist *outputlist, const char *filename, struct cosmology *cosmo); -void outputlist_read_next_time(struct outputlist *t, const struct engine *e, const char* name, integertime_t *ti_next); +void outputlist_read_next_time(struct outputlist *t, const struct engine *e, + const char *name, integertime_t *ti_next); void outputlist_init(struct outputlist **list, const struct engine *e, - char* name, double *delta_time, double *time_first); + char *name, double *delta_time, double *time_first); void outputlist_print(const struct outputlist *outputlist); void outputlist_clean(struct outputlist *outputlist); void outputlist_struct_dump(struct outputlist *list, FILE *stream);