0

I was searching around the web for an answer to this question however I couldn't find anything useful, so I've got the feeling what I'm looking for is not possible but maybe I missed something... So I'm just gonna try to ask here:

When submitting PBS job arrays, I want the WORKING DIRECTORY for each job to depend on the array ID. A small example to clarify. For a job array ranging from 1 to 100 (qsub -t 1-100 -v $array_size=100 .... called_script.sh), each job has its own working directory bunch_1-100, bunch_2-100,..... bunch_100-100. Atm I just use the $PBS_ARRAY_ID variable and a passed variable that contains the array size ($array_size), to navigate to the appropriate folder.

Imo this solution is not really optimal, because I'm fixing the naming scheme inside the called_script.sh script which is called by the submit script.

Hence if there would be some kind of placeholder for the job array id when submitting the job, i.e. qsub -t 1-100 -v $somevar=/some/directory/path/bunch-#PBS_ARRAY_ID_PLACEHOLDER-100 ... called_script.sh. So each called_script.sh would have a different $somevar variable automatically.

I think it should be possible in theory, however I got the feeling this is only theory :).

Thx in advance for any answers

steve
  • 133
  • 1
  • 2
  • 10
  • how about `cd ${somevar/\#PBS_ARRAY_ID_PLACEHOLDER/$PBS_ARRAY_ID}` inside the `called_script.sh`? – Dima Chubarov Nov 27 '13 at 06:11
  • @DmitriChubarov Hmm I don't really understand what you mean. If I understand your comment correctly, the solution that you are suggesting is what I am using atm. But as I mentioned I think its not as flexible. I modified my question a bit to clarify things. – steve Nov 27 '13 at 10:49
  • I suggest to use BASH pattern substitution in [parameter expansion](http://www.gnu.org/software/bash/manual/bashref.html#Shell-Parameter-Expansion) mechanism to replace the placeholder. Doing this you have to fix only the placeholder name, i.e. `#PBS_ARRAY_ID_PLACEHOLDER` and the name of the template variable, i.e. `$somevar`, but the actual template can be submitted in `qsub` command line. I still do not see what is the principal difference between your current solution and your proposed scheme. – Dima Chubarov Nov 27 '13 at 16:51
  • Ah ok I see. That would be indeed very similar. Basically I was asking if qsub can insert the correct array ID for that placeholder automatically instead of me having to do that. I was thinking if you want to have the log files written to different directories, you would run into trouble. But I'm not really sure if that makes all to much sense. Thx for the reply though! – steve Nov 28 '13 at 15:12

0 Answers0