From 08b2c5fb2eb116b25f9affb92faff09a3dd89e3a Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Wed, 12 Apr 2017 09:49:58 +0100
Subject: [PATCH] Code formatting

---
 src/collectgroup.c | 15 ++++++---------
 src/collectgroup.h |  6 ++----
 src/engine.c       | 40 ++++++++++++++++++++++------------------
 src/space.c        | 12 ++++++------
 4 files changed, 36 insertions(+), 37 deletions(-)

diff --git a/src/collectgroup.c b/src/collectgroup.c
index d115f5ab1b..0b4ddc4057 100644
--- a/src/collectgroup.c
+++ b/src/collectgroup.c
@@ -89,7 +89,8 @@ void collectgroup1_apply(struct collectgroup1 *grp1, struct engine *e) {
  *
  * @param grp1 The #collectgroup1 to initialise
  * @param updates the number of updated hydro particles on this node this step.
- * @param g_updates the number of updated gravity particles on this node this step.
+ * @param g_updates the number of updated gravity particles on this node this
+ * step.
  * @param s_updates the number of updated star particles on this node this step.
  * @param ti_end_min the minimum end time for next time step after this step.
  * @param ti_end_max the maximum end time for next time step after this step.
@@ -98,10 +99,8 @@ void collectgroup1_apply(struct collectgroup1 *grp1, struct engine *e) {
  */
 void collectgroup1_init(struct collectgroup1 *grp1, size_t updates,
                         size_t g_updates, size_t s_updates,
-                        integertime_t ti_end_min,
-                        integertime_t ti_end_max,
-                        integertime_t ti_beg_max,
-                        int forcerebuild) {
+                        integertime_t ti_end_min, integertime_t ti_end_max,
+                        integertime_t ti_beg_max, int forcerebuild) {
   grp1->updates = updates;
   grp1->g_updates = g_updates;
   grp1->s_updates = s_updates;
@@ -133,8 +132,7 @@ void collectgroup1_reduce(struct collectgroup1 *grp1) {
 
   struct mpicollectgroup1 mpigrp12;
   if (MPI_Allreduce(&mpigrp11, &mpigrp12, 1, mpicollectgroup1_type,
-                    mpicollectgroup1_reduce_op, MPI_COMM_WORLD)
-      != MPI_SUCCESS)
+                    mpicollectgroup1_reduce_op, MPI_COMM_WORLD) != MPI_SUCCESS)
     error("Failed to reduce mpicollection1.");
 
   /* And update. */
@@ -147,7 +145,6 @@ void collectgroup1_reduce(struct collectgroup1 *grp1) {
 #endif
 }
 
-
 #ifdef WITH_MPI
 /**
  * @brief Do the reduction of two structs.
@@ -176,7 +173,7 @@ static void doreduce1(struct mpicollectgroup1 *mpigrp11,
  * @brief MPI reduce operator for #mpicollectgroup structures.
  */
 static void mpicollectgroup1_reduce(void *in, void *inout, int *len,
-                             MPI_Datatype *datatype) {
+                                    MPI_Datatype *datatype) {
 
   for (int i = 0; i < *len; ++i)
     doreduce1(&((struct mpicollectgroup1 *)inout)[0],
diff --git a/src/collectgroup.h b/src/collectgroup.h
index f9b8e9ccca..b0cbf0763d 100644
--- a/src/collectgroup.h
+++ b/src/collectgroup.h
@@ -48,10 +48,8 @@ void collectgroup_init();
 void collectgroup1_apply(struct collectgroup1 *grp1, struct engine *e);
 void collectgroup1_init(struct collectgroup1 *grp1, size_t updates,
                         size_t g_updates, size_t s_updates,
-                        integertime_t ti_end_min,
-                        integertime_t ti_end_max,
-                        integertime_t ti_beg_max,
-                        int forcerebuild);
+                        integertime_t ti_end_min, integertime_t ti_end_max,
+                        integertime_t ti_beg_max, int forcerebuild);
 void collectgroup1_reduce(struct collectgroup1 *grp1);
 
 #endif /* SWIFT_COLLECTGROUP_H */
diff --git a/src/engine.c b/src/engine.c
index 194b8af954..c8ce267982 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -2852,8 +2852,8 @@ void engine_collect_timestep_and_rebuild(struct engine *e, int apply) {
   }
 
   /* Store these in the temporary collection group. */
-  collectgroup1_init(&e->collect_group1, updates,g_updates, s_updates,
-                     ti_end_min,ti_end_max,ti_beg_max,e->forcerebuild);
+  collectgroup1_init(&e->collect_group1, updates, g_updates, s_updates,
+                     ti_end_min, ti_end_max, ti_beg_max, e->forcerebuild);
 
 /* Aggregate collective data from the different nodes for this step. */
 #ifdef WITH_MPI
@@ -2869,8 +2869,8 @@ void engine_collect_timestep_and_rebuild(struct engine *e, int apply) {
                       MPI_COMM_WORLD) != MPI_SUCCESS)
       error("Failed to aggregate ti_end_min.");
     if (in_i[0] != (long long)e->collect_group1.ti_end_min)
-      error("Failed to get same ti_end_min, is %lld, should be %lld",
-            in_i[0], e->collect_group1.ti_end_min);
+      error("Failed to get same ti_end_min, is %lld, should be %lld", in_i[0],
+            e->collect_group1.ti_end_min);
 
     long long in_ll[3], out_ll[3];
     out_ll[0] = updates;
@@ -2880,29 +2880,30 @@ void engine_collect_timestep_and_rebuild(struct engine *e, int apply) {
                       MPI_COMM_WORLD) != MPI_SUCCESS)
       error("Failed to aggregate particle counts.");
     if (in_ll[0] != (long long)e->collect_group1.updates)
-      error("Failed to get same updates, is %lld, should be %ld",
-            in_ll[0], e->collect_group1.updates);
+      error("Failed to get same updates, is %lld, should be %ld", in_ll[0],
+            e->collect_group1.updates);
     if (in_ll[1] != (long long)e->collect_group1.g_updates)
-      error("Failed to get same g_updates, is %lld, should be %ld",
-            in_ll[1], e->collect_group1.g_updates);
+      error("Failed to get same g_updates, is %lld, should be %ld", in_ll[1],
+            e->collect_group1.g_updates);
     if (in_ll[2] != (long long)e->collect_group1.s_updates)
-      error("Failed to get same s_updates, is %lld, should be %ld",
-            in_ll[2], e->collect_group1.s_updates);
+      error("Failed to get same s_updates, is %lld, should be %ld", in_ll[2],
+            e->collect_group1.s_updates);
 
     int buff = 0;
     if (MPI_Allreduce(&e->forcerebuild, &buff, 1, MPI_INT, MPI_MAX,
                       MPI_COMM_WORLD) != MPI_SUCCESS)
       error("Failed to aggregate the rebuild flag across nodes.");
     if (!!buff != !!e->collect_group1.forcerebuild)
-      error("Failed to get same rebuild flag from all nodes, is %d,"
-            "should be %d", buff, e->collect_group1.forcerebuild);
+      error(
+          "Failed to get same rebuild flag from all nodes, is %d,"
+          "should be %d",
+          buff, e->collect_group1.forcerebuild);
   }
 #endif
 #endif
 
   /* Apply to the engine, if requested. */
-  if (apply)
-    collectgroup1_apply(&e->collect_group1, e);
+  if (apply) collectgroup1_apply(&e->collect_group1, e);
 
   if (e->verbose)
     message("took %.3f %s.", clocks_from_ticks(getticks() - tic),
@@ -3222,8 +3223,10 @@ void engine_step(struct engine *e) {
     for (int i = 0; i < e->s->nr_cells; ++i)
       num_gpart_mpole += e->s->cells_top[i].multipole->m_pole.num_gpart;
     if (num_gpart_mpole != e->s->nr_gparts)
-      error("Multipoles don't contain the total number of gpart mpoles=%zd ngparts=%zd",
-	    num_gpart_mpole, e->s->nr_gparts);
+      error(
+          "Multipoles don't contain the total number of gpart mpoles=%zd "
+          "ngparts=%zd",
+          num_gpart_mpole, e->s->nr_gparts);
   }
 #endif
 
@@ -3245,7 +3248,8 @@ void engine_step(struct engine *e) {
   gravity_exact_force_check(e->s, e, 1e-1);
 #endif
 
-  if (!(e->policy & engine_policy_hydro) && (e->policy & engine_policy_self_gravity) && e->step % 20 == 0)
+  if (!(e->policy & engine_policy_hydro) &&
+      (e->policy & engine_policy_self_gravity) && e->step % 20 == 0)
     e->forcerebuild = 1;
 
   /* Collect the values of rebuild from all nodes and recover the (integer)
@@ -4075,7 +4079,7 @@ void engine_init(struct engine *e, struct space *s,
   /* Find the time of the first output */
   engine_compute_next_snapshot_time(e);
 
-  /* Construct types for MPI communications */
+/* Construct types for MPI communications */
 #ifdef WITH_MPI
   part_create_mpi_types();
   stats_create_MPI_type();
diff --git a/src/space.c b/src/space.c
index 04bb3a513f..d9ce5f5a58 100644
--- a/src/space.c
+++ b/src/space.c
@@ -2151,13 +2151,13 @@ void space_split_recursive(struct space *s, struct cell *c,
 
     /* Construct the multipole and the centre of mass*/
     if (s->gravity) {
-      if(gcount > 0) 
-	gravity_P2M(c->multipole, c->gparts, c->gcount);
+      if (gcount > 0)
+        gravity_P2M(c->multipole, c->gparts, c->gcount);
       else {
-	gravity_multipole_init(&c->multipole->m_pole);
-	c->multipole->CoM[0] = c->loc[0] + c->width[0] / 2.;
-	c->multipole->CoM[1] = c->loc[1] + c->width[1] / 2.;
-	c->multipole->CoM[2] = c->loc[2] + c->width[2] / 2.;
+        gravity_multipole_init(&c->multipole->m_pole);
+        c->multipole->CoM[0] = c->loc[0] + c->width[0] / 2.;
+        c->multipole->CoM[1] = c->loc[1] + c->width[1] / 2.;
+        c->multipole->CoM[2] = c->loc[2] + c->width[2] / 2.;
       }
     }
   }
-- 
GitLab