2

I wanted to submit a R job to the grid. I have saved the main R code in MGSA_rand.r In the file callmgsa.r I have written

print('here')
source('/home/users/pegah/MGSA_rand.r')
mgsalooprand($SGE_TASK_ID,382)

And I use the file Rscript.sh to call the job (with the -t parameter I send the value corrseponding to $SGE_TASK_ID)

R CMD BATCH --no-save callmgsa.r

I submit the job like this:

qsub -t 1 -cwd -b y -l  vf=1000m /home/users/pegah/Rscript.sh  

I neither get an error nor any output. The job terminates just as I submit it, with out any output. Could you please help me?
thanks, Pegah

Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
Pegah
  • 672
  • 2
  • 13
  • 23
  • Have you tried Rscript as a shebang? That's the usual way for creating scripts: http://stackoverflow.com/questions/750786/whats-the-best-way-to-use-r-scripts-on-the-command-line – flodel Feb 19 '12 at 12:12
  • If $SGE_TASK_ID is an environment variable, you need to use `Sys.getenv("SGE_TASK_ID")` to access it within your R script. – flodel Feb 19 '12 at 12:38

1 Answers1

0

The variable $SGE_TASK_ID is a shelscript variable. Calling it in R with the same syntax is no going to work. What you could do is use Rscript in stead. From the shellscript you call:

Rscript callmgsa.r $SGE_TASK_ID

In the R script you can catch the command line arguments like:

args <- commandArgs(trailingOnly = TRUE)
print('here')
source('/home/users/pegah/MGSA_rand.r')
mgsalooprand(args[1],382)

This should work...

Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149