Mathematica can be used in different ways on the SCC. If possible you should prefer using non-interactive methods to optimize utilization of the nodes.

For interactive usage the Mathematica Frontend is preferable. You can start it with

  Mathematica

in a terminal. Here you can also configure to use remote kernel for evaluation (see here). If you only need to evaluate single commands you can use the interactive command line interface by starting

 math

in a terminal. A typical session may look like this:

$ math
Mathematica 10.0 for Linux x86 (64-bit)
Copyright 1988-2014 Wolfram Research, Inc.

In[1]:=1+1

Out[1]= 2

For non-interactive using Mathematica you need to create a script containing all the Mathematica commands to execute. Here a simple example

# simple Mathematica script

Print["Hello"] 
1+1

This script can be executed by using

math -noprompt < script.m > script.out

or

math -script script.m

in a terminal or Grid Engine Script, while the later command only shows output printed with Print[]. If you like to use command line options just use "MathematicaScript" instead of "math".

You can also create an executable script by using a special first line in the script. Here a small example:

#!/software/bin/MathematicaScript -script
 Print["Hello"]
 Print[1+1]

$ chmod +x script_exe.m
$ ./script_exe.m
Hello
2

To use Mathematica Kernel remotely from your Mathematica Frontend do the following

  • Evaluation -> Kernel Configuration Options
  • Add Kernel
  • Name: "SCC"
  • Machine Name: scc.uni-konstanz.de
  • Remote Login: [your user name]
  • Kernel program: math
  • Select "Advanced Options" and "Raw MathLink connection"

 Now you can use this remote Kernel for the notebook ("Notebooks Kernel": SCC) or as default ("Default Kernel": SCC). You will be ask for your login data when necessary.

Interactively you can easily use parallelization with the commands ParallelEvaluate or Parallelize. A simple parallel session may look like this:

In[1] := Print[$ProcessorCount]
Out[1] = 2
In[2] := ParallelEvaluate[$ProcessID]
Out[2] = {9799, 9801}
In[3] := Parallelize[Table[i^3,{i,0,9}]]
Out[3] = {0, 1, 8, 27, 64, 125, 216, 343, 512, 729}

In scripts you need to start the parallel kernel yourself. This can be done with LaunchKernels[] which takes the number of needed kernels as argument. This can be used to work with Mathematica parallization in Grid Engine scripts. Here is a simple example: 

#$ -N math-job
#$ -pe openmp 4
 
/software/bin/MathematicaScript -script "script.m" $NSLOTS

# script.m
nkernel=ToExpression[$ScriptCommandLine[[2]]];
LaunchKernels[nkernel];
Print["KernelID = ", ParallelEvaluate[$KernelID]]