#!/bin/sh
#####################################################################
# This script obtains the Radar Mosaic Data
# and interpolate them onto 212 grid as for the NAM grid
# History:   Binbin Zhou  -- May 2010, original version
#            Julia Zhu  -- June 30th, second version
#####################################################################
set -x

export copygb=${copygb:-/nwprod/util/exec/copygb}
export wgrib=${wgrib:-/nwprod/util/exec/wgrib}
export MOSAICDIR=${MOSAICDIR:-/com/hourly/prod}

model=$1
vday=$2

cd $DATA

for HH in 00 06 12 18
do
  mosaicfile=$MOSAICDIR/radar.$vday/refd3d.t${HH}z.grbf00
  case $model in
    hiresw) west='255 3 884 614 24500 -129200 8 -108000 5000 5000 0 64 0 40500 40500 0 0'   #west
            east='255 3 884 614 22100 -109800 8  -89000 5000 5000 0 64 0 38000 38000 0 0'   #east
            $copygb -g"$west" -i2,1 -x $mosaicfile $COMOUT/refd3d.t${HH}z.westgrid.f00
            $copygb -g"$east" -i2,1 -x $mosaicfile $COMOUT/refd3d.t${HH}z.eastgrid.f00
            ;; 
       nam) grid='227'   # Hiresw-WRF grid
            $copygb -g${grid} -i2,1 -x $mosaicfile $COMOUT/refd3d.t${HH}z.grid227.f00
            ;;
  esac
done
