From 3f1ca83b9f6f1fd9a590d1e47b0360b779af53b3 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Tue, 27 Feb 2018 18:02:37 +0000 Subject: [PATCH] Only call cosmology_update() after the cosmological tables have been allocated. --- src/cosmology.c | 11 ++++------- src/engine.c | 3 ++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/cosmology.c b/src/cosmology.c index e09a63316d..17ed572ba0 100644 --- a/src/cosmology.c +++ b/src/cosmology.c @@ -414,9 +414,6 @@ void cosmology_init(const struct swift_params *params, c->H0 = H0_cgs * units_cgs_conversion_factor(us, UNIT_CONV_TIME); c->Hubble_time = 1. / c->H0; - /* Set remaining variables to alid values */ - cosmology_update(c, 0); - /* Initialise the interpolation tables */ c->drift_fac_interp_table = NULL; c->grav_kick_fac_interp_table = NULL; @@ -425,6 +422,9 @@ void cosmology_init(const struct swift_params *params, c->time_interp_table_offset = 0.; cosmology_init_tables(c); + /* Set remaining variables to alid values */ + cosmology_update(c, 0); + /* Update the times */ c->time_begin = cosmology_get_time_since_big_bang(c, c->a_begin); c->time_end = cosmology_get_time_since_big_bang(c, c->a_end); @@ -433,11 +433,8 @@ void cosmology_init(const struct swift_params *params, /** * @brief Initialise the #cosmology for non-cosmological time-integration * - * Essentially sets all constants to 1. + * Essentially sets all constants to 1 or 0. * - * @param params The parsed values. - * @param us The current internal system of units. - * @param phys_const The physical constants in the current system of units. * @param c The #cosmology to initialise. */ void cosmology_init_no_cosmo(struct cosmology *c) { diff --git a/src/engine.c b/src/engine.c index 5972702f9d..96ebe7b093 100644 --- a/src/engine.c +++ b/src/engine.c @@ -5946,7 +5946,8 @@ void engine_struct_restore(struct engine *e, FILE *stream) { chemistry_struct_restore(chemistry, stream); e->chemistry = chemistry; - struct sourceterms *sourceterms = (struct sourceterms *) malloc(sizeof(struct sourceterms)); + struct sourceterms *sourceterms = + (struct sourceterms *)malloc(sizeof(struct sourceterms)); sourceterms_struct_restore(sourceterms, stream); e->sourceterms = sourceterms; -- GitLab