Our school uses SLURM as the queueing system, where one has to specify some "preambles" before other commands. Hence, a shell script in this case usually starts with
#!/bin/bash
#SBATCH -n 10 # Number of cores requested
#SBATCH -N 1 # Ensure that all cores are on one machine
#SBATCH -p general # Partition to submit to
#SBATCH --mem-per-cpu=20000 # Memory per cpu in MB (see also --mem)
#SBATCH -o out # Standard out goes to this file
Now, I wish to make my core number as a constant, which facilitates modifications. I did
#!/bin/bash
ZEROTH_PORT=50000
NO_CORES=10
#SBATCH -n $((NO_CORES)) # Number of cores requested
#SBATCH -N 1 # Ensure that all cores are on one machine
#SBATCH -p general # Partition to submit to
#SBATCH --mem-per-cpu=20000 # Memory per cpu in MB (see also --mem)
#SBATCH -o out # Standard out goes to this file
It fails at #SBATCH -n $((NO_CORES))
. As a complete newbie in shell script, I have no idea why $((NO_CORES))
here returns the value of NO_CORES
.