#! /bin/ksh

# This script ends to stdout the name of the file that should contain
# the tcvitals for a cycle.  All arguments are optional and have these
# meanings:
#
# $1 -- the YYYYMMDDHH of the cycle.  
# $2 -- YES = wait for data to appear (if running on Jet)
#       NO = don't wait for data to appear
#       CACHED = use the cached tcvitals file if there is one, otherwise
#                go to the default file.  This is only meaningful on Jet,
#                otherwise it is equivalent to $2=NO
# $3 -- the output of hwrf_where_am_i.sh: v for vapor, c for cirrus, s
#       for stratus and jet for Jet.
# $4 -- HISTORY for a retrospective run, FORECAST for a real-time run

set -x
ymdh="${1:-${ymdh:-$YYYY$MM$DD$HH}}"
wait="${2:-$RUN_REALTIME}"
where="${3:-$WHERE_AM_I}"
caseroot="${4:-$CASE_ROOT}"

yyyy=` echo "$ymdh" | cut -c1-4 `

vitdir=""

case "$where" in
    zeus)
        vitdir=${SYNDAT_CORRECTED:-/scratch1/portfolios/NCEPDEV/hwrf/noscrub/input/SYNDAT/}syndat_tcvitals.$yyyy
        ;;
    jet)
        vitdir=${SYNDAT_CORRECTED:-/lfs1/projects/hwrf-vd/hwrf-input/SYNDAT/}syndat_tcvitals.$yyyy
        ;;

    *)
        if [[ "$caseroot" == FORECAST ]] ; then
            vitdir=/com/arch/prod/syndat/syndat_tcvitals.$yyyy
        else
            vitdir=${SYNDAT_CORRECTED:-/com/arch/prod/syndat}/syndat_tcvitals.$yyyy
        fi
        ;;
esac

echo "$vitdir"
