With a very simple zsh
script:
#!/bin/zsh
nums=(1 2 3)
num=$nums[$SGE_TASK_ID]
$SGE_TASK_ID
is the sun-grid engine task id. I'm using qsub to submit an array of jobs.
I am following what is advised in the qsub manpage (http://www.clusterresources.com/torquedocs/commands/qsub.shtml#t) and submitting my array job as
#script name: job_script.sh
qsub job_script.sh -t 1-3
$SGE_TASK_ID is not being set for this array job... does anyone have any ideas why?
Thanks!
thanks everyone for the answers. I found a solution that works:
Depending on how the cluster is set up, the Sun Grid Engine might be configured to use another variable name for array ids.. This was the case for me. I found out the variable to use by doing the following:
// job_script.sh
#!/bin/zsh
env >> ~/job_env
set >> ~/job_env
This dumps all environment variables set by the script into a file called job_env. Just simply look in the file and look for a variable array ID that is incremented for each job. Should not be that hard to find.
Remember to submit the job_script.sh with qsub as follows:
qsub -t 1-3 job_script.sh
In my case, the ID that was set was $PBS_ARRAYID. I don't think that's the default so $SGE_TASK_ID should work for standard SGE setups on clusters.
Cheers!