Reputation: 1729
I've got an R script that runs on Linux, using openmpi, doMPI, and nested foreach loops to do some big simulations on ~ 300 cores, and it works quite well. Recently I've modulized the code into lots of individual .R files which are "sourced". However I still have to ".export" over 70 individual objects on the inside foreach loop. I've made several attempts to clean up the code by putting the names of all of these objects in a separate .R file, and then sourcing it. I also thought that
.export=c(ls())
might work, just export all objects to the cores but that didn't work either. Anyone know of a way of putting a list of object names in a file and passing the objects with those names to the cores? Thanks J
Upvotes: 1
Views: 1617
Reputation: 11738
Use environments.
.export = ls(globalenv())
.ls(parent.env())
.ls(environment())
.Upvotes: 3