#!/bin/csh -f
#
# formhis
#     script to invoke formhis.exe to make formatted history files
#     Part of discover
#     invoke from UNIX prompt with formhis 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  /usr/global/msi/cerius2_4.2MS/cdiscover
setenv BIOSYM_LIBRARY  /usr/global/msi/cerius2_4.2MS/cdiscover/res
source /usr/global/msi/cerius2_4.2MS/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.fhis

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/formhise
#
# Clean up
#
out:
/bin/rm fort.20
/bin/rm fort.21
/bin/rm ftn20
/bin/rm ftn21
echo ""
echo 'formhis stopped'
