From cbb1e59112f3c55b2d9aacf02245c84266644fcb Mon Sep 17 00:00:00 2001
From: "Peter W. Draper" <p.w.draper@durham.ac.uk>
Date: Wed, 17 Jan 2018 17:55:15 +0000
Subject: [PATCH] Dump engine repartition params

---
 src/engine.c    |  7 ++++---
 src/partition.c | 25 +++++++++++++++++++++++++
 src/partition.h |  4 ++++
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/src/engine.c b/src/engine.c
index 27fcb11810..330e626ae4 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -5643,6 +5643,7 @@ void engine_struct_dump(struct engine *e, FILE *stream) {
   e->s->e = e;
   units_struct_dump(e->internal_units, stream);
   units_struct_dump(e->snapshotUnits, stream);
+  partition_struct_dump(e->reparttype, stream);
 
   /* repartition */
   /* physical constants */
@@ -5685,10 +5686,10 @@ void engine_struct_restore(struct engine *e, FILE *stream) {
 
   /* Now for the other pointers, these use their own save functions. */
   space_struct_restore(e->s, stream);
+  units_struct_restore(e->internal_units, stream);
+  units_struct_restore(e->snapshotUnits, stream);
+  partition_struct_restore(e->reparttype, stream);
 
-  /* internal units */
-  /* snapshot units */
-  /* repartition */
   /* physical constants */
   /* hydro props */
   /* gravity props */
diff --git a/src/partition.c b/src/partition.c
index 297ac71ac7..70777fe1a6 100644
--- a/src/partition.c
+++ b/src/partition.c
@@ -50,6 +50,7 @@
 #include "debug.h"
 #include "error.h"
 #include "partition.h"
+#include "restart.h"
 #include "space.h"
 #include "tools.h"
 
@@ -1250,3 +1251,27 @@ int partition_space_to_space(double *oldh, double *oldcdim, int *oldnodeIDs,
   /* Check we have all nodeIDs present in the resample. */
   return check_complete(s, 1, nr_nodes + 1);
 }
+
+/**
+ * @brief Write a repartition struct to the given FILE as a stream of bytes.
+ *
+ * @param reparttype the struct
+ * @param stream the file stream
+ */
+void partition_struct_dump(struct repartition *reparttype, FILE *stream) {
+    restart_write_blocks(reparttype, sizeof(struct repartition), 1, stream,
+                       "repartition params");
+}
+
+
+/**
+ * @brief Restore a repartition struct from the given FILE as a stream of
+ * bytes.
+ *
+ * @param reparttype the struct
+ * @param stream the file stream
+ */
+void partition_struct_restore(struct repartition *reparttype, FILE *stream) {
+  restart_read_blocks(reparttype, sizeof(struct repartition), 1, stream,
+                      "repartition params");
+}
diff --git a/src/partition.h b/src/partition.h
index c3eade190c..50a4456a2c 100644
--- a/src/partition.h
+++ b/src/partition.h
@@ -74,4 +74,8 @@ void partition_init(struct partition *partition,
                     struct repartition *repartition,
                     const struct swift_params *params, int nr_nodes);
 
+/* Dump/restore. */
+void partition_struct_dump(struct repartition *reparttype, FILE *stream);
+void partition_struct_restore(struct repartition *reparttype, FILE *stream);
+
 #endif /* SWIFT_PARTITION_H */
-- 
GitLab