diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2010-08-04 16:49:47 +0200 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2010-08-04 16:49:47 +0200 |
commit | 62b0a3821fd3f9e860bc3306b43e447e427089ac (patch) | |
tree | 4b78b5d23555aa20eff2052f7a4e649e7e1475ca /Bin | |
parent | 3d6cc02c4fc79e7969adeeeaf3a2a044462e440c (diff) |
kranc: Update the Kranc/Bin/kranc script and move some functionality into a new RunKranc.m file
The kranc script now looks for a Kranc installation relative to the path of the kranc script. It also has a "-v" option now to increase verbosity. Exceptions should be printed nicely.
Diffstat (limited to 'Bin')
-rwxr-xr-x | Bin/kranc | 52 |
1 files changed, 29 insertions, 23 deletions
@@ -1,32 +1,38 @@ #!/bin/bash -# A shell script to run Kranc on a mathematica input file - -INFILE=$1 - -if ! which math >/dev/null +# Assume that this script is called from the Kranc/Bin directory +export KRANCDIR=$(dirname $0)/.. +export KRANCVERBOSE=no + +while getopts "v" flag +do + case $flag in + "v") + export KRANCVERBOSE=yes + ;; + esac +done + +shift $(expr $OPTIND - 1) + +if [ $# -eq 0 ] then - echo "Cannot find math executable. Is Mathematica on your path?" + echo "Usage: $0 [-v] <script>" + exit 1 fi -LOCALKRANCPATH="Kranc/Tools/CodeGen:Kranc/Tools/MathematicaMisc:Kranc/Tools/External" +MMASCRIPT=$1 +shift -if [ -z "$MATHPATH" ] -then - MATHPATH=$LOCALKRANCPATH +MATH_MACOS=/Applications/Mathematica.app/Contents/MacOS/MathKernel + +if which math >/dev/null; then + MATH=math +elif [ -x $MATH_MACOS ]; then + MATH=$MATH_MACOS else - MATHPATH=$LOCALKRANCPATH:$MATHPATH + echo "Cannot find math executable. Is Mathematica on your path?" + exit 1 fi -export MATHPATH - -math <<EOF - -Module[{mp, newPath}, - mp = StringToStream[Environment["MATHPATH"]]; - newPath = Map[ToString, ReadList[mp, Word, WordSeparators->{":"}]]; - \$Path = Join[newPath, \$Path]]; -Needs["Errors\`"]; -exception = Catch[Get["$INFILE"], KrancError]; -PrintError[exception]; -EOF +$MATH -run "Get[\"$KRANCDIR/Tools/MathematicaMisc/RunKranc.m\"]" $MMASCRIPT </dev/null |