From 997b8f161f82ca94a9f54aaef445a196b4018555 Mon Sep 17 00:00:00 2001
From: Stefan Arridge <stefan.arridge@durham.ac.uk>
Date: Wed, 14 Sep 2016 17:36:59 +0100
Subject: [PATCH] Added conversion of box dimensions

---
 src/parallel_io.c | 4 ++++
 src/serial_io.c   | 4 ++++
 src/single_io.c   | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/src/parallel_io.c b/src/parallel_io.c
index 0da34d4dad..0d7c0d5c3c 100644
--- a/src/parallel_io.c
+++ b/src/parallel_io.c
@@ -486,6 +486,10 @@ void read_ic_parallel(char* fileName, const struct UnitSystem* internal_units,
     }
   }
 
+  /* Convert the dimensions of the box */
+  for (int j = 0; j<3 ; j++)
+   dim[j] *= units_conversion_factor(ic_units, internal_units, UNIT_CONV_LENGTH);
+
   /* Allocate memory to store SPH particles */
   *Ngas = N[0];
   if (posix_memalign((void*)parts, part_align, (*Ngas) * sizeof(struct part)) !=
diff --git a/src/serial_io.c b/src/serial_io.c
index 6e26be1a33..ab4a81a8f1 100644
--- a/src/serial_io.c
+++ b/src/serial_io.c
@@ -528,6 +528,10 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units,
     H5Fclose(h_file);
   }
 
+  /* Convert the dimensions of the box */
+  for (int j = 0; j<3 ; j++)
+   dim[j] *= units_conversion_factor(ic_units, internal_units, UNIT_CONV_LENGTH);
+
   /* Now need to broadcast that information to all ranks. */
   MPI_Bcast(flag_entropy, 1, MPI_INT, 0, comm);
   MPI_Bcast(periodic, 1, MPI_INT, 0, comm);
diff --git a/src/single_io.c b/src/single_io.c
index 6cb7e83020..6d752388ad 100644
--- a/src/single_io.c
+++ b/src/single_io.c
@@ -433,6 +433,10 @@ void read_ic_single(char* fileName, const struct UnitSystem* internal_units,
             internal_units->UnitTemperature_in_cgs);
   }
 
+  /* Convert the dimensions of the box */
+  for (int j = 0; j<3 ; j++)
+   dim[j] *= units_conversion_factor(ic_units, internal_units, UNIT_CONV_LENGTH);
+
   /* Allocate memory to store SPH particles */
   *Ngas = N[0];
   if (posix_memalign((void*)parts, part_align, *Ngas * sizeof(struct part)) !=
-- 
GitLab