pbs_file=${1:?}
jtyp=${jtyp:gdas}

shift
qsub_opts=$@

# if file to be submitted contains string(s) %HHMM%, modify to stamp with
# current hour and minute
[ -n "$desc" ] && _desc="_$desc"
[ -n "$PDY" ] && _PDY="_$PDY"
if [ -n "$qsub_opts" ]; then
 qsub_command="qsub $qsub_opts"
else
 qsub_command=qsub
fi

# cd to destination output dir for logfiles to be written there w/ pid
outdir=/lfs/h2/emc/stmp/$USER/CRON/$desc/output
echo $outdir
mkdir -p $outdir
cd $outdir
echo `pwd`

sed "s/%HHMM%/`date -u +\%H\%M`/;s/%CC%/$cyc/;s/%CCM%/$cycM/;s/%JTYP%/$jtyp/;s/%YYYYMMDD%/`date -u +\%Y\%m\%d`/;s/%PDY%/$PDY/;s/%_PDY%/$_PDY/;s/%TMMARK%/$tmmark/;s/%DESC%/$desc/;s/%_DESC%/$_desc/" $pbs_file | $qsub_command

