# Running Mathematica on Mace01

## Overview

Mathematica jobs run on Mace01

*must*be submitted to the batch/queue system, SGE — Mathematica must not be used interactively on Mace01.- To use Mathematica with SGE, there are three steps: write a SGE submission script; write a Mathematica batch file; and finally, use the "qsub" command to submit the job to the batch system. Examples are given below.
Jobs should be submitted to either the

`serialshort.q`queue (for test jobs of up to one hour in length) or the`serial.q`(for all other jobs).Mathematica is installed in

`/software/mathematica`— this is a link to`/software/mathematica_6.0.2`. It is expected that should a newer version of Mathematica be installed, the link will be updated to point to this newer version.

## A Simple Example

Here is an example SGE submission script for use with Mathematica — we assume it is saved as `runmatlab.sh`:

#!/bin/sh #$ -cwd # # ...use the current working directory --- from where you type # "qsub runmatlab.sh" --- to run the job... # #$ -q serial.q # # ...tell SGE to run the job within the "serial.q" queue... # /software/mathematica/bin/math < test.m > out.txt # # ...the job consists of running the above command, i.e., run # Mathematica in batch mode with "test.m" as the input file/script # and send the output to "out.txt"...

The contents of the `test.m` file is, for example,

Block[{spa, nmax = 1*10^7, expo = 3}, Reap[For[n = 1, n <= nmax, n++, (If[Head[#1] === spa, #1 = n, Sow[{n, #1}]] &)[ spa[DivisorSigma[expo, n]]]]][[2, 1]]]