From 20fc8a25e29ab2454f73b5dcd6d45d0733ad0bb6 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Sun, 30 Dec 2018 23:03:07 +0100 Subject: [PATCH] Un-tested parallel-io version. --- src/common_io.c | 4 ++-- src/parallel_io.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/common_io.c b/src/common_io.c index 2842fad78d..1289e0a413 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -489,8 +489,8 @@ void io_write_cell_offsets(hid_t h_grp, const int cdim[3], MPI_COMM_WORLD); #endif - message("offsets=%lld %lld", offset_part[0], offset_part[1]); - message("counts=%lld %lld", count_part[0], count_part[1]); + /* Only rank 0 actually writes */ + if (nodeID != 0) return; /* Write some meta-information first */ hid_t h_subgrp = diff --git a/src/parallel_io.c b/src/parallel_io.c index 611e4af99f..170c1c67dd 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -1282,6 +1282,21 @@ void write_output_parallel(struct engine* e, const char* baseName, snprintf(fileName, FILENAME_BUFFER_SIZE, "%s_%04i.hdf5", baseName, e->snapshot_output_count); + if (nodeID == 0) { + h_file = H5Fopen(fileName, H5F_ACC_RDWR, H5P_DEFAULT); + if (h_file < 0) + error("Error while opening file '%s' on rank %d.", fileName, mpi_rank); + } else { + h_file = 0; + } + + io_write_cell_offsets(h_file, e->s->cdim, e->s->cells_top, e->s->nr_cells, + e->s->width, e->nodeID, N_total, offset); + + if (nodeID == 0) { + H5Fclose(h_file); + } + /* Prepare some file-access properties */ hid_t plist_id = H5Pcreate(H5P_FILE_ACCESS); -- GitLab