Mathematica

General

Wharton has a site license server for Mathematica. Please contact your Academic Distributed Representative for access.

Mathematica in Wharton’s HPC Environment

Interactive Mathematica Sessions

  • Graphical (requires X Forwarding): qrsh mathematica
  • Textual: qrsh math

Submitting a Mathematica Job

Create Mathematica Commands File

Create a .m file with your commands, for example:

TableForm[ParallelEvaluate[{$ProcessorID,$MachineName,$SystemID,$ProcessID,$Version}],TableHeadings->{None,{"ID","host","OS","process","Mathematica Version"}}]

Create Mathematica Job Script

Create a .sh file with at least the following contents:

#!/bin/bash

math -noprompt < your-commands-file.m

Submit Mathematica Job

More information: HPCC Job Management

Parallel Mathematica on the HPCC

Imbox_notice Remember HPCC Job Management with job limits for job queues

For code that supports parallelization, add the following commands:

Needs["ClusterIntegration`"]
LaunchKernels[SGE["localhost"],5]
YOUR COMMANDS HERE
CloseKernels[]

You will also need to add the following code either to your ~/.bashrc file (if using interactive Mathematica), or in your job submission script (if you’re submitting with ‘qsub’) to use parallel Mathematica:

load module mathematica

Plotting Functionality on the HPCC

Sample commands and job script for plotting via Mathematica.

Commands file:

Plotex=Plot[x*2,{x,0,2}];
Export["demo-plotting.pdf",Plotex]
Quit[]

Job script:

#!/bin/bash
# set up the video frame buffer and DISPLAY to use it
xvfb-run -d math -noprompt < your-commands-file.m