batch script w/ pbs

This comes up fairly regularly at PSU : “How do I launch multiple processes w/ pbs for my paramater sweep/MCMC run etc”. The following works fairly well; when you’re confident the pbs scripts are correct, you can replace ‘more’ with ‘qsub’.

 #!/bin/bash


for (( i=1; i<=4; i++ ))

do

y=$(echo "($i-1)*2+1" | bc)

cat > $i_$y".pbs" << END


        #PBS -l nodes=1:ppn=1
        #PBS -l walltime=4:00:00
        #PBS -l pmem=1gb
        #PBS -j oe
        #
        cd \$PBS_O_WORKDIR
        #
        #Run an application, script etc which takes command line arguments to alter running conditions
        #Need to ensure file i/o is handled correctly for multiple concurrent processes
        echo " "
        echo " "
        echo "Job started on \`hostname\` at \`date\`"
        ./batch_application $y $i
        echo " "
        echo "Job Ended at \`date\`"
        echo " "



END

more $i_$y".pbs"

done

exit

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s