calcoloscientifico:userguide:mathematica
Mathematica
Mathematica serial job
Execution of a Mathematica serial program
Script math-vrt.m
:
- math-vrt.m
Print[Integrate[1/(x^4 - a^4), x]]; (*Prints all Mersenne PRime numbers less than 10000*) Print[Select[Range[10000],PrimeQ[2^#-1]&]]; A = Sum[i, {i,1,100}]; B = Mean[{25, 36, 22, 16, 8, 42}]; Print[A + B]; Quit[];
Script slurm-math-vrt.sh
:
- slurm-math-vrt.sh
#!/bin/bash #SBATCH --job-name=MathVRT #SBATCH --output=%x.o%j #SBATCH --error=%x.e%j #SBATCH --ntasks=1 #SBATCH --partition=vrt #SBATCH --qos=vrt #SBATCH --mem=8G #SBATCH --time=0-00:30:00 #SBATCH --account=<account> module load mathematica math -script math-vrt.m
Submitting slurm-math-vrt.sh
:
sbatch slurm-math-vrt.sh
Mathematica parallel job
Execution of a parallel job with Mathematica
Script math-cpu.m
:
- math-cpu.m
GetEnvironment["SLURM_NTASKS_PER_NODE"] (*Limits Mathematica to requested resources*) Unprotect[$ProcessorCount]; $ProcessorCount = ToExpression[Environment["SLURM_NTASKS_PER_NODE"]]; (*Prints the machine name that each kernel is running on*) Print[ParallelEvaluate[$MachineName]]; (*Prints all Mersenne PRime numbers less than 10000*) Print[Parallelize[Select[Range[10000],PrimeQ[2^#-1]&]]]; Quit[];
Script slurm-math-cpu.sh
:
- slurm-math-cpu.sh
#!/bin/bash #SBATCH --job-name=MathCPU #SBATCH --output=%x.o%j #SBATCH --error=%x.e%j #SBATCH --nodes=1 #SBATCH --ntasks-per-node=8 #SBATCH --partition=cpu #SBATCH --qos=cpu #SBATCH --mem=16G #SBATCH --time=0-00:30:00 #SBATCH --account=<account> module load mathematica math -script math-cpu.m
Submitting slurm-math-cpu.sh
:
sbatch slurm-math-cpu.sh
calcoloscientifico/userguide/mathematica.txt · Ultima modifica: 03/11/2022 11:33 da federico.prost