#!/bin/sh
#
# ofs_gribit.sh - standalone script that creates grib on "native" grid 
#
# imported variables:
#   COMIN - location of archive files
#   infile - location of .in file
#   outfile - name of output file
#   executable - name of executable
#   yyyy
#   mm
#   dd
#   cyc
#   cLEAD
#

echo "*** Started script $0"

set -x
gridno=${gridno:-255}

# create the in file
cat > infile<<EOF
archv.b
GRIB1
$yyyy   'yyyy'   = year
$mm     'month ' = month
$dd     'day   ' = day
$cyc    'hour  ' = hour
$cLEAD  'verfhr' = verification hour
EOF

cat $infile >> ./infile

# create auxilary infile for this subdomain
cat > fort.22 << EOF
$gridno
EOF

echo "========== $outfile =============" >> $pgmout
$executable < infile >> $pgmout

export err=$?; err_chk
echo ' ' >> $pgmout
if [ -s fort.51 ] 
then
  procstatus=0
  cp fort.51 $outfile
else
  procstatus=1
fi

echo "*** Finished script $0"

return $procstatus


