#! /bin/csh -f

source ./Tools/ccsm_getenv || exit -2

./check_case || echo "check_case failed" && exit -2
set sdate = `date +"%Y-%m-%d %H:%M:%S"`

if (-e ${CASE}.test) then

cat > templar <<EOF
  ${BATCHSUBMIT} ./${CASE}.test
EOF
source templar
if ($status != 0) then
  echo "ERROR: cesm_submit problem sourcing templar " 
endif
rm templar
echo "test submitted $sdate" >>& CaseStatus

else

cat > templar <<EOF
  ${BATCHSUBMIT} ./${CASE}.run
EOF
source templar
if ($status != 0) then
  echo "ERROR: cesm_submit problem sourcing templar " 
endif
rm templar
echo "run submitted $sdate" >>& CaseStatus

endif

