Running a Program
Single Core Case
Specifying the Number of Nodes and Processes

It is possible to run Matlab on the cluster in order to either run multiple instances at the same time or by using the Parallel capabilities of Matlab. The key is that since the jobs are run on nodes without graphics capabilities, Matlab needs to be told to not try to render any graphics. This can be done on the command line. Other than that the job scripts are set up in the same way as other jobs. Here is an example:

#!/bin/bash -l
#PBS -q batch
#PBS -N NetCDF_repeat
#PBS -l nodes=1:ppn=1
#PBS -l walltime=100:00:00
#PBS -o out.txt
#PBS -e err.txt
module load matlab
matlab -nodesktop -nosplash -r running_monthly_mean &> out..log

In this example only one process is being used (one node with one process per node). The added parameters on the Matlab command line are:

  • -nodesktop : this tells Matlab to not bring up the graphical desktop environment
  • -nosplash : don’t bring up the initial Matlab graphic
  • -r : run the script that follows, in this case a script called running_monthly_mean.m


If you’d like to use the Parallel capabilities the cluster is set up for shared-memory use of up to 12 cores in the pool. It is important that your job script cpu resource request matches what your Matlab script set up. For instance, if in your script you set up a pool of 6 cores:

poolobj = parpool(6);
parfor (i = 1:6 )

... your code ...


then you also need to have your job script request 6 cores on one node:

#!/bin/bash -l
#PBS -q batch
#PBS -N parallel_matlab
#PBS -l nodes=1:ppn=6
#PBS -l walltime=100:00:00
module load matlab
matlab -nodesktop -nosplash -r my_parallel_matlab_script &> out..log