#!/bin/csh -f
onintr EXINT
set onl=n
echo -n 'DATA [terminal]: '
set DATA=$<
set tchk=`echo $DATA|tr a-z A-Z`
if ( $tchk == "" || $tchk == TERMINAL ) set onl=y
echo 'mkdir $LAUE_SCR/dir$$' >>$1
echo 'setenv AVSPOT $LAUE_SCR/dir$$/avespot.dat' >>$1
echo 'setenv BADSPOTS $LAUE_SCR/dir$$/badspots.dat' >>$1
echo 'setenv SPOTVEC $LAUE_SCR/dir$$/spotvec.dat' >>$1
echo 'setenv TEMPSPOT $LAUE_SCR/dir$$/tempspot.dat' >>$1
echo 'setenv MOSTEMP $LAUE_SCR/dir$$/mostemp.dat' >>$1
echo 'setenv SORTTEMP $LAUE_SCR/dir$$/sorttemp.dat' >>$1
if ( $onl == 'y' ) goto onlin
echo 'tty>/dev/null' >>$1
echo 'if ( $status == 0 ) goto intact' >>$1
echo 'setenv LOGFILE $LAUE_SCR/dir$$/logfile' >>$1
echo "time ${2}/intlaue < $DATA" >>$1
echo 'cat $LAUE_SCR/dir$$/logfile' >>$1
echo '/bin/rm -r $LAUE_SCR/dir$$' >>$1
echo 'exit 0' >>$1
echo 'intact:' >>$1
echo "set LOGFIL=intlaue.log" >>$1
echo "chklog:" >>$1
echo 'if ( -e $LOGFIL == 0 ) goto runprog' >>$1
echo 'echo "**File $LOGFIL already exists**"' >>$1
echo 'echo -n "Enter new name for log file or rm to remove existing file: "'\
>>$1
echo 'set newlog=$<' >>$1
echo 'if ( $newlog == "rm" ) then' >>$1
echo '   /bin/rm $LOGFIL' >>$1
echo '   goto runprog' >>$1
echo 'endif' >>$1
echo 'if ( $newlog == "") set newlog=$LOGFIL' >>$1
echo 'set LOGFIL=$newlog' >>$1
echo 'goto chklog' >>$1
echo 'runprog:' >>$1
echo 'setenv LOGFILE $LOGFIL' >>$1
echo "${2}/intlaue < $DATA" >>$1
echo '/bin/rm -r $LAUE_SCR/dir$$' >>$1
exit 0
onlin:
echo "set LOGFIL=intlaue.log" >>$1
echo "chklog:" >>$1
echo 'if ( -e $LOGFIL == 0 ) goto runprog' >>$1
echo 'echo "**File $LOGFIL already exists**"' >>$1
echo 'echo -n "Enter new name for log file or rm to remove existing file: "'\
>>$1
echo 'set newlog=$<' >>$1
echo 'if ( $newlog == "rm" ) then' >>$1
echo '   /bin/rm $LOGFIL' >>$1
echo '   goto runprog' >>$1
echo 'endif' >>$1
echo 'if ( $newlog == "") set newlog=$LOGFIL' >>$1
echo 'set LOGFIL=$newlog' >>$1
echo 'goto chklog' >>$1
echo 'runprog:' >>$1
echo 'setenv LOGFILE $LOGFIL' >>$1
echo "${2}/intlaue" >>$1
echo '/bin/rm -r $LAUE_SCR/dir$$' >>$1
exit 101
EXINT:
exit 99
