You don't run MatLab directly on the CSC clusters, you run it within the queue.
This involves three simple steps:
- Use a wrapper script that will run your MatLab program and save the output.
- Use a simple Torque script to run that wrapper in the queue
- Submit the job to the queue.
One big advantage of doing this is that you can submit a bunch of jobs at once and then walk away. The system can run many at once as well, so you can get a lot done in a short time! It also doesn't tie up a bunch of licenses (which we pay for). However, be aware of this in the naming of your files so you don't overwrite your data - perhaps put each run in a separate subdirectory.
Step one: You use a wrapper script to run your program (Say in this example it's 'FreezingPoint.m'). The script is simply:
All you need to do is change the line with 'FreezingPoint' to the name of your MatLab program. The 'close all' closes any graphics windows you have open (remember it's running it in the queue, you won't necessarily be sitting there at the computer when it runs), and the 'save MyData' creates a data file that you can later open in MatLab to look at your results (and there you can plot the data!). Ideally, you would comment out lines where it may plot results - you won't be able to see the plots while it's running anyway.
Step two: Compiling the program (i.e. turning it into a stand alone exectuable file that can be run on any Linux system).
From within MatLab type mcc -m wrapper.m (assuming your 'wrapper' from above is wrapper.m). If you look in your directory now you'll have a new file named 'wrapper' (it may have a * after it). This is the executable - it no longer needs 'MatLab' to run!
Step three: You submit this job to the queue with a simple file. This is a regular Torque file.
#!/bin/bash # This next line asks for 1 node with only 1 processor/node – so a serial job #PBS -l nodes=1:ppn=1 # # Change to the directory we are in cd $PBS_O_WORKDIR # ./run_wrapper.sh /sw/MatLab/matlab-2012b/
If this file is named myscript.job, just run it with 'qsub myscript.job'. Note that you can submit a bunch of jobs at once, so say you need to run a calculation at 100 different temperatures.
Monitor to see when your job finishes with 'qstat' and 'showq' - when it's done, start up MatLab and read in the file 'MyData.m' which will contain all of your MatLab variables.
Obviously you can make the wrapper scripts (and your MatLab programs) much more elegant to write a different filename for each temperature, etc. but this should get you started!