Skip to content
Snippets Groups Projects
Commit 9c699a3a authored by James Willis's avatar James Willis
Browse files

Check that stf output file directory exists.

parent 115966b6
No related branches found
No related tags found
1 merge request!578Swift velociraptor
......@@ -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;
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment