Commit 6d512f84 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Use the new safe_checkdir() function in the distributed i/o

parent e7f1197b
......@@ -21,6 +21,9 @@
#include "../config.h"
/* Local includes */
#include "engine.h"
/* Load the correct star type */
#if defined(BLACK_HOLES_NONE)
#include "./black_holes/Default/black_holes_io.h"
......
......@@ -54,6 +54,7 @@
#include "part_type.h"
#include "star_formation_io.h"
#include "stars_io.h"
#include "tools.h"
#include "tracers_io.h"
#include "units.h"
#include "velociraptor_io.h"
......@@ -220,16 +221,19 @@ void write_distributed_array(const struct engine* e, hid_t grp,
* @brief Writes a snapshot distributed into multiple files.
*
* @param e The engine containing all the system.
* @param baseName The common part of the snapshot file name.
* @param internal_units The #unit_system used internally
* @param snapshot_units The #unit_system used in the snapshots
* @param mpi_rank The rank number of the calling MPI rank.
* @param mpi_size the number of MPI ranks.
* @param comm The communicator used by the MPI ranks.
* @param info The MPI information object.
*
* Creates a series of HDF5 output files (1 per MPI node) as a snapshot.
* Writes the particles contained in the engine.
* If such files already exist, it is erased and replaced by the new one.
* The companion XMF file is also updated accordingly.
*/
void write_output_distributed(struct engine* e, const char* baseName,
void write_output_distributed(struct engine* e,
const struct unit_system* internal_units,
const struct unit_system* snapshot_units,
const int mpi_rank, const int mpi_size,
......@@ -317,8 +321,8 @@ void write_output_distributed(struct engine* e, const char* baseName,
}
/* Create the directory */
if (mpi_rank == 0) mkdir(dirName, 0777);
MPI_Barrier(MPI_COMM_WORLD);
if (mpi_rank == 0) safe_checkdir(dirName, /*create=*/1);
MPI_Barrier(comm);
/* Compute offset in the file and total number of particles */
const long long N[swift_type_count] = {Ngas_written, Ndm_written,
......
......@@ -29,13 +29,10 @@
#include <mpi.h>
#endif
/* Includes. */
#include "engine.h"
#include "io_properties.h"
#include "part.h"
#include "units.h"
struct engine;
struct unit_system;
void write_output_distributed(struct engine* e, const char* baseName,
void write_output_distributed(struct engine* e,
const struct unit_system* internal_units,
const struct unit_system* snapshot_units,
int mpi_rank, int mpi_size, MPI_Comm comm,
......
......@@ -3616,9 +3616,8 @@ void engine_dump_snapshot(struct engine *e) {
if (e->snapshot_distributed) {
write_output_distributed(e, snapshotBase, e->internal_units,
e->snapshot_units, e->nodeID, e->nr_nodes,
MPI_COMM_WORLD, MPI_INFO_NULL);
write_output_distributed(e, e->internal_units, e->snapshot_units, e->nodeID,
e->nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL);
} else {
#if defined(HAVE_PARALLEL_HDF5)
......
......@@ -28,10 +28,10 @@
#include <mpi.h>
/* Includes. */
#include "engine.h"
#include "io_properties.h"
#include "part.h"
#include "units.h"
struct engine;
struct unit_system;
void read_ic_parallel(char* fileName, const struct unit_system* internal_units,
double dim[3], struct part** parts, struct gpart** gparts,
......
......@@ -30,10 +30,10 @@
#endif
/* Includes. */
#include "engine.h"
#include "io_properties.h"
#include "part.h"
#include "units.h"
struct engine;
struct unit_system;
void read_ic_serial(char* fileName, const struct unit_system* internal_units,
double dim[3], struct part** parts, struct gpart** gparts,
......
......@@ -24,11 +24,11 @@
#if defined(HAVE_HDF5) && !defined(WITH_MPI)
/* Includes. */
#include "engine.h"
#include "io_properties.h"
/* Local includes */
#include "part.h"
#include "units.h"
struct engine;
struct unit_system;
void read_ic_single(const char* fileName,
const struct unit_system* internal_units, double dim[3],
......
Markdown is supported
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