MATLAB

From the MathWorks website https://uk.mathworks.com/products/matlab.html

MATLAB combines a desktop environment tuned for iterative analysis and design processes with a programming language that expresses matrix and array mathematics directly. It includes the Live Editor for creating scripts that combine code, output, and formatted text in an executable notebook.

Running MATLAB on CSD3

Running MATLAB will require you to load the matlab module which will load the latest version of MATLAB installed on CSD3. The MATLAB script below, with filename example.m, contains a function which requires an argument. This functions stores a value in a mat file named with the value of the given argument.

function example(name)
    x=2;
    save([name '.mat'],'x');
end

The slurm submit script which calls the above MATLAB function is shown below:

#!/bin/bash
#SBATCH -A MYACCOUNT-CHANGEME
#SBATCH -p skylake
#SBATCH -N 1
#SBATCH -n 1
#SBATCH -t 00:01:00
#SBATCH -J matlab-example
#SBATCH -o matlab_example.out
#SBATCH -e matlab_example.err

module purge
module load rhel7/default-peta4 matlab

matlab -nodisplay -r "example('output_file'); quit"

The slurm submit script can be submitted to the queue with sbatch from the same directory as the example.m MATLAB script file. This will run on one node using one core up to a limit of 1 minute. To run on more cores the -n option should be adjusted and the timelimit can be changed with -t.

NOTE that the quit command in the slurm submit script is required to quit MATLAB after the completion of the example MATLAB function.