From ee35158714aa2c5ec42ed5f78b9a6f05e35a58c8 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Sat, 23 May 2020 16:36:00 +0200 Subject: [PATCH] Also add an output type to the header of all the snapshots --- src/distributed_io.c | 1 + src/line_of_sight.c | 30 ++++++++++++++---------------- src/parallel_io.c | 1 + src/serial_io.c | 1 + src/single_io.c | 1 + 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/distributed_io.c b/src/distributed_io.c index 8a5a21f4fc..355fdb05ac 100644 --- a/src/distributed_io.c +++ b/src/distributed_io.c @@ -391,6 +391,7 @@ void write_output_distributed(struct engine* e, swift_type_count); io_write_attribute_i(h_grp, "NumFilesPerSnapshot", numFiles); io_write_attribute_i(h_grp, "ThisFile", mpi_rank); + io_write_attribute_s(h_grp, "OutputType", "Snapshot"); /* Close header */ H5Gclose(h_grp); diff --git a/src/line_of_sight.c b/src/line_of_sight.c index f5d2557bc2..a4c4aa9a8c 100644 --- a/src/line_of_sight.c +++ b/src/line_of_sight.c @@ -488,17 +488,19 @@ void write_hdf5_header(hid_t h_file, const struct engine *e, e->s->dim[2] * factor_length}; io_write_attribute(h_grp, "BoxSize", DOUBLE, dim, 3); - io_write_attribute(h_grp, "Time", DOUBLE, &dblTime, 1); - const int dimension = (int)hydro_dimension; - io_write_attribute(h_grp, "Dimension", INT, &dimension, 1); - io_write_attribute(h_grp, "Redshift", DOUBLE, &e->cosmology->z, 1); - io_write_attribute(h_grp, "Scale-factor", DOUBLE, &e->cosmology->a, 1); + io_write_attribute_d(h_grp, "Time", dblTime); + io_write_attribute_d(h_grp, "Dimension", (int)hydro_dimension); + io_write_attribute_d(h_grp, "Redshift", e->cosmology->z); + io_write_attribute_d(h_grp, "Scale-factor", e->cosmology->a); io_write_attribute_s(h_grp, "Code", "SWIFT"); io_write_attribute_s(h_grp, "RunName", e->run_name); - const int num_files_per_snapshot = 1; - io_write_attribute(h_grp, "NumFilesPerSnapshot", INT, &num_files_per_snapshot, - 1); - io_write_attribute_s(h_grp, "OutputType", "LineOfSight"); + + /* Store the time at which the snapshot was written */ + time_t tm = time(NULL); + struct tm *timeinfo = localtime(&tm); + char snapshot_date[64]; + strftime(snapshot_date, 64, "%T %F %Z", timeinfo); + io_write_attribute_s(h_grp, "Snapshot date", snapshot_date); /* GADGET-2 legacy values */ /* Number of particles of each type */ @@ -516,13 +518,9 @@ void write_hdf5_header(hid_t h_file, const struct engine *e, swift_type_count); io_write_attribute(h_grp, "NumPart_Total_HighWord", UINT, numParticlesHighWord, swift_type_count); - - /* Store the time at which the snapshot was written */ - time_t tm = time(NULL); - struct tm *timeinfo = localtime(&tm); - char snapshot_date[64]; - strftime(snapshot_date, 64, "%T %F %Z", timeinfo); - io_write_attribute_s(h_grp, "Snapshot date", snapshot_date); + io_write_attribute_i(h_grp, "NumFilesPerSnapshot", 1); + io_write_attribute_i(h_grp, "ThisFile", 0); + io_write_attribute_s(h_grp, "OutputType", "LineOfSight"); /* Close group */ H5Gclose(h_grp); diff --git a/src/parallel_io.c b/src/parallel_io.c index 5f26423800..be820e2ecd 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -1139,6 +1139,7 @@ void prepare_file(struct engine* e, const char* fileName, swift_type_count); io_write_attribute(h_grp, "NumFilesPerSnapshot", INT, &numFiles, 1); io_write_attribute_i(h_grp, "ThisFile", 0); + io_write_attribute_s(h_grp, "OutputType", "Snapshot"); /* Close header */ H5Gclose(h_grp); diff --git a/src/serial_io.c b/src/serial_io.c index 58b8f28451..478058299a 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -1006,6 +1006,7 @@ void write_output_serial(struct engine* e, swift_type_count); io_write_attribute(h_grp, "NumFilesPerSnapshot", INT, &numFiles, 1); io_write_attribute_i(h_grp, "ThisFile", 0); + io_write_attribute_s(h_grp, "OutputType", "Snapshot"); /* Close header */ H5Gclose(h_grp); diff --git a/src/single_io.c b/src/single_io.c index 2cc44cc59a..d25da91279 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -851,6 +851,7 @@ void write_output_single(struct engine* e, swift_type_count); io_write_attribute(h_grp, "NumFilesPerSnapshot", INT, &numFiles, 1); io_write_attribute_i(h_grp, "ThisFile", 0); + io_write_attribute_s(h_grp, "OutputType", "Snapshot"); /* Close header */ H5Gclose(h_grp); -- GitLab