#! /bin/tcsh -f # "@(#) $Id: ferosPrepDateDir,v 1.6 2005/11/20 06:22:06 jpritcha Exp $" set exstat=0 set defguess=0196 set guess=$defguess set midUnit="99" if ( ! $?FEROS_DRS ) echo "Warning\!\!\! environment variable FEROS_DRS does NOT exist." set ssdir="${FEROS_DRS}/saved_session" set swd="`pwd`" while ( $#argv ) switch ( $1 ) case -h: goto usage case -c: set convLinks; shift; breaksw case -g: set guess=$2; shift; shift; breaksw case -r: set rawDataDir=$2; shift; shift; breaksw case --ssdir: set ssdir=$2; shift; shift; breaksw case -u: set midUnit=$2; shift; shift; breaksw case --templateDir: set templateDir=$2; shift; shift; breaksw default: set dateDir=$1; shift; breaksw endsw end if ( ! $?dateDir ) then echo "Error\!\!\! Must at least supply " set exstat=1 goto usage endif set fmw= if ( $?FEROS_MIDWORK ) then set fmw="-m $FEROS_MIDWORK" else echo "Warning\!\!\! Environment variable FEROS_MIDWORK does NOT exist" if ( -d `pwd`/midwork ) then echo "Found `pwd`/midwork, setting FEROS_MIDWORK to `pwd`/midwork." setenv FEROS_MIDWORK `pwd`/midwork set fmw="-m $FEROS_MIDWORK" endif endif which drs >& /dev/null if ( $status == 0 ) then set drs="drs" else if ( $?MIDASHOME && $?MIDVERS ) then if ( -e $MIDASHOME/$MIDVERS/system/unix/drs ) set drs="$MIDASHOME/$MIDVERS/system/unix/drs" endif endif if ( ! $?drs ) then echo "Error\!\!\! Can not find MIDAS command drs." echo "It is normally located in:" echo " //system/unix/drs" echo "Please either add it to your path (e.g. make a softlink to it) or set" echo "the environment variables MIDASHOME & MIDVERS." endif if ( $?MID_WORK ) then set saveMW="${MID_WORK}" endif setenv MID_WORK "$FEROS_MIDWORK" set guessFileList="BLAZE.tbl ThAr50000.tbl ThAr${guess}_{{GORDER,INIT,ORDER,{LINE,WLC}{1,2}}.tbl,TEMPLATE.bdf}" if ( ! -e ${FEROS_DRS}/Objects.tbl ) then if ( -e ${FEROS_DRS}/fmt/FEROS-Objects.fmt && -e ${FEROS_DRS}/dat/null.dat ) then echo "Warning\!\!\! Creating ${FEROS_DRS}/Objects.tbl" # inmidas ${fmw} -p ${midUnit} <& /dev/null if ( $status ) then echo "Error\!\!\! --templateDir option requires rsync to be installed" exit 1 endif rsync -av $templateDir/* $dateDir else echo "Error\!\!\! Can't find specified template directory $templateDir" exit 1 endif else set i=0 foreach file ( $guessFileList ) if ( ! -e ${FEROS_DRS}/guess${guess}/$file ) @ i++ end if ( $i != 0 ) then if ( -e ${ssdir}/guess${guess}.tar.gz ) then # make required files... if ( ! -d ${FEROS_DRS}/guess${guess} ) mkdir -p ${FEROS_DRS}/guess${guess} set lcwd="`pwd`" cd ${FEROS_DRS}/guess${guess} ln -fvs ${ssdir}/guess${guess}.tar.gz guess${guess}.tar.gz if ( $?convLinks ) symlinks -c . if ( $?convLinks ) symlinks -cs . # tar -zxvf guess${guess}.tar.gz # inmidas ${fmw} -p ${midUnit} < [-g ] [--ssdir ]" echo " [--templateDir ]" echo " " echo "" echo " Directory to prepare" echo "-g " echo " The four digit index number of the initial guess session. Default is $defguess." echo "-c" echo " Use symlinks programme to attempt convert absolute links to relative." echo "--ssdir ]" echo " Location of save_session directory containing guess archives." echo "--templateDir " echo " Instead of processing a guess session, rsync a template directory" echo " rsync MUST be installed." exit $exstat