<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Dear all,<br class="">
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
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:
<div class=""><br class="">
</div>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="">
<div class="">
<div class=""><font face="Helvetica" size="4" class="">#!/bin/sh</font></div>
</div>
<div class="">
<div class=""><font face="Helvetica" size="4" class="">#SBATCH --job-name=my_job</font></div>
</div>
<div class="">
<div class=""><font face="Helvetica" size="4" class="">#SBATCH —time=01:00:00</font></div>
</div>
<div class="">
<div class=""><font face="Helvetica" size="4" class=""><br class="">
</font></div>
</div>
<div class="">
<div class=""><font face="Helvetica" size="4" class="">A = 1.0;</font></div>
</div>
<div class="">
<div class=""><font face="Helvetica" size="4" class="">time ./my_code.o -a $A</font></div>
</div>
<div class=""><font face="Helvetica" size="4" class=""><br class="">
</font></div>
<div class="">
<div class=""><font face="Helvetica" size="4" class="">A = 2.0;</font></div>
<div class=""><font face="Helvetica" size="4" class="">time ./my_code.o -a $A</font></div>
</div>
</blockquote>
<div class=""><font face="Helvetica" size="4" class=""><br class="">
</font></div>
<div class="">However, this does not work. Do you know a way around this?</div>
<div class=""><br class="">
</div>
<div class="">Best,</div>
<div class="">M</div>
</div>
</div>
<br class="">
</body>
</html>