title: While loop in SLURM script
body: <p>I am using a cluster to my computations for the first time, and as a result using a SLURM script for the first time.</p>
  
  <p>I'm iterating the python code I'm using over a list of numbers. I did this before on my own machine with a simple while-loop in a bash script. </p>
  
  <p>I thought this would translate fairly directly into the SLURM script. However, upon execution, only the first number of the list is read and executed, after which the execution stops. So, the rest of the ~200 numbers are ignored. 
  Any ideas what could cause this?</p>
  
  <p>Here is the SLURM script, for reference:</p>
  
  <pre><code>#!/bin/bash -l
  
  #SBATCH -o ./job.out.%j
  #SBATCH -e ./job.err.%j
  #SBATCH -D ./
  #SBATCH -J NAME
  #SBATCH --nodes=2
  #SBATCH --tasks-per-node=40
  #SBATCH --cpus-per-task=1
  #SBATCH --time=06:59:00
  
  module load anaconda
  
  while read IDX; do
      echo $PWD
      cd "model_"$IDX
      srun python ../mcmc.py 
      cd ".."
  done &lt;sample.txt
  </code></pre>