2017-05-15 21:10:49 +05:30
|
|
|
# sets up an environment for DAMASK on zsh
|
2017-05-17 12:23:37 +05:30
|
|
|
# usage: source DAMASK.zsh
|
2017-05-15 21:10:49 +05:30
|
|
|
|
2017-08-01 06:27:42 +05:30
|
|
|
function canonicalPath {
|
2018-06-19 16:24:43 +05:30
|
|
|
python -c "import os,sys; print(os.path.normpath(os.path.realpath(os.path.expanduser(sys.argv[1]))))" $1
|
2017-08-01 06:27:42 +05:30
|
|
|
}
|
|
|
|
|
2018-06-19 16:24:43 +05:30
|
|
|
function blink {
|
|
|
|
echo -e "\033[2;5m$1\033[0m"
|
|
|
|
}
|
|
|
|
|
|
|
|
DAMASK_ROOT=$(canonicalPath "${0:a:h}'/..")
|
2017-05-15 21:10:49 +05:30
|
|
|
|
|
|
|
# shorthand command to change to DAMASK_ROOT directory
|
2017-05-24 10:01:58 +05:30
|
|
|
eval "function DAMASK_root() { cd $DAMASK_ROOT; }"
|
2017-05-15 21:10:49 +05:30
|
|
|
|
|
|
|
# defining set() allows to source the same file for tcsh and zsh, with and without space around =
|
|
|
|
set() {
|
|
|
|
export $1$2$3
|
|
|
|
}
|
|
|
|
source $DAMASK_ROOT/CONFIG
|
|
|
|
unset -f set
|
|
|
|
|
2018-12-18 19:41:44 +05:30
|
|
|
# add BRANCH if DAMASK_ROOT is a git repository
|
|
|
|
cd $DAMASK_ROOT >/dev/null; BRANCH=$(git branch 2>/dev/null| grep -E '^\* '); cd - >/dev/null
|
|
|
|
|
2017-05-17 12:23:37 +05:30
|
|
|
# add DAMASK_BIN if present
|
2018-12-18 19:54:25 +05:30
|
|
|
[[ "x$DAMASK_BIN" != "x" ]] && PATH=$DAMASK_BIN:$PATH
|
2017-05-15 21:10:49 +05:30
|
|
|
|
2018-06-22 01:20:11 +05:30
|
|
|
SOLVER=$(which DAMASK_spectral || true 2>/dev/null)
|
2018-12-18 19:54:25 +05:30
|
|
|
[[ "x$SOLVER" == "x" ]] && SOLVER=$(blink 'Not found!')
|
2017-07-12 16:20:59 +05:30
|
|
|
|
2018-06-22 01:20:11 +05:30
|
|
|
PROCESSING=$(which postResults || true 2>/dev/null)
|
2018-12-18 19:54:25 +05:30
|
|
|
[[ "x$PROCESSING" == "x" ]] && PROCESSING=$(blink 'Not found!')
|
2017-07-12 16:20:59 +05:30
|
|
|
|
2018-12-18 19:54:25 +05:30
|
|
|
[[ "x$DAMASK_NUM_THREADS" == "x" ]] && DAMASK_NUM_THREADS=1
|
2017-05-15 21:10:49 +05:30
|
|
|
|
2017-07-12 16:20:59 +05:30
|
|
|
# currently, there is no information that unlimited causes problems
|
2018-08-04 18:05:57 +05:30
|
|
|
# still, http://software.intel.com/en-us/forums/topic/501500 suggest to fix it
|
|
|
|
# more info https://jblevins.org/log/segfault
|
|
|
|
# https://stackoverflow.com/questions/79923/what-and-where-are-the-stack-and-heap
|
2017-08-01 12:43:25 +05:30
|
|
|
# http://superuser.com/questions/220059/what-parameters-has-ulimit
|
2017-07-12 16:20:59 +05:30
|
|
|
ulimit -d unlimited 2>/dev/null # maximum heap size (kB)
|
|
|
|
ulimit -s unlimited 2>/dev/null # maximum stack size (kB)
|
|
|
|
ulimit -v unlimited 2>/dev/null # maximum virtual memory size
|
|
|
|
ulimit -m unlimited 2>/dev/null # maximum physical memory size
|
2017-05-15 21:10:49 +05:30
|
|
|
|
|
|
|
# disable output in case of scp
|
|
|
|
if [ ! -z "$PS1" ]; then
|
|
|
|
echo
|
|
|
|
echo Düsseldorf Advanced Materials Simulation Kit --- DAMASK
|
|
|
|
echo Max-Planck-Institut für Eisenforschung GmbH, Düsseldorf
|
|
|
|
echo https://damask.mpie.de
|
|
|
|
echo
|
|
|
|
echo "Using environment with ..."
|
2018-12-18 19:41:44 +05:30
|
|
|
echo "DAMASK $DAMASK_ROOT $BRANCH"
|
2017-05-15 21:10:49 +05:30
|
|
|
echo "Spectral Solver $SOLVER"
|
|
|
|
echo "Post Processing $PROCESSING"
|
2018-12-18 19:54:25 +05:30
|
|
|
if [ "x$PETSC_DIR" != "x" ]; then
|
2018-06-19 16:24:43 +05:30
|
|
|
echo -n "PETSc location "
|
|
|
|
[ -d $PETSC_DIR ] && echo $PETSC_DIR || blink $PETSC_DIR
|
2017-08-01 06:27:42 +05:30
|
|
|
[[ $(canonicalPath "$PETSC_DIR") == $PETSC_DIR ]] \
|
|
|
|
|| echo " ~~> "$(canonicalPath "$PETSC_DIR")
|
2017-05-15 21:10:49 +05:30
|
|
|
fi
|
2018-12-18 19:54:25 +05:30
|
|
|
[[ "x$PETSC_ARCH" == "x" ]] \
|
2017-05-15 21:10:49 +05:30
|
|
|
|| echo "PETSc architecture $PETSC_ARCH"
|
2018-06-19 16:24:43 +05:30
|
|
|
echo -n "MSC.Marc/Mentat "
|
|
|
|
[ -d $MSC_ROOT ] && echo $MSC_ROOT || blink $MSC_ROOT
|
2017-05-15 21:10:49 +05:30
|
|
|
echo
|
2018-06-19 16:24:43 +05:30
|
|
|
echo "Multithreading DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS"
|
2017-05-15 21:10:49 +05:30
|
|
|
echo -n "heap size "
|
|
|
|
[[ "$(ulimit -d)" == "unlimited" ]] \
|
|
|
|
&& echo "unlimited" \
|
|
|
|
|| echo $(python -c \
|
|
|
|
"import math; \
|
|
|
|
size=$(( 1024*$(ulimit -d) )); \
|
|
|
|
print('{:.4g} {}'.format(size / (1 << ((int(math.log(size,2) / 10) if size else 0) * 10)), \
|
|
|
|
['bytes','KiB','MiB','GiB','TiB','EiB','ZiB'][int(math.log(size,2) / 10) if size else 0]))")
|
|
|
|
echo -n "stack size "
|
|
|
|
[[ "$(ulimit -s)" == "unlimited" ]] \
|
|
|
|
&& echo "unlimited" \
|
|
|
|
|| echo $(python -c \
|
|
|
|
"import math; \
|
|
|
|
size=$(( 1024*$(ulimit -s) )); \
|
|
|
|
print('{:.4g} {}'.format(size / (1 << ((int(math.log(size,2) / 10) if size else 0) * 10)), \
|
|
|
|
['bytes','KiB','MiB','GiB','TiB','EiB','ZiB'][int(math.log(size,2) / 10) if size else 0]))")
|
2018-11-30 21:05:01 +05:30
|
|
|
echo
|
2017-05-15 21:10:49 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
export DAMASK_NUM_THREADS
|
2019-01-05 15:22:39 +05:30
|
|
|
export PYTHONPATH=$DAMASK_ROOT/python:$PYTHONPATH
|
2017-05-15 21:10:49 +05:30
|
|
|
|
2018-12-18 19:41:44 +05:30
|
|
|
for var in BASE STAT SOLVER PROCESSING FREE DAMASK_BIN BRANCH; do
|
2017-05-15 21:10:49 +05:30
|
|
|
unset "${var}"
|
|
|
|
done
|
|
|
|
for var in DAMASK MSC; do
|
|
|
|
unset "${var}_ROOT"
|
|
|
|
done
|
|
|
|
for var in ABAQUS MARC; do
|
|
|
|
unset "${var}_VERSION"
|
|
|
|
done
|