#!/bin/csh # this script is a qsub companion script that's written explicitly to # handle Array Jobs (-t) option for MATLAB standalone batch jobs. # Similar to matlab -r ". . ." but more flexible # Usage: # scc1$ qsub -V ./run_standalone_job # SGE_TASK_ID = 1 # scc1$ qsub -V -t 3 ./run_standalone_job # SGE_TASK_ID = 3 # scc1$ qsub -V -t 4-6 ./run_standalone_job # 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) ./myExecR2013a $n $nprocs