-
Notifications
You must be signed in to change notification settings - Fork 14
/
machine-setup.sh
157 lines (148 loc) · 5.13 KB
/
machine-setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Create a test function for sh vs. bash detection. The name is
# randomly generated to reduce the chances of name collision.
__ms_function_name="setup__test_function__$$"
eval "$__ms_function_name() { /bin/true ; }"
# Determine which shell we are using
__ms_ksh_test=$( eval '__text="text" ; if [[ $__text =~ ^(t).* ]] ; then printf "%s" ${.sh.match[1]} ; fi' 2> /dev/null | cat )
__ms_bash_test=$( eval 'if ( set | grep '$__ms_function_name' | grep -v name > /dev/null 2>&1 ) ; then echo t ; fi ' 2> /dev/null | cat )
if [[ ! -z "$__ms_ksh_test" ]] ; then
__ms_shell=ksh
elif [[ ! -z "$__ms_bash_test" ]] ; then
__ms_shell=bash
else
# Not bash or ksh, so assume sh.
__ms_shell=sh
fi
target=""
USERNAME=`echo $LOGNAME | awk '{ print tolower($0)'}`
if [[ -d /lfs4 ]] ; then
# We are on NOAA Jet
if ( ! eval module help > /dev/null 2>&1 ) ; then
echo load the module command 1>&2
source /apps/lmod/lmod/init/$__ms_shell
fi
target=jet
module purge
elif [[ -d /scratch1 ]] ; then
# We are on NOAA Hera
if ( ! eval module help > /dev/null 2>&1 ) ; then
echo load the module command 1>&2
source /apps/lmod/lmod/init/$__ms_shell
fi
target=hera
module purge
elif [[ -d /gpfs/hps && -e /etc/SuSE-release ]] ; then
# We are on NOAA Luna or Surge
if ( ! eval module help > /dev/null 2>&1 ) ; then
echo load the module command 1>&2
source /opt/modules/default/init/$__ms_shell
fi
target=wcoss_cray
# Silence the "module purge" to avoid the expected error messages
# related to modules that load modules.
module purge > /dev/null 2>&1
module use /usrx/local/prod/modulefiles
module use /gpfs/hps/nco/ops/nwprod/lib/modulefiles
module use /gpfs/hps/nco/ops/nwprod/modulefiles
module use /opt/cray/alt-modulefiles
module use /opt/cray/craype/default/alt-modulefiles
module use /opt/cray/ari/modulefiles
module use /opt/modulefiles
module purge > /dev/null 2>&1
# Workaround until module issues are fixed:
#unset _LMFILES_
#unset LOADEDMODULES
echo y 2> /dev/null | module clear > /dev/null 2>&1
module use /usrx/local/prod/modulefiles
module use /gpfs/hps/nco/ops/nwprod/lib/modulefiles
module use /gpfs/hps/nco/ops/nwprod/modulefiles
module use /opt/cray/alt-modulefiles
module use /opt/cray/craype/default/alt-modulefiles
module use /opt/cray/ari/modulefiles
module use /opt/modulefiles
module load modules
elif [[ -L /usrx && "$( readlink /usrx 2> /dev/null )" =~ dell ]] ; then
# We are on NOAA Venus or Mars
if ( ! eval module help > /dev/null 2>&1 ) ; then
echo load the module command 1>&2
source /usrx/local/prod/lmod/lmod/init/$__ms_shell
fi
target=wcoss_dell_p3
module purge
elif [[ "$(hostname)" == derecho* ]]; then
target=derecho
module purge
elif [[ -d /glade ]] ; then
# We are on NCAR Cheyenne
if ( ! eval module help > /dev/null 2>&1 ) ; then
echo load the module command 1>&2
. /glade/u/apps/ch/opt/lmod/8.1.7/lmod/8.1.7/init/sh
fi
target=cheyenne
module purge
elif [[ -d /lustre && -d /ncrc ]] ; then
# We are on GAEA.
if ( ! eval module help > /dev/null 2>&1 ) ; then
# We cannot simply load the module command. The GAEA
# /etc/profile modifies a number of module-related variables
# before loading the module command. Without those variables,
# the module command fails. Hence we actually have to source
# /etc/profile here.
source /etc/profile
__ms_source_etc_profile=yes
else
__ms_source_etc_profile=no
fi
module purge > /dev/null 2>&1
module purge
# clean up after purge
unset _LMFILES_
unset _LMFILES_000
unset _LMFILES_001
unset LOADEDMODULES
module load modules
if [[ -d /opt/cray/ari/modulefiles ]] ; then
module use -a /opt/cray/ari/modulefiles
fi
if [[ -d /opt/cray/pe/ari/modulefiles ]] ; then
module use -a /opt/cray/pe/ari/modulefiles
fi
if [[ -d /opt/cray/pe/craype/default/modulefiles ]] ; then
module use -a /opt/cray/pe/craype/default/modulefiles
fi
if [[ -s /etc/opt/cray/pe/admin-pe/site-config ]] ; then
source /etc/opt/cray/pe/admin-pe/site-config
fi
if [[ "$__ms_source_etc_profile" == yes ]] ; then
source /etc/profile
unset __ms_source_etc_profile
fi
target=gaea
elif [[ "$(hostname)" =~ "Orion" ]]; then
target="orion"
module purge
elif [[ "$(hostname)" =~ "hercules" ]]; then
target="hercules"
module purge
elif [[ "$(hostname)" =~ "ln" ]]; then
source /scratch/ywang/tools/lmod/lmod/init/bash
target="vecna"
elif [[ -d /work/00315 && -d /scratch/00315 ]] ; then
target=stampede
module purge
elif [[ -d /data/prod ]] ; then
# We are on SSEC S4
if ( ! eval module help > /dev/null 2>&1 ) ; then
echo load the module command 1>&2
source /usr/share/lmod/lmod/init/$__ms_shell
fi
target=s4
module purge
else
echo WARNING: UNKNOWN PLATFORM 1>&2
fi
unset __ms_shell
unset __ms_ksh_test
unset __ms_bash_test
unset $__ms_function_name
unset __ms_function_name