Breadcrumb Links:

Submitting a Matlab Job

By default, when running Matlab, the program is running interactively on the Head/Login nodes (isaac or newton). This is perfectly acceptable when developing programs and/or running short tests. Though, when you wish to execute jobs, especially jobs that run for a reasonable amount of time, you should submit the program to execute on the "Cluster" of compute nodes to be run non-interactively.

If you execute large jobs on the "Head" node, this will slow down usability and will impact other users performance.

The following guide provides details on how to submit a Matlab job to the HPC cluster.

Submitting a Matlab Job to the cluster in non interactive mode

In order to submit a Matlab job to the cluster, you need to write a script file similar to the one below. Lines beginning with "##" represents comments.

The variable $PBS_O_WORKDIR indicates the directory where the PBS script file is located and launched from. All text defined as "< ... >" indicated a value or text that needs to be defined.

Please note - this sample script can be found at /apps/samples/PBS and you are welcome to copy this to your home directory for use.

######  Select resources #####
#PBS -N <jobname>
#PBS -l ncpus=<requested cpu's>
#PBS -l mem=<requested memory>
#PBS -l MATLAB=1

##### Queue #####
#pbs -q workq

##### Mail Options #####
#PBS -m abe
#PBS -M <your email address>

########## Output File ##########
#PBS -o \$PBS_O_WORKDIR/<output-filename>

########## Error File ##########
#PBS -e \$PBS_O_WORKDIR/<error-filename>

##### Change to current working directory #####
cd \$PBS_O_WORKDIR

##### Execute Program #####
matlab -nodisplay -nodesktop -nojvm -nosplash < <matlab-program.m> 


Real Example

######  Select resources #####
#PBS -N Test
#PBS -l ncpus=1
#PBS -l mem=1gb
#PBS -l MATLAB=1

##### Queue #####
#pbs -q workq

##### Mail Options #####
#PBS -m abe
#PBS -M j.bell@cqu.edu.au

########## Output File ##########
#PBS -o $PBS_O_WORKDIR/output.txt

########## Error File ##########
#PBS -e $PBS_O_WORKDIR/error.txt

##### Change to current working directory #####
cd $PBS_O_WORKDIR

##### Execute Program #####
matlab -nodisplay -nodesktop -nojvm -nosplash < hello2.m


Executing script on the cluster

The HPC facilities uses a job scheduler that allows you to schedule and run jobs on the various compute nodes. To submit a job, simply execute the command:

qsub [pbs_script_file]

To check if your job is running, queued or completed can be seen by using the commands:

qstat

qusers

myjobs