Mathematica: Difference between revisions
m (Added navbox) |
|||
(One intermediate revision by one other user not shown) | |||
Line 60: | Line 60: | ||
Please send any questions regarding using Mathematica on ARC to support@hpc.ucalgary.ca. | Please send any questions regarding using Mathematica on ARC to support@hpc.ucalgary.ca. | ||
= Links = | |||
[[ARC Software pages]] | |||
[[Category:Mathematica]] | [[Category:Mathematica]] | ||
[[Category:Software]] | [[Category:Software]] | ||
[[Category:ARC]] | [[Category:ARC]] | ||
{{Navbox | {{Navbox ARC}} |
Latest revision as of 19:36, 18 October 2023
Introduction
Mathematica (external link) is a general-purpose high-level programming package for both symbolic and numerical calculations.
The main purpose of this page is to show how to use Mathematica on the University of Calgary ARC (Advanced Research Computing) cluster. It is presumed that you already have an account an ARC and have read the material on reserving resources and running jobs with the Slurm job management system.
Licensing
At the University of Calgary, Information Technologies has purchased a site license for using Mathematica for teaching and learning and non-commercial research purposes. The software has been installed on the ARC cluster, where multiple instances can be run at the same time. When Mathematica starts up, it checks with a central license server.
For information about installing Mathematica on your own computer, see the Information Technologies Knowledge Base article on Mathematica.
Running Mathematica on the ARC cluster
Although it is possible to run Mathematica interactively (with or without a graphical user interface) on a compute node reserved with the Slurm salloc command, the expectation is that most calculations with Mathematica on ARC will be completed by submitting a batch job script to the Slurm job scheduler with the sbatch command.
Suppose that the following Mathematica code to print out the first million prime numbers is in a file, primes_list.m :
primeslist = Table[Prime[k],{k,1,1000000}]; Export["primes_1000000.out",primeslist,"Table","FieldSeparators"->" "];
Note that formatted Mathematica notebooks cannot be used directly. You need to convert your notebook to a text-format ".m" file, as discussed, for example, here (external link). The general idea is to mark cells to be executed as initialization cells and then use "File->Save as" menu item with the "Package" option to produce the .m file.
The following Slurm batch job script, primes_list.slurm, can be used to run the primes_list.m code on a single complete compute node.
#!/bin/bash #SBATCH --nodes=1 #SBATCH --time=00:30:00 #SBATCH --mem=128gb #SBATCH --partition=pawson-bf,apophis-bf,razi-bf,single,lattice,parallel,cpu2019,cpu2013 # Mathematica batch processing example. # 2020-05-28. # Select Mathematica command to run: MATH=/global/software/mathematica/mathematica1101/bin/math # Specify the name of the input file of Mathematica text commands: INPUT=primes_list.m OUTPUT=$(basename $INPUT .m)_${SLURM_JOB_ID}.out echo "Current working directory is $(pwd)" echo "Running on compute node $(hostname)" echo "Starting run at: $(date)" $MATH -noprompt -run -script $INPUT > $OUTPUT echo "Finished with at: $(date)"
Note that the name of the executable for running Mathematica without a graphical interface is "math". Submit the job with
sbatch primes_list.slurm
For the case of million primes, the run took about 30 seconds on a compute node in one of the slowest partitions (single) on ARC. The time and memory limits should be adjusted to match the requirements of your calculations, but, some testing is usually required to fine tune those settings.
Support
Please send any questions regarding using Mathematica on ARC to support@hpc.ucalgary.ca.