GNU Octave is a high-level language, primarily intended for numerical computations. It provides a convenient command line interface for solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with Matlab. It may also be used as a batch-oriented language.
Many, but not all, Matlab .m scripts will run in Octave. MEX files (to call custom C or Fortran routines directly from Matlab) can be executed in Octave with some limitations.
Octave was written by John Eaton and others, and is available from the Octave website. Octave on Biowulf is installed courtesy of Tom Holroyd, NIMH. The version of Octave on Biowulf can be determined by typing octave -v at the Biowulf prompt.
Octave runs are typically slower than the equivalent Matlab run. However, Octave is not license-limited, so many more simultaneous runs are possible than with Matlab. Thus, on the Biowulf cluster Octave is most useful for projects which can be split into large numbers of independent simultaneous runs.
The following toolboxes are currently installed on the system.
Package Name | Version | Installation directory |
combinatorics | 1.0.0 | /usr/local/octave/share/octave/packages/combinatorics-1.0.0 |
geometry | 1.0.1 | /usr/local/octave/share/octave/packages/geometry-1.0.1 |
informationtheory | 0.1.0 | /usr/local/octave/share/octave/packages/informationtheory-0.1.0 |
io | 1.0.0 | /usr/local/octave/share/octave/packages/io-1.0.0 |
linear-algebra | 1.0.0 | /usr/local/octave/share/octave/packages/linear-algebra-1.0.0 |
odepkg | 0.2.3 | /usr/local/octave/share/octave/packages/odepkg-0.2.3 |
parallel | 1.0.0 | /usr/local/octave/share/octave/packages/parallel-1.0.0 |
physicalconstants | 0.1.0 | /usr/local/octave/share/octave/packages/physicalconstants-0.1.0 |
signal | 1.0.0 | /usr/local/octave/share/octave/packages/signal-1.0.0 |
statistics | 1.0.0 | /usr/local/octave/share/octave/packages/statistics-1.0.0 |
Octave is primarily a command-line program. There are currently no Octave GUIs available on Biowulf.
- Create an Octave script. The following sample script takes a single
argument from the command line.
-------------file array.oct------------------------------- #!/usr/local/bin/octave -qf if( nargin != 1 ) printf( "Usage: %s <integer>\n", program_name ); return; endif len = str2num( argv(){1} ); printf( "Working with array size %6d\n", len ); clear a; tic(); for i=1:len a(i) = i; endfor time1 = toc(); a = [1]; tic(); for i=2:len a = [a i]; endfor time2 = toc(); printf( "The time taken for method 1 was %.4f seconds\n", time1 ); printf( "The time taken for method 2 was %.4f seconds\n", time2 ); -------------------------------------------------------------------
- Create a batch script for the job. Sample script:
-------- file array.bat---------------------- #!/bin/csh cd /data/user/mydir ./array.oct 10000 ---------------------------------------------
- Submit this job to the batch system with:
qsub -l nodes=1 ./array.bat
./array.oct 10000 > filename.outin the batch script above.
Octave on Biowulf is most useful for running large numbers of simultaneous independent jobs via the swarm program. The sample script array.oct above could be used to submit many jobs with different parameters.
- Create a swarm command file, with one line for each command you wish to
run. Sample file:
/data/user/mydir/array.oct 1000 > array.out.1000 /data/user/mydir/array.oct 2000 > array.out.2000 /data/user/mydir/array.oct 3000 > array.out.3000 ... /data/user/mydir/array.oct 20000 > array.out.20000
- Submit this to the swarm program with swarm -f commandfilename.
Sample session:
[user@biowulf octave]$ swarm -f swarm.cmd 291383.biobos 291384.biobos [user@biowulf octave]$
For debugging purposes, it is also possible to run Octave interactively. An interactive node should be allocated for this purpose. Sample session (user input in bold):
[susanc@biowulf ~]$ qsub -I -l nodes=1 qsub: waiting for job 290150.biobos to start qsub: job 290150.biobos ready p226 job-busy interactive [susanc@p226 ~]$ octave GNU Octave, version 2.9.9 (i686-pc-linux-gnu). Copyright (C) 2006 John W. Eaton. This is free software; see the source code for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'. Additional information about Octave is available at http://www.octave.org. Please contribute if you find this software useful. For more information, visit http://www.octave.org/help-wanted.html Report bugs to bug@octave.org (but first, please read http://www.octave.org/bugs.html to learn how to write a helpful report). octave:1> a=1+1 a = 2 octave:2> sin(x) ans = -0.27942 octave:3> x=5*pi x = 15.708 octave:4> sin(x) ans = 6.1230e-16 octave:6> quit [susanc@p226 ~]$ exit logout qsub: job 290150.biobos completed [susanc@biowulf ~]$
- Online documentation is available by typing help at the Octave prompt. (e.g. help acos)
- The Octave Manual
- Octave Wiki
- Differences between Matlab & Octave, at Wikibooks.
- Speed comparisons of R, S-Plus, Matlab, Octave, and Scilab (sciviews.org, 2003)