FORUMParallel Computing in bash using a R script
anandam demandée il y a 8 mois



I am trying to run some species distribution models using a R script in bash. Since I have many raster files as the predictors for my models and I need to run the same R script 20 times (I am using sample function in my R script which generates one different result each time), I want to run it in parallel (16 jobs) using shell variables.
It is the first time I am using gnu parallel and I am struggling with two things:
1) How can I use assigned shell variables as inputs in my script?
2) How do I run the same R script 20 times and save each result as a number (e.g. first analysis as $model.1.tif )?
Bellow is the script I tried to run and (of course) is not working. I appreciate any help.
Ps.: SMD.R is my R script which has

occurdata <- args[1]
model.type <- args[2]
outputpath <- args[3]
predictors <- args[4:length(args)]
model=bioclim
Rscriptpath="Users/arpm/Scripts"
occurdata="Users/arpm/ocr"
outputpath="Users/arpm/output"
parallel -j 16 "Rscript $Rscriptpath/SDM.R $occurdata/ocr1.txt $model $outputpath/$model.{ }.tif $predictors" ::: {1..20}

 

jshleap personnel répondue il y a 7 mois

It is difficult to know what is happening without the full Rscript and bash file, and without the error message you are receiving. For the second part, the bash script, you have not assigned $predictors, so not sure how is the behaviour of your R code when predictors is not defined. Also, you can remove the quotes for parallel (I believe). But to really answer your question please also post the error.