Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| habrok:examples:mathematica [2019/11/13 11:41] – external edit 127.0.0.1 | habrok:examples:mathematica [2025/06/11 12:09] (current) – Use Mathematica syntax highlighting pedro | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| The following example can be used as a template for Mathematica jobs: | The following example can be used as a template for Mathematica jobs: | ||
| - | < | + | < |
| #!/bin/bash | #!/bin/bash | ||
| #SBATCH --job-name=Mathematica | #SBATCH --job-name=Mathematica | ||
| Line 13: | Line 13: | ||
| #SBATCH --time=00: | #SBATCH --time=00: | ||
| - | module load Mathematica/ | + | module purge |
| + | module load Mathematica/ | ||
| math -script myscript.m | math -script myscript.m | ||
| Line 21: | Line 22: | ||
| Your script can contain any Mathematica code, e.g.: | Your script can contain any Mathematica code, e.g.: | ||
| - | < | + | < |
| Select[Range[8000], | Select[Range[8000], | ||
| </ | </ | ||
| Line 30: | Line 31: | ||
| Once you have started multiple kernels, you can use built-in functions for parallelizing some of the work, e.g. the Parallelize function: | Once you have started multiple kernels, you can use built-in functions for parallelizing some of the work, e.g. the Parallelize function: | ||
| - | < | + | < |
| LaunchKernels[4] | LaunchKernels[4] | ||
| p=Parallelize[Select[Range[8000], | p=Parallelize[Select[Range[8000], | ||
| Line 37: | Line 38: | ||
| In your job script, leave '' | In your job script, leave '' | ||
| - | < | + | < |
| ncores = ToExpression[Environment[" | ncores = ToExpression[Environment[" | ||
| LaunchKernels[ncores] | LaunchKernels[ncores] | ||