From Documentation
Revision as of 10:17, 30 August 2016 by Edward (Talk | contribs)

Jump to: navigation, search

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.

Version Selection

To see what versions of Octave are available on sharcnet clusters consult the Availability table on the sharcnet OCTAVE web portal software page OR run the following command directly on a cluster:

module avail

Starting with version 3.6.3 its necessary to first unload the intel compiler module (or any other compiler that might be loaded) before loading the Octave module. This is done to ensure any octave-forge packages that are to be downloaded and installed into user space are built with the native gcc compiler which is version 4.4.6 at the time of this writing. Therefore to load octave/3.6.3 one would do:

module unload intel
module load octave/3.6.3

Similarly, to load the default Octave module (currently version 3.8.1) one would do:

module unload intel
module load octave

Job Submission

On SHARCNET clusters for production work Octave should only be run via the queuing system. Octave serial jobs can be submitted to the serial queue using following sqsub command:

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

As of version 3.4.3 the sharcnet octave installation supports multi-threading which based on initial testing lapack/blas intensive octave jobs run in the threaded queue achieve an order of magnitude speedup compared to running single core jobs in the serial queue, without making any changes to your code. Once the optimal number of processors is determined by scaling tests submit the job to the threaded queue for example:

sqsub -r 60m -n 8 -q threaded --mpp=1G -o  ofile.%J time octave mycode.m

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

Running in the development nodes

Besides running production work in Octave via the scheduler on SharcNET systems it is also possible to use Octave interactively on systems' development nodes.

To start Octave from a development node one can login to a system with trusted X11 forwarding enabled:

ssh -Y

Then login to one of the development nodes with trusted X11 forwarding enabled:

ssh -Y kraken-devel1

Once logged into the development node one can load the Octave modules and launch the program:

module unload intel
module load octave
 GNU Octave, version 3.8.1
 Copyright (C) 2014 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-unknown-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'.


With X11 forwarding enabled in the development node interactive work with Octave can include figure generation.

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)