#! /bin/csh
#++++++++++++++++
#.IDENTIFICATION epoch.csh
#.LANGUAGE       C-shell
#.AUTHOR         Francois Ochsenbein [CDS]
#.ENVIRONMENT    
#.KEYWORDS       
#.VERSION  1.0   23-Apr-1996
#.PURPOSE        Correct epochs of GSC Plates
#.COMMENTS       
#----------------

setenv GSCDAT /usr6/GSC		# Original Andrea's
set GSCNEW = `dirname $0`
if ($GSCNEW !~ /*) set GSCNEW = $cwd/$GSCNEW
set PLATES = $GSCNEW/plates.epoch

echo "----Creating the New GSC files in $GSCNEW with plate epochs:"
ls -l $PLATES
if (! -r $PLATES) exit 1

cd src ; make epoch 
if ($status) exit(1)
set PGM = $cwd/epoch
cd $GSCNEW

echo $GSCDAT/[NS]*
foreach d($GSCDAT/[NS]*)
    set z = `basename $d`
    if (! -d $z) then
	echo "....Creating $GSCNEW/$z"
	mkdir $GSCNEW/$z
    else
	echo "....Remove files in $GSCNEW/$z"
	rm -f $GSCNEW/$z/*
    endif

    cd $d
    foreach f(*.GSC)
	$PGM $PLATES $f > $GSCNEW/$z/$f
	if ($status) exit 1
    end
end
