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 CALLED=($_)
set DIRNAME=`dirname $CALLED[2]` 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` set DAMASK_ROOT=`python -c "import os,sys; print(os.path.realpath(os.path.expanduser(sys.argv[1])))" $DIRNAME`
source $DAMASK_ROOT/CONFIG source $DAMASK_ROOT/CONFIG
# if DAMASK_BIN is present and not in $PATH, add it # if DAMASK_BIN is present
if ( $?DAMASK_BIN) then if ( $?DAMASK_BIN) then
set MATCH=`echo :${PATH}: | grep ${DAMASK_BIN}:` set path = ($DAMASK_BIN $path)
if ( "x$MATCH" == "x" ) then
set PATH=${DAMASK_BIN}:${PATH}
endif
endif endif
set SOLVER=`which DAMASK_spectral` set SOLVER=`which DAMASK_spectral`
@ -62,4 +67,8 @@ if ( $?prompt ) then
endif endif
setenv DAMASK_NUM_THREADS $DAMASK_NUM_THREADS setenv DAMASK_NUM_THREADS $DAMASK_NUM_THREADS
if ( ! $?PYTHONPATH ) then
setenv PYTHONPATH $DAMASK_ROOT/lib
else
setenv PYTHONPATH $DAMASK_ROOT/lib:$PYTHONPATH setenv PYTHONPATH $DAMASK_ROOT/lib:$PYTHONPATH
endif

View File

@ -1,5 +1,5 @@
# sets up an environment for DAMASK on bash # sets up an environment for DAMASK on bash
# usage: source DAMASK_env.sh # usage: source DAMASK.sh
if [ "$OSTYPE" == "linux-gnu" ] || [ "$OSTYPE" == 'linux' ]; then if [ "$OSTYPE" == "linux-gnu" ] || [ "$OSTYPE" == 'linux' ]; then
@ -10,6 +10,11 @@ else
DAMASK_ROOT=${STAT##* } DAMASK_ROOT=${STAT##* }
fi 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 # shorthand command to change to DAMASK_ROOT directory
eval "function damask() { cd $DAMASK_ROOT; }" eval "function damask() { cd $DAMASK_ROOT; }"
@ -20,22 +25,16 @@ set() {
source $DAMASK_ROOT/CONFIG source $DAMASK_ROOT/CONFIG
unset -f set unset -f set
# add DAMASK_BIN if present but not yet in $PATH # add DAMASK_BIN if present
if [[ "x$DAMASK_BIN" != "x" && ! $(echo ":$PATH:" | grep $DAMASK_BIN:) ]]; then [ "x$DAMASK_BIN" != "x" ] && PATH=$DAMASK_BIN:$PATH
export PATH=$DAMASK_BIN:$PATH
fi
SOLVER=$(which DAMASK_spectral || true 2>/dev/null) SOLVER=$(which DAMASK_spectral || true 2>/dev/null)
if [ "x$SOLVER" == "x" ]; then [ "x$SOLVER" == "x" ] && SOLVER='Not found!'
SOLVER='Not found!'
fi
PROCESSING=$(which postResults || true 2>/dev/null) PROCESSING=$(which postResults || true 2>/dev/null)
if [ "x$PROCESSING" == "x" ]; then [ "x$PROCESSING" == "x" ] && PROCESSING='Not found!'
PROCESSING='Not found!'
fi [ "x$DAMASK_NUM_THREADS" == "x" ] && DAMASK_NUM_THREADS=1
if [ "x$DAMASK_NUM_THREADS" == "x" ]; then
DAMASK_NUM_THREADS=1
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

View File

@ -1,7 +1,12 @@
# sets up an environment for DAMASK on zsh # 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} DAMASK_ROOT=${0:a:h}
fi
# shorthand command to change to DAMASK_ROOT directory # shorthand command to change to DAMASK_ROOT directory
eval "function damask() { cd $DAMASK_ROOT; }" eval "function damask() { cd $DAMASK_ROOT; }"
@ -13,17 +18,12 @@ set() {
source $DAMASK_ROOT/CONFIG source $DAMASK_ROOT/CONFIG
unset -f set unset -f set
# add DAMASK_BIN if present but not yet in $PATH # add DAMASK_BIN if present
MATCH=`echo ":$PATH:" | grep $DAMASK_BIN:` [ ( "x$DAMASK_BIN" != "x" ) ] && PATH=$DAMASK_BIN:$PATH
if [[ ( "x$DAMASK_BIN" != "x" ) && ( "x$MATCH" = "x" ) ]]; then
export PATH=$DAMASK_BIN:$PATH
fi
SOLVER=`which DAMASK_spectral || True 2>/dev/null` SOLVER=`which DAMASK_spectral || True 2>/dev/null`
PROCESSING=`which postResults || True 2>/dev/null` PROCESSING=`which postResults || True 2>/dev/null`
if [ "x$DAMASK_NUM_THREADS" = "x" ]; then [ "x$DAMASK_NUM_THREADS" = "x" ] && DAMASK_NUM_THREADS=1
DAMASK_NUM_THREADS=1
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