diff --git a/src/proxy.c b/src/proxy.c index 1a395045bf80aa9940fb0934cc8b04eb6f3764ad..dcb7deb2fd4238013d40e412a1006b3f0a721e9d 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -106,8 +106,8 @@ void proxy_tags_exchange(struct proxy *proxies, int num_proxies, num_reqs_in += proxies[k].nr_cells_in; num_reqs_out += proxies[k].nr_cells_out; } - MPI_Request *reqs_in; - int *cids_in; + MPI_Request *reqs_in = NULL; + int *cids_in = NULL; if ((reqs_in = (MPI_Request *)malloc(sizeof(MPI_Request) * (num_reqs_in + num_reqs_out))) == NULL || (cids_in = (int *)malloc(sizeof(int) * (num_reqs_in + num_reqs_out))) == diff --git a/src/runner.c b/src/runner.c index 828adc4185e2050fee2c48fa31b7af3ad7962f7e..00965b675161a9c89aceab0cbacf504e88eb4045 100644 --- a/src/runner.c +++ b/src/runner.c @@ -643,6 +643,7 @@ void runner_do_extra_ghost(struct runner *r, struct cell *c, int timer) { const int count = c->count; const struct engine *e = r->e; const integertime_t ti_end = e->ti_current; + const int with_cosmology = (e->policy & engine_policy_cosmology); const double time_base = e->time_base; const struct cosmology *cosmo = e->cosmology; @@ -665,9 +666,15 @@ void runner_do_extra_ghost(struct runner *r, struct cell *c, int timer) { struct xpart *restrict xp = &xparts[i]; if (part_is_active(p, e)) { - /* Calculate the time-step for passing to hydro_prepare_force, used for - * the evolution of alpha factors (i.e. those involved in the artificial - * viscosity and thermal conduction terms) */ + + /* Finish the gradient calculation */ + hydro_end_gradient(p); + + /* As of here, particle force variables will be set. */ + + /* Calculate the time-step for passing to hydro_prepare_force. + * This is the physical time between the start and end of the time-step + * without any scale-factor powers. */ double dt_alpha; if (with_cosmology) { const integertime_t ti_step = get_integer_timestep(p->time_bin); @@ -676,11 +683,6 @@ void runner_do_extra_ghost(struct runner *r, struct cell *c, int timer) { dt_alpha = get_timestep(p->time_bin, time_base); } - /* Finish the gradient calculation */ - hydro_end_gradient(p); - - /* As of here, particle force variables will be set. */ - /* Compute variables required for the force loop */ hydro_prepare_force(p, xp, cosmo, dt_alpha); @@ -774,17 +776,6 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) { float h_new; int has_no_neighbours = 0; - /* Calculate the time-step for passing to hydro_prepare_force, used for - * the evolution of alpha factors (i.e. those involved in the artificial - * viscosity and thermal conduction terms) */ - double dt_alpha; - if (with_cosmology) { - const integertime_t ti_step = get_integer_timestep(p->time_bin); - dt_alpha = cosmology_get_delta_time(cosmo, ti_end - ti_step, ti_end); - } else { - dt_alpha = get_timestep(p->time_bin, time_base); - } - if (p->density.wcount == 0.f) { /* No neighbours case */ /* Flag that there were no neighbours */ @@ -831,6 +822,18 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) { #else /* As of here, particle force variables will be set. */ + /* Calculate the time-step for passing to hydro_prepare_force. + * This is the physical time between the start and end of the + * time-step without any scale-factor powers. */ + double dt_alpha; + if (with_cosmology) { + const integertime_t ti_step = get_integer_timestep(p->time_bin); + dt_alpha = + cosmology_get_delta_time(cosmo, ti_end - ti_step, ti_end); + } else { + dt_alpha = get_timestep(p->time_bin, time_base); + } + /* Compute variables required for the force loop */ hydro_prepare_force(p, xp, cosmo, dt_alpha); @@ -913,6 +916,17 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) { #else /* As of here, particle force variables will be set. */ + /* Calculate the time-step for passing to hydro_prepare_force. + * This is the physical time between the start and end of the time-step + * without any scale-factor powers. */ + double dt_alpha; + if (with_cosmology) { + const integertime_t ti_step = get_integer_timestep(p->time_bin); + dt_alpha = cosmology_get_delta_time(cosmo, ti_end - ti_step, ti_end); + } else { + dt_alpha = get_timestep(p->time_bin, time_base); + } + /* Compute variables required for the force loop */ hydro_prepare_force(p, xp, cosmo, dt_alpha);