#!/bin/ksh 

########################################
# Preliminary data setup step
########################################
set -xa
export PS4='$SECONDS + ' 
date

########################################################### 
# obtain unique process id (pid) and make temp directories
###########################################################
export DATA=${DATA:-${DATAROOT:?}/${jobid:?}}
mkdir -p $DATA
rm -rf $DATA/*
cd $DATA

export jlogfile=${jlogfile:-${DATA}/jlogfile.${jobid}}
msg="JOB $job HAS BEGUN"
postmsg "$jlogfile" "$msg"

export cycle=${cycle:-t${cyc}z}
setpdy.sh
. ./PDY

##################################################
# SENDCOM  - Copy Files From TMPDIR to $COMOUT
# SENDDBN  - Issue DBNet Client Calls
##################################################
export SENDCOM=${SENDCOM:-YES}
export SENDECF=${SENDECF:-YES}
export SENDDBN=${SENDDBN:-YES}
export SENDDBN_NTC=${SENDDBN_NTC:-NO}

###############################################################
# This block can be modified for different Production test
# environment. This is used for operational testings
###############################################################

## PDY not included here as pull data from PDYm1 as well

export EXEChref=${EXEChref:-$HOMEhref/exec}
export PARMhref=${PARMhref:-$HOMEhref/parm}
export USHhref=${USHhref:-$HOMEhref/ush}
export FIXhref=${FIXhref:-$HOMEhref/fix}
export SCRIPTShref=${SCRIPTShref:-$HOMEhref/scripts}

###################################
# Specify NET and RUN Name and model
####################################
export NET=${NET:-href}
export RUN=${RUN:-href}

# JY will see if needs following line: (from EMC checkout, but not from canned run)
# export IOBUF_PARAMS='*:size=8M:count=8'

##############################################
# Define running directory and COM directories
##############################################
export COMINhiresw=${COMINhiresw:-$(compath.py  prod/hiresw/${hiresw_ver})/hiresw}

export GESROOT=${GESROOT:-$(compath.py $envir/$NET/${href_ver})/nwges}
export COMINnam=${COMINnam:-$GESROOT/${RUN}}
export COMINhrrr=${COMINhrrr:-$GESROOT/${RUN}}

export COMOUT=${COMOUT:-$(compath.py -o $NET/${href_ver})/$RUN.${PDY}}

if [ ! -d $COMOUT ] ; then
 mkdir -p $COMOUT/ensprod
 mkdir -p $COMOUT/verf_g2g
fi

export pgmout="OUTPUT.$$"
 
########################################################
# Execute the script.

$HOMEhref/scripts/exhref_eas_1.sh
########################################################

msg="JOB $job HAS COMPLETED NORMALLY."
postmsg "$jlogfile" "$msg"

cd $DATAROOT
if [ $KEEPDATA = NO ]; then rm -rf $DATA; fi

date