82 lines
2.4 KiB
Bash
82 lines
2.4 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
#############################################################
|
||
|
# This example produces a very simple plot and #
|
||
|
# saves it as Matlab figure file and as PNG file #
|
||
|
#############################################################
|
||
|
|
||
|
#############################################################
|
||
|
# set qsub options #
|
||
|
#############################################################
|
||
|
# run in low.q
|
||
|
#$ -l low
|
||
|
|
||
|
# request enough memory
|
||
|
#$ -l h_vmem=8G,memory=8G,h_stack=8M
|
||
|
|
||
|
# request 1 matlab license.
|
||
|
#$ -l matlab=1
|
||
|
|
||
|
# Name the job 'Matlab'
|
||
|
#$ -N Matlab
|
||
|
|
||
|
# send e-mail after job has finished
|
||
|
# use the -M option to define your e-mail address
|
||
|
# #$ -M meine-email@example.org
|
||
|
#$ -m e
|
||
|
|
||
|
# join stdout and stderr in one file
|
||
|
#$ -j y
|
||
|
|
||
|
#############################################################
|
||
|
# output hostname and date (comment out if not needed) #
|
||
|
#############################################################
|
||
|
echo "Runnning Matlab on host " `hostname`
|
||
|
echo "Starting Matlab at " `date`
|
||
|
|
||
|
#############################################################
|
||
|
# launch matlab #
|
||
|
#############################################################
|
||
|
|
||
|
# run non-interactive Matlab session
|
||
|
# use no display (-nodisplay)
|
||
|
# don't show splash screen at startup (-nosplash)
|
||
|
# don't start the matlab desktop (-nodesktop)
|
||
|
# use software opengl (-softwareopengl)
|
||
|
# only use single threaded computations (limit to use of 1 core, -singleCompThread)
|
||
|
# execute all matlab commands between '<< END' and matching 'END'
|
||
|
|
||
|
# Don't forget to add 'exit' and 'END' after replacing
|
||
|
# the commands with your own!
|
||
|
|
||
|
/opt/matlab/bin/matlab -nodisplay -nosplash -nodesktop -softwareopengl -singleCompThread << END
|
||
|
|
||
|
% get environment variable JOB_ID
|
||
|
jobid=str2num(getenv('JOB_ID'));
|
||
|
if isempty(jobid)
|
||
|
jobid = 0;
|
||
|
end
|
||
|
|
||
|
% create filenames for the figure
|
||
|
filename=sprintf('matlab_figure_%d', jobid);
|
||
|
|
||
|
% create new empty figure and save figure handle
|
||
|
fh = figure();
|
||
|
|
||
|
% draw plot
|
||
|
plot(-pi:0.01:pi, sin(-pi:0.01:pi));
|
||
|
|
||
|
% save figure as matlab figure and PNG
|
||
|
saveas(fh, filename, 'fig');
|
||
|
saveas(fh, filename, 'png');
|
||
|
|
||
|
% EXIT MATLAB
|
||
|
exit;
|
||
|
|
||
|
END
|
||
|
|
||
|
#############################################################
|
||
|
# output date (comment out if not needed) #
|
||
|
#############################################################
|
||
|
echo "Matlab finnished at " `date`
|