title: SLURM sbatch job array for the same script but with different input arguments run in parallel
body: <p>I have a problem where I need to launch the same script but with different input arguments.</p>
  
  <p>Say I have a script <code>myscript.py -p &lt;par_Val&gt; -i &lt;num_trial&gt;</code>, where I need to consider <code>N</code> different <code>par_values</code> (between <code>x0</code> and <code>x1</code>) and M trials for each value of <code>par_values</code>.  </p>
  
  <p>Each trial of M is such that almost reaches the time limits of the cluster where I am working on (and I don't have priviledges to change this). So in practice I need to run <code>NxM</code> independent jobs.</p>
  
  <p>Because each batch jobs has the same node/cpu configuration, and invokes the same python script, except for changing the input parameters, in principle, in pseudo-language I should have a <code>sbatch</code> script that should do something like:</p>
  
  <pre><code>#!/bin/bash
  #SBATCH --job-name=cv_01
  #SBATCH --output=cv_analysis_eis-%j.out
  #SBATCH --error=cv_analysis_eis-%j.err
  #SBATCH --partition=gpu2
  #SBATCH --nodes=1
  #SBATCH --cpus-per-task=4
  
  for p1 in 0.05 0.075 0.1 0.25 0.5
  do
      for i in {0..150..5}
      do
          python myscript.py -p p1 -v i
      done
  done
  </code></pre>
  
  <p>where every call of the script is itself a batch job.
  Looking at the <a href="https://slurm.schedmd.com/sbatch.html" rel="noreferrer">sbatch doc</a>, the <code>-a --array</code> option seems promising. But in my case I need to change the input parameters for every script of the <code>NxM</code> that I have. How can I do this? I would like not to write <code>NxM</code> batch scripts and then list them in a <code>txt</code> file as suggested by <a href="https://stackoverflow.com/questions/28511556/is-it-possible-to-submit-a-series-of-different-jobs-to-slurm/28542272#28542272">this post</a>. Nor the solution proposed <a href="https://stackoverflow.com/questions/32071612/slurm-sbatch-multiple-parallel-calls-to-executable/32122460#32122460">here</a> seems ideal, as this is the case imho of a job array. Moreover I would like to make sure that all the <code>NxM</code> scripts are launched at the same time, and the invoking above script is terminated right after, so that it won't clash with the time limit and my whole job will be terminated by the system and remain incomplete (whereas, since each of the <code>NxM</code> jobs is within such limit, if they are run together in parallel but independent, this won't happen).</p>