This source file includes following definitions.
- check_launch_environment
- get_rem_time
- finalize
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 #include "orte_config.h"
  13 #include "orte/types.h"
  14 #include "opal/types.h"
  15 
  16 #ifdef HAVE_UNISTD_H
  17 #include <unistd.h>
  18 #endif
  19 #include <ctype.h>
  20 
  21 #include "opal/util/argv.h"
  22 #include "opal/util/basename.h"
  23 #include "opal/util/opal_environ.h"
  24 
  25 #include "orte/runtime/orte_globals.h"
  26 #include "orte/util/name_fns.h"
  27 #include "orte/mca/schizo/base/base.h"
  28 
  29 #include "schizo_moab.h"
  30 
  31 static orte_schizo_launch_environ_t check_launch_environment(void);
  32 static void finalize(void);
  33 static long get_rem_time(void);
  34 
  35 orte_schizo_base_module_t orte_schizo_moab_module = {
  36     .check_launch_environment = check_launch_environment,
  37     .get_remaining_time = get_rem_time,
  38     .finalize = finalize
  39 };
  40 
  41 static char **pushed_envs = NULL;
  42 static char **pushed_vals = NULL;
  43 static orte_schizo_launch_environ_t myenv;
  44 static bool myenvdefined = false;
  45 
  46 static orte_schizo_launch_environ_t check_launch_environment(void)
  47 {
  48     int i;
  49 
  50     if (myenvdefined) {
  51         return myenv;
  52     }
  53     myenvdefined = true;
  54 
  55     
  56 
  57 
  58 
  59     if (NULL != orte_process_info.my_daemon_uri) {
  60         
  61         myenv = ORTE_SCHIZO_NATIVE_LAUNCHED;
  62         opal_argv_append_nosize(&pushed_envs, OPAL_MCA_PREFIX"ess");
  63         opal_argv_append_nosize(&pushed_vals, "pmi");
  64         goto setup;
  65     }
  66 
  67     
  68     if (NULL == getenv("PBS_NODEFILE")) {
  69         
  70         myenv = ORTE_SCHIZO_UNDETERMINED;
  71         return myenv;
  72     }
  73 
  74     
  75 
  76         opal_argv_append_nosize(&pushed_envs, OPAL_MCA_PREFIX"ess");
  77         opal_argv_append_nosize(&pushed_vals, "singleton");
  78         myenv = ORTE_SCHIZO_MANAGED_SINGLETON;
  79 
  80   setup:
  81       opal_output_verbose(1, orte_schizo_base_framework.framework_output,
  82                           "schizo:moab DECLARED AS %s", orte_schizo_base_print_env(myenv));
  83     if (NULL != pushed_envs) {
  84         for (i=0; NULL != pushed_envs[i]; i++) {
  85             opal_setenv(pushed_envs[i], pushed_vals[i], true, &environ);
  86         }
  87     }
  88     return myenv;
  89 }
  90 
  91 static long get_rem_time(void)
  92 {
  93     long time;
  94 
  95     MCCJobGetRemainingTime(NULL, NULL, &time, NULL);
  96     return time;
  97 }
  98 
  99 static void finalize(void)
 100 {
 101     int i;
 102 
 103     if (NULL != pushed_envs) {
 104         for (i=0; NULL != pushed_envs[i]; i++) {
 105             opal_unsetenv(pushed_envs[i], &environ);
 106         }
 107         opal_argv_free(pushed_envs);
 108         opal_argv_free(pushed_vals);
 109     }
 110 }