SWIFT crashes when writing snapshots after a restart
@matthieu: I opened a new issue here to gather debugging output/data so we don't do things twice.
Current master branch, code configured with
--disable-mpi --disable-doxygen-doc --enable-cell-graph --disable-hand-vec --with-rt=none --with-hydro=anarchy-du --enable-debug --enable-debugging-checks --enable-task-debugging
compiled with gcc 10.2.0.
Running the examples/HydroTests/UniformBox_3D
example and restarting from step 12 consistently gives me an error:
[00003.7] tools.c:safe_checkdir():1090: Failed to create directory (No such file or directory)
I tracked the issue down to single_io.c:write_output_single()
, where the call to output_options_get_basename(...)
gives different results.
I added more messages to output_options_get_basename()
:
void output_options_get_basename(const struct output_options* output_options,
const char* selection_name,
const char* default_subdirname,
const char* default_basename,
char subdir_name[FILENAME_BUFFER_SIZE],
char basename[FILENAME_BUFFER_SIZE]) {
/* Get the ID of the output selection in the structure */
int selection_id =
parser_get_section_id(output_options->select_output, selection_name);
message("check 1.0 - selection_id=%d", selection_id);
/* Special treatment for absent `Default` section */
if (selection_id < 0) {
selection_id = output_options->select_output->sectionCount;
message("check 1.1 - selection_id=%d", selection_id);
}
/* If the default keyword is found, we use the name provided
* in the param file (not the select output!), aka. the argument
* of the function. */
message("check 1.1.1 - output_options->basenames[]='%s'; select_output_default_basename='%s'",
output_options->basenames[selection_id], select_output_default_basename);
if (strcmp(output_options->basenames[selection_id],
select_output_default_basename) == 0) {
sprintf(basename, "%s", default_basename);
message("check 1.2 - basename '%s'; '%s';", basename, default_basename);
} else {
sprintf(basename, "%s", output_options->basenames[selection_id]);
message("check 1.3 - basename '%s'; '%s';", basename, default_basename);
}
/* If the default keyword is found, we use the subdir name provided
* in the param file (not the select output!), aka. the argument
* of the function. */
if (strcmp(output_options->subdir_names[selection_id],
select_output_default_subdir_name) == 0) {
sprintf(subdir_name, "%s", default_subdirname);
message("check 1.4 - subdir_name '%s'; '%s';", subdir_name, default_subdirname);
} else {
sprintf(subdir_name, "%s", output_options->subdir_names[selection_id]);
message("check 1.5 - subdir_name '%s'; '%s';", subdir_name, default_subdirname);
}
}
The output when starting the simulation from scratch:
[00028.1] output_options_get_basename: check 1.0 - selection_id=0
[00028.1] output_options_get_basename: check 1.1.1 - output_options->basenames[]='Standard'; select_output_default_basename='Standard'
[00028.1] output_options_get_basename: check 1.2 - basename 'uniformBox'; 'uniformBox';
[00028.1] output_options_get_basename: check 1.4 - subdir_name '.'; '.';
The output when restarting from step 12:
[00003.5] output_options_get_basename: check 1.0 - selection_id=0
[00003.5] output_options_get_basename: check 1.1.1 - output_options->basenames[]=''; select_output_default_basename='Standard'
[00003.5] output_options_get_basename: check 1.3 - basename ''; 'uniformBox';
[00003.5] output_options_get_basename: check 1.5 - subdir_name ''; '.';
So somehow the output_options->basenames[0]
values are changed when the code restarts.
Edited by Mladen Ivkovic