Access to Mathematica may be restricted to various groups for licensing reasons. If you have a Mathematica license, and would like to avail of our hardware resources, please contact the systems team.
Running Mathematica Interactively
To run Mathematica interactively on the TCHPC clusters, you must:
- log in via SSH
- obtain an interactive allocation on the cluster, using your project code
- load the modules:
module load apps Mathematica
- and then run it from the command-line:
Running Mathematica through the Batch System
To submit a batch Mathematica job on the TCHPC clusters, you must:
- create a text file containing the commands you wish to run, e.g. "
test.m" (see below for an example)
.mMathematica file should include
Exitas the last line, to make sure that mathematica exits correctly.
- create a SLURM batch submission script (see below for an example)
- submit it to the queue
- when the job has finished, check the output
Sample Mathematica File
This file (called "
test.m") simply calls the Binomial function a few times.
(* comments in the mathematica file are enclosed in *) (* truncate the output file *)
Put[ "pascals_tri.out" ]
(* run the commands and save the output *)
Binomial[ 1, 1 ] >>>"pascals_tri.out"
Binomial[ 2, 1 ] >>>"pascals_tri.out"
Binomial[ 2, 2 ] >>>"pascals_tri.out"
(* now exit *) Exit
Sample SLURM Script
This loads the relevant modules, calls Mathematica with the given instructions, and redirects the output to a file called "
#!/bin/bash #SBATCH -n 1 # number of cores #SBATCH -p compute # compute queue #SBATCH -t 00:10:00 # time (ddd-hh:mm:ss) #SBATCH -J mathematica # job name # load up the correct modules . /etc/profile.d/modules.sh module load apps Mathematica # call mathematica non-interactively math -noprompt -script test.m
Links to Mathematica Documentation for Command-Line Mode
- Version 8: http://reference.wolfram.com/legacy/v8/ref/program/math.html
- Version 7: http://reference.wolfram.com/legacy/v7/ref/program/math.html