Computational Science Community Wiki

Running Mathematica on Mace01

Overview

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]]]