• eResearch
    • Collaborative Technologies
      • ARDC (Australian Research Data Commons)
      • ARDC Nectar Research Cloud
      • Australian Access Federation
      • QRIScloud
      • Video Collaboration
    • Data Management
      • Research Data Management Plans
    • Data Services
      • Australian and International Data Portals
      • CQUni Research Data Storage Options
      • CQUniversity Research Data Storage
      • GEOSCIENCE DATA PORTALS
    • eResearch and Security: MFA and CyberSafety
      • Encrypting Data on Portable Devices
    • High Performance Computing
      • The History of CQU’s HPC Facilities
        • Ada Lovelace Cluster (New HPC)
        • Marie Curie Cluster (Current HPC)
        • Einstein Cluster (Decommissioned)
        • Isaac Newton HPC Facility (Decommissioned)
      • HPC User Guides and FAQs
        • Basics of working on the HPC
        • Getting started on CQUniversity’s Ada Lovelace HPC System
        • Graphical Connection to the HPC System
        • Compiling Programs (and using the optimization flags)
        • Connecting to the Marie Curie Cluster
        • Finding Installed Software
        • Frequently Asked Questions
        • Graphical connection HPC via Open On Demand
        • HPC Job Scheduler
        • HPC Trouble Shooting
        • Machine and Deep Learning
        • PBS Commands
        • PBS to Slurm Command tables (HPC Scheduler)
        • Running LLM’s on the HPC system
        • Running Python on HPC
        • Simple Unix Commands
        • Software Module Information
        • Submitting an Interactive Job
        • Transferring Files to the HPC System
        • Transferring Files to the HPC System (Ada)
        • Using Abaqus
        • Using ANSYS (Fluent) on the HPC System
        • Using APSIM
        • Using HPC Scheduler on Ada Lovelace Cluster
        • Using MATLAB
        • Using R
        • Virtualisation and Containers
      • HPC Community
      • HPC Related Links
      • HPC Sample Code Scripts
        • MATLAB Sample Scripts
        • Multiple Job Submission
        • Multiple Run Job Submission
        • PBS Job Array Submission
        • R Sample Scripts
        • Sample PBS Submission Script
        • Sample Slurm Submission Script
      • HPC Software
        • Mathematica Sample Scripts
    • Research Software
    • Scholarly Communication
    • Survey Tools
    • Training
      • QCIF – Queensland Cyber Infrastructure Foundation
      • Teaching Lab Skills for Scientific Computing

eResearch

MATLAB Sample Scripts

On the CQ University HPC systems, a PBS (HPC Schedule) resource “MATLAB” has been implemented, which checks to see if a MATLAB license is available.  If the MATLAB resource is available, as well as the other resources (CPU, Memory, etc), it will start the job, otherwise it will queue the job/s until the required resources become available.  The purpose of using this resource allows to submit as many MATLAB jobs to the HPC system, without having to worry if a License is available or not.

A sample MATLAB PBS Script can be found on the HPC system at /apps/samples/PBS/matlab.pbs which can be copied your home directory for use.  The details for this script can be found below:

Example Matlab PBS Submission Script (/apps/samples/PBS/matlab.pbs)

###### 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 -nosplash < <matlab-program.m>

Additionally, a very basic “hello world” matlab program which passes a program id number and execute 10 programs concurrently.

These programs can be copied from /apps/samples/matlab to your home directory to try out and use as a foundation for your programs.

These scripts and programs are as follows:

Matlab Sample Program (/apps/samples/matlab/hello.m)

function hello(i)

message = ['Hello world from program ' num2str(i) ]

disp(message);

quit

and

Sample Matlab multiple Submission Script (/apps/samples/matlab/matlab-test.sh)

#!/bin/bash

for ((i=1; i<=10; i+=1))
do
jobname=Matlab_$i
    cat << EOF | qsub
###### Select resources #####
#PBS -N $jobname
#PBS -l ncpus=1
#PBS -l mem=1g
#PBS -l MATLAB=1
##### Queue #####
#PBS -q workq
########## Output File ##########
#PBS -o \$PBS_O_WORKDIR/$jobname.txt
########## Error File ##########
#PBS -e \$PBS_O_WORKDIR/$jobname.err
##### Change to current working directory #####
cd \$PBS_O_WORKDIR
##### Execute Program #####
. /etc/profile.d/modules.sh 
module unload matlab
module load matlab-r2017b
matlab -nodisplay -nodesktop -nosplash -r 'hello($i)'
EOF
done

You will noticed that the script above uses different “job names”, different error and output file names for each program.  Additionally, we removed the email notifications, otherwise we would get 10 emails every time the jobs start and finish.

It is hoped that these sample scripts and programs will assist you to develop better MATLAB programs and assist to increase your research output, by being able to submit many jobs in parallel.

Support

eresearch@cqu.edu.au

tasac@cqu.edu.au OR 1300 666 620

Hacky Hour (3pm – 4pm every Tuesday)

High Performance Computing Teams site