This change just looks wrong - you can't split the variables on a "space"
as there is no way to know how many variables there might be, and thus how
to parse the rest of the cmd line. At best, you need a comma-delimited list.

Please fix this!
Ralph



On Tue, Apr 1, 2014 at 2:14 PM, <svn-commit-mai...@open-mpi.org> wrote:

> Author: miked (Mike Dubman)
> Date: 2014-04-01 17:14:31 EDT (Tue, 01 Apr 2014)
> New Revision: 31302
> URL: https://svn.open-mpi.org/trac/ompi/changeset/31302
>
> Log:
> opal: add mca param to control ranks env variables
>
> add -mca base_env_list "var1=val1 var2=val2 ..." mca parameter that can be
> used in mca param files
> or with -am app.conf mpirun commandline to set rank env variables with mca
> mechanism
>
> fixed by Elena, reviewed by Miked
>
> cmr=v1.8.1:reviewer=ompi-rm1.8
>
> Text files modified:
>    trunk/opal/mca/base/help-mca-var.txt |     5 +++++
>    trunk/opal/mca/base/mca_base_var.c   |    36
> ++++++++++++++++++++++++++++++++++++
>    trunk/opal/mca/base/mca_base_var.h   |     2 ++
>    trunk/orte/tools/orterun/orterun.c   |     2 ++
>    4 files changed, 45 insertions(+), 0 deletions(-)
>
> Modified: trunk/opal/mca/base/help-mca-var.txt
>
> ==============================================================================
> --- trunk/opal/mca/base/help-mca-var.txt        Tue Apr  1 16:57:12 2014
>      (r31301)
> +++ trunk/opal/mca/base/help-mca-var.txt        2014-04-01 17:14:31 EDT
> (Tue, 01 Apr 2014)      (r31302)
> @@ -121,3 +121,8 @@
>
>    Value:      %s
>    Source:     %s
> +#
> +[incorrect-env-list-param]
> +The format of mca_base_env_list parameter is incorrect. It should be
> +VAR1=VAL1 VAR2=VAL2 VAR3=VAL3 ...
> +  Value:      %s
>
> Modified: trunk/opal/mca/base/mca_base_var.c
>
> ==============================================================================
> --- trunk/opal/mca/base/mca_base_var.c  Tue Apr  1 16:57:12 2014
>  (r31301)
> +++ trunk/opal/mca/base/mca_base_var.c  2014-04-01 17:14:31 EDT (Tue, 01
> Apr 2014)      (r31302)
> @@ -61,6 +61,7 @@
>  static char *mca_base_var_override_file = NULL;
>  static char *mca_base_var_file_prefix = NULL;
>  static char *mca_base_param_file_path = NULL;
> +static char *mca_base_env_list = NULL;
>  static bool mca_base_var_suppress_override_warning = false;
>  static opal_list_t mca_base_var_file_values;
>  static opal_list_t mca_base_var_override_values;
> @@ -259,6 +260,41 @@
>      return OPAL_SUCCESS;
>  }
>
> +int mca_base_var_process_env_list(char ***context_env)
> +{
> +    int i, ret;
> +    char** tokens;
> +    char* ptr;
> +    char* param, *value;
> +    ret = mca_base_var_register ("opal", "mca", "base", "env_list",
> +                                 "Set SHELL env variables",
> +                                 MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
> OPAL_INFO_LVL_3,
> +                                 MCA_BASE_VAR_SCOPE_READONLY,
> &mca_base_env_list);
> +    if ((0 > ret) || (NULL == mca_base_env_list)) {
> +        return ret;
> +    }
> +    tokens = opal_argv_split(mca_base_env_list, ' ');
> +    if (NULL != tokens) {
> +        for (i = 0; NULL != tokens[i]; i++) {
> +            if (NULL == (ptr = strchr(tokens[i], '='))) {
> +                opal_show_help("help-mca-var.txt",
> "incorrect-env-list-param",
> +                        true, mca_base_env_list);
> +                opal_argv_free(tokens);
> +                return OPAL_ERROR;
> +            } else {
> +                param = strdup(tokens[i]);
> +                value = strchr(param, '=');
> +                *value = '\0';
> +                value++;
> +                opal_setenv(param, value, false, context_env);
> +                free(param);
> +            }
> +        }
> +        opal_argv_free(tokens);
> +    }
> +    return OPAL_SUCCESS;
> +}
> +
>  static int mca_base_var_cache_files(bool rel_path_search)
>  {
>      char *tmp;
>
> Modified: trunk/opal/mca/base/mca_base_var.h
>
> ==============================================================================
> --- trunk/opal/mca/base/mca_base_var.h  Tue Apr  1 16:57:12 2014
>  (r31301)
> +++ trunk/opal/mca/base/mca_base_var.h  2014-04-01 17:14:31 EDT (Tue, 01
> Apr 2014)      (r31302)
> @@ -716,6 +716,8 @@
>   */
>  OPAL_DECLSPEC int mca_base_var_dump(int vari, char ***out,
> mca_base_var_dump_type_t output_type);
>
> +OPAL_DECLSPEC int mca_base_var_process_env_list(char ***context_env);
> +
>  END_C_DECLS
>
>  #endif /* OPAL_MCA_BASE_VAR_H */
>
> Modified: trunk/orte/tools/orterun/orterun.c
>
> ==============================================================================
> --- trunk/orte/tools/orterun/orterun.c  Tue Apr  1 16:57:12 2014
>  (r31301)
> +++ trunk/orte/tools/orterun/orterun.c  2014-04-01 17:14:31 EDT (Tue, 01
> Apr 2014)      (r31302)
> @@ -1628,6 +1628,8 @@
>          goto cleanup;
>      }
>      mca_base_cmd_line_process_args(&cmd_line, app_env, &global_mca_env);
> +    mca_base_var_process_env_list(app_env);
> +
>
>      /* Is there an appfile in here? */
>
> _______________________________________________
> svn mailing list
> s...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/svn
>

Reply via email to