0

After reading through numerous bash script threads and help sites, I cannot find a solution that works.

I want to pass a variable argument 'i' from a script to another script $i, then qsub this to a program "$1". In the program I read the variable from the argument vector (**argv) and then use this variable to modify the name of output files as *_0, *_1, *_2, ..., *_n.

The idea is so I can have a unique output file for each instance of a program. The program is parallel but due to limitations of the computing resources, I need to submit one job for a maximum of four computing nodes - or it will never pass through the que. So, I'd like to spin off 64 4-node jobs.

So far I have read topic on:

After reading these, I feel comfortable with the concept but still it is confusing how exactly the -C and -S command are used, or if they are used at all; most examples exclude these.

This is my spinoff pre-script

#
#$ -cwd
#$ -S /bin/bash
#$ -pe fah 1
for((i=0; i < 2; i++)); do qsub test_S17_script.sh $i; done

side info: what is qsub

And this is my script

#
#$ -M duser@acme_u.edu
#$ -m bae
#$ -cwd
#$ -S /bin/bash
#$ -pe fah 1

./daedalus_linux_1.3_64 1 "$1"

So, the spinoff works fine, and generates the files. And, the script works fine passing a constant ./daedalus_linux_1.3_64 1 1 but passing the variable does not work. I do not know if the prescript correctly passes variable i to the script. I don't know how to write to a error file from a script - or if this is even how I want to check if the variable is passed. The computing has no user interface so once it is in the queue I must rely on error file outputs.

Thank you in advance for your help.

4

2 回答 2

0

考虑使用PBS Job Arrays。单个 pbs 脚本将提交多个作业,每个作业将具有不同的环境变量 $PBS_ARRAY_INDEX 值。

于 2014-01-08T15:30:34.577 回答
0

如果您希望将标准输出从您的 prescript 传递到脚本,您可以执行以下操作:

./daedalus_linux_1.3_64 1 `<prescript>`

如果 prescript 在单独的行上打印来自 for 循环 (i=0, i=1) 的每次迭代的输出,您可能可以将 prescript 生成的输出通过管道传输到 xargs 命令。

在 prescript 中,您可以更改输出格式以在一行上显示由 qsub 的每次迭代生成的所有输出,如下所示:

for((i=0; i < 2; i++)); do qsub test_S17_script.sh $i; done | xargs

或者您可以使用 xargs 如下:

./daedalus_linux_1.3_64 1 `<prescript> | xargs`

希望有帮助。

于 2013-08-25T04:48:25.043 回答