#!/bin/bash # # HMMER runtime environment script for Nordugrid ARC # # Runtime environment scripts are called (bash source) # from NorduGrid ARC with argument 0,1 or 2. # First call with argument "0" is made before the the batch # job submission script is written. # Second call is made with argument "1" just prior to execution of the # user specified executable. # Third "clean-up" call is made with argument "2" after the user # specified executable has returned. # # author: Olli Tourunen # # internal variable for setting the number of threads num_threads=8 # shared directory for application installation application_base_path=/grid/nordugrid-arc/appl/ case "$1" in 0 ) # Here we can reserve a whole node (with $num_thread cores) for running HMMer threaded. # append the number of cores to the joboptions i=0 # we need indirect reference here so this looks a bit nasty eval jonp=\${joboption_nodeproperty_$i} while [ ! -z $jonp ] ; do (( i++ )) eval jonp=\${joboption_nodeproperty_$i} done declare joboption_nodeproperty_$i="ppn=$num_threads" ;; 1 ) # no TMPDIR set up by PBS? Create one here and clean it up in stage 2 export TMPDIR=`mktemp -d -p /scratch` # include HMMer binaries in the path export PATH=$PATH:$application_base_path/hmmer/3.0/bin # set the number of threads used by HMMer # NOTE: if HMMER_NCPU is not set, HMMer will run on all CPUs on the node, # so set this even if you intend to allow serial jobs only! export HMMER_NCPU=$num_threads # create the database directory to local scratch if [ ! -d $TMPDIR/database ]; then mkdir $TMPDIR/database if [ $? != 0 ]; then echo "ERROR: Can't create database directory, TMPDIR=$TMPDIR" 1>&2 df -h 1>&2 exit 1 fi fi # export the database directory location export HMMER_DB_DIR=$TMPDIR/database ;; 2 ) # clean up the temporary directory if [ -d $TMPDIR ]; then rm -rf $TMPDIR fi ;; * ) # Now, calling argument is wrong or missing. # If call was made from NorduGrid ARC, it is considered # an error. If this script is to be used also to initialize # MPI environment for local jobs in cluster, raising error here # could be improper. return 1 ;; esac