From ccbc008c82e6fca0da184f85b7196e62cc989ddc Mon Sep 17 00:00:00 2001
From: Francesco Sabatini <francesco.sabatini@idiv.de>
Date: Tue, 24 Nov 2020 09:59:52 +0100
Subject: [PATCH] aligned cluster functions

---
 code/A98_PredictorsExtract.R |  3 ++-
 code/submit-A98-array.sh     | 37 ++++++++++++++++++++++++++++++++++++
 code/submit-A98.sh           |  8 ++++----
 3 files changed, 43 insertions(+), 5 deletions(-)
 create mode 100644 code/submit-A98-array.sh

diff --git a/code/A98_PredictorsExtract.R b/code/A98_PredictorsExtract.R
index b13dd91..7af6d9f 100644
--- a/code/A98_PredictorsExtract.R
+++ b/code/A98_PredictorsExtract.R
@@ -37,6 +37,7 @@ PredExtr <- function(x.shp, myfunction=NA, output=NA,
     } 
 
   print("myfunction defined as")
+  myfunction <- get(myfunction)
   print(myfunction)
   
   print("go parallel")
@@ -53,7 +54,7 @@ PredExtr <- function(x.shp, myfunction=NA, output=NA,
   } else {
     out <- sp::over(x=header.shp, y=mypredictor) 
     toassign <- header.shp[which(is.na(out[,1])),]
-    print(paste(length(toassign), "plots not matched directely - seek for NN"))
+    print(paste(length(toassign), "plots not matched directly - seek for NN"))
   if(length(toassign)>0){
     
     nearest <- foreach(i=1:length(toassign), .packages=c('raster'), .combine=rbind) %dopar% { 
diff --git a/code/submit-A98-array.sh b/code/submit-A98-array.sh
new file mode 100644
index 0000000..fc22685
--- /dev/null
+++ b/code/submit-A98-array.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+#$ -S /bin/bash
+#$ -N PredictorExtract
+
+#$ -o /work/$USER/$JOB_NAME-$JOB_ID-$TASK_ID.log
+#$ -j y
+
+#$ -l h_rt=00:30:00:00
+#$ -l h_vmem=1G
+
+#$ -pe smp 5-32
+
+#$ -cwd
+
+#$ -t 1-99
+
+
+module load GCC/8.3.0
+module load OpenMPI/3.1.4
+module load R/3.6.2
+
+filename="$1"
+shift 
+
+output=/data/splot/_data_splot3/output_pred/$(basename $filename .shp)-$SGE_TASK_ID.csv
+
+Rscript \
+    cli_A98.r \
+    --cores ${NSLOTS:-1} \
+    --typp "shp" \
+    --chunk.i "$SGE_TASK_ID" \
+    --chunkn 99 \
+    /data/splot/_data_splot3/header.shp.shp \
+    robust.mean \
+    "$output" \
+    "$filename"
diff --git a/code/submit-A98.sh b/code/submit-A98.sh
index 6450490..8f5550f 100644
--- a/code/submit-A98.sh
+++ b/code/submit-A98.sh
@@ -18,15 +18,15 @@ module load R
 filename="$1"
 shift 
 
-output=/data/splot/_data_splot3/output_pred/$(basename $"filename" .shp)_sd.csv
+output=/data/splot/_data_splot3/output_pred/$(basename $filename .tif)_sd.csv
 
 Rscript \
     cli_A98.r \
-    --cores $"{NSLOTS:-1}" \
-    --typp "raster" \
+    --cores ${NSLOTS:-1} \
+    --typp "shp" \
     --chunk.i 1 \
     --chunkn 1 \
     /data/splot/_data_splot3/header.shp.shp \
-    robust.sd \
+    "NA" \
     "$output" \
     "$filename"
-- 
GitLab