diff --git a/examples/main.c b/examples/main.c index 46bae3171b98bcbce9bbf9363bade711f01606a6..74b8d9ddda186ac8a701d4e472c67a38deb03275 100644 --- a/examples/main.c +++ b/examples/main.c @@ -471,6 +471,17 @@ int main(int argc, char *argv[]) { if (access(dirp, W_OK | X_OK) != 0) { error("Cannot write snapshots in directory %s (%s)", dirp, strerror(errno)); } + + /* Check that we can write the structure finding catalogues by testing if the output + * directory exists and is searchable and writable. */ + if(with_structure_finding) { + char stfbasename[PARSER_MAX_LINE_SIZE]; + parser_get_param_string(params, "StructureFinding:output_file_name", stfbasename); + const char *stfdirp = dirname(stfbasename); + if (access(stfdirp, W_OK | X_OK) != 0) { + error("Cannot write stf catalogues in directory %s (%s)", stfdirp, strerror(errno)); + } + } /* Prepare the domain decomposition scheme */ struct repartition reparttype; diff --git a/src/velociraptor_interface.c b/src/velociraptor_interface.c index dda8f884ed18ed9054bfddb07f7178595e74476e..699e403586f18d44745f6da653c41a9875ea31b7 100644 --- a/src/velociraptor_interface.c +++ b/src/velociraptor_interface.c @@ -25,6 +25,7 @@ /* Config parameters. */ #include "../config.h" +/* Some standard headers. */ #include <errno.h> #include <libgen.h> #include <unistd.h> @@ -32,6 +33,9 @@ /* This object's header. */ #include "velociraptor_interface.h" +/* Local includes. */ +#include "common_io.h" + /** * @brief Initialise VELOCIraptor with input and output file names along with cosmological info needed to run. * @@ -161,18 +165,15 @@ void velociraptor_invoke(struct engine *e) { //for(int i=0; i<nr_gparts; i++) message("Potential: %f", gparts[i].potential); - /* Check that we can write the snapshots by testing if the output - * directory exists and is searchable and writable. */ - char outputfilename[PARSER_MAX_LINE_SIZE]; - parser_get_param_string(e->parameter_file, "StructureFinding:output_file_name", outputfilename); - const char *dirp = dirname(outputfilename); - if (access(dirp, W_OK | X_OK) != 0) { - error("Cannot write snapshots in directory %s (%s)", dirp, strerror(errno)); - } - - message("Output file name: %s", outputfilename); - - InvokeVelociraptor(nr_gparts, gparts, cell_node_ids, outputfilename); + /* Read output base name and append with the step number */ + char outputbasename[PARSER_MAX_LINE_SIZE]; + parser_get_param_string(e->parameter_file, "StructureFinding:output_file_name", outputbasename); + + char outputFileName[FILENAME_BUFFER_SIZE]; + snprintf(outputFileName, FILENAME_BUFFER_SIZE, "%s_%04i.VELOCIraptor", outputbasename, + e->step); + + InvokeVelociraptor(nr_gparts, gparts, cell_node_ids, outputFileName); /* Free cell node ids after VELOCIraptor has copied them. */ free(cell_node_ids);