#!/bin/sh

#####################################################################
# Script trpsfprv.sh generates the TRPSFPRV product for the GFS
#
# History: OCT 2004 Julia Zhu First implementation of this script
# History: SEPT 2005 Steve Lilly remove snd2forgn
# HISTORY Oct. 2005 - Converted fax graphics to T4 format and
#                     stopped writing to the stat file.
#####################################################################

cd $DATA

COMIN=${COMIN:-/com/$NET/$envir/$RUN.$PDY}
cyc=${cyc:-00}
cycle=${cycle:-t00z}
PARMgraph=${PARMgraph:-/nwprod/util/parm}
FIXgraph=${FIXgraph:-/nwprod/util/fix}
EXECgraph=${EXECgraph:-/nwprod/util/exec}
model=${model:-gfs}
pcom=${pcom:-/pcom/gfs}

set +x
echo "######################################"
echo " Execute TRPSFPRV"
echo "######################################"
set -x
  
###################################
# Copy Grib files
###################################
cp ${COMIN}/${RUN}.${cycle}.pgrbf24 pgrbf24
cp ${COMIN}/${RUN}.${cycle}.pgrbf48 pgrbf48
cp ${COMIN}/${RUN}.${cycle}.pgrbif24 pgrbif24
cp ${COMIN}/${RUN}.${cycle}.pgrbif48 pgrbif48
cp $PARMgraph/graph_trpsfprv_ft08.$cycle trpsfprv_ft08.$cycle
cp $PARMgraph/graph_trpsfprv_ft05.$cycle trpsfprv_ft05.$cycle
cp $FIXgraph/graph_awpseed awpseed
cp ${FIXgraph}/graph_gphbg/mr4002.pur mr4002.pur
  
export pgm=trpsfprv;. prep_step
  
export XLFUNIT_8="trpsfprv_ft08.$cycle" 
export XLFUNIT_11="mr4002.pur"
export XLFUNIT_12="pgrbf24"
export XLFUNIT_22="pgrbif24"
export XLFUNIT_15="pgrbf48"
export XLFUNIT_25="pgrbif48"
export XLFUNIT_55="f55"
export XLFUNIT_60="f60"
export XLFUNIT_61="f61"
export XLFUNIT_62="f62"
export XLFUNIT_63="f63"
export XLFUNIT_71="ras"
export XLFUNIT_72="rs2"
export XLFUNIT_52="x6b"
export XLFUNIT_48="awpseed"
export XLFUNIT_81="trpsfprv.faxx.${model}_${cyc}"
  
msg="$pgm start"
postmsg "$jlogfile" "$msg"
  
$EXECgraph/trpsfprv  < trpsfprv_ft05.$cycle >> $pgmout 2> errfile
err=$?;export err;err_chk
  
echo "Leaving trpsfprv.sh"
exit
