1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
#!/bin/bash
# launcher for matlab/octave/ifit data plotter
@MCCODE_BASH_STANDARD_PREAMBLE@
LIB="${MCCODE_TOOLDIR}/matlab/@P@plot"
TOOL="mcplot"
VERS="@MCCODE_VERSION@"
canrun_m() {
if ! [ -x ${LIB}/${TOOL}.m ]; then
exit 127;
fi
# is matlab on the path?
if ! [ `which matlab` ]; then
exit 127;
fi
}
canrun_i() {
if ! [ -x ${LIB}/${TOOL}.m ]; then
exit 127;
fi
# is ifit on the path?
if ! [ `which ifit` ]; then
exit 127;
fi
}
canrun_o() {
if ! [ -x ${LIB}/${TOOL}.m ]; then
exit 127;
fi
# is octave on the path?
if ! [ `which octave` ]; then
exit 127;
fi
}
# defaults
if ( canrun_m ); then RUN_MATLAB=1; else RUN_MATLAB=0; fi
if ( canrun_o ); then RUN_OCTAVE=1; else RUN_OCTAVE=0; fi
if ( canrun_i ); then RUN_IFIT=1; else RUN_IFIT=0; fi
# handle input options, overriding defaults
while getopts hiom flag
do
case "${flag}" in
o)
RUN_OCTAVE=1
RUN_MATLAB=0
RUN_IFIT=0
;;
m)
RUN_MATLAB=1
RUN_OCTAVE=0
RUN_IFIT=0
;;
i)
RUN_IFIT=1
RUN_MATLAB=0
RUN_OCTAVE=0
;;
*)
echo "$0: plot a McCode simulation result using the Matlab/Octave backend."
echo "usage:"
echo " $0 FILE|DIR"
echo " Display the specified monitor file or directory."
echo " $0 [-png|-jpg|-fig|-eps|-pdf] [FILE|DIR]"
echo " Export the specified monitor file or directory to given format."
echo " $0 -m FILE|DIR"
echo " Explicitely request to use Matlab"
echo " $0 -o FILE|DIR"
echo " Explicitely request to use Octave"
exit 1
;;
esac
done
shift $((OPTIND-1))
if [ "$RUN_MATLAB" == "1" ]; then
matlab -nosplash -nodesktop -r "addpath('${LIB}');${TOOL} $*"
elif [ "$RUN_IFIT" == "1" ]; then
ifit -r $*
elif [ "$RUN_OCTAVE" == "1" ]; then
octave --eval "addpath('${LIB}');${TOOL} $*;"
else
echo ":: Failed to run Matlab/iFit/Octave ${TOOL}, trying default ${TOOL} instead."
echo ":: If this fails too, consider reinstalling ${TOOL}."
echo ""
# Try old Perl-version of mcplot if Python version cannot run
${TOOL} $*
fi
|