#!/usr/bin/env bash #----------------------------------------------------------------------- # runs one job # call: concat2 dataset_id data_server section # assume that everything is distributed over the network # assume that requests are stored in $data_server:$WORK_DIR/requests #----------------------------------------------------------------------- # . $HOME/.bashrc usage() { echo concat2 dataset_id data_server section } export STRIP_SERVER=fcdflnx3.fnal.gov if [ .$3 == "." ] ; then usage ; exit ; fi export DATASET_ID=$1 if [[ $2 != "." && .$2 != ".." ]] ; then export STRIP_SERVER=$2 ; fi sec=$3 if [ `hostname` == $STRIP_SERVER ] ; then remote="" else remote="rsh -x -N -n $STRIP_SERVER" fi echo STRIP_SERVER=$STRIP_SERVER remote=$remote section=`printf "%03i" $3` prefix="" ; if [ .$4 != "." ] ; then prefix="echo" ; fi . $PWD/cdfopr/scripts/common_procedures RELEASE_DIR=$PWD name=concat2 export OUTPUT_DIR=/cdf/scratch/cdfopr/strip/$DATASET_ID export BOOK=cdfpewk WORK_DIR=/cdf/scratch/cdfopr/strip/$DATASET_ID REQUEST_DIR=$WORK_DIR/.book/requests logfile=$$.log echo cmd: $remote ls $REQUEST_DIR "|" grep $section >> $logfile echo request_file=`$remote ls $REQUEST_DIR | grep $section` >> $logfile request_file=`$remote ls $REQUEST_DIR | grep $section` echo `date`: $name started , .request_file.=.$request_file. >> $logfile cd $RELEASE_DIR source ~cdfsoft/cdf2.shrc setup cdfsoft2 `cat .base_release` srt_setup -a setup fcp if [ ."$remote" != "." ] ; then rcp $STRIP_SERVER:$REQUEST_DIR/$request_file . else cp $REQUEST_DIR/$request_file . fi cat $request_file echo $remote mv $REQUEST_DIR/$request_file $REQUEST_DIR/.$request_file.tmp $remote mv $REQUEST_DIR/$request_file $REQUEST_DIR/.$request_file.tmp echo DISPLAY=$DISPLAY >> $logfile root.exe -b -l <>$logfile 2>>$logfile .L Stntuple/scripts/dh.C dh::concatenate("${request_file}"); EOF rc=$? exit $rc pattern=`echo $DATASET_ID | awk '{ print substr($1,1,1)substr($1,6,1)"*.*"substr($1,2,4) }'` if [ $rc == 0 ] ; then # copy output file to FCDFDATA033 output_file=`ls $pattern` fcp $output_file cdfopr@$DATA_SERVER:$OUTPUT_DIR/. rc=$? if [ $rc == 0 ] ; then # delete the local concatenated file rm $output_file rc=$? if [ $rc == 0 ] ; then echo removing input files: rm $LIST_OF_FILES >> $logfile for f in $LIST_OF_FILES ; do $remote mv $f .$f.done done # $remote rm $LIST_OF_FILES echo removing original request : $REQUEST_DIR/$request_file >> $logfile $remote mv $REQUEST_DIR/.$request_file.tmp $REQUEST_DIR/.$request_file.done fi fi fi echo `date`: $name finished with RC=$rc >> $logfile fcp $logfile cdfopr@$DATA_SERVER:$WORK_DIR/.log/$request_file.log #----------------------------------------------------------------------- # cleanup and exit #----------------------------------------------------------------------- if [ $? == 0 ] ; then rm $logfile ; fi if [ .`hostname | grep fcdfcaf` != "." ] ; then rm -rf Stntuple cdfopr shlib rm ./.base_release ./.rootrc ./rootlogon.C ./GNUmakefile fi exit $rc #-------------------------------------------------------------------------------