When you use mcc
to generate a standalone, in addition to the executable myExecR2013a
, a companion run script run_myExecR2013a.sh
is also produced.
run_myExecR2013a.sh
#!/bin/sh
# script for execution of deployed applications
#
# Sets up the MCR environment for the current $ARCH and executes
# the specified command.
#
exe_name=$0
exe_dir=`dirname “$0″`
echo “——————————————”
if [ “x$1” = “x” ]; then
echo Usage:
echo $0 \<deployedMCRroot\> args
else
echo Setting up environment variables
MCRROOT=”$1″
echo —
LD_LIBRARY_PATH=.:${MCRROOT}/runtime/glnxa64 ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRROOT}/bin/glnxa64 ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRROOT}/sys/os/glnxa64;
MCRJRE=${MCRROOT}/sys/java/jre/glnxa64/jre/lib/amd64 ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRJRE}/native_threads ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRJRE}/server ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRJRE}/client ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRJRE} ;
XAPPLRESDIR=${MCRROOT}/X11/app-defaults ;
export LD_LIBRARY_PATH;
export XAPPLRESDIR;
echo LD_LIBRARY_PATH is ${LD_LIBRARY_PATH};
shift 1
args=
while [ $# -gt 0 ]; do
token=$1
args=”${args} \”${token}\””
shift
done
eval “\”${exe_dir}/myExecR2013a\”” $args
fi
exit
- Run interactively:
scc1$ ./run_myExecR2013a.sh /usr/local/matlab 2000 4
This run script expects the MCR path /usr/local/matlab
in addition to other command line inputs.
If you have multiple standalones compiled for different MATLAB releases, this could be a good alternative to the method recommended in the main page, which is ideal for standalones that are all compiled for a single MATLAB release (often the system default).
- Run in batch mode
scc1$ qsub ./run_standalone_shell
Note the above batch script is different than run_standalone_job
because of this change: run_myExec2013a.sh
replaces myExecR2013a
.
run_standalone_shell
#!/bin/csh
# SGE script for MATLAB standalone (generated with mcc)
# Usage:
# scc1$ qsub ./run_standalone_shell # SGE_TASK_ID = 1
# scc1$ qsub -t 3 ./run_standalone_shell # SGE_TASK_ID = 3
# scc1$ qsub -t 4-6 ./run_standalone_shell # SGE_TASK_ID = [4,5,6]
#
# Specify SGE batch scheduler options
# Merge output and error files in one
#$ -j y
# Send email to SCC userID when job finished or aborted
#$ -m ae
# Request 4 cores from omp queue (example needs multicores)
# For serial apps, prepend the line below with another #
##$ -pe omp 4
echo "\n\n********************************************"
echo "* This job runs on $HOSTNAME"
echo "********************************************\n\n"
set NODENAME = `echo $HOSTNAME | sed 's/.scc.bu.edu//'`
# Running MATLAB standalone results in creation of a cache folder in home dir
# This may cause runtime issues. Below is a workaround.
echo tmpdir is $TMPDIR
setenv MCR_CACHE_ROOT $TMPDIR
echo "\n\n********************************************"
echo "* Created local scratch folder /net/$NODENAME$TMPDIR"
echo "********************************************\n\n"
unsetenv DISPLAY
# Output to screen go to your ?.o$JOB_ID file
if ($SGE_TASK_ID == 'undefined') then
@ n = 1000;
#echo "SGE_TASK_ID does NOT exist: ${#SGE_TASK_ID} ; $SGE_TASK_ID"
else
@ n = $SGE_TASK_ID * 1000;
#echo "SGE_TASK_ID does exist: ${#SGE_TASK_ID} ; $SGE_TASK_ID"
endif
if ($NSLOTS == 'undefined') then
@ nprocs = 1; # in absence of -pe . . .
else
@ nprocs = $NSLOTS; # -pe omp 4 ==> NSLOTS = 4
endif
# this standalone example expects n (parfor i=1:n) & nprocs (cores)
./run_myExecR2014b.sh /usr/local/matlab $n $nprocs