#!/bin/csh
# set default to 4 cores unless override with, say, qsub -pe omp 8
#$ -pe omp 4
# add more qsub options here (start with #$)
matlab -nodisplay << MATLAB_ENV
% The below works like a script m-file between MATLAB_ENVs
% Better to use environment variable to pick up the runtime core size
matlabpool open $NSLOTS
s = 0;        % initialize
parfor i=1:n  % Parallel Computing Toolbox's for-loop
  s = s + i;  % compute arithmetic sequence sum s
end
matlabpool close
s             % print
% you can also invoke your own function- or script- m-files
exit          % essential to include this
MATLAB_ENV