#!/bin/ksh
USAGE="usage: $MEMBER" 
export vertime="2000-03-17 0855L"
VERS="version:$USHutil/$MEMBER $vertime "
#______________________________________________________________________________
# NAME     : contoawp.sh
# Purpose  : This script runs script,
#            "afstoawp.sh" which runs program afstoawp to convert 
#            the AFOS radar maps 90s & 90r into AWIPS Redbook formatted maps. 
#            These AWIPS maps are then sent using snd2forgn
#
# History  : 1999-07-12 Peter Henrichsen modified to run on the IBM SP.
#          : 1999-12-02 Peter Henrichsen modified to use USHutil.
#          : 2000-03-15 Peter Henrichsen modified to run on ibmsp in dbnet.
#
# Location : This script is found on hp36 as:
#          : /tmp_mnt/export/sgi73/peterhen/util/scripts/ibm/contoawp.sh
#          : on the ncosp as:          
#          : /nwprod/util/ush/contoawp.sh or
#          : /nfsuser/g02/wx12ph/util/ush/contoawp.sh            
#             
#
#
#  Remarks : This script assumes that the following values have been exported
#            by the parent shell:
#            DATA EXECgraph ENVIR job SENDCOM SENDDBN 
#            jlogfile model pcom pgmout pid utilities 
#             
#
#  Note    : If you ARE NOT running as dbnprd and are testing
#            this script: Then set ENVIN=TEST and SENDCOM=NO 
#            in the parent job.
#            If you ARE running as dbnprd and are testing
#            this script: Then set ENVIN=PROD and SENDCOM=NO
#            in the parent job.                     
# 
#
#_______________________________________________________________________________

#
print "$USAGE"
print "$VERS"
cd $DATA
set -x
#
integer   istat
export ilename=`basename ${INFILE}`
export afosfile=`echo ${filename} | awk 'BEGIN{FS="."} {print $1}'` 
  
export name=$NAME

case $name in
  90r*)	pils="90r 90s"
	;;
  90s*)	pils="90r 90s" 
	;;
     *)	pils="$3"
	;;
esac
PILNAME="90r90s"

 export member=afstoawp.sh 
 $USHutil/$member $INFILE "${pils}"

   read awiprc < $DATA/$jobid.awiprc

  if test $awiprc -eq '0'
  then
    msg="$pils Converted to AWIPS!"
  else
    msg="ERROR $pils NOT Converted to AWIPS!" 
    postmsg "$jlogfile" "$msg" 
  fi
msg="$MEMBER HAS COMPLETED NORMALLY!"
postmsg "$jlogfile" "$msg"
    
    
# move output into comout!

outcom=$comout/foreign.$PDY
chmod 775 $DATA/$pgmout

mkdir -m 775 -p $outcom >/dev/null 2>&1
cp $DATA/$pgmout  $outcom/${job}.${PILNAME}.$pid









