From 6bdcfd35ff0016970e3738887ecd811493ac68a2 Mon Sep 17 00:00:00 2001
From: "theodore.efremov" <theodore.efremov@cea.fr>
Date: Mon, 2 Dec 2024 09:57:50 +0100
Subject: [PATCH] Fixed convert parallelisation

---
 Projects/AlPhaPha/conversion/2024/ChainConvert.sh | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Projects/AlPhaPha/conversion/2024/ChainConvert.sh b/Projects/AlPhaPha/conversion/2024/ChainConvert.sh
index fdffedb5e..a3933aa0f 100644
--- a/Projects/AlPhaPha/conversion/2024/ChainConvert.sh
+++ b/Projects/AlPhaPha/conversion/2024/ChainConvert.sh
@@ -3,11 +3,15 @@
 max_jobs=20  # Set the maximum number of parallel jobs (cores)
 
 for run in {201..260}; do
-  while [ $(jobs | wc -l) -ge $max_jobs ]; do
+  while [ $(jobs -r | wc -l) -ge $max_jobs ]; do
     wait -n  # Wait for at least one job to finish
+    echo "A job has finished. $(jobs -r | wc -l) jobs remaining."
   done
-  root "convert.C($run)" &
+  root -b -q "convert.C($run)" &
+  echo "Started job for run $run. $(jobs -r | wc -l) jobs currently running."
 done
 
-wait  # Wait for all jobs to finish
+# Ensure all remaining jobs are completed
+wait
+echo "All jobs are complete."
 
-- 
GitLab