UMBC logo
UMBC High Performance Computing Facility
How to run FreeMat on tara

Introduction

On this page we'll see how to use FreeMat on the tara cluster. Before proceeding, make sure you've read the how to run tutorial first. FreeMat is an open source mathematics package, similar to in functionality to MATLAB.

Loading modules

Some prerequisite libraries are needed to run FreeMat. To load these, enter the following commands

[araim1@tara-fe1 ~]$ module load qt/4.5.2
[araim1@tara-fe1 ~]$ module load freemat
This must be done in every SSH session before attempting to launch FreeMat. Once this is done, you may launch FreeMat on the command line for interactive use, or launch it from a batch script. Alternatively, you can load the module from within your submission scripts as follows
#!/bin/bash -l
#SBATCH --job-name=hello_freemat
#SBATCH --output=slurm.out
#SBATCH --error=slurm.err
#SBATCH --partition=develop

module load qt/4.5.2
module load freemat
... Launch Freemat ...
Notice the "-l" argument on the first line, which is necessary. (This allows Bash to use the "module" alias).

If you are a frequent user of FreeMat, you can add the "module load" statements to the end of your ~/.bash_profile, so that they'll be automatically run on every SSH session.

Example batch script

We'll write a simple FreeMat script that says "hello", and does some simple linear algebra operations.
% host is a cell array, 1st element is the hostname string
host = system('hostname');
printf('Hello world from %s\n', host{1});

A = [1 3 5; 2 5 1; 2 3 8]
inv(A)
det(A)

Download: ../code/freemat_hello/hello.m
We can launch it with a standard SLURM script. Again, we'll specify the "-l" option to Bash and load the module from within the batch script. The script will probably function correctly if you haven't made these additions, but have entered the "module load" commands in your current SSH session. We suggest these modifications to your batch script regardless, as a best practice.
#!/bin/bash -l
#SBATCH --job-name=hello_freemat
#SBATCH --output=slurm.out
#SBATCH --error=slurm.err
#SBATCH --partition=develop

module load qt/4.5.2
module load freemat
FreeMat -e -noX -nogreet -f hello

Download: ../code/freemat_hello/run.slurm
Now we launch the job
[araim1@tara-fe1 freemat_hello]$ sbatch run.slurm
sbatch: Submitted batch job 2618
[araim1@tara-fe1 freemat_hello]$ ls
hello.m  run.slurm  slurm.err  slurm.out
[araim1@tara-fe1 freemat_hello]$ cat slurm.out
--> Hello world from n1

A = 
 1 3 5 
 2 5 1 
 2 3 8 


ans = 
   -1.4800    0.3600    0.8800 
    0.5600    0.0800   -0.3600 
    0.1600   -0.1200    0.0400 


ans = 
 -25 

--> [araim1@tara-fe1 freemat_hello]$ 
Also note that hello.m can be run directly on the front end node, which is okay here because it's a small job
[araim1@tara-fe1 freemat_hello]$ module load qt/4.5.2
[araim1@tara-fe1 freemat_hello]$ module load freemat
[araim1@tara-fe1 freemat_hello]$ FreeMat -e -noX -nogreet -f hello
--> Hello world from tara-fe1.rs.umbc.edu

A = 
 1 3 5 
 2 5 1 
 2 3 8 


ans = 
   -1.4800    0.3600    0.8800 
    0.5600    0.0800   -0.3600 
    0.1600   -0.1200    0.0400 


ans = 
 -25 

--> [araim1@tara-fe1 freemat_hello]$ 

Running Freemat interactively

Freemat can also be used interatively on the front end node, as in the following example
[araim1@tara-fe1 freemat_hello]$ module load qt/4.5.2
[araim1@tara-fe1 freemat_hello]$ module load freemat
[araim1@tara-fe1 freemat_hello]$ FreeMat -noX
 FreeMat v4.0
 Copyright (c) 2002-2008 by Samit Basu
 Licensed under the GNU Public License (GPL)
 Type <help license> to find out more
      <helpwin> for online help
      <pathtool> to set or change your path
 Use <dbauto on/off> to control stop-on-error behavior
 Use ctrl-b to stop execution of a function/script
 JIT is enabled by default - use jitcontrol to change it
 Use <rootpath gui> to set/change where the FreeMat toolbox is installed
--> host = system('hostname')

host = 
 [tara-fe1.rs.umbc.edu] 

--> printf('Hello world from %s\n', host{1});
Hello world from tara-fe1.rs.umbc.edu
--> A = [1 3 5; 2 5 1; 2 3 8]

A = 
 1 3 5 
 2 5 1 
 2 3 8 

--> inv(A)

ans = 
   -1.4800    0.3600    0.8800 
    0.5600    0.0800   -0.3600 
    0.1600   -0.1200    0.0400 

--> det(A)

ans = 
 -25 

--> quit
[araim1@tara-fe1 freemat_hello]$ 
As always, this should only be used for smaller computations. Intensive programs should be submitted to the compute nodes.

Above we've shown FreeMat in command line mode. You can launch the GUI version by the following

[araim1@tara-fe1 freemat_hello]$ FreeMat