My objective is to repeatedly run an R script, each time with a different set of parameters.
To do so, I have been using a bash script to pass the command-line parameters to the R script by looping through an input file, in which each line contains a different combination of 7 parameters.
The input file looks like this:
10 food 0.00005 0.002 1 OBSERVED 0
10 food 0.00005 0.002 1 OBSERVED 240
10 food 0.00005 0.002 1 OBSERVED 480
10 food 0.00005 0.002 1 OBSERVED 720
10 food 0.00005 0.002 1 OBSERVED 960
10 food 0.00005 0.002 1 OBSERVED 1200
The R script to which the command-line parameters are passed, begins like this:
commandArgs(trailingOnly=FALSE)
A <- as.numeric (commandArgs()[as.numeric(length(commandArgs()) -6 )])
B <- commandArgs()[as.numeric(length(commandArgs()) -5 )]
C <- as.numeric (commandArgs()[as.numeric(length(commandArgs()) -4 )])
D <- as.numeric (commandArgs()[as.numeric(length(commandArgs()) -3 )])
E <- as.numeric (commandArgs()[as.numeric(length(commandArgs()) -2 )])
F <- commandArgs()[as.numeric(length(commandArgs()) -1 )]
G <- as.numeric (commandArgs()[as.numeric(length(commandArgs()) )])
The bash loop that reads these in and dispatches the R script, is as follows;
#!/bin/bash
N=0
cat Input.txt | while read LINE ; do
N=$((N+1))
echo "R --no-save < /home/trichard/Script.R" "$LINE" | bsub -N -q priority -R "select[model==Xeon5450]"
done
However, the problem is that there are millions of lines in Input.txt, so this approach is way too slow (it prevents other LSF users from submitting their own jobs).
So, the question is, how to do the above using an LSF array?