#!/bin/csh
#	runs      mission tapes using run.mission.PRD
#	generates mission tapes using run.all.vgr
#setopts o 9
setenv GGG_COPY mergexxx
#setenv GET_ALL	GET_ALL
if ( $?RSH ) then
	set rsh=${RSH}
	unsetenv RSH
else
	unset rsh
endif
if ( ! ${?DIR} ) then
	setenv DIR0 /plasma/d6/vgr/data
else
	setenv DIR0	${DIR}
endif
unset sc iter
if ( $?SC )	then
	set	sc=${SC}
else
	unset	sc
endif
if ( $?ITER )	then
	set iter=${ITER}
else
	unset	iter
endif
if ( $?TYPE ) then
	set type=${TYPE}
else
	unset type
endif
clear_env
if ( $?type ) then
	setenv TYPE ${type}
endif
if ( $?iter ) then
	setenv ITER ${iter}
else
	setenv ITER 4
endif
if ( $?sc ) then
	setenv SC ${sc}
else
	setenv SC 2
endif
setenv	DIR	${DIR0}
if ( ! -d ${DIR}/v${SC} ) then
	mkdir -p ${DIR}/v${SC}
endif
date
if ( ! -d ${DIR}/v${SC}/vgr ) then
	mkdir -p  ${DIR}/v${SC}/vgr 
endif
#	if VGR_${yr} is set to other than '' or $1 != $2 make vgr tape
#	environmental variable VGR_$YR is set if vgr tapes already made
setenv XX	VGR_$1
set xx=( `printenv | egrep ^${XX} ` )
if ( $1 != $2 || $#xx == 0 ) then
	run.all.vgr $1 $2 >& out.run.all.vgr.${SC}.${1}.${2}
	gzip -v9 out.run.all.vgr.${SC}.${1}.${2}
endif
date
unsetenv GET_ALL
if ( $?rsh ) then
	setenv RSH ${rsh}
endif
if ( ! -d ${DIR}/v${SC}/sedr ) then
	ln -s $vgrDATA/v${SC}/sedr ${DIR}/v${SC}/sedr
endif
setenv	vgrDATA	${DIR}
setenv	DELETE_HA
echo run.mission.PRD $1 $2 \>\&\ out.run.mission.PRD.${SC}.${1}.${2}
run.mission.PRD $1 $2 >& out.run.mission.PRD.${SC}.${1}.${2}
#gzip -v9 out.run.mission.PRD.${SC}.${1}.${2}
date