From Documentation
Revision as of 09:34, 6 June 2019 by Edward (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
This page is will be deleted pending it's creation on the CC wiki.
Description: Mostly compatible language with Matlab primarily intended for numerical computations
SHARCNET Package information: see OCTAVE software page in web portal
Full list of SHARCNET supported software


Octave is provided on SHARCNET clusters to allow serial or threaded jobs to be run in the queue as described below.

OCTAVE on the Graham national system

On the Graham system the user simply needs to call the "module load" command without manually unloading conflicting packages.

$ module load octave/4.2.1

To obtain information about the package's dependencies the "spider" action can be included in the call to "module":

$ module spider octave

      GNU Octave is a high-level interpreted language, primarily intended for numerical computations. - Homepage:


  For detailed information about a specific "octave" module (including how to load the modules) use the module's full name.
  For example:

     $ module spider octave/4.2.1


[jdesjard@gra-login1 ~]$ module spider octave/4.2.1

  octave: octave/4.2.1
      GNU Octave is a high-level interpreted language, primarily intended for numerical computations. - Homepage:

      Tools for development / Outils de développement

    You will need to load all module(s) on any one of the lines below before the "octave/4.2.1" module is available to load.

      nixpkgs/16.09  gcc/5.4.0
      nixpkgs/16.09  intel/2016.4
      nixpkgs/16.09  intel/2017.1
      GNU Octave is a high-level interpreted language, primarily intended for numerical computations. - Homepage:

Job Submission

The Graham national system uses the Slurm scheduler which is different from the Torque Moab scheduler that is typical to the majority of other SHARCNET systems. In order to submit a simple "Hello World!" process to Graham the user would first need to create a submit script as follows.

$ cat 
#SBATCH -t 0-00:01
#SBATCH --mem=400
octave --eval 'disp("Hello World! from Octave")'

Then pass this submit script to "sbatch" to be entered into the queue:

$ sbatch --account=accountname

... where "accountname" is the name of the accounting group to submit to (e.g. def-groupname, rgg-projectname).

Example Job

This section shows howto submit a sample.m file to the serial queue that accepts command line arguments.

[roberpj@hnd20:~/samples/octave/args] cat sample.m 
#! /bin/octave -qf
printf ("%s", program_name ());
arg_list = argv ();
for i = 1:nargin
    printf (" %s", arg_list{i});
printf ("\n");

To eliminate exatraneous verbosity in the output file two switches are passed:

[roberpj@hnd20:~/samples/octave/args] sqsub -r 60m -o ofile.%J octave -qf --no-window-system sample.m arg1 arg2 arg3 etc
WARNING: no memory requirement defined; assuming 2GB per process.
submitted as jobid 6937872

The output file from the job appears as:

[roberpj@hnd20:~/samples/octave/args] cat ofile.6937872.hnd50
sample.m arg1 arg2 arg3 etc

One the Graham national system

Rather than dedicated development as it typical on some of the other SHARCNET systems the national systems have nodes that prioritize interactive jobs allocated by call to "salloc" of the Slurm scheduler.

To use Octave interactively on Graham you can do the following:

Use salloc to request a single task for one hour:

$ salloc --account=def-roxa88 --time=1:0:0 --ntasks=1

Then you will receive notification when the reservation is granted (including jobid), for example:

salloc: Granted job allocation 12345

Then use srun to start a terminal to work in on the reservation:

$ srun --wait 0 --pty bash

Once running the terminal in the allocation you can start your work with Octave by loading the module and starting the program:

$ module load octave
$ octave
octave: X11 DISPLAY environment variable not set
octave: disabling GUI features
GNU Octave, version 4.2.1
Copyright (C) 2017 John W. Eaton and others.
This is free software; see the source code for copying conditions.
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-pc-linux-gnu".

Additional information about Octave is available at

Please contribute if you find this software useful.
For more information, visit

Read to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.


... Then once you have the "octave:#>" prompt the terminal will behave like the Matlab command line.

Once you are finished with Octave use "quit" to exit the program, then "exit" to logout of the compute node (terminate srun), then "exit" again to terminate the allocation (relinquishing the allocate resources).

Running on a visualization system

Once logged in to a visualization system an instance of Octave can be launched from Applications Menu > Eduction > GNU Octave.

General notes

Matlab Compatibility

The online wiki resources "Octave Wiki":  

or "Wikibook": 

provide good introductory explanations of code compatibility between Octave and Matlab.

In order to run Octave so that it interprets scripts as closely as possible to Matlab, use the --traditional flag. Taking from the above sqsub example the maximum Matlab compatible submission would be:

sqsub -r 60m -o ofile.%J octave --traditional mycode.m

Reading/Writing Files

There are two strategies for handling file input and output described in the "Octave manual" viz ...

The following stanza demonstrates the "simple file I/O" approach:

save myiofile.dat A B C
save ("-text", "myiofile.dat", "A", "B", "C")
save ("-binary", "myiofile.dat", "A", "B", "C")
load myiofile.dat
load ("-text", "myiofile.dat", "A", "B", "C")
load ("-binary", "myiofile.dat", "A", "B", "C")

where A, B and C are a potential mix of entities such as scalars, vectors or matrices. Note that for large files the binary format is strongly recommended to both minimize disk space and file read/write wallclock times.


Octave-forge packages are not pre-installed on SHARCNET clusters since none are available at this time for the operating system. Therefore any required packages must be downloaded, manually installed from source and then managed in local user accounts (as described below).

However 16 of approximately 95 octave-forge packages are installed on some sharcnet visualization workstations including viz1,2,3-uwaterloo, viz2-uwo, viz6-uoguelph under /usr/share/octave/packages. As a word of caution however, all package versions will likely be significantly old since they are tied to the operating system fedora /etc/redhat-release major version and hence not contain recent critical bug fixes (which could be numerical in nature). Users are therefore strongly recommended to likewise download and install the latest version similarly as would be done on the clusters.

Sharing Packages

Note that packages installed by a single sharcnet user in their home account can be shared out to other research group members or even among general SHARCNET users. To do this simply set access permissions for group or global read access accordingly. For details on how to change the permissions see:

Managing Packages

The "Octave Forge" project provides extra packages for use with octave that can be downloaded into a directory such as ~/my_octave_sources then manually installed into your own sharcnet account as will be shown in the follow example. A current list of packages available for download that notable are generally only compatible with the latest major release of octave cat be found here

In the event where the major version of octave on sharcnet you are using (for instance 3.4.x) is not the same as latest major version (at the time of writing 3.6.x) and there were programming api changes between the two versions that effect the package you want to use, then you probably will need to download an older version of a package from for it to work.

To help estimate the package version required as a starting point, consider the major release dates of recent which are octave-3.4.3 (10/10/11), octave-3.6.0 (01/15/12), octave-3.6.1 (02/22/12) and finally octave-3.6.2 (05/31/12). Next consider you want to download the latest geometry package that was compatible with octave-3.4.3 at the time of its release, then simply display all the archived versions as shown in the following stanza and pick the last available geometry release date before the next major release octave-3.6.0 (01/15/12). To show a list of all archived geometry versions, do the following steps:
Click Packages on top menu menu bar
Scroll down to the miscellaneous package row and click details
Click (older versions) located below "Download Package"
Click Octave Forge Packages
Click  Individual Package Releases
Please wait for the page to load ...
Click "Name" at the top of first colum to sort packages alphabetically
Scroll down you will find all available archived geometry packages:
 geometry-1.0.1.tar.gz  2011-09-27
 geometry-1.1.1.tar.gz  2011-10-06
 geometry-1.1.2.tar.gz  2011-10-09
 geometry-1.1.3.tar.gz  2011-10-13
 geometry-1.1.tar.gz    2011-10-04
 geometry-1.2.0.tar.gz  2011-10-22
 geometry-1.2.1.tar.gz  2011-11-02
 geometry-1.2.2.tar.gz  2011-11-04
 geometry-1.4.0.tar.gz  2012-01-25
 geometry-1.4.1.tar.gz  2012-03-24
 geometry-1.5.0.tar.gz  2012-06-05

Therefore you will download geometry-1.2.2.tar.gz (2011-11-04) since the next release geometry-1.4.0.tar.gz (2012-01-25) and then install it into octave 3.4.3 as follows:

[roberpj@tope:~/my_octave_sources] octave
GNU Octave, version 3.4.3
octave:1> pkg install geometry-1.2.2.tar.gz
octave:2> pkg list
Package Name   | Version | Installation directory
     geometry  |   1.2.2 | /home/roberpj/octave/geometry-1.2.2
octave:15> pkg load geometry
octave:16> pkg describe geometry
Package name:
Short description:
        Library for geometric computing extending MatGeom functions. Useful to create,
transform, manipulate and display geometric primitives.

Note: Any questions regarding package version compatibility with major or minor octave release should be referred to the developers.

Package Commands

Additional examples of package commands are shown in this section. For demonstration purpose linear-algebra will first be downloaded:

[roberpj@iqaluk:~] mkdir my_octave_sources
[roberpj@iqaluk:~] cd my_octave_sources
octave:1>  help pkg

To install a package such as linear-algebra do:

octave:2>  cd ~/my_octave_sources
octave:3>  pkg install  general-1.3.2.tar.gz
octave:4>  pkg install linear-algebra-2.2.0.tar.gz

To remove a package, from a terminal first do:

cd ~/octave
rm -rf linear-algebra-2.2.0

... then from within octave do:

octave:5>  pkg uninstall linear-algebra

To list all installed packages do:

octave:6>  pkg list

To add a named packages to your path:

octave:7>  pkg load name

To remove a named package from your path:

octave:8>   pkg unload

To list all functions provided by a package:

octave:9>  pkg describe -verbose all

To list functions provide by extra odepkg package:

octave:10>  pkg describe odepkg

To list functions details for extra financial package:

octave:11>  pkg describe financial -verbose

To get documentation for a topic such as sin do:

octave:12>   doc sin

To get help using the doc command do:

octave:13>   help doc

To get documentation for a topic such as matrix do:

octave:14>  doc matrix

To get documentation for any topic run the doc command alone:

octave:15>  doc

Package Example

This example assumes you first create two directories in your home account one being named


and the other


then download the required three tar.gz files into the latter from ...
[roberpj@orc-login1:~] module unload octave
[roberpj@orc-login1:~] module load octave
[roberpj@orc-login1:~] octave
GNU Octave, version 3.4.3
octave:1> pkg prefix ~/my_octave_packages
ans = /home/roberpj/my_octave_packages
octave:2> cd my_octave_sources
octave:3> ls
miscellaneous-1.0.11.tar.gz  optim-1.0.17.tar.gz   struct-1.0.9.tar.gz
octave:4> pkg install miscellaneous-1.0.11.tar.gz  optim-1.0.17.tar.gz struct-1.0.9.tar.gz
octave:5> pkg list
Package Name   | Version | Installation directory
miscellaneous *|  1.0.11 |  /home/roberpj/my_octave_packages/miscellaneous-1.0.11
       optim *|  1.0.17 |  /home/roberpj/my_octave_packages/optim-1.0.17
      struct *|   1.0.9 |  /home/roberpj/my_octave_packages/struct-1.0.9</PRE>


o Octave Homepage

o Octave 725 Page Manual (Version 3.4.0)

o Statistic Package Function Reference

o GNU Octave Wiki

o Matlab-Like Tools for HPC (article)