-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathg5_modules
executable file
·428 lines (338 loc) · 11.8 KB
/
g5_modules
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
#!/bin/csh -f
########################################################################
#
# Name: g5_modules
#
# Purposes -
# * provide single location for BASEDIR and module values
# * initialize the following:
# - set BASEDIR
# - update LD_LIBRARY_PATH with BASEDIR lib (if useldlibs is set)
# - load library modules
# * echo expected BASEDIR and library module values when queried
#
# Notes:
# 1. The script will not function correctly if the scriptname
# definition within the script is incorrect.
# 2. Type "g5_modules help" for usage information.
#
# Perl Notes:
# ==========
# 1. You cannot "source" this file from a perl script.
# 2. Instead use the following in your perl script:
# #--------------------------------
# use Env;
# do "g5_modules_perl_wrapper";
# #--------------------------------
# 3. Use the g5_modules_perl_wrapper file located in the build's bin
# directory, where a copy of g5_modules also resides. This is important
# since g5_modules_perl_wrapper uses g5_modules and expects it to be in
# the same directory.
#
# Bash Notes:
# ==========
# If you are in a bash shell, then source the g5_modules.sh script.
# > source g5_modules.sh
#
# REVISION HISTORY
# 31Aug2007 Stassi Initial version of code
# 15Oct2007 Stassi Expand list of machines and include defaults
# 15Dec2007 Stassi Added LD_LIBRARY_PATH functionality
# 21Jul2008 Takacs New modules and BASEDIR on discover after OS upgrade
# 13Apr2009 Stassi Updated for pleiades
# 22Apr2010 Kokron Updated for Fortuna-2.1 on pleiades
# 21Jul2011 Kokron Overlay older MKL module as on discover to gain reproducible results from dgeev in GSI
# 24Aug2012 Stassi Added sh option to write bash source-able file
# 03Nov2016 Thompson Remove JIBB
########################################################################
# NOTE: Spell out scriptname--DO NOT SET EQUAL TO $0!
#----------------------------------------------------
set scriptname = g5_modules
if ( $scriptname == "$0:t" ) then
set sourced = 0
else
set sourced = 1
endif
# check for improper usage
#-------------------------
if (! $sourced && ! $#argv) goto usage # not sourced and no args
if ( $sourced && $#argv) goto usage # sourced with args
# get architecture, machine, and node information
#------------------------------------------------
set arch = `uname -s`
set mach = `uname -m`
set node = `uname -n`
# Find site
# ---------
if (($node =~ discover*) || ($node =~ borg*) || \
($node =~ dali*) || ($node =~ warp*)) then
set site = "NCCS"
else if (($node =~ pfe*) || ($node =~ afe*) || \
($node =~ r[0-9]*i[0-9]*n[0-9]*) || \
($node =~ r[0-9]*c[0-9]*t[0-9]*n[0-9]*)) then
# We are on NAS...
set site = "NAS"
else if ( -d /ford1/share/gmao_SIteam/ && -d /ford1/local/ && $arch == Linux ) then
set site = "GMAO.desktop"
else
set site = $node
endif
alias echo2 "echo \!* > /dev/stderr"
# get values
#-----------
if ($mach == x86_64) goto X86_64
if ($mach == arm64) goto ARM64
# ERROR -- unknown architecture/machine
#--------------------------------------
echo2 "${scriptname}: >>>WARNING<<< unrecognizable arch/machine = $arch/$mach"
echo 0 # indicating error condition
exit 8
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# X86_64 values (Linux)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
X86_64:
#==================#
# X86_64 default #
#==================#
set modinit = DUMMY
set usemodules = 0
set useldlibs = 0
#========#
# NCCS #
#========#
if ( $site == NCCS ) then
set basedir = /discover/swdev/gmao_SIteam/Baselibs/ESMA-Baselibs-8.13.0/x86_64-pc-linux-gnu/ifort_2021.13.0-intelmpi_2021.13.0-SLES15
set mod1 = python/GEOSpyD/24.11.3-0/3.12
set mod2 = GEOSenv
set mod3 = comp/gcc/12.3.0
set mod4 = comp/intel/2024.2.0
set mod5 = mpi/impi/2021.13
set mod6 = other/jemalloc/5.3.0
set mods = ( $mod1 $mod2 $mod3 $mod4 $mod5 $mod6 )
set modinit = /usr/share/modules/init/csh
set usemod1 = /discover/swdev/gmao_SIteam/modulefiles-SLES15
set usemods = ( $usemod1 )
set usemodules = 1
set useldlibs = 1
#=======#
# NAS #
#=======#
else if ( $site == NAS ) then
set basedir = /nobackup/gmao_SIteam/Baselibs/ESMA-Baselibs-8.13.0/x86_64-pc-linux-gnu/ifort_2021.13.0-mpt_2.30
set mod1 = python/GEOSpyD/24.11.3-0/3.12
set mod2 = GEOSenv
set mod3 = comp-gcc/12.3.0-TOSS4
set mod4 = comp-intel/2024.2.0-ifort
set mod5 = mpi-hpe/mpt
set mods = ( $mod1 $mod2 $mod3 $mod4 $mod5 )
set modinit = /usr/share/modules/init/tcsh
set usemod1 = /u/scicon/tools/modulefiles
set usemod2 = /nobackup/gmao_SIteam/modulefiles
set usemod3 = /nasa/modulefiles/testing
set usemods = ( $usemod1 $usemod2 $usemod3 )
set usemodules = 1
set useldlibs = 0
#=================#
# GMAO DESKTOP #
#=================#
else if ( $site == GMAO.desktop ) then
set basedir=/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-8.13.0/x86_64-pc-linux-gnu/ifort_2021.13.0-intelmpi_2021.13
set mod1 = other/python/GEOSpyD/24.11.3-0/3.12
set mod2 = GEOSenv
set mod3 = comp/gcc/12.1.0
set mod4 = comp/intel/2024.2-ifort
set mod5 = mpi/impi/2021.13
set mod6 = other/jemalloc/5.3.0
set mods = ( $mod1 $mod2 $mod3 $mod4 $mod5 $mod6 )
set modinit = /usr/share/Modules/init/tcsh
set usemod1 = /ford1/share/gmao_SIteam/modulefiles
set usemods = ( $usemod1 )
set usemodules = 1
# Testing shows adding BASEDIR lib to LD_LIBRARY_PATH
# causes issues with the TCL modules on the GMAO machines
set useldlibs = 0
endif
goto ACTION
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# ARM64 values
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
ARM64:
#=================#
# ARM64 default #
#=================#
set modinit = DUMMY
set usemodules = 0
set useldlibs = 0
goto ACTION
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# perform requested action
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
ACTION:
#===================#
# ECHO VALUE(s) #
#===================#
set wrapper = 0
if ( $#argv > 0 ) then
if ( $1 == basedir ) then
echo $basedir
else if ( $1 == modules ) then
echo $mods
else if ( $1 == modinit ) then
echo $modinit
else if ( $1 == usemodules ) then
echo $usemods
else if ( $1 == useldlibs ) then
echo $useldlibs
else if ( $1 == ESMA_FC ) then
echo $ESMA_FC
else if ( $1 == site ) then
echo $site
else if ( $1 == sh ) then
set wrapper = 1
goto SETVALUES
else if ( $1 == help ) then
goto usage
else
echo2 "${scriptname}: >>>ERROR<<< unrecognizable option -- $1"
echo2 Type "$scriptname help" for usage information.
echo 0 # indicating error condition
exit 9
endif
exit
endif
SETVALUES:
#================#
# SET VALUES #
#================#
#-------------------------------------------------------------------------
# set environment variables, BASEDIR and LD_LIBRARY_PATH; and load modules
#-------------------------------------------------------------------------
# setenv BASEDIR
#---------------
if ($?basedir) then
if (! $wrapper) echo -n "${scriptname}: Setting BASEDIR"
setenv BASEDIR $basedir
else if ($?BASEDIR) then
if (! $wrapper) echo -n "${scriptname}: BASEDIR found in environment"
else
echo
echo "BASEDIR not found in environment or set by ${scriptname}"
exit 3
endif
# add BASEDIR lib to LD_LIBRARY_PATH, if not already there
#---------------------------------------------------------
if ($useldlibs) then
if ($?LD_LIBRARY_PATH) then
echo $LD_LIBRARY_PATH | grep $BASEDIR/$arch/lib > /dev/null
if ($status) then # == 1, if not found
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$BASEDIR/$arch/lib
endif
else
setenv LD_LIBRARY_PATH $BASEDIR/$arch/lib
endif
# add individual $ld_libraries to LD_LIBRARY_PATH, if not already there
#----------------------------------------------------------------------
if ($?ld_libraries) then
foreach lib ( $ld_libraries )
if ($LD_LIBRARY_PATH !~ *$lib*) then
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$lib
endif
end
endif
if ($?LD_LIBRARY64_PATH) then
echo $LD_LIBRARY64_PATH | grep $BASEDIR/$arch/lib > /dev/null
if ($status) then # == 1, if not found
setenv LD_LIBRARY64_PATH ${LD_LIBRARY64_PATH}:$BASEDIR/$arch/lib
endif
endif
endif
# Set UDUNITS2_XML_PATH
# ---------------------
setenv UDUNITS2_XML_PATH $BASEDIR/$arch/share/udunits/udunits2.xml
# load library modules
#---------------------
if (-e $modinit) then
if (! $wrapper) echo -n " and modules"
source $modinit
module purge
if ($usemodules) then
foreach usemod ( $usemods )
module use -a $usemod
end
endif
foreach mod ( $mods )
module load $mod
end
if ($?XTRAMODS2LOAD) then
set xmods = (`echo $XTRAMODS2LOAD | cut -d: -f1- --output-delimiter=" "`)
foreach mod ( $xmods )
module load $mod
end
endif
endif
if (! $wrapper) echo " for $node"
# write sh commands to a .g5_modules.sh file
#-------------------------------------------
if ($wrapper) then
set outfil = ".g5_modules.sh"
if ($?BASEDIR) then
echo "export BASEDIR=$BASEDIR" >! $outfil
endif
if ($?LD_LIBRARY_PATH) then
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $outfil
endif
if ($?LD_LIBRARY64_PATH) then
echo "export LD_LIBRARY64_PATH=$LD_LIBRARY64_PATH" >> $outfil
endif
if ($?UDUNITS2_XML_PATH) then
echo "export UDUNITS2_XML_PATH=$UDUNITS2_XML_PATH" >> $outfil
endif
set modulecmd = `which modulecmd`
if ($status) set modulecmd = "/usr/bin/modulecmd"
set modinit_sh = `echo $modinit | sed "s|/csh|/sh|"`
if (-e $modulecmd) then
if (-e $modinit_sh) then
echo 'source '$modinit_sh >> $outfil
endif
echo 'eval `'$modulecmd sh purge'`' >> $outfil
foreach mod ($mods)
echo 'eval `'$modulecmd sh load $mod'`' >> $outfil
end
endif
endif
exit
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# usage information #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
usage:
more <<EOF
NAME
$scriptname - Script to handle BASEDIR and library module definitions
DESCRIPTION
This script provides a single location for storing the BASEDIR and
library module name information. Previous to this script, this
information was coded in multiple files.
This script will set the BASEDIR environment variable to its proper value,
add the BASEDIR lib directory to LD_LIBRARY_PATH (if necessary), and will
load library modules when sourced.
If the script is called with "basedir", "modules", "modinit", or
"useldlibs", then it will echo the values to standard output without
modifying the environment.
SYNOPSIS
source $scriptname
or
$scriptname <option>
OPTIONS
help echo usage
basedir echo expected value for BASEDIR environment variable
modules echo expected list of modules
modinit echo location of csh module initialization script
useldlibs echo logical indicating whether BASEDIR lib should be
added to LD_LIBRARY_PATH
usemodules echo logical indicating whether "module use directory(s)"
is needed prior to loading other modules
ESMA_FC echo value of ESMA_FC if set
site echo site as detected by $scriptname
sh write sh version of g5_modules to file named, ".g5_modules.sh"
EOF
exit 1