Running a job on Meta-Titus using Sun Grid Engine
July 26, 2007
Advanced Stuff
Below are three example scripts showing some slightly more advanced scripting stuff one can do on titus. Much of the explanation of this code can be found in the first section of these instructions. A good explanation of array jobs (the –t and $SGE_TASK_ID stuff) and herefiles
Array job with loop
#! /bin/bash
#$-S /bin/bash
#$-cwd
#$-t 1-4
export LD_LIBRARY_PATH=/opt/rocks/lib/mysql/
export PERL5LIB=/usr/local/lib/perl/:/usr/local/lib/perl/i386-linux-thread-multi/
export PERLLIB=/usr/local/lib/perl/:/usr/local/lib/perl/i386-linux-thread-multi/
for j in $(seq 1 2500); do
i=$(echo "2500 * ($SGE_TASK_ID-1)+$j" | bc -l)
/usr/bin/perl ./ML_s_mod.pl ger_44_sim.$i >> NEW_10000_new.out.$SGE_TASK_ID
done
Array job with herefile
#! /bin/bash
#$-S /bin/bash
#$-cwd
#$-t 1-10
k=$SGE_TASK_ID
R --quiet --no-save <<HEREFILE
params<-read.table("gucf.post")
nm1=params\$V3
nm2=params\$V4
n2=params\$V5
tau=params\$V6
for( p in 1:100 ){
nm1r=numeric(0);
nm2r=numeric(0);
n2pr=numeric(0);
tapr=numeric(0);
for(i in 1:10000){n2pr[i]=n2[runif(1,1,10001)]
tapr[i]=tau[runif(1,1,10001)]
nm1r[i]=nm1[runif(1,1,10001)]
nm2r[i]=nm2[runif(1,1,10001)]}
predprior=data.frame(nm1r,nm2r,n2pr,tapr,tapr)
write.table(predprior,append=T,file=paste("pswe_same.$k.txt"),quote=F,col.names=F,row.names=F)
}
HEREFILE
Array job with ms, random number generation, and lots of piping
#!/bin/bash
#$-S /bin/bash
#$-cwd
#$-N te_sfs
#$ -t 1-46
PATH=$PATH:$HOME/bin/mstbsdir:$HOME/bin/
k=$SGE_TASK_ID
family="AC"
nger=11
nuc=12
scratch=/state/partition1
te=$family
r1=$(echo "$RANDOM+$k" | bc -l)
r2=$(echo "$RANDOM+$k" | bc -l)
r3=$(echo "$RANDOM+$k" | bc -l)
## UC
mstbs $(echo "$nger + $nuc" | bc -l) 10000000 -s 1 -I 2 $nger $nuc 0 -m 1 2 tbs -m 2 1 tbs -n 2 tbs -ej tbs 2 1 -eM tbs 0 -seed $r1 $r2 $r3 < pguc_same.txt |
mssplit 1 -I 2 $nger $nuc | msfsfix | nfsaver $scratch/uc.$k.$te
mv $scratch/uc.$k.$te ~/projects/TEsims/