From 039694a960c2425b412d32505e19b72e4495141e Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Mon, 27 Apr 2020 18:14:25 +0200 Subject: [PATCH] Fix crash in the unit tests related to the new way of constructing the cell meta-data and snapshot names --- src/common_io.c | 4 ++++ tests/testFeedback.c | 3 ++- tests/testSelectOutput.c | 6 ++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/common_io.c b/src/common_io.c index 3adda8000a..8846c8847b 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -896,6 +896,10 @@ void io_write_cell_offsets(hid_t h_grp, const int cdim[3], const double dim[3], } #endif + /* Abort if we don't have any cells yet (i.e. haven't constructed the space) + */ + if (nr_cells == 0) return; + double cell_width[3] = {width[0], width[1], width[2]}; /* Temporary memory for the cell-by-cell information */ diff --git a/tests/testFeedback.c b/tests/testFeedback.c index 56b4fedf77..1228a6fae0 100644 --- a/tests/testFeedback.c +++ b/tests/testFeedback.c @@ -79,7 +79,8 @@ int main(int argc, char *argv[]) { &hydro_properties, &cosmo); /* Init spart */ - stars_first_init_spart(&sp, &stars_properties); + stars_first_init_spart(&sp, &stars_properties, /*with_cosmology=*/0, cosmo.a, + cosmo.time); /* Define an initial stellar mass. (for use when calling the feedback * functions, the results are presented per initial stellar mass, so the diff --git a/tests/testSelectOutput.c b/tests/testSelectOutput.c index 8a08bcf58f..4e16df60d8 100644 --- a/tests/testSelectOutput.c +++ b/tests/testSelectOutput.c @@ -83,7 +83,7 @@ int main(int argc, char *argv[]) { unsigned long long cpufreq = 0; clocks_set_cpufreq(cpufreq); - const char *base_name = "testSelectOutput"; + // const char *base_name = "testSelectOutput"; size_t Ngas = 0, Ngpart = 0, Ngpart_background = 0, Nspart = 0, Nbpart = 0; int flag_entropy_ICs = -1; int periodic = 1; @@ -146,6 +146,8 @@ int main(int argc, char *argv[]) { /* pseudo initialization of the engine */ message("Initialization of the engine."); struct engine e; + e.physical_constants = &prog_const; + sprintf(e.snapshot_base_name, "testSelectOutput"); sprintf(e.run_name, "Select Output Test"); select_output_engine_init(&e, &s, &cosmo, ¶m_file, &cooling, &hydro_properties); @@ -158,7 +160,7 @@ int main(int argc, char *argv[]) { /* write output file */ message("Writing output."); - write_output_single(&e, base_name, &us, &us); + write_output_single(&e, &us, &us); /* Clean-up */ message("Cleaning memory."); -- GitLab