#! /bin/csh -f

set yy=`date +%y`
set mm=`date +%m`
set dd=`date +%d`

set ymd=$yy$mm$dd

rm EGRD*

###################################################################
#
#  head is used to define symbolic links.  On HP's it should be "ftn"
#  Believe most other machines (SGI's and Suns, at least) use "fort."
#
set head="ftn"
#
#######################

if ( $#argv < 3 ) then
echo "need three arguments "
echo "first is starting time"
echo "second is ending fore hr"
echo "third is interval"
exit
endif

if ( $#argv == 3 ) then
echo "if include type (latlon or lmbc) as argument 4"
echo "and a gempak file name as argument 5"
echo "the file will automatically be degribbed using GEMPAKs"
echo "nagrib program"
echo " "
echo " "
echo "if you dont use GEMPAK, ignore this"
echo " "
endif

#--------------------------------------------------------------                 
set out_dir = `pwd`
setenv COMSP ${out_dir}/
echo $COMSP
setenv fcsthr 00                             
setenv tmmark t00s               

set tend = $2
set numtimes = $2
@ numtimes -= $1
@ numtimes /= $3
@ numtimes ++
set invar="$1 $numtimes $3"

echo starting at forecast time $1 and doing $numtimes at $3 hour intervals
sleep 2
echo $invar > namelist

#------------------
#
# QUILT JOB
#
#------------------

set checkval=`ls restrt*quilt.${tmmark} | wc -l`

if ($checkval >= 1) then
echo "quilting up"
ln -sf cnst.file ${head}12
../exe/quilt.x < namelist >& quilt.log
#
# rm restrt*quilt.${tmmark}
endif
