1
1

Fix orterun so it does not get influenced by an application's argv set.

For example, if I have an application that, internal to the application, takes
the argument '-mca foo bar' we do not want orterun to pick up this argument and
pass it through the system.

So the following
{{{
 shell$ mpirun -np 2 -mca btl tcp,self ./myapp -mca foo bar
}}}

orterun should pick up {{{-mca btl tcp,self}}} but not {{{-mca foo bar}}} which
it was previous to this commit.

I tested command line runs and runs with app files to confirm this patch works.

This commit was SVN r16431.
Этот коммит содержится в:
Josh Hursey 2007-10-11 18:33:40 +00:00
родитель 1299ed433e
Коммит 31e9369e8b

Просмотреть файл

@ -1444,16 +1444,24 @@ static int create_app(int argc, char* argv[], orte_app_context_t **app_ptr,
opal_argv_append(&new_argc, &new_argv, str);
save_arg = false;
}
/* save any mca command line args so they can be passed
* separately to the daemons
* separately to the daemons.
* Only do so here if we are going to parse an appfile later.
* Use Case:
* $ cat launch.appfile
* -np 1 -mca aaa bbb ./my-app -mca ccc ddd
* -np 1 -mca aaa bbb ./my-app -mca eee fff
* $ mpirun -np 2 -mca foo bar --app launch.appfile
* Only pick up '-mca foo bar' on this pass.
*/
else if (0 == strcmp("-mca", argv[i]) ||
(0 == strcmp("--mca", argv[i]))) {
if (NULL != orterun_globals.appfile) {
if (0 == strcmp("-mca", argv[i]) ||
0 == strcmp("--mca", argv[i]) ) {
opal_argv_append_nosize(&orted_cmd_line, argv[i]);
opal_argv_append_nosize(&orted_cmd_line, argv[i+1]);
opal_argv_append_nosize(&orted_cmd_line, argv[i+2]);
}
}
/* If this token was C/N map data, save it */
@ -1508,6 +1516,26 @@ static int create_app(int argc, char* argv[], orte_app_context_t **app_ptr,
goto cleanup;
}
/*
* Determine the application name, and location in the argv so we do not
* accidentally pick of the application's arguments while trying to get
* our own. Example:
* mpirun -np 2 -mca foo bar ./my-app -mca bip bop
* We want to pick up '-mca foo bar' but not '-mca bip bop'
*/
for (i = 0; i < (argc - count); ++i) {
/* save any mca command line args so they can be passed
* separately to the daemons
*/
if (0 == strcmp("-mca", argv[i]) ||
0 == strcmp("--mca", argv[i]) ) {
opal_argv_append_nosize(&orted_cmd_line, argv[i]);
opal_argv_append_nosize(&orted_cmd_line, argv[i+1]);
opal_argv_append_nosize(&orted_cmd_line, argv[i+2]);
i += 2;
}
}
/* Grab all OMPI_* environment variables */
app->env = opal_argv_copy(*app_env);
@ -1741,6 +1769,15 @@ static int parse_appfile(char *filename, char ***env)
char bogus[] = "bogus ";
char **tmp_env;
/*
* Make sure to clear out this variable so we don't do anything odd in
* app_create()
*/
if( NULL != orterun_globals.appfile ) {
free( orterun_globals.appfile );
orterun_globals.appfile = NULL;
}
/* Try to open the file */
fp = fopen(filename, "r");