diff --git a/src/engine.c b/src/engine.c index 776d3e388a519629775bbfbbe7fb40f1dbc46794..82cd2012c5d47a1ebc608be0ee719ed166a67ac3 100644 --- a/src/engine.c +++ b/src/engine.c @@ -5609,10 +5609,11 @@ void engine_check_for_dumps(struct engine *e) { /* Dump everything */ engine_print_stats(e); - if (e->policy & engine_policy_logger) - engine_dump_index(e); - else - engine_dump_snapshot(e); +#if defined(WITH_LOGGER) + engine_dump_index(e); +#else + engine_dump_snapshot(e); +#endif } else if (e->ti_next_stats < e->ti_next_snapshot) { @@ -5642,10 +5643,11 @@ void engine_check_for_dumps(struct engine *e) { engine_drift_all(e); /* Dump snapshot */ - if (e->policy & engine_policy_logger) - engine_dump_index(e); - else - engine_dump_snapshot(e); +#if defined(WITH_LOGGER) + engine_dump_index(e); +#else + engine_dump_snapshot(e); +#endif } else if (e->ti_next_stats > e->ti_next_snapshot) { @@ -5663,10 +5665,11 @@ void engine_check_for_dumps(struct engine *e) { engine_drift_all(e); /* Dump snapshot */ - if (e->policy & engine_policy_logger) - engine_dump_index(e); - else - engine_dump_snapshot(e); +#if defined(WITH_LOGGER) + engine_dump_index(e); +#else + engine_dump_snapshot(e); +#endif /* Let's fake that we are at the stats dump time */ e->ti_current = e->ti_next_stats; @@ -5701,10 +5704,11 @@ void engine_check_for_dumps(struct engine *e) { engine_drift_all(e); /* Dump... */ - if (e->policy & engine_policy_logger) - engine_dump_index(e); - else - engine_dump_snapshot(e); +#if defined(WITH_LOGGER) + engine_dump_index(e); +#else + engine_dump_snapshot(e); +#endif /* ... and find the next output time */ engine_compute_next_snapshot_time(e); @@ -6464,9 +6468,6 @@ void engine_dump_snapshot(struct engine *e) { e->snapshot_units, e->nodeID, e->nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL); #endif -#elif defined(WITH_LOGGER) - write_index_single(e, e->snapshotBaseName, e->internal_units, - e->snapshotUnits); #else write_output_single(e, e->snapshotBaseName, e->internal_units, e->snapshotUnits); @@ -6489,14 +6490,27 @@ void engine_dump_snapshot(struct engine *e) { */ void engine_dump_index(struct engine *e) { +#if defined(WITH_LOGGER) struct clocks_time time1, time2; clocks_gettime(&time1); +#ifdef SWIFT_DEBUG_CHECKS + /* Check that all cells have been drifted to the current time. + * That can include cells that have not + * previously been active on this rank. */ + space_check_drift_point(e->s, e->ti_current, + e->policy & engine_policy_self_gravity); + + /* Be verbose about this */ + if (e->nodeID == 0) message("writing index at t=%e.", e->time); +#else if (e->verbose) message("writing index at t=%e.", e->time); +#endif /* Dump... */ /* Should use snapshotBaseName for the index name */ - message("I am dumping an index file..."); + write_index_single(e, e->snapshotBaseName, e->internal_units, + e->snapshotUnits); e->dump_snapshot = 0; @@ -6504,6 +6518,9 @@ void engine_dump_index(struct engine *e) { if (e->verbose) message("writing particle properties took %.3f %s.", (float)clocks_diff(&time1, &time2), clocks_getunit()); +#else + error("Logger disabled"); +#endif } #ifdef HAVE_SETAFFINITY @@ -6680,6 +6697,7 @@ void engine_init(struct engine *e, struct space *s, struct swift_params *params, strcat(logger_name_file, ".dump"); e->logger_dump = malloc(sizeof(struct dump)); dump_init(e->logger_dump, logger_name_file, 1024 * 1024 * 100); + e->logger_time_offset = 0; #endif /* Make the space link back to the engine. */ diff --git a/src/engine.h b/src/engine.h index e2dfd701ff6dfb6e1265bd82129708fffb2b4b4f..5efd53b2300c08faa1266d621af78367be4093fb 100644 --- a/src/engine.h +++ b/src/engine.h @@ -319,6 +319,12 @@ struct engine { /* File name of the dump file */ struct dump *logger_dump; + /* timestamp offset for logger*/ + size_t logger_time_offset; + + /* Need to dump a snapshot ? */ + int dump_snapshot; + /* How many steps have we done with the same set of tasks? */ int tasks_age;