#########################################################################
#
# Script: exarbuoy.sh    Author:  Bob Hollern
#
# Abstract: This script performs the tasks for making the SSVD50 KWBC
#  bulletin, which contains drifting buoy reports north of 69.9
#  degrees north latitude.  The tasks include determining the cycle
#  hour, running the dumpjb program to retrieve the drifting buoy
#  reports that are within a plus or minus 3 hours of the cycle hour,
#  executing the ARTCBUOY program to generate the SSVD50 KWBC bulletin.
#  This script runs in the 00, 06, 12, 18Z RW2.
# 
# History:  
#       March 1997 - first implementation
#########################################################################
set -xa
cd $DATA

HOUR=$1

set +x
echo 
echo "*****************"
echo "* ARTCBUOY"
echo "*****************"
echo
set -xa
  
################################################
# dump dbuoy data
################################################

DUPC=off
DUMP=/nwprod/ush/dumpjb
$DUMP ${PDY}${HOUR} 3 dbuoy
errdmp=$?
DUPC=on

if test "$errdmp" -ne '0'
then
   msg="ERROR IN DUMPING DBUOY DATA - ABORTING RW2"
   postmsg "$jlogfile" "$msg"
   export pgm="dumping"
   err_exit
fi

export pgm=artcbuoy
. prep_step

export ARTCTRAN="artcbuoy.buls.t${HOUR}z"

export XLFUNIT_20="dbuoy.ibm"
export XLFUNIT_51="$ARTCTRAN"
 
startmsg
$EXECutil/artcbuoy >> $pgmout 2> errfile
export err=$?;err_chk
  
################################################
# copy output to /pcom
################################################

if test "$SENDCOM" = 'YES'
then
   cp $ARTCTRAN $pcom/artcbuoy.buls$HOUR.$job

   ################################################
   # send message to dbnet about the output file
   ################################################
   if test "$SENDDBN" = 'YES'
   then
      $USHutil/make_ntc_bull.pl WMOBH NONE KWBC NONE $DATA/$ARTCTRAN $pcom/artcbuoy.buls$HOUR.$job
   fi

 fi

################################################
msg='Script exarbuoy.sh completed Normally.'
postmsg "$jlogfile" "$msg"
################################################

# ---------------END OF EXRW2 SCRIPT ----------------------------
