From 10e0c8db690ee6422bc8f8e2db00ad428d6a1386 Mon Sep 17 00:00:00 2001
From: Brandon Rodriguez <brodriguez8774@gmail.com>
Date: Mon, 22 Feb 2021 20:42:09 -0500
Subject: [PATCH] Correct grr counter initialization sometimes sending a
 negative value

---
 src/load_balance_schemes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/load_balance_schemes.c b/src/load_balance_schemes.c
index 156a12d..05290b2 100644
--- a/src/load_balance_schemes.c
+++ b/src/load_balance_schemes.c
@@ -289,7 +289,7 @@ void grr_main(thread_struct* thread_args_ptr) {
     int msg_received = 0;
     int* recv_array;
     int msg_status_flag;
-    int grr_counter;
+    int grr_counter = 0;
     int temp = 0;
     MPI_Request request_var;
 
@@ -348,7 +348,7 @@ void grr_main(thread_struct* thread_args_ptr) {
                     MPI_Recv(&temp, 1, MPI_INT, grr_index, tag_grr_query, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
 
                     grr_counter = (grr_counter + 1) % thread_args_ptr->total_processors;
-                    while (grr_counter == 0 || grr_counter == grr_index) {
+                    while (grr_counter <= 0 || grr_counter == grr_index) {
                         grr_counter = (grr_counter + 1) % thread_args_ptr->total_processors;
                     }
 
-- 
GitLab