===== Mathematica Jobs ===== ==== Mathematica serial job ==== === Execution of a Mathematica serial program === Script ''math-vrt.m'': 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}] Answer = A + B Quit[]; Script ''slurm-math-vrt.sh'': #!/bin/sh #SBATCH --job-name=MathVRT #SBATCH --output=%x.o%j #SBATCH --error=%x.e%j #SBATCH --ntasks=1 #SBATCH --partition=vrt #SBATCH --mem=8G #SBATCH --time=0-00:30:00 #SBATCH --account= module load mathematica math 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-bdw.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-bdw.sh'': #!/bin/sh #SBATCH --job-name=MathBDW #SBATCH --output=%x.o%j #SBATCH --error=%x.e%j #SBATCH --nodes=1 #SBATCH --tasks-per-node=8 #SBATCH --partition=bdw #SBATCH --mem=16G #SBATCH --time=0-00:30:00 #SBATCH --account= module load mathematica math math-bdw.m Submitting ''slurm-math-bdw.sh'': sbatch slurm-math-bdw.sh