#!/bin/bash # # This script was supplied by Lisa M. Perez at the Laboratory # for Molecular Simulation at Texas A&M University and is provided # on an "as is" basis. # # http://www.chem.tamu.edu/LMS # # This script was specifically designed for use on hydra ( IBM p575 Cluster running LoadLeveler ) # # Revision: 01252008 # Format: MMDDYYYY # # 04052007 added -y flag and changed walltime default from 1 hour to 24 hours # 07022007 minor bug fix: quotes on Trap line caused errors # 11082007 consumablmemory changed to ConsumableMemory # 01252008 fixed example # 02292008 changed parallel to serial for gaussian jobs since the parallel keyword is only for mpi jobs # and removed extra accounting summary at the end since it was also processed by the trap command # 12272008 changed default g03 to revision D.02 in /usr/local/lms/g03_D02_new and need to set LIBPATH to point to older compiler # # .................................................................... rev=12272008 # help function gethelp () { #clear echo " " echo " This script was specifically set up for the LoadLeveler queueing system on hydra.tamu.edu " echo " and currently can submit G03 jobs to the smp_normal and smp_long queues" echo " " echo " Syntax : qprep [-n] [-l] [-32] [-64] [-128] [-256] [-n[x]] [-mb[y]] -gb[z] [-t[hh]] [-y] [-r] filename" echo " " echo " x : number of processors requested and can have values that range from 1-592" echo " : non mpi jobs (ie. Gaussian) can have a range from 1-16" echo " : mpi jobs (ie. AMBER) can have a range from 16-592" echo " " echo " y : memory requested in MB (ie. -mb500 would request 500MB)" echo " z : memory requested in GB (ie. -gb2 would request 2GB)" echo " " echo " Flags to specify the queue (requests the maximum walltime available)" echo " smp_normal smp_long mpi32 mpi64 mpi128 mpi256" echo " -n -l -32 -64 -128 -256" echo " " echo " Alternatively, you may specify the walltime instead of using one of the queue flags" echo " -t[hh] : hh is the number of walltime hours (ie. -t5 requests 5 hours of walltime)" echo " " echo " filename is the name of the input file (filename.com)" echo " " echo " The default program: g03, queue: smp_normal, memory: 8gb, processors: 8" echo " " echo " NOTE : do NOT include %nproc or %mem in your input file (filename.com). The job file " echo " automatically sets the number of processors and the memory based on your flags." echo " " echo " If you wish to submit to the smp_long queue using 4 processors and 6gb of memory, " echo " you will need to use the -l and -gb4 flags" echo " " echo " example: qprep -l -gb4 -n4 filename" echo " " echo " The qprep -l -gb4 -n4 filename command will create filename.job and submit " echo " it to the smp_long queue with a request for 4gb of memory and 4 processors" echo " " echo " example2: qprep -n -n12 -gb12 -t20 filename" echo " submits to the smp_normal queue and requests 12 processors, 12gb of memory, and 20 hours of walltime" echo " " echo " The -r flag is used to append the output to the output file instead of overwriting it." echo " The -y flag will not ask you to look over the job file and will automatically submit." echo " " echo " USEFUL commands " echo " " echo " qlimit lists queue names, their limits, and which queues have open slots" echo " llclass lists queue names and some of their limits" echo " llclass -l lists queue information in long format" echo " llq lists all jobs in the queueing system" echo " llq -u user lists the jobs jobs for user (user should be a username)" echo " " echo " man llq manual pages for llq" echo " man llclass" echo " man llsubmit" echo " " echo " General step to submit a job to the queueing system" echo " " echo " Step 1: prepare your input file manually, using GaussView, Cerius, or " echo " your favorite interface" echo " Step 2: use qlimit to determine which queue to submit to" echo " Step 3: use qprep with the appropriate flags to create the job file and have it " echo " submitted to the appropriate queue" echo " " echo " To report problems with this script, e-mail Lisa M. Perez at mouse@mail.chem.tamu.edu" echo " " exit 0 } # goto help if there are no arguments ................................ # .................................................................... if [ $# -eq 0 ]; then gethelp fi # .................................................................... # parameters ......................................................... # .................................................................... # mb - memory in MB -bg - memory in GB; t - walltime requested in hours # t2 - queue name r - whether to overwrite output file # or append to it; n - number of processors; p - program to use # ttest - flag to see if -t was used m=8gb mg=1000000000 t=24 t2="smp_normal" r=0 n=8 p=g03 ttest=0 ask=1 i=0 for flag in "$@"; do case "$flag" in -h ) gethelp ;; -help ) gethelp ;; -mb[0-9]* ) m=`echo $flag|sed 's/-mb//'` let "mg=$m*1000000/8" m=${m}mb ;; -gb[0-9]* ) m=`echo $flag|sed 's/-gb//'` let "mg=$m*1000000000/8" m=${m}gb ;; -t[0-9]* ) t=`echo $flag|sed 's/-t//'` ttest=1 ;; -n ) if [[ $ttest -eq 0 ]]; then t=24 fi t2=smp_normal ;; -l ) if [[ $ttest -eq 0 ]]; then t=96 fi t2=smp_long ;; -32 ) if [[ $ttest -eq 0 ]]; then t=24 fi t2=mpi32 ;; -64 ) if [[ $ttest -eq 0 ]]; then t=12 fi t2=mpi64 ;; -128 ) if [[ $ttest -eq 0 ]]; then t=06 fi t2=mpi128 ;; -256 ) if [[ $ttest -eq 0 ]]; then t=04 fi t2=mpi256 ;; -r ) r=1 ;; -y ) ask=0 ;; -n[0-9]* ) n=`echo $flag|sed 's/-n//'` ;; -* ) echo '' echo 'Error: '$flag' is not a legal flag' echo 'use qprep -h for help' echo '' exit ;; *.com ) flag=`echo $flag|sed 's/\.com//'` filename=${filename}" "${flag} ;; * ) echo '' echo 'Error: '$flag' needs to end in .com' echo 'use qprep -h for help' echo '' exit ;; esac done # .................................................................... # Prepare the file ........................................... # .................................................................... if [[ $t -gt 24 && $t2 == "smp_normal" ]] ; then echo "" echo "Error: You have requested more than 24 hours of walltime" echo "and the smp_normal queue. Please request less than 24 hours" echo "of walltime to submit to the smp_normal queue" echo "" exit fi if [[ $n -gt 4 && $t2 == "smp_long" ]] ; then echo "" echo "Error: You have requested more than 4 cpus and the smp_long queue" echo "Please request 4 cpus or less to submit to the smp_long queue" echo "" exit fi if [[ $n -gt 16 && $t2 == "smp_normal" ]] ; then echo "" echo "Error: You have requested more than 16 cpus and the smp_normal queue" echo "Please request 16 cpus or less to submit to the smp_normal queue" echo "" exit fi if [[ $n -gt 16 && $t2 == "smp_normal" ]] ; then echo "" echo "Error: You have requested more than 16 cpus and the smp_normal queue" echo "Please request 16 cpus or less to submit to the smp_normal queue" echo "" exit fi if [[ $p == "g03" ]] ; then case "$t2" in mpi* ) echo "" echo "Error: Gaussian currently will not run in the mpi queues" echo "Please submit to the smp_normal or smp_long queue" echo "" exit ;; esac fi let "memtest=($mg)/($n*125000000)" if [[ $memtest -gt 2 ]]; then echo "" echo "Warning: you should only specify up to 2 GB per processor." echo "" echo -n 'Do you want to continue? (y or n) ' read cont if [[ $cont == "n" || $cont == "no" || $cont == "N" || $cont == "NO" || $cont == "No" ]]; then exit fi fi for data in $filename ; do if [[ $p == "g03" && ! -e ${data}.com ]] ; then echo "***************************************************" echo " Error: The input file "${data}".com does not exist " echo "***************************************************" else echo '#@ shell = /bin/bash' > $data.job echo '#@ comment = '$data >> $data.job echo '#@ job_name = '$data >> $data.job echo '#@ error = $(job_name).job.e$(jobid)' >> $data.job echo '#@ output = $(job_name).job.o$(jobid)' >> $data.job echo '#@ wall_clock_limit = '$t':00:00' >> $data.job # if [[ $n -eq 1 ]] ; then echo '#@ job_type = serial' >> $data.job # else # echo '#@ job_type = parallel' >> $data.job # fi echo '#@ resources = ConsumableCpus('$n') ConsumableMemory('$m')' >> $data.job echo '#@ node_usage = shared' >> $data.job echo '#@ notification = complete' >> $data.job echo '#@ queue' >> $data.job echo '#' >> $data.job echo '' >> $data.job echo '# in case the job runs out of time, grab the job info' >> $data.job echo 'trap "echo -n End Date: ;date;echo accounting;ls -al /work/$LOADL_STEP_ID;llq -lx $LOADL_STEP_ID;llq -w $LOADL_STEP_ID" 0 1 2 3 15' >> $data.job echo '' >> $data.job echo 'export OBJECT_MODE=64' >> $data.job echo '' >> $data.job echo 'export g03root=/usr/local/lms/g03_D02_new' >> $data.job echo '. $g03root/g03/bsd/g03.profile' >> $data.job echo '' >> $data.job echo 'export LIBPATH=/usr/local/xlf10.1/usr/lib' >> $data.job echo '' >> $data.job echo 'cd /work/$LOADL_STEP_ID' >> $data.job echo '' >> $data.job echo 'echo "-P-" '${n}' > Default.Route' >> $data.job echo 'echo "-M-" '${mg}' >> Default.Route' >> $data.job echo '' >> $data.job echo 'echo Environmental Settings' >> $data.job echo 'env' >> $data.job echo 'echo -n "Start Date: "' >> $data.job echo 'date' >> $data.job echo '' >> $data.job if [[ $r -eq 0 ]] ; then echo 'g03 < $LOADL_STEP_INITDIR/$LOADL_JOB_NAME.com > $LOADL_STEP_INITDIR/$LOADL_JOB_NAME.log' >> $data.job else echo 'g03 < $LOADL_STEP_INITDIR/$LOADL_JOB_NAME.com >> $LOADL_STEP_INITDIR/$LOADL_JOB_NAME.log' >> $data.job fi echo '' >> $data.job echo 'exit' >> $data.job echo '******************************************' if [[ $ask == 1 ]] ; then echo Look over the contents of your job file echo '' echo '<<<< Job file' ${data}.job '>>>>>' echo '' cat ${data}.job echo '' echo '<<<< end of Job file' ${data}.job '>>>>>' echo '' echo -n 'Do you want to submit this job? (y or n) ' read submitit else submitit=y fi if [[ $submitit == "y" || $submit == "yes" ]]; then llsubmit ${data}.job echo '' echo 'Your job has been submitted to the' ${t2} 'queue with a request for' ${t} 'hours of walltime,' ${m} 'memory and' ${n} 'processors' echo '' else echo 'Your job was NOT submitted to the' ${t2} 'queue with a request for' ${t} 'hours of walltime,' ${m} 'memory and' ${n} 'processors' echo echo 'You may manually submit your job with the command llsubmit '$data'.job' fi echo '' fi done llq -f %o %jn %jt %h %is %p %nh %id %dq %dd %c %st -u $LOGNAME exit