[slurm-users] Define variables within slurm script

Benson Muite benson_muite at emailplus.org
Mon Feb 18 14:12:13 UTC 2019

May be some aspects outside of slurms control that are tied to the 
machine you are using which require a specific way of handling 
environment variables. You might try the following:

#SBATCH --job-name=my_job
#SBATCH —time=01:00:00

for A in 1 2
  time ./my_code.o -a ${A}

On 2/18/19 4:03 PM, Renfro, Michael wrote:
> If you’re literally putting spaces around the ‘=‘ character, I don’t think that’s valid shell syntax, and should throw errors into your slurm-JOBID.out file when you try it.
> See if it works with A=1.0 instead of A = 1.0
>> On Feb 18, 2019, at 7:55 AM, Castellana Michele <Michele.Castellana at curie.fr> wrote:
>> External Email Warning
>> This email originated from outside the university. Please use caution when opening attachments, clicking links, or responding to requests.
>> Dear all,
>> I would like to use a variable within a slurm script as shown in the following minimal working example. I want to define a variable A, assign a value to it, and run multiple times a code where I use A in a command-line flag:
>> #!/bin/sh
>> #SBATCH --job-name=my_job
>> #SBATCH —time=01:00:00
>> A = 1.0;
>> time ./my_code.o -a $A
>> A = 2.0;
>> time ./my_code.o -a $A
>> However, this does not work. Do you know a way around this?
>> Best,
>> M

More information about the slurm-users mailing list