#!/bin/csh
#  4 August 1992 - MWS - Execute DENDIF on UNIX
#
set JOB=$1
set SCR=/scr/$USER
if (`hostname` == si.msg.chem.iastate.edu) set SCR=~/scr
#
if (null$JOB == null) then
   echo "The syntax to execute DENDIF is "
   echo "     dendif xxx"
   echo "where xxx is the name of your xxx.ddf input file."
   exit
endif
#
if (-e $JOB.ddf) then
else
   echo I could not find $JOB.ddf in your current directory.
   echo Bombing out...
   exit
endif
#
echo " "
echo "Please enter 'xw' for X-windows output, 'ps' for PostScript."
set OUTPUT=$<
#
setenv DDFINP $JOB.ddf
setenv DDFLOG $JOB.lis
setenv FOR020 $SCR/$JOB.rho
#
echo " "
echo "You will now be asked for the name(s) of the $SCR/yyy.rho grid"
echo "files to be subtracted from the total density in $SCR/$JOB.rho."
echo " "
echo "Enter 'done' when all (if any) of the subtraction grid sets have"
echo "been given, or 'exit' to abort."
echo " "
@ minus=20
assignloop:
   echo "What is the next file's yyy?  Enter a value for yyy, done, or exit:"
   set subtract=$<
   if ($subtract == exit) exit
   if ($subtract == done) goto readytogo
   @ minus++
   setenv FOR0$minus $SCR/$subtract.rho
goto assignloop
#
readytogo:
@ minus = $minus - 20
echo $minus sets of grids will be subtracted.
#
if ($OUTPUT == xw) then
   dendif.xw.x
endif
#
if ($OUTPUT == ps) then
   setenv PSTNAM $JOB.ps
   dendif.ps.x
   echo "Your PostScript image is now in the file $PSTNAM"
   unsetenv PSTNAM
endif
#
unsetenv DDFINP
unsetenv DDFLOG
unsetenv FOR020
@ minus = $minus + 20
while ($minus > 20)
  unsetenv FOR0$minus
  @ minus--
end
exit
