From 4d5ead3f7520666e852ff8eaa5105169bdd6772a Mon Sep 17 00:00:00 2001
From: Francesco Sabatini <francesco.sabatini@idiv.de>
Date: Fri, 24 Apr 2020 16:31:23 +0200
Subject: [PATCH] Fixed bug in 01b cluster

---
 01b_MesobromionCluster.R | 4 ++--
 cli_01b.r                | 3 ---
 submit_01b.sh            | 1 +
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/01b_MesobromionCluster.R b/01b_MesobromionCluster.R
index 413638d..f92c85b 100644
--- a/01b_MesobromionCluster.R
+++ b/01b_MesobromionCluster.R
@@ -55,7 +55,7 @@ get.best <- function(x, N){
 
 
 Mesobromion <- function(species.path, traits.path, output, myfunction="get.corXY.bootstrap", 
-                        combinations=c("all", "sequential"), max.inter.t, chunkn, chunk.i, nperm=199, ncores=1){
+                        combinations=c("all", "sequential"), max.inter.t, chunkn, chunk.i, nperm=199, ncores){
   
   if(ncores>1){
     require(parallel)
@@ -151,7 +151,7 @@ Mesobromion <- function(species.path, traits.path, output, myfunction="get.corXY
       
       ## start main foreach loop
       print(paste("Start main loop - round", nround))
-      corXY.output <- foreach(ch=1:length(allcomb.t, .combine=rbind) %myinfix% {
+      corXY.output <- foreach(ch=1:length(allcomb.t), .combine=rbind) %myinfix% {
         allcomb.i <- allcomb.t[ch]
         print(paste("Running on", length(allcomb.i),"out of", nall, "combinations"))
         
diff --git a/cli_01b.r b/cli_01b.r
index 79d6177..51a65a6 100644
--- a/cli_01b.r
+++ b/cli_01b.r
@@ -88,8 +88,5 @@ ncores         <- cli$options$ncores
 
 source("01b_MesobromionCluster.R")
 
-Mesobromion(species.path, traits.path, output, myfunction, combinations, max.inter.t, 
-            chunkn, chunk.i, nperm)
-
 Mesobromion(species.path, traits.path, output, myfunction, combinations, max.inter.t, 
             chunkn, chunk.i, nperm, ncores)
diff --git a/submit_01b.sh b/submit_01b.sh
index c634b3d..af6a9f1 100644
--- a/submit_01b.sh
+++ b/submit_01b.sh
@@ -24,6 +24,7 @@ Rscript \
     --chunk.i NA \
     --chunkn 32 \
     --nperm 99 \
+    --ncores ${NSLOTS:-1} \
     /data/splot/HIDDEN/species.out.10perc.txt \
     /data/splot/HIDDEN/traits.out.10perc.txt \
     "$output" \
-- 
GitLab