[R-sig-hpc] export options to workers?
Martin Ivanov
martin.ivanov at ifg.uni-tuebingen.de
Thu Apr 18 13:53:02 CEST 2013
Dear all,
I am running R-3.0.0 on Slackware64-Linux with kernel 2.6.38.4. I want
to have the
warnings printed as they occur, so I have to set options(warn=1). The
problem is that the
options settings are not automatically transferred to the worker
processes. And I do not know how to achieve this.
The workaround I found is exporting the .Options variable and then
setting options locally in the worker process:
library(parallel)
ow <- options("warn");
options(warn=1);
cl <- makeCluster(getOption("cl.cores", detectCores()), outfile="");
varlist <- unlist(sapply(X=c(".GlobalEnv"), FUN=ls));
clusterExport(cl=cl, varlist=c(varlist, ".Options"), envir=.GlobalEnv);
x <- parSapply(cl=cl, X=1:240, FUN=function(repl) { options(.Options);
matrix(1:7, 3,4); } );
stopCluster(cl=cl);
options(ow); # reset
If you comment the options(.Options) command above, you will see that
again no warnings are printed.
My question is, is there a neater way of exporting options to the worker
processes?
Best regards,
--
Dr. Martin Ivanov
Eberhard-Karls-Universität Tübingen
Mathematisch-Naturwissenschaftliche Fakultät
Fachbereich Geowissenschaften
Water & Earth System Science (WESS)
Hölderlinstraße 12, 72074 Tübingen, Deutschland
Tel. +4970712974213
More information about the R-sig-hpc
mailing list