Repository navigation
Expand file tree
/
Copy pathsetup.ksh
More file actions
executable file
·377 lines (338 loc) · 13.4 KB
/
Copy pathsetup.ksh
File metadata and controls
executable file
·377 lines (338 loc) · 13.4 KB
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
#! /bin/ksh
# This script sets up the environment for SOLPS-ITER (paths, env, aliases, etc.)
# including the site identification via HOST_NAME and COMPILER variables.
# It is intended to be sourced from the command line, not executed.
#
# The main variables SOLPSTOP, HOST_NAME, COMPILER are determined according
# to a precedence logic described below.
#
# Variable SOLPSTOP is determined with decreasing priority from:
# 1. $SOLPSTOP_FORCE
# 2. Automatic detection, fallback to $PWD
#
# Variable HOST_NAME is determined with decreasing priority from:
# 1. $SOLPS_HOST_NAME_FORCE
# 2. SETUP/setup.ksh.HOST_NAME.local file (sourced if present)
# 3. output of `whereami` script
# 4. fallback to UNKNOWN
#
# SETUP/setup.ksh.HOST_NAME.COMPILER.pre is sourced after HOST_NAME and
# COMPILER are determined, before the main machine/compiler setup file.
#
# Variable COMPILER is determined with decreasing priority from:
# 1. First argument to `source setup.ksh` command
# 2. $SOLPS_COMPILER_FORCE
# 3. output of `default_compiler` script
# 4. fallback to ifort64
#
echo Welcome to SOLPS-ITER!
echo Documentation can be found at:
echo https://iterorganization.sharepoint.com/sites/SOLPS-ITER/Shared%20Documents/General
echo and
echo https://user.iter.org/\?uid=Q92BAQ
echo "(requires a valid ITER IDM account)"
echo The full SOLPS-ITER manual can be found in \$SOLPSTOP/doc/solps/solps.pdf
echo The Eirene manual can be found in \$SOLPSTOP/modules/Eirene/Manual/eirene.pdf
echo or online at http://www.eirene.de/
export LAST_COMMAND=`echo $_`
if [ "$SOLPSTOP_FORCE" != "" ]; then
setenv SOLPSTOP $SOLPSTOP_FORCE
elif [ "$LAST_COMMAND" = "" ]; then
export SETUP_FILE=`echo ${LAST_COMMAND} | cut -d " " -f 2`
export REAL_FILE=`eval echo ${SETUP_FILE}`
export REAL_PATH=`dirname ${REAL_FILE}`
export SOLPSTOP=`cd ${REAL_PATH}; pwd -L`
else
export SOLPSTOP=$PWD
fi
# Preserve a site/user value for central run directories; otherwise use the
# traditional runs directory under SOLPSTOP.
[ -z "$SOLPSWORK" ] && export SOLPSWORK=${SOLPSTOP}/runs
# Set HOST_NAME and COMPILER, which will determine setup files to be used
#------------------------------------------------------------------------
if [ "$SOLPS_HOST_NAME_FORCE" != "" ]; then
export HOST_NAME=$SOLPS_HOST_NAME_FORCE
echo "Running at $HOST_NAME (set by SOLPS_HOST_NAME_FORCE)"
elif [ -s "${SOLPSTOP}/SETUP/setup.ksh.HOST_NAME.local" ]; then
echo Loading SETUP/setup.ksh.HOST_NAME.local.
. ${SOLPSTOP}/SETUP/setup.ksh.HOST_NAME.local
else
[ -s ${SOLPSTOP}/whereami ] && {
iamat=`${SOLPSTOP}/whereami|tail -1`
echo Running at $iamat
} || {
iamat="UNKNOWN"
}
case $iamat in
*UNKNOWN )
export HOST_NAME=UNKNOWN
;;
* )
export HOST_NAME=$iamat
;;
esac
fi
# COMPILER can also be the argument to setup.csh call
if [ "$1" != "" ]; then
export COMPILER=$1
echo "Using compiler $1 (set by command argument)."
elif [ "$SOLPS_COMPILER_FORCE" != "" ]; then
export COMPILER=$SOLPS_COMPILER_FORCE
echo "Using compiler $COMPILER (set by SOLPS_COMPILER_FORCE)."
elif [ -s ${SOLPSTOP}/default_compiler ]; then
export COMPILER=`${SOLPSTOP}/default_compiler|tail -1`
echo Using compiler $COMPILER.
else
export COMPILER=ifort64
echo Assuming default compiler ifort64.
fi
[ -z "$COMPILER" ] && echo 'COMPILER not defined!'
setup_pre=${SOLPSTOP}/SETUP/setup.ksh.${HOST_NAME}.${COMPILER}.pre
if [ -s "${setup_pre}" ]; then
echo Loading SETUP/setup.ksh.${HOST_NAME}.${COMPILER}.pre.
. "${setup_pre}"
fi
unset setup_pre
[ -x "`which gmake`" ] && {
export MAKE=`which gmake`
} || {
export MAKE=`which make`
}
# setup files for combination of HOST_NAME and COMPILER, + local modifications if present
[ -s ${SOLPSTOP}/SETUP/setup.ksh.${HOST_NAME}.${COMPILER} ] && {
echo Loading SETUP/setup.ksh.${HOST_NAME}.${COMPILER}.
. ${SOLPSTOP}/SETUP/setup.ksh.${HOST_NAME}.${COMPILER}
} || {
echo File SETUP/setup.ksh.${HOST_NAME}.${COMPILER} not found!
}
if [ -s ${SOLPSTOP}/SETUP/setup.ksh.${HOST_NAME}.${COMPILER}.local ]; then
echo Loading SETUP/setup.ksh.${HOST_NAME}.${COMPILER}.local.
. ${SOLPSTOP}/SETUP/setup.ksh.${HOST_NAME}.${COMPILER}.local
fi
ulimit -s unlimited
[ -z "$GRAPHCAP" ] && export GRAPHCAP=X11
[ -z "$B2PLOT_DEV" ] && export B2PLOT_DEV="x11 ps"
[ -z "$GRSOFT_DEVICE" ] && export GRSOFT_DEVICE="211 62"
export SonnetTopDirectory=${SOLPSTOP}/modules/Sonnet-light
export EscapeSonnet=`echo ${SonnetTopDirectory} | sed 's:\/:\\\/:g'`
export DG=${SOLPSTOP}/modules/DivGeo
export CARRE_STOREDIR=${SOLPSTOP}/modules/Carre/meshes
export INTDIR=${SOLPSTOP}/modules/Eirene/src/interfaces/couple_SOLPS-ITER
# Set path to scripts and executables
#------------------------------------
# First, remove the old path to SOLPS if already set
# (avoid too long paths)
[ -n "$SOLPS_PATH" ] && export PATH=`echo $PATH | sed "s|${SOLPS_PATH}:||"`
# Default PATH: no mpi, no openmp, no debug
TOOLCHAIN=${HOST_NAME}.${COMPILER}
CARRE_PATH=${SOLPSTOP}/modules/Carre/builds/${TOOLCHAIN}
DIVGEO_PATH=${SOLPSTOP}/modules/DivGeo/builds/${TOOLCHAIN}:${SOLPSTOP}/modules/DivGeo/equtrn/builds/${TOOLCHAIN}:${SOLPSTOP}/modules/DivGeo/convert/builds/${TOOLCHAIN}
EIRENE_PATH=${SOLPSTOP}/modules/Eirene/builds/standalone.${TOOLCHAIN}
B25_PATH=${SOLPSTOP}/modules/B2.5/builds/standalone.${TOOLCHAIN}
B25EIRENE_PATH=${SOLPSTOP}/modules/B2.5/builds/couple_SOLPS-ITER.${TOOLCHAIN}
UINP_PATH=${SOLPSTOP}/modules/Uinp/builds/${TOOLCHAIN}
TRIANG_PATH=${SOLPSTOP}/modules/Triang/builds/${TOOLCHAIN}
SCRIPTS_PATH=${SOLPSTOP}/scripts.local:${SOLPSTOP}/scripts:${SOLPSTOP}/scripts/${TOOLCHAIN}:${SOLPSTOP}/modules/Eirene/scripts:${SOLPSTOP}/modules/Eirene/scripts/eirenex_v1.0.4:${SOLPSTOP}/modules/B2.5/src/test
AMDS_PATH=${SOLPSTOP}/modules/amds/builds/${TOOLCHAIN}
S45_PATH=${SOLPSTOP}/modules/solps4-5/builds/${TOOLCHAIN}
# Create mirror scripts directory links
# - only re-creating links if they are not correct, so that we are compatible with read-only file systems (container)
link_scripts="${SOLPSTOP}/scripts/${TOOLCHAIN}"
scripts_writable=0
[ -w "${SOLPSTOP}/scripts" ] && scripts_writable=1
links_available=1
if [ ! -d "${link_scripts}" ]; then
if [ "${scripts_writable}" -eq 1 ]; then
mkdir -p "${link_scripts}"
[ "$?" -eq 0 ] || links_available=0
else
echo "Warning: cannot create ${link_scripts}; ${SOLPSTOP}/scripts is not writable"
links_available=0
fi
fi
if [ "${links_available}" -eq 1 ]; then
link_current="`readlink "${link_scripts}.debug"`"
if [ "${link_current}" = "${link_scripts}" ]; then
if [ "${scripts_writable}" -eq 1 ]; then
rm -Rf "${link_scripts}.debug"
mkdir -p "${link_scripts}.debug"
else
echo "Warning: cannot update ${link_scripts}.debug; ${SOLPSTOP}/scripts is not writable"
fi
fi
active_suffixes=".openmp"
[ -z "$NO_MPI" ] && active_suffixes="${active_suffixes} .mpi .openmp.mpi"
for suffix in ${active_suffixes}; do
for debug_mode in normal debug; do
debug_suffix=""
[ "${debug_mode}" = "debug" ] && debug_suffix=".debug"
link_target="${link_scripts}${suffix}${debug_suffix}"
link_source="${link_scripts}${debug_suffix}"
link_current="`readlink "${link_target}"`"
if [ "${link_current}" != "${link_source}" ]; then
if [ "${scripts_writable}" -eq 1 ]; then
rm -Rf "${link_target}"
ln -s "${link_source}" "${link_target}"
else
echo "Warning: cannot update ${link_target}; ${SOLPSTOP}/scripts is not writable"
fi
fi
done
done
if [ -n "$NO_MPI" ]; then
mpi_links_present=0
for suffix in ".mpi" ".openmp.mpi"; do
for debug_mode in normal debug; do
debug_suffix=""
[ "${debug_mode}" = "debug" ] && debug_suffix=".debug"
link_target="${link_scripts}${suffix}${debug_suffix}"
if [ -e "${link_target}" ] || [ -L "${link_target}" ]; then
if [ "${scripts_writable}" -eq 1 ]; then
rm -Rf "${link_target}"
else
mpi_links_present=1
fi
fi
done
done
if [ "${mpi_links_present}" -eq 1 ]; then
echo "Warning: cannot remove MPI toolchain links; ${SOLPSTOP}/scripts is not writable"
fi
fi
fi
# Note: in case of name clash between script and executable, script will be found first
export SOLPS_PATH=${SCRIPTS_PATH}:${CARRE_PATH}:${DIVGEO_PATH}:${B25EIRENE_PATH}:${EIRENE_PATH}:${B25_PATH}:${UINP_PATH}:${TRIANG_PATH}:${AMDS_PATH}:${S45_PATH}
export SOLPSLIB=${SOLPSTOP}/lib/${HOST_NAME}.${COMPILER}
export OLD_PATH=${PATH}
export PATH=${SOLPS_PATH}:${PATH}
[ -n "$LD_LIBRARY_PATH" ] && {
export LD_LIBRARY_PATH=${SOLPSLIB}:${SOLPSTOP}/lib/python:${LD_LIBRARY_PATH}
} || {
export LD_LIBRARY_PATH=${SOLPSLIB}:${SOLPSTOP}/lib/python
}
[ -z "$PYTHONPATH" ] && {
export PYTHONPATH="$SOLPSTOP/lib/python:${SCRIPTS_PATH}"
} || {
export PYTHONPATH="${PYTHONPATH}:$SOLPSTOP/lib/python:${SCRIPTS_PATH}"
}
[ -z "$PYTHON_PATH" ] || {
export PYTHONPATH="${PYTHONPATH}:${PYTHON_PATH}"
}
unset TOOLCHAIN SCRIPTS_PATH CARRE_PATH DIVGEO_PATH EIRENE_PATH B25_PATH B25EIRENE_PATH UINP_PATH TRIANG_PATH AMDS_PATH S45_PATH
# Check whether SOLPS_DEBUG, SOLPS_OPENMP and SOLPS_MPI have been set already by the user
[ -n "$SOLPS_OPENMP" ] && . $SOLPSTOP/SETUP/openmp.ksh
[ -n "$SOLPS_DEBUG" ] && . $SOLPSTOP/SETUP/debug.ksh
[ -n "$SOLPS_MPI" ] && . $SOLPSTOP/SETUP/mpi.ksh
# Set path to manuals
#--------------------
[ -n "$MANPATH" ] && {
export MANPATH=${MANPATH}:${SonnetTopDirectory}/man:${DG}/equtrn/doxygen/man
} || {
export MANPATH=${SonnetTopDirectory}/man:${DG}/equtrn/doxygen/man
}
# Remove double entries from some environment variables, if there are any
# export PATH=`echo $PATH | awk -v RS=: -v ORS= '\\!a[$0]++ {if (NR>1) printf(":"); printf("%s",$0) }'`
# export LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH | awk -v RS=: -v ORS= '\\!a[$0]++ {if (NR>1) printf(":"); printf("%s",$0) }'`
# export MANPATH=`echo $MANPATH | awk -v RS=: -v ORS= '\\!a[$0]++ {if (NR>1) printf(":"); printf("%s",$0) }'`
# export PYTHONPATH=`echo $PYTHONPATH | awk -v RS=: -v ORS= '\\!a[$0]++ {if (NR>1) printf(":"); printf("%s",$0) }'`
# export OLD_PATH=`echo $OLD_PATH | awk -v RS=: -v ORS= '\\!a[$0]++ {if (NR>1) printf(":"); printf("%s",$0) }'`
alias sb2='cd ${SOLPSTOP}/modules/B2.5'
alias sbb='cd ${SOLPSTOP}/modules/B2.5'
alias sei='cd ${SOLPSTOP}/modules/Eirene'
alias ssw='cd ${SOLPSTOP}/modules/Sonnet-light'
alias ssd='cd ${SOLPSTOP}/modules/DivGeo'
alias ssc='cd ${SOLPSTOP}/modules/Carre'
alias sst='cd ${SOLPSTOP}/modules/Triang'
alias ssu='cd ${SOLPSTOP}/modules/Uinp'
alias sbin='cd ${SOLPSTOP}/scripts'
alias slib='cd ${SOLPSTOP}/lib/${HOST_NAME}.${COMPILER}'
if [ -z "$SOLPS_CENTRAL" ]; then
alias sbr='cd ${SOLPSTOP}/runs'
fi
alias scr='cd ${SOLPSTOP}/scripts'
alias stop='cd ${SOLPSTOP}'
alias sdg='cd ${SOLPSTOP}/modules/DivGeo/device/${DEVICE}'
alias ssf='cd ${SOLPSTOP}/modules/DivGeo/device/${DEVICE}'
alias xyplot='plot xyplot'
alias xyplot2='plot xyplot2'
alias xyplot3='plot xyplot3'
alias xyplot4='plot xyplot4'
alias xyplot5='plot xyplot5'
alias xyplot6='plot xyplot6'
alias xyplot7='plot xyplot7'
alias xyplot8='plot xyplot8'
alias xyplot8='plot xyplot8'
alias xyplot9='plot xyplot9'
alias xlyplot='plot xlyplot'
alias xlyplot2='plot xlyplot2'
alias xlyplot3='plot xlyplot3'
alias xlyplot4='plot xlyplot4'
alias xlyplot5='plot xlyplot5'
alias xlyplot6='plot xlyplot6'
alias xlyplot7='plot xlyplot7'
alias xlyplot8='plot xlyplot8'
alias xlyplot8='plot xlyplot8'
alias xlyplot9='plot xlyplot9'
alias xylplot='plot xylplot'
alias xylplot2='plot xylplot2'
alias xylplot3='plot xylplot3'
alias xylplot4='plot xylplot4'
alias xylplot5='plot xylplot5'
alias xylplot6='plot xylplot6'
alias xylplot7='plot xylplot7'
alias xylplot8='plot xylplot8'
alias xylplot8='plot xylplot8'
alias xylplot9='plot xylplot9'
alias xlylplot='plot xlylplot'
alias xlylplot2='plot xlylplot2'
alias xlylplot3='plot xlylplot3'
alias xlylplot4='plot xlylplot4'
alias xlylplot5='plot xlylplot5'
alias xlylplot6='plot xlylplot6'
alias xlylplot7='plot xlylplot7'
alias xlylplot8='plot xlylplot8'
alias xlylplot8='plot xlylplot8'
alias xlylplot9='plot xlylplot9'
alias set_debug='. $SOLPSTOP/SETUP/debug.ksh'
alias unset_debug='. $SOLPSTOP/SETUP/nodebug.ksh'
alias set_openmp='. $SOLPSTOP/SETUP/openmp'
alias unset_openmp='. $SOLPSTOP/SETUP/noopenmp'
alias set_mpi='. $SOLPSTOP/SETUP/mpi'
alias unset_mpi='. $SOLPSTOP/SETUP/nompi'
alias set_ig='. $SOLPSTOP/SETUP/ig'
alias unset_ig='. $SOLPSTOP/SETUP/noig'
# Check if Motif library is present
[ -e "`which mwm`" ] || {
export NO_MOTIF=1
}
[ -n "$NO_MOTIF" ] && {
[ `whereis libXm | wc -w` != 1 ] && unset NO_MOTIF
}
[ -n "$NO_MOTIF" ] && {
[ `ldconfig -p | grep 'libXm\.' | wc -l` != 0 ] && unset NO_MOTIF
}
# Compilation also requires Motif development headers; restore NO_MOTIF if they are absent
[ -z "$NO_MOTIF" ] && {
[ "$(find /usr/include /usr/local/include ${EBROOTMOTIF} -name 'Xm.h' 2>/dev/null | wc -l)" -eq 0 ] && export NO_MOTIF=1
}
# Check if Manual can be built
export LATEX=`${SOLPSTOP}/scripts/which_latex`
[ "$LATEX" = "" ] && {
export NO_MANUAL=true
echo 'No LaTeX executable found: Manual will not be built'
}
# Check if CMake available for Eirene compilation
export CMAKE=`which cmake`
[ "$CMAKE" = "" ] && {
export NO_CMAKE=true
echo 'Did not find a CMake installation. Will revert to traditional Eirene compilation style'
} || {
[ "$CMAKE_MAJOR_VERSION" = "" ] && {
export CMAKE_MAJOR_VERSION=`cmake --version | head -1 | cut -d ' ' -f 3 | cut -d '.' -f 1`
}
}
# Add any local settings if present
if [ -s ${SOLPSTOP}/SETUP/setup.ksh.local ]; then
echo "Loading SETUP/setup.ksh.local"
. ${SOLPSTOP}/SETUP/setup.ksh.local
fi