#!/bin/csh -f
# Script to run the program unres (serial version).
#
if ($#argv<2) then
  echo "USAGE: unres_clust.csh INPUT INTIN [OUTPUT]"
  exit (1)
endif

set BIN = /users/bartek/UNRESPACK/unres/bin/cluster
setenv INPUT $1
setenv INTIN $2
if ($#argv<3) then
  setenv OUTPUT $2
else
  setenv OUTPUT $3
endif

# Check for the existence of the input file

if (!(-e $1.inp)) then
  echo "Error: The input file $1.inp does not exist."
  exit(1)
endif

if (!(-e $2.int)) then
  echo "Error: The input internal coordinate file $2.int does not exist."
  exit(1)
endif

time ${BIN}/unres_clustMD

# Clear empty files
foreach zbior (`/bin/ls ${INTIN}.* ${OUTPUT}.* `)
  ls -l $zbior
  if (-z $zbior) /bin/rm $zbior
end
