[Aces-support] variables as job names?

Constantinos Evangelinos ce107 at ocean.mit.edu
Fri Dec 17 10:24:03 EST 2004


On Thursday 16 December 2004 17:12, Einat Lev wrote:

> Hi
> Is there a way to put an enviroment variable as the job name (in the #PBS
> -N ___ option) ? I tried a few options, but nothing was accepted.
> I would like to have a way to distinguish which of my models is running
> while using "qstat".
Depends on what you need to do:

a) If you want to use an environment variable that is defined in the script 
itself in the #PBS option lines then that cannot be done as the #PBS option 
lines are interpreted before the rest of the script itself.
b) If you want to use an external to the script environment variable then it 
is do-able thus:

Say you have a set of environment variables JOBNAME1 to JOBNAMEk

You can always not put the "#PBS -N" option in the script file and submit the 
jobs as
qsub -N $JOBNAME1 scriptfile
qsub -N $JOBNAME2 scriptfile
etc.
You can then go ahead and do the job submission in a loop if required. I've 
done this in the past in a manner that allows me to then use the environment 
variable PBS_JOBNAME to retrieve the sequence number of the job and act 
accordingly.

That is (in C-Shell lingo) these fragments:

i) of the job multi-submission script
set icpert=1
set mnpert=100
set jobname="foo"
while ($icpert <= $mnpert)
	set jobcounter = $jobname%$icpert
	qsub -N $jobcounter singleton
end

ii) of the PBS job script

# recover icpert from PBS_JOBNAME
set icpert = `echo $PBS_JOBNAME | awk '{split ($1, tmpa, "%"); print tmpa[2]}' 
-`
# Then use icpert to do something different in every job

Constantinos
-- 
Dr. Constantinos Evangelinos
Department of Earth, Atmospheric and Planetary Sciences
Massachusetts Institute of Technology




More information about the Aces-support mailing list