From fb349e04e55b5017f3b69f5bd5faf4ccda40c14b Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Mon, 4 Apr 2011 18:06:23 +0000
Subject: [PATCH] BGQ - fix to actually call the correct exe with runjob

---
 src/srun/opt.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/srun/opt.c b/src/srun/opt.c
index 918a263ef72..36cac6c9df9 100644
--- a/src/srun/opt.c
+++ b/src/srun/opt.c
@@ -1568,21 +1568,20 @@ static void _opt_args(int argc, char **argv)
 		while (rest[opt.argc] != NULL)
 			opt.argc++;
 	}
-#if defined HAVE_BG_FILES && HAVE_BGQ
+#if defined HAVE_BG_FILES && defined HAVE_BGQ
 	command_pos = 3;
 	opt.argc += command_pos;
 #endif
 
 	opt.argv = (char **) xmalloc((opt.argc + 1) * sizeof(char *));
 
-#if defined HAVE_BG_FILES && HAVE_BGQ
+#if defined HAVE_BG_FILES && defined HAVE_BGQ
 	opt.argv[0] = xstrdup(runjob_loc);
 	opt.argv[1] = xstrdup("--env_all");
 	opt.argv[2] = xstrdup("--exe");
 #endif
-
 	for (i = command_pos; i < opt.argc; i++)
-		opt.argv[i] = xstrdup(rest[i]);
+		opt.argv[i] = xstrdup(rest[i-command_pos]);
 	opt.argv[i] = NULL;	/* End of argv's (for possible execv) */
 
 	if (opt.multi_prog) {
@@ -1602,7 +1601,8 @@ static void _opt_args(int argc, char **argv)
 		}
 	}
 
-	if (opt.multi_prog && verify_multi_name(opt.argv[0], opt.ntasks))
+	if (opt.multi_prog && verify_multi_name(opt.argv[command_pos],
+						opt.ntasks))
 		exit(error_exit);
 }
 
-- 
GitLab