Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| habrok:examples:mathematica [2023/03/22 13:25] – fokke | 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 22: | 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 31: | 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 38: | Line 38: | ||
| In your job script, leave '' | In your job script, leave '' | ||
| - | < | + | < |
| ncores = ToExpression[Environment[" | ncores = ToExpression[Environment[" | ||
| LaunchKernels[ncores] | LaunchKernels[ncores] | ||