############################################################################
##
## SCRIPT: listq.sh                 NCO/PMB/SDM
##
## Syntax:  listq $1 $2
##          $1 = model date (yyyymmddZZ)
##          $2 = Station ID (from column 1 of file listq.yyyymmddZZ)
##
## CHANGE LOG:
##
##   04/2010   MALONE      Changed working directory from local
##                         /nco/pmb/$LOGNAME/sdmedit to /nco/ops/sdm[2]
##
############################################################################

set -xa

## DEFINE THE MACHINE AND ASSOCIATED VARIABLES.
machi=`hostname | cut -c1`
user=`whoami`
## If machi is c, then machine is cirrus.  If machi is s, then machine is stratus.

date=$1
loc=$2

## DEFINE THE WORKING DIRECTORY.
if [ $LOGNAME = 'wx12sd' ]; then
   DATA=/nco/ops/sdm
else
   DATA=/nco/ops/sdm2
fi
mkdir -p $DATA
cd $DATA

## PRESENT STATION DATA.
ls -t /nco/ops/sdm/listq*$1 /nco/ops/sdm2/listq*$1 > filesel
file=`head -1 filesel`
echo "Looking for station $loc in $file"
if test -s $file
then
   head -1 $file > outfile 
   grep "^$loc" $file >> outfile
   more outfile
else
   echo "$file does not exist."
fi

## END OF SCRIPT
