#!/bin/csh
#
#   4 Feb 1996 - KG - Execute PLTORB under 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 PLTORB is "
   echo "     pltorb xxx"
   echo "where xxx is the name of your xxx.orb and xxx.vec input files."
   exit
endif
#
#  if a path is included, change directories then strip the path off
#
if ($JOB == $JOB:h) then
else
   chdir $JOB:h
   set JOB=$JOB:t
endif
#
#   We don't check for existence of the .vec file in the unlikely
#   circumstance the user is typing them by hand in the .orb file.
#
if (-e $JOB.orb) then
else
   echo I could not find $JOB.orb in your current directory.
   echo Bombing out...
   exit
endif
#
echo " "
echo "Please enter 'xw' for X-windows output, 'ps' for PostScript."
set OUTPUT=$<
#
echo " "
echo "It is possible to save the MO grid data for later use by DENDIF."
echo "Should I save the $SCR/$JOB.rho file for DENDIF (y/n)?"
set saveden=$<
#
setenv PLTORB $JOB.orb
setenv PLTVEC $JOB.vec
setenv PLTLOG $JOB.lis
setenv PRGRID $SCR/$JOB.PLT08
setenv COGRID $SCR/$JOB.PLT09
setenv MOGRID $SCR/$JOB.PLT10
if ($saveden == y) setenv MOGRID $SCR/$JOB.rho
#
if ($OUTPUT == xw) then
   pltorb.xw.x
   rm $SCR/$JOB.PLT*
endif
#
if ($OUTPUT == ps) then
   setenv PSTNAM $JOB.ps
   pltorb.ps.x $JOB ; rm $SCR/$JOB.PLT* ; echo PLTORB ended &
   echo "Your PLTORB job is now running in the background.  When it"
   echo "finishes, your PostScript images will be in the file $PSTNAM"
   unsetenv PSTNAM
endif
#
unsetenv PLTORB
unsetenv PLTVEC
unsetenv PLTLOG
unsetenv PRGRID
unsetenv COGRID
unsetenv MOGRID
exit
