#!/bin/csh -f                                                                   
# script to run analyze
#
# file/unit assignments, and program output        
set echo
# Set this to your ECEPP database directory
setenv DBASDIR ${ECEPP_ROOT}/Data/Residue
if ($#argv < 2 ) then
    echo "FILENAME of the Input files are missing"
    echo " (FILENAME1.inp and outo.FILENAME2)"
    echo "You must enter: analyze FILANAME1  FILANAME2 [FILENAME3] [FILENAME4]"
    exit (1)
endif
# Main input file
setenv FOR008 $1.inp
# Input angle file from EDMC run(s)
setenv FOR011 outo.$2
# List file & output angle file from clustering
if ($#argv < 3) then
  setenv FOR004 $2_clust.ang
  setenv FOR020 $2.out
  setenv FOR009 $1.noe
  setenv FOR022 $2.noe_out
  setenv FOR077 $2.coupl_out
else if ($#argv < 4) then
  setenv FOR004 $3.ang
  setenv FOR020 $3.out
  setenv FOR009 $1.noe
  setenv FOR022 $3.noe_out
  setenv FOR077 $3.coupl_out
else
  setenv FOR004 $3.ang
  setenv FOR020 $3.out
  setenv FOR009 $4.noe
  setenv FOR022 $3.noe_out
  setenv FOR077 $3.coupl_out
endif
# Residue data base
setenv FOR035 ${DBASDIR}/rsdata.new
ln -s ${DBASDIR}/angid.data fort.12
setenv FOR033 ${DBASDIR}/nmr_protons.data
if ( -e ${FOR020} ) then
  mv ${FOR020} ${FOR020}_old
  echo "Existing results file has been moved to ${FOR020}_old"
endif
if ( -e ${FOR004} ) then
  mv ${FOR004} ${FOR004}_old
  echo "Existing angle output file has been moved to ${FOR004}_old"
endif
setenv COORPREF $2
setenv PREFIX $2
env | grep FOR
set os = `uname -s`
if ($os == "AIX") then
    analyze-morass-AIX.x
else if ($os == "IRIX") then
    analyze-morass-IRIX.x
else if ($os == "IRIX64") then
    analyze-morass-IRIX64.x
else if ($os == "SunOS") then
    analyze-morass-SunOS.x
else if ($os == "Linux") then
    analyze-morass-Linux.x
#    gdb -d /usera/users/adam2/sources/analyze/source_nmr/ /usera/users/adam2/sources/analyze/bin/analyze-morass-debug-Linux.x
else
    echo "Unsupported architecture $os"
    exit
endif
# Remove empty "junk" files.
foreach fil (*)
   if (-z $fil) /bin/rm $fil
end
/bin/rm fort.12
