ls(envir=spatialreg:::.spatialregOptions)
library(parallel)
nc <- max(2L, detectCores(logical=FALSE), na.rm = TRUE)-1L
nc
# set nc to 1L here
if (nc > 1L) nc <- 1L
#nc <- ifelse(nc > 2L, 2L, nc)
coresOpt <- get.coresOption()
coresOpt
if (!is.na(nc)) {
invisible(set.coresOption(nc))
print(exists("mom_calc"))
if(.Platform$OS.type == "windows") {
# forking not permitted on Windows - start cluster
# removed for Github actions 210502
if (FALSE) {
print(get.mcOption())
cl <- makeCluster(get.coresOption())
print(clusterEvalQ(cl, exists("mom_calc")))
set.ClusterOption(cl)
clusterEvalQ(get.ClusterOption(), library(spatialreg))
print(clusterEvalQ(cl, exists("mom_calc")))
clusterEvalQ(get.ClusterOption(), detach(package:spatialreg))
set.ClusterOption(NULL)
print(clusterEvalQ(cl, exists("mom_calc")))
stopCluster(cl)
}
} else {
mcOpt <- get.mcOption()
print(mcOpt)
print(mclapply(1:get.coresOption(), function(i) exists("mom_calc"),
mc.cores=get.coresOption()))
invisible(set.mcOption(FALSE))
cl <- makeCluster(nc)
print(clusterEvalQ(cl, exists("mom_calc")))
set.ClusterOption(cl)
clusterEvalQ(get.ClusterOption(), library(spatialreg))
print(clusterEvalQ(cl, exists("mom_calc")))
clusterEvalQ(get.ClusterOption(), detach(package:spatialreg))
set.ClusterOption(NULL)
print(clusterEvalQ(cl, exists("mom_calc")))
stopCluster(cl)
invisible(set.mcOption(mcOpt))
}
invisible(set.coresOption(coresOpt))
}
Run the code above in your browser using DataLab