########################################################################
##
## SCRIPT: listadp.sh             NCO/PMB/SDM
##
## Syntax:  listadp $1 $2
##          $1 = model hour (00 06 12 18)
##          $2 = station ID (from column 1 of file GETADPZZ)
##
## CHANGE LOG:
##
##   04/2010   MALONE      Changed working directory from local
##                         /nco/pmb/$LOGNAME/sdmedit to /nco/ops/sdm[2]
##
########################################################################

set -ax

## 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.

hour=$1
loc=$2

## ERROR CHECK.
## Exit if 2 valid arguments are not entered.
## $1 = model hour... 00 06 12 18
## $2 = station ID... found in column 1 of GETADPZZ
[ $# != 2 ] && { echo "$0 <hour> <loc> (where <loc> is Station ID)"; exit 99; }

## 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/GETADP$1 /nco/ops/sdm2/GETADP$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.
