From 431b13daf00c5f20c0064268c1a03d5d4b213ab9 Mon Sep 17 00:00:00 2001
From: lhausamm <loic_hausammann@hotmail.com>
Date: Tue, 3 Apr 2018 00:27:37 +0200
Subject: [PATCH] Change output fields structure to PartType%i

---
 examples/output_fields_example.yml | 29 ++++++++++++++++++++++++++---
 src/single_io.c                    |  4 ++--
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/examples/output_fields_example.yml b/examples/output_fields_example.yml
index 6ab88a74d4..9dabdac217 100644
--- a/examples/output_fields_example.yml
+++ b/examples/output_fields_example.yml
@@ -1,4 +1,27 @@
-OutputFields:
+# Gas
+PartType0:
+  Coordinates: 1 # Request to write output
+  Masses: 1
+  Velocities: 1
+  SmoothingLenght: 1
+  Entropy: 1
+  ParticleIDs: 1
+  Density: 1
+  InternalEnergy: 0 # Request to not write output
+  Pressure: 0
+  Potential: 0
+
+# Dark Matter
+PartType1:
   Coordinates: 1
-  Masses: 0
-  SmoothingLenght: 1
\ No newline at end of file
+  Velocities: 1
+  Masses: 1
+  ParticleIDs: 1
+  Potential: 0
+
+# Stars
+PartType2:
+  Coordinates: 1
+  Velocities: 1
+  Masses: 1
+  ParticleIDs: 1
\ No newline at end of file
diff --git a/src/single_io.c b/src/single_io.c
index dd1c132484..fec094d113 100644
--- a/src/single_io.c
+++ b/src/single_io.c
@@ -827,8 +827,8 @@ void write_output_single(struct engine* e, const char* baseName,
 
     /* Write everything */
     for (int i = 0; i < num_fields; ++i) {
-      char field[200] = "OutputFields:";
-      strcat(field, list[i].name);
+      char field[200];
+      sprintf(field, "ParticleType%i:%s", i, list[i].name);
       int should_write = parser_get_opt_param_int(output_fields, field,
                                                   list[i].default_output);
       if (should_write)
-- 
GitLab