Skip to content
Snippets Groups Projects
octave.md 2.74 KiB
Newer Older
  • Learn to ignore specific revisions
  • Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    # Octave
    
    ## Introduction
    
    GNU Octave is a high-level interpreted language, primarily intended for numerical computations. It provides capabilities for the numerical solution of linear and nonlinear problems, and for performing other numerical experiments. It also provides extensive graphics capabilities for data visualization and manipulation. Octave is normally used through its interactive command line interface, but it can also be used to write non-interactive programs. The Octave language is quite similar to Matlab so that most programs are easily portable. Read more [here][a].
    
    For a list of available modules, type:
    
    ```console
    $ ml av octave
    
    ------------------------------- /apps/modules/math -------------------------------
       Octave/6.3.0-intel-2020b-without-X11
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    ## Modules and Execution
    
    
    To load the latest version of Octave load the module:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```console
    $ ml Octave
    ```
    
    
    Octave on clusters is linked to a highly optimized MKL mathematical library. This provides threaded parallelization to many Octave kernels, notably the linear algebra subroutines. Octave runs these heavy calculation kernels without any penalty. By default, Octave would parallelize to 128 threads on Karolina. You may control the threads by setting the `OMP_NUM_THREADS` environment variable.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    To run Octave interactively, log in with the `ssh -X` parameter for X11 forwarding. Run Octave:
    
    ```console
    $ octave
    ```
    
    
    Jan Siwiec's avatar
    Jan Siwiec committed
    To run Octave in batch mode, write an Octave script, then write a bash jobscript and execute via the `salloc` command. By default, Octave will use 128 threads on Karolina when running MKL kernels.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    ```bash
    #!/bin/bash
    
    # change to local scratch directory
    
    Jan Siwiec's avatar
    Jan Siwiec committed
    DIR=/scratch/project/PROJECT_ID/$SLURM_JOB_ID
    
    mkdir -p "$DIR"
    cd "$DIR" || exit
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    # copy input file to scratch
    
    Jan Siwiec's avatar
    Jan Siwiec committed
    cp $SLURM_SUBMIT_DIR/octcode.m .
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    # load octave module
    
    ml  Octave/6.3.0-intel-2020b-without-X11
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    # execute the calculation
    octave -q --eval octcode > output.out
    
    # copy output file to home
    
    Jan Siwiec's avatar
    Jan Siwiec committed
    cp output.out $SLURM_SUBMIT_DIR/.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    #exit
    exit
    ```
    
    
    Jan Siwiec's avatar
    Jan Siwiec committed
    This script may be submitted directly to Slurm via the `salloc` command. The inputs are in the octcode.m file, outputs in the output.out file. See the single node jobscript example in the [Job execution section][1].
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    The Octave c compiler `mkoctfile` calls the GNU GCC 6.3.0 for compiling native C code. This is very useful for running native C subroutines in Octave environment.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    ```console
    $ mkoctfile -v
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Octave may use MPI for interprocess communication This functionality is currently not supported on the clusters. In case you require the Octave interface to MPI, contact [support][b].
    
    [1]: ../../general/job-submission-and-execution.md
    
    [a]: https://www.gnu.org/software/octave/
    [b]: https://support.it4i.cz/rt/
    [c]: https://octave.sourceforge.net/parallel/