Referencing job index in LSF job array

心已入冬 提交于 2019-12-12 18:19:12

问题


I'm trying to pass the index of a job in a job array as a parameter to another bash script.

numSims=3 
numTreatments=6 # uses numTreatments top rows of parameters.csv
maxFail=10
j=1
while [ $j -le $numSims ];
do
    bsub -q someQueue -J "mySim[1-$numTreatments]%2" ./another_script.sh $LSB_JOBINDEX $j $maxFail
    let j=j+1
done

The ultimate idea here is to submit, for each of 1,...,numTreatments,numSims jobs (simulations). I'd like two jobs running at a time (%2). Outputs have the form XX_indexNumber_simNumber, where indexNumber runs from 1,...,numTreatments and simNumber from 1,...,numSims.

Ideally, everything submitted as part of this script would have the same job ID. This isn't yet set up correctly, because all jobs with the same j are being assigned a distinct job ID. My immediate problem is that another_script.sh is not recognizing $LSB_JOBINDEX as input--it sees $j and $maxFail as the first and only two passed parameters. When I put some other variable in place of $LSB_JOBINDEX, there's no problem. What am I doing wrong?


Edit - some things I've tried: "$LSB_JOBINDEX", ${LSB_JOBINDEX}, %I, and I=$LSB_JOBINDEX; bsub ... $I $j $maxFail


回答1:


From this link:

The definition above will launch not just one batch job, but 100 batch jobs where the subjob specific environment variable $LSB_JOBINDEX gets values form 1 to 100. This variable can then be utilized in the actual job launching commands so that each subtask gets processed.

In your case, this means that the variable $LSB_JOBINDEX is available from inside the script another_script.sh. You do not need to pass it as a parameter, but just access $LSB_JOBINDEX in your script.



来源:https://stackoverflow.com/questions/11212923/referencing-job-index-in-lsf-job-array

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!