# salloc -N 4 orterun -n 1 R -f spawn.R 
library(Rmpi)
nWorkers <- mpi.universe.size() - 1L
mpi.spawn.Rslaves(nsl=nWorkers)
mpi.remote.exec(mpi.comm.rank())
mpiRank <- function(i)
  c(i=i, rank=mpi.comm.rank())
mpi.parSapply(seq_len(2*nWorkers), mpiRank)
mpi.close.Rslaves()
mpi.quit()

