From f5a403c0f02c5d6598fb50e1afd58b5f0248c47b Mon Sep 17 00:00:00 2001
From: Pedro Gonnet <pedro.gonnet@durham.ac.uk>
Date: Tue, 17 Sep 2013 20:18:21 +0000
Subject: [PATCH] minor change to particle offset and count computation.

Former-commit-id: 80776e5216fecad62d2822399345bcb49e42dc74
---
 src/parallel_io.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/parallel_io.c b/src/parallel_io.c
index 13ba72df69..e881aba052 100644
--- a/src/parallel_io.c
+++ b/src/parallel_io.c
@@ -335,13 +335,9 @@ void read_ic_parallel ( char* fileName, double dim[3], struct part **parts,  int
   dim[1] = ( boxSize[1] < 0 ) ? boxSize[0] : boxSize[1];
   dim[2] = ( boxSize[2] < 0 ) ? boxSize[0] : boxSize[2];
 
-  /* Divide the particles among the tasks. The last task gets the extra particles */
-  *N = (int) (N_total / (long long) mpi_size);
-  if(mpi_rank == mpi_size - 1)
-    *N += N_total % (long long) mpi_size;
-
-  if(mpi_rank > 0)
-    offset = ( (long long) *N ) * ( (long long) mpi_rank - 1ll );
+  /* Divide the particles among the tasks. */
+  offset = mpi_rank * N_total / mpi_size;
+  *N = (mpi_rank + 1) * N_total / mpi_size - offset;
 
   /* message("Found %d particles in a %speriodic box of size [%f %f %f].",  */
   /* 	 *N, (periodic ? "": "non-"), dim[0], dim[1], dim[2]); */
-- 
GitLab