#!/bin/sh
#########################################################################
#									#
# Script:  ngm_bfr2gpk							#
#									#
#  This script reads nam BUFR output and transfers it into GEMPAK	#
#  surface and sounding data files.					#
#									#
# Log:									#
# K. Brill/HPC		11/28/01					#
# B. Gordon/NCO         11/18/05 - modified for NGM monolithic bufr file#
#########################################################################  
set -x

# Set GEMPAK paths.

. /nwprod/gempak/.gempak

#  Go to a working directory.

cd $DATA

#  Set input file name.

export INFILE=$COMIN/ngm.t${cyc}z.snd.bufr

outfilbase=ngm_${PDY}${cyc}

namsnd << EOF 
SNBUFR   = $INFILE
SNOUTF   = ${outfilbase}.snd
SFOUTF   = ${outfilbase}.sfc
SNPRMF   = snngm.prm
SFPRMF   = sfngm.prm
TIMSTN   = 
r

exit
EOF

/bin/rm *.nts

snd=${outfilbase}.snd
sfc=${outfilbase}.sfc

cp $snd $COMAWP/$snd
cp $sfc $COMAWP/$sfc

if [ $SENDDBN = "YES" ]
then
   $DBNROOT/bin/dbn_alert MODEL SFC_NGM $job $COMAWP/$sfc
   $DBNROOT/bin/dbn_alert MODEL SND_NGM $job $COMAWP/$snd
fi

