From e12b3e216f4665a0aef28e83ec5874d41ef5da14 Mon Sep 17 00:00:00 2001 From: lhausamm <loic_hausammann@hotmail.com> Date: Wed, 14 Feb 2018 12:56:47 +0100 Subject: [PATCH] Bugfix: fix code without logger --- src/gravity/Default/gravity.h | 2 +- src/gravity/Default/gravity_io.h | 4 ++++ src/hydro/Gadget2/hydro.h | 5 ++++- src/hydro/Gadget2/hydro_io.h | 5 +++++ src/hydro/Gadget2/hydro_part.h | 4 ++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gravity/Default/gravity.h b/src/gravity/Default/gravity.h index 98bc7edb46..93ceb3803e 100644 --- a/src/gravity/Default/gravity.h +++ b/src/gravity/Default/gravity.h @@ -230,7 +230,7 @@ __attribute__((always_inline)) INLINE static void gravity_first_init_gpart( gravity_init_gpart(gp); #ifdef WITH_LOGGER - gp->last_output = 0; + gp->last_output = SHRT_MAX; gp->last_offset = 0; #endif } diff --git a/src/gravity/Default/gravity_io.h b/src/gravity/Default/gravity_io.h index d8fb1bb1fc..c653e09f7e 100644 --- a/src/gravity/Default/gravity_io.h +++ b/src/gravity/Default/gravity_io.h @@ -130,6 +130,7 @@ INLINE static void darkmatter_write_particles(const struct gpart* gparts, void darkmatter_write_index(struct gpart* gparts, struct io_props* list, int* num_fields) { +#ifdef WITH_LOGGER /* Say how much we want to read */ *num_fields = 2; @@ -139,6 +140,9 @@ void darkmatter_write_index(struct gpart* gparts, struct io_props* list, list[1] = io_make_output_field("Offset", ULONGLONG, 1, UNIT_CONV_NO_UNITS, gparts, last_offset); +#else + error("Cannot write index without logger"); +#endif } #endif /* SWIFT_DEFAULT_GRAVITY_IO_H */ diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h index 6232f3d327..9cdb6344a6 100644 --- a/src/hydro/Gadget2/hydro.h +++ b/src/hydro/Gadget2/hydro.h @@ -743,7 +743,6 @@ __attribute__((always_inline)) INLINE static void hydro_first_init_part( struct part *restrict p, struct xpart *restrict xp) { p->time_bin = 0; - p->last_offset = 0; xp->v_full[0] = p->v[0]; xp->v_full[1] = p->v[1]; xp->v_full[2] = p->v[2]; @@ -751,7 +750,11 @@ __attribute__((always_inline)) INLINE static void hydro_first_init_part( xp->a_grav[1] = 0.f; xp->a_grav[2] = 0.f; xp->entropy_full = p->entropy; + +#ifdef WITH_LOGGER + p->last_offset = 0; xp->last_output = SHRT_MAX; +#endif hydro_reset_acceleration(p); hydro_init_part(p, NULL); diff --git a/src/hydro/Gadget2/hydro_io.h b/src/hydro/Gadget2/hydro_io.h index 1b43306bb3..ec99174201 100644 --- a/src/hydro/Gadget2/hydro_io.h +++ b/src/hydro/Gadget2/hydro_io.h @@ -201,6 +201,7 @@ INLINE static void hydro_write_particles(const struct part* parts, void hydro_write_index(struct part* parts, struct io_props* list, int* num_fields) { +#ifdef WITH_LOGGER *num_fields = 2; /* List what we want to write */ @@ -209,6 +210,10 @@ void hydro_write_index(struct part* parts, struct io_props* list, list[1] = io_make_output_field("Offset", ULONGLONG, 1, UNIT_CONV_NO_UNITS, parts, last_offset); +#else + error("Cannot write index without logger"); +#endif + } diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h index 102e6aeb7b..ad72d40ec0 100644 --- a/src/hydro/Gadget2/hydro_part.h +++ b/src/hydro/Gadget2/hydro_part.h @@ -55,8 +55,10 @@ struct xpart { /* Additional data used to record cooling information */ struct cooling_xpart_data cooling_data; +#ifdef WITH_LOGGER /* Number of time step since last output */ short int last_output; +#endif } SWIFT_STRUCT_ALIGN; @@ -93,8 +95,10 @@ struct part { /* Entropy time derivative */ float entropy_dt; +#ifdef WITH_LOGGER /* offset at last writing */ size_t last_offset; +#endif union { -- GitLab