Commit b56cb576 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'fix_directories' into 'master'

Use safe_checkdir() to create directories everywhere. Set the default directories to '.'

Closes #681 and #669

See merge request !1092
parents aabbaa0a ee591c3d
......@@ -2532,11 +2532,13 @@ void io_write_output_field_parameter(const char* filename, int with_cosmology) {
/**
* @brief Create the subdirectory for snapshots if the user demanded one.
*
* Does nothing if the directory is '.'
*
* @param dirname The name of the directory.
*/
void io_make_snapshot_subdir(const char* dirname) {
if (strnlen(dirname, PARSER_MAX_LINE_SIZE) > 0) {
if (strcmp(dirname, ".") != 0 && strnlen(dirname, PARSER_MAX_LINE_SIZE) > 0) {
safe_checkdir(dirname, /*create=*/1);
}
}
......
......@@ -116,8 +116,8 @@ enum engine_step_properties {
#define engine_max_sparts_per_ghost_default 1000
#define engine_star_resort_task_depth_default 2
#define engine_tasks_per_cell_margin 1.2
#define engine_default_stf_subdir_per_output ""
#define engine_default_snapshot_subdir ""
#define engine_default_stf_subdir_per_output "."
#define engine_default_snapshot_subdir "."
/**
* @brief The rank of the engine as a global variable (for messages).
......
......@@ -750,7 +750,7 @@ void parser_get_opt_param_string(struct swift_params *params, const char *name,
strcpy(retParam, params->data[i].value);
/* Ensure same behavior if called multiple times for same parameter */
if (params->data[i].is_default && !strcmp(def, retParam))
if (params->data[i].is_default && strcmp(def, retParam) != 0)
error(
"Tried parsing %s again but cannot parse a parameter with "
"two different default value ('%s' != '%s')",
......
......@@ -653,11 +653,9 @@ void velociraptor_invoke(struct engine *e, const int linked_with_snap) {
e->snapshot_subdir) >= FILENAME_BUFFER_SIZE) {
error("FILENAME_BUFFER_SIZE is to small for snapshot directory name!");
}
if (engine_rank == 0) io_make_snapshot_subdir(e->snapshot_subdir);
#ifdef WITH_MPI
if (engine_rank == 0) mkdir(outputDirName, 0777);
MPI_Barrier(MPI_COMM_WORLD);
#else
mkdir(outputDirName, 0777);
#endif
}
......@@ -670,11 +668,9 @@ void velociraptor_invoke(struct engine *e, const int linked_with_snap) {
error(
"FILENAME_BUFFER_SIZE is to small for Velociraptor directory name!");
}
if (engine_rank == 0) io_make_snapshot_subdir(subDirName);
#ifdef WITH_MPI
if (engine_rank == 0) mkdir(subDirName, 0777);
MPI_Barrier(MPI_COMM_WORLD);
#else
mkdir(subDirName, 0777);
#endif
} else {
/* Not making separate directories so subDirName=outputDirName */
......
......@@ -214,7 +214,7 @@ int main(int argc, char *argv[]) {
parser_get_opt_param_string(&param_file, "MetaData:run_name", run_name_1,
"Untitled SWIFT simulation");
parser_get_opt_param_string(&param_file, "MetaData:run_name", run_name_2,
"banana");
"Untitled SWIFT simulation");
assert(strcmp(run_name_1, run_name_2) == 0);
return 0;
......
#!/bin/bash
rm -f parser_output.yml
./testParser @srcdir@/testParserInput.yaml
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment