Texas A&M Supercomputing Facility Texas A&M University Texas A&M Supercomputing Facility

Loading Mathematica

Before you can use Mathematica you will need to load the Mathematica module by typing
   module load Mathematica
This will setup the environment of the latest version of Mathematica (currently version 9.0.1). For more information about the modules, please visit the Modules page.

Interactive Mode

Mathematica can be run either in GUI mode and command line mode

Command Line Mode

To run in command line just type:
   math
This will start a Mathematica kernel inside the current shell. Here you can enter input and the kernel will evaluate the expression

To execute Mathematica scripts directly you can use the following command:
   math -script< myscript.m
Another option will be to just redirect the input to the math command:
   math -script< myscript.m
For more information, please visit the Mathematica math page.

GUI Mode

To run in GUI mode you can use the following command:
   Mathematica
When running GUI mode your local computer needs to be able to display the X commands. See Accessing TAMU Supercomputing Machines for more information.

NOTE: Please be advised that GUI applications might respond considerably slower when running remotely due the large amount of network communication. This is especially true when connecting off campus.

Running in Batch mode

When your Mathematica calculation needs more than 1 hour to execute (or requires more memory than allowed in an interactive session) you have to use the batch system. Below is a sample job file that will execute a Mathematica script named myscript.m.
#PBS -l nodes=1:ppn=1
#PBS -l walltime=01:50:00
#PBS -l mem=22gb
#PBS -N MathematicaJob
#PBS -m be
#PBS -j oe
#PBS -V

cd $PBS_O_WORKDIR
module load Mathematica

math < myscript.m
For your job you will most likely adjust the job requirements, such as walltime, memory, etc. If you want to run a parallel job you will need to specify nodes=X:ppn=Y to values that fit your needs. In that case, please read the "Parallel Computations" section below carefully.

Parallel Computations

Mathematica offers excellent build-in capabilities for parallel processing (multi core, multi node, gpus). The standard approach to use multiple cores (and nodes) is to launch a number of additional kernels and offload computation to these kernels. Currently, the Supercomputing Facility's Mathematica license allows for up to 400 additional kernels (can be increased if needed). For a more detailed discussion about parallel computing, please visit the Parallel Computing Guide.

Unfortunately Mathematica does not support the cluster management tool used on eos (TORQUE) and therefore there is no transparent and easy way to launch kernels. For your convenience the Supercomputing facility created a package to make it as straightforward as possible to launch additional kernels. In your program replace the standard command to launch kernels:
   LaunchKernels[]
with the following command:
   Needs["EosUtils`EosKernels`]
      :
      :
   LaunchEosKernels[]
The LaunchEosKernels[] command will launch as many kernels as requested in the PBS job file. If LaunchEosKernels[] is called in interactive mode it will launch 3 kernels locally (due to 4 procesor limit in interactive mode). Additional functionality to launch kernels can be added later per user request.