checking for presence of "free" command before use. checking of BASH_SOURCE for absolute or relative path

This commit is contained in:
Philip Eisenlohr 2014-08-20 21:51:46 +00:00
parent 5c429a9939
commit 46bf0cfc28
1 changed files with 14 additions and 8 deletions

View File

@ -4,9 +4,9 @@
if [ "$OSTYPE" == "linux-gnu" ] || [ "$OSTYPE" == 'linux' ]; then if [ "$OSTYPE" == "linux-gnu" ] || [ "$OSTYPE" == 'linux' ]; then
DAMASK_ROOT=$(readlink -f "`dirname $BASH_SOURCE`") DAMASK_ROOT=$(readlink -f "`dirname $BASH_SOURCE`")
else else
STAT=$(stat "`dirname $BASH_SOURCE`") [[ "${BASH_SOURCE::1}" == "/" ]] && BASE="" || BASE="`pwd`/"
STAT=$(stat "`dirname $BASE$BASH_SOURCE`")
DAMASK_ROOT=${STAT##* } DAMASK_ROOT=${STAT##* }
unset STAT
fi fi
[[ -f $HOME/.damask/damask.conf ]] && source $HOME/.damask/damask.conf || source /etc/damask.conf [[ -f $HOME/.damask/damask.conf ]] && source $HOME/.damask/damask.conf || source /etc/damask.conf
@ -27,13 +27,16 @@ fi
# according to http://software.intel.com/en-us/forums/topic/501500 # according to http://software.intel.com/en-us/forums/topic/501500
# this seems to make sense for the stack size # this seems to make sense for the stack size
freeMem=`free -k | grep -E '(Mem|Speicher):' | awk '{print $4;}'` FREE=`which free 2>/dev/null`
heap=`expr $freeMem / 2` if [ "x$FREE" != "x" ]; then
stack=`expr $freeMem / $DAMASK_NUM_THREADS / 2` freeMem=`free -k | grep -E '(Mem|Speicher):' | awk '{print $4;}'`
heap=`expr $freeMem / 2`
stack=`expr $freeMem / $DAMASK_NUM_THREADS / 2`
# http://superuser.com/questions/220059/what-parameters-has-ulimit # http://superuser.com/questions/220059/what-parameters-has-ulimit
ulimit -s $stack 2>/dev/null # maximum stack size (kB) ulimit -s $stack 2>/dev/null # maximum stack size (kB)
ulimit -d $heap 2>/dev/null # maximum heap size (kB) ulimit -d $heap 2>/dev/null # maximum heap size (kB)
fi
ulimit -c 2000 2>/dev/null # core file size (512-byte blocks) ulimit -c 2000 2>/dev/null # core file size (512-byte blocks)
ulimit -v unlimited 2>/dev/null # maximum virtual memory size ulimit -v unlimited 2>/dev/null # maximum virtual memory size
ulimit -m unlimited 2>/dev/null # maximum physical memory size ulimit -m unlimited 2>/dev/null # maximum physical memory size
@ -67,6 +70,9 @@ fi
export DAMASK_NUM_THREADS export DAMASK_NUM_THREADS
export PYTHONPATH=$DAMASK_ROOT/lib:$PYTHONPATH export PYTHONPATH=$DAMASK_ROOT/lib:$PYTHONPATH
for var in BASE STAT SOLVER PROCESSING FREE; do
unset "${var}"
done
for var in DAMASK IMKL ACML LAPACK MSC FFTW HDF5; do for var in DAMASK IMKL ACML LAPACK MSC FFTW HDF5; do
unset "${var}_ROOT" unset "${var}_ROOT"
done done