#!/bin/csh -f
#
# uformhis
#   script to invoke uformhis.exe to make formatted history files
#   Part of discover
#   invoke from UNIX prompt with
#   uformhis name.his
#   where name is the root name of the history file
#
# Environment: 
#    Will only run on current platform using discover in Cerius2 release area
# 
# Product: discover
#
# Molecular Simulations Inc 1997
#-----------------------------------------------------------------------------
#
# Setup environment variables
#
setenv BIOSYM  %MSIInstallRoot%/cdiscover
setenv BIOSYM_LIBRARY  %MSIInstallRoot%/cdiscover/res
source %MSIInstallRoot%/install/lic_setup
#
# check argument list
#
if ($#argv > 0) then
    set file = $argv[1]
endif

if ( -e $file ) then
   ln -s $file fort.20
   ln -s $file ftn20
   goto go
else
   echo ""
   echo "Input-file $file unavailable\!"
   goto out
endif

go:

set outp = $file:r.his
if ( -e $outp ) then
   echo ""
   echo "Output-file $outp already exists\!"
   echo "Delete $outp (Y/N)? "
   set delete = $<
   if ( $delete == 'Y' || $delete == 'y' ) then
      /bin/rm $outp
   else
      goto out
   endif
endif
#
# setup links
#
ln -s $outp fort.21
ln -s $outp ftn21
#
# execute conversion program
#
$BIOSYM/exec/uformhise
#
# clean up
#
out:

/bin/rm fort.20
/bin/rm fort.21
/bin/rm ftn20
/bin/rm ftn21
echo ""
echo 'uformhis stopped'
