title: How to send a loop on several nodes with Slurm?
body: <p>I have a R script that I would like to execute on several nodes. I show the loop of my slurm code :</p>
  
  <p>Edit</p>
  
  <pre><code>#!/bin/bash
  #SBATCH -o job-%A_task.out
  #SBATCH --job-name=paral_cor
  #SBATCH --partition=normal
  #SBATCH --time=1-00:00:00
  #SBATCH --mem=124G                #I want to use 124Go / node
  #SBATCH --cpus-per-task=32        #and 32CPUs / node 
  #SBATCH --exclude=hpcsmp01
  
  
  module load gcc/8.1.0 openblas/0.3.3 R
  
  OUTPUT="$HOME"/PROJET_M2/data/$(date +"%Y%m%d")_parallel_nodes_test
  mkdir -p "$OUTPUT"
  
  export FILENAME=~/PROJET_M2/bin/RHO_COR.R
  
  echo "Start job :"`date`
  
  for i in $(seq 100)
  do
     srun Rscript my_scrit.R --subset $i  
  done
  
  echo "Stop job :"`date`
  
  </code></pre>
  
  <p>I execute this basically </p>
  
  <pre><code>sbatch my_script.sh 
  </code></pre>
  
  <p>This is the loop in my R code where <code>--subset $i</code> appears: </p>
  
  <pre><code>res &lt;- foreach(i = opt$subset) %dopar% {      #without argument, that gives
   G1 &lt;- split[[combs[i,1]]]                    i=seq_len(nrow(combs))
   G2 &lt;- split[[combs[i,2]]]                    combs is a vector with several
   dat.i &lt;- cbind(data[,G1], data[,G2])         rows, according to my input 
   rho.i &lt;- cor_rho(dat.i)                      file
  }
  </code></pre>
  
  <p>I want to execute the different value of <code>i</code> on several nodes. This code is only executed on one node. Do you have an issue to run this code on several nodes?</p>
  
  <p>Thanks</p>