Reputation: 293
I use a shell script to launch several jobs on a computing cluster by calling qsub
inside a loop. I use the loop to give each job a different starting value. I wanted to specify the number of cores for each job to request by simply passing a number to the shell script when I run it from the command line. For example
./lauchJobs.sh 8
would launch jobs which requests 8 cores per node. I attempted to do this with
#!/bin/tcsh
#check that all input arguments are there
if ($# != 3) then
echo "This script requires three input arguments: (i) number of cores per job, (ii) starting guessNum, (iii) ending guessNum"
else
foreach iNum (`seq $2 1 $3`) #loop over guess numbers
qsub -v iGuess=${iNum} estimate.pbs
end
endif
(yes, technically my first example should have been something like ./launchJobs.sh 8 1 50
because I expect three arguments)
And estimate.pbs began with
#!/bin/tcsh
#PBS -l pmem=1gb,nodes=1:ppn=${nCores},walltime=60:00:00
The problem is that ${nCores}
did not resolve to the value I passed from the shell script because it is inside the PBS directive.
Is it possible to write a script file and PBS file that will allow me to specify the number of cores to request by passing it to the script, as in ./lauchJobs.sh 8
?
Upvotes: 0
Views: 552
Reputation: 332
You don't have to specify nodes=1:ppn=${nCores}
in estimate.pbs.
You can also invoke qsub in this way:
qsub -l nodes=1:ppn=${1} -v iGuess=${iNum} estimate.pbs
Upvotes: 3