From db68a9f420fe15b6d86709f43ff8b4172e89a8e8 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Wed, 18 Jan 2023 21:39:41 +0800
Subject: [PATCH] Add the missing fields in the output header of FOF and LoS

---
 src/fof_catalogue_io.c | 8 ++++++++
 src/line_of_sight.c    | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/src/fof_catalogue_io.c b/src/fof_catalogue_io.c
index e7410a0b17..e437492209 100644
--- a/src/fof_catalogue_io.c
+++ b/src/fof_catalogue_io.c
@@ -103,6 +103,8 @@ void write_fof_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);
+  io_write_attribute(h_grp, "TotalNumberOfParticles", LONGLONG, N_total,
+                     swift_type_count);
   double MassTable[swift_type_count] = {0};
   io_write_attribute(h_grp, "MassTable", DOUBLE, MassTable, swift_type_count);
   io_write_attribute(h_grp, "InitialMassTable", DOUBLE,
@@ -113,7 +115,13 @@ void write_fof_hdf5_header(hid_t h_file, const struct engine* e,
                      swift_type_count);
   io_write_attribute_i(h_grp, "NumFilesPerSnapshot", e->nr_nodes);
   io_write_attribute_i(h_grp, "ThisFile", e->nodeID);
+  io_write_attribute_s(h_grp, "SelectOutput", "Default");
+  io_write_attribute_i(h_grp, "Virtual", 0);
+  const int to_write[swift_type_count] = {0};
+  io_write_attribute(h_grp, "CanHaveTypes", INT, to_write, swift_type_count);
   io_write_attribute_s(h_grp, "OutputType", "FOF");
+
+  /* FOF-specific counters */
   io_write_attribute_ll(h_grp, "NumGroups_Total", num_groups_total);
   io_write_attribute_ll(h_grp, "NumGroups_ThisFile", num_groups_this_file);
 
diff --git a/src/line_of_sight.c b/src/line_of_sight.c
index 40ddf36323..94291770bc 100644
--- a/src/line_of_sight.c
+++ b/src/line_of_sight.c
@@ -524,6 +524,8 @@ 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);
+  io_write_attribute(h_grp, "TotalNumberOfParticles", LONGLONG, N_total,
+                     swift_type_count);
   double MassTable[swift_type_count] = {0};
   io_write_attribute(h_grp, "MassTable", DOUBLE, MassTable, swift_type_count);
   io_write_attribute(h_grp, "InitialMassTable", DOUBLE,
@@ -536,6 +538,8 @@ void write_hdf5_header(hid_t h_file, const struct engine *e,
   io_write_attribute_i(h_grp, "ThisFile", 0);
   io_write_attribute_s(h_grp, "SelectOutput", "Default");
   io_write_attribute_i(h_grp, "Virtual", 0);
+  const int to_write[swift_type_count] = {1}; /* We can only have gas */
+  io_write_attribute(h_grp, "CanHaveTypes", INT, to_write, swift_type_count);
   io_write_attribute_s(h_grp, "OutputType", "LineOfSight");
 
   /* Close group */
-- 
GitLab