#!/bin/ksh
################################################################################
#
####  UNIX Script Documentation Block
#                      .                                             .
# Script name:         exdgex_mkbnd.sh.sms
# Script description:  Runs code to interpolate FNL/AVN sigma files to DGEX boundaries
#
# Author:        Eric Rogers       Org: NP22         Date: 2004-03-30
#
# Abstract: Runs code to interpolate FNL/AVN sigma files to WRF-NMM DGEX.
#
################################################################################

set -x
ipiece=$1

cd $DATA/mkbnd/mkbndwork.${ipiece}
sh /nwprod/util/ush/setup.sh

export PS4='MKBND${ipiece}_T$SECONDS + '

let "ione=ipiece*3"
let "itwo=ione+1"
let "ithree=itwo+1"

export pgm=dgex_${REGION}_mkbnd
. prep_step

ln -sf $DATA/gfsbc${ione}   fort.11
ln -sf $DATA/gfsbc${itwo}   fort.12
ln -sf $DATA/gfsbc${ithree} fort.13
export XLFUNIT_40=$FIXdgex/dgex_${REGION}_static.wrfsi.rotlat_nonetcdf_mod
export XLFUNIT_41=$PARMdgex/dgex_modtop.parm
export XLFUNIT_42=$PARMdgex/nam_deta.60.rev
export XLFUNIT_51=$DATA/rvetalbc_${ipiece}
export XLFUNIT_52=$DATA/dgexbcs00_${ipiece}

startmsg
$EXECdgex/dgex_mkbnd_${REGION} < $PARMdgex/dgex_mkbnd.parm >> $pgmout.${ipiece}
export err=$?;err_chk

if [ $err -ne 0 ]
then
  sleep 60
fi

echo MKBND PIECE ${ipiece} DONE > $DATA/mkbnddone.${ipiece}

exit
