title: How to setup and use MPI on Windows with R
body: <p>I have downloaded an R script from the web that says that it &quot;must be run in an MPI environment&quot;. Now I know literally nothing of MPI, except for that it is used for parallel computing, and it is rather hard to find a simple tutorial on how to set it up and use it.</p>
  <p>Can someone give me a <strong>simple, step-by-step</strong> guide on what I should install to run this, how I should do this, and how I can run the script?</p>
  <p>Thanks in advance.</p>
  <p>Edit, here is what I tried:</p>
  <ul>
  <li>I installed <a href="https://msdn.microsoft.com/en-us/library/bb524831%28v=vs.85%29.aspx" rel="noreferrer">Microsoft MPI</a></li>
  <li>I installed and loaded the RMpi package in R</li>
  </ul>
  <p>Specific Problems:</p>
  <pre><code>&gt; # number of available slots is passed via environment variable
  &gt; slots &lt;- as.integer(Sys.getenv(&quot;NSLOTS&quot;))
  </code></pre>
  <p>gives <code>NA_integer_</code>.</p>
  <p>In case I use the following (i.e. I replace Sys.getenv(&quot;NSLOTS&quot;) with some scalar)</p>
  <pre><code>&gt; slots &lt;- as.integer(4)
  &gt; cl &lt;- snow::makeMPIcluster(slots)
  </code></pre>
  <p>I get the error</p>
  <blockquote>
  <p>Error in mpi.comm.spawn(slave = mpitask, slavearg = args, nslaves =
  count,  :    Other MPI error, error stack:
  MPI_Comm_spawn(cmd=&quot;C:/PROGRA~1/R/R-31~1.0/bin/Rscript.exe&quot;,
  argv=0x0000000009A12CA8, maxprocs=4, MPI_INFO_NULL, root=0,
  MPI_COMM_SELF, intercomm=0x000000000A2FF8B0,
  errors=0x00000000100E3C70) failed Function not implemented</p>
  </blockquote>
  <p>So I suspect that I did not properly configure my MPI environment.</p>