Running Mathematica on compute nodes
Jump to navigation
Jump to search
Here are some instructions on how to run Mathematica on the cluster.
Step 1.
Load the mathematica module:
>>module load astro >>module load mathematica
Step 2.
Prepare our test script. You can make mathematica scripts in different ways, but .wls files are good option. Here is an example script, you can make it into a file called test.wls
:
#!/usr/bin/env wolframscript outdir = "Data/"; fn1 = outdir<>"test.dat"; values = Table[{x, x^2},{x,0,1,0.1}]; Export[fn1, values, "Table"];
Step 3.
Now prepare your bash script to submit the job. Here's a template:
#!/bin/bash #SBATCH --job-name=math_test # shows up in the output of squeue #SBATCH --time=00:59:00 # specify the requested wall-time #SBATCH --partition=astro3_devel # specify the partition to run on #SBATCH --ntasks=1 # number of tasks #SBATCH --cpus-per-task=1 # number of OpenMP threads per MPI rank #SBATCH --threads-per-core=1 # number of threads active per CPU core (=1: Hyperthreading off) # Make sure that Mathematica is loaded module load astro module load math # Set up port forwarding so that Mathematica finds the license ssh astro01.hpc.ku.dk -L16286:mathlm.nbi.dk:16286 -L16287:mathlm.nbi.dk:16287 -Nf # Execute the code wolframscript stupid_test.wls # Make sure that the ssh tunnel is killed pkill -fu $USER astro01
Now you are ready to submit your job and have fun. Before submitting, make sure you create the directory >>mkdir Data
. If it runs successfully, you will see a Data/test.dat
file.