|
66 | 66 |
|
67 | 67 | log "Loading modules (& env variables) for $M$COMPUTER$CR on $M$CG$CR"'s:' |
68 | 68 |
|
69 | | -# Reset modules to default system configuration (unless Phoenix or Carpenter) |
70 | | -if [ "$u_c" != 'p' ] && [ "$u_c" != 'c' ]; then |
| 69 | +# Reset modules to default system configuration (unless Carpenter) |
| 70 | +if [ "$u_c" != 'c' ]; then |
71 | 71 | module reset > /dev/null 2>&1 |
72 | 72 | code="$?" |
73 | 73 |
|
|
79 | 79 | module purge > /dev/null 2>&1 |
80 | 80 | fi |
81 | 81 |
|
82 | | -ELEMENTS=($(__extract "$u_c-all") $(__extract "$u_c-$cg")) |
| 82 | +ELEMENTS="$(__extract "$u_c-all") $(__extract "$u_c-$cg")" |
| 83 | +MODULES=`echo "$ELEMENTS" | tr ' ' '\n' | grep -v = | xargs` |
| 84 | +VARIABLES=`echo "$ELEMENTS" | tr ' ' '\n' | grep = | xargs` |
83 | 85 |
|
84 | | -for element in ${ELEMENTS[@]}; do |
85 | | - if [[ "$element" != *'='* ]]; then |
86 | | - log " $ module load $M$element$CR" |
87 | | - module load "$element" > /dev/null 2>&1 |
| 86 | +log " $ module load $MODULES" |
| 87 | +if ! module load $MODULES; then |
| 88 | + error "Failed to load modules." |
88 | 89 |
|
89 | | - # Handle Success / Failure |
90 | | - code=$? |
91 | | - if [ "$code" != '0' ]; then |
92 | | - error "Failed to load module $M$element$CR:" |
93 | | - |
94 | | - # Run load again to show error message |
95 | | - module load "$element" |
| 90 | + return |
| 91 | +fi |
96 | 92 |
|
97 | | - return |
98 | | - fi |
99 | | - else |
100 | | - log " $ export $M$element$CR" |
101 | | - export $element |
102 | | - fi |
103 | | -done |
| 93 | +if [ $(echo "$VARIABLES" | grep = | wc -c) -gt 0 ]; then |
| 94 | + log " $ export $VARIABLES" |
| 95 | + export $VARIABLES > /dev/null |
| 96 | +fi |
104 | 97 |
|
105 | 98 | # Don't check for Cray paths on Carpenter, otherwise do check if they exist |
106 | 99 | if [ ! -z ${CRAY_LD_LIBRARY_PATH+x} ] && [ "$u_c" != 'c' ]; then |
|
0 commit comments