scripts now work if sourced from new location

This commit is contained in:
Martin Diehl 2017-05-17 08:53:37 +02:00
parent 60b7870abe
commit eff2b4ca1c
6 changed files with 41 additions and 33 deletions

View File

@ -1 +1 @@
env/DAMASK_env.csh
./env/DAMASK.csh

View File

@ -1 +1 @@
env/DAMASK_env.sh
./env/DAMASK.sh

View File

@ -1 +1 @@
env/DAMASK_env.zsh
./env/DAMASK.zsh

View File

@ -3,16 +3,21 @@
set CALLED=($_)
set DIRNAME=`dirname $CALLED[2]`
# transition compatibility (renamed $DAMASK_ROOT/DAMASK_env.csh to $DAMASK_ROOT/env/DAMASK.csh)
set FILENAME=`basename $CALLED[2]`
if ($FILENAME == "DAMASK.csh") then
set DIRNAME=$DIRNAME"/../"
endif
set DAMASK_ROOT=`python -c "import os,sys; print(os.path.realpath(os.path.expanduser(sys.argv[1])))" $DIRNAME`
source $DAMASK_ROOT/CONFIG
# if DAMASK_BIN is present and not in $PATH, add it
# if DAMASK_BIN is present
if ( $?DAMASK_BIN) then
set MATCH=`echo :${PATH}: | grep ${DAMASK_BIN}:`
if ( "x$MATCH" == "x" ) then
set PATH=${DAMASK_BIN}:${PATH}
endif
set path = ($DAMASK_BIN $path)
endif
set SOLVER=`which DAMASK_spectral`
@ -62,4 +67,8 @@ if ( $?prompt ) then
endif
setenv DAMASK_NUM_THREADS $DAMASK_NUM_THREADS
if ( ! $?PYTHONPATH ) then
setenv PYTHONPATH $DAMASK_ROOT/lib
else
setenv PYTHONPATH $DAMASK_ROOT/lib:$PYTHONPATH
endif

View File

@ -1,5 +1,5 @@
# sets up an environment for DAMASK on bash
# usage: source DAMASK_env.sh
# usage: source DAMASK.sh
if [ "$OSTYPE" == "linux-gnu" ] || [ "$OSTYPE" == 'linux' ]; then
@ -10,6 +10,11 @@ else
DAMASK_ROOT=${STAT##* }
fi
# transition compatibility (renamed $DAMASK_ROOT/DAMASK_env.sh to $DAMASK_ROOT/env/DAMASK.sh)
if [ ${BASH_SOURCE##*/} == "DAMASK.sh" ]; then
DAMASK_ROOT=$DAMASK_ROOT'/..'
fi
# shorthand command to change to DAMASK_ROOT directory
eval "function damask() { cd $DAMASK_ROOT; }"
@ -20,22 +25,16 @@ set() {
source $DAMASK_ROOT/CONFIG
unset -f set
# add DAMASK_BIN if present but not yet in $PATH
if [[ "x$DAMASK_BIN" != "x" && ! $(echo ":$PATH:" | grep $DAMASK_BIN:) ]]; then
export PATH=$DAMASK_BIN:$PATH
fi
# add DAMASK_BIN if present
[ "x$DAMASK_BIN" != "x" ] && PATH=$DAMASK_BIN:$PATH
SOLVER=$(which DAMASK_spectral || true 2>/dev/null)
if [ "x$SOLVER" == "x" ]; then
SOLVER='Not found!'
fi
[ "x$SOLVER" == "x" ] && SOLVER='Not found!'
PROCESSING=$(which postResults || true 2>/dev/null)
if [ "x$PROCESSING" == "x" ]; then
PROCESSING='Not found!'
fi
if [ "x$DAMASK_NUM_THREADS" == "x" ]; then
DAMASK_NUM_THREADS=1
fi
[ "x$PROCESSING" == "x" ] && PROCESSING='Not found!'
[ "x$DAMASK_NUM_THREADS" == "x" ] && DAMASK_NUM_THREADS=1
# according to http://software.intel.com/en-us/forums/topic/501500
# this seems to make sense for the stack size

View File

@ -1,7 +1,12 @@
# sets up an environment for DAMASK on zsh
# usage: source DAMASK_env.zsh
# usage: source DAMASK.zsh
# transition compatibility (renamed $DAMASK_ROOT/DAMASK_env.zsh to $DAMASK_ROOT/env/DAMASK.zsh)
if [ ${0:t:r} = 'DAMASK' ]; then
DAMASK_ROOT=${0:a:h}'/..'
else
DAMASK_ROOT=${0:a:h}
fi
# shorthand command to change to DAMASK_ROOT directory
eval "function damask() { cd $DAMASK_ROOT; }"
@ -13,17 +18,12 @@ set() {
source $DAMASK_ROOT/CONFIG
unset -f set
# add DAMASK_BIN if present but not yet in $PATH
MATCH=`echo ":$PATH:" | grep $DAMASK_BIN:`
if [[ ( "x$DAMASK_BIN" != "x" ) && ( "x$MATCH" = "x" ) ]]; then
export PATH=$DAMASK_BIN:$PATH
fi
# add DAMASK_BIN if present
[ ( "x$DAMASK_BIN" != "x" ) ] && PATH=$DAMASK_BIN:$PATH
SOLVER=`which DAMASK_spectral || True 2>/dev/null`
PROCESSING=`which postResults || True 2>/dev/null`
if [ "x$DAMASK_NUM_THREADS" = "x" ]; then
DAMASK_NUM_THREADS=1
fi
[ "x$DAMASK_NUM_THREADS" = "x" ] && DAMASK_NUM_THREADS=1
# according to http://software.intel.com/en-us/forums/topic/501500
# this seems to make sense for the stack size