#!/bin/tcsh

#---------
# TCSH SHELL SCRIPT TO DIFFERENTIATE OUTPUT BETWEEN TWO PROTOMOL EXECUTABLES   
#
# Note: this script requires that you have links to protomol1 and protomol2
#       in your bin file with the names as specified by program1 and program2 
#       below
#---------

set program1 = "protomol1"
set program2 = "protomol2"
#set program3 = "namd"

set workdir = "`pwd`"
set examdir = "${workdir}/.."

set atoms = ("alanin")
set configs = ( "lf.Ewald.pb.conf" "lf.MG.conf" "lf.PME.pb.conf" "lf.std.conf" "lf.std.pb.conf" "slf.std.pb.conf" "hmc.std.conf"  "hmc.Bsp_PME.pb.conf" "shmc.std.pb.conf" "shmc.Bsp_PME.pb.conf")

#----------
# Runs the tests
#----------

foreach f ($atoms)
  
  # Atomic system specific parameters

  if ("$f" == "alanin") then
    set inputdir = "${examdir}/alanin_66"
    set steps = 10
  endif

  if ("$f" == "bpti") then
    set inputdir = "${examdir}/bpti_water_14281"
    set steps = 10 
  endif

  mkdir $f
  cd ${f}
  
  foreach w ($program1 $program2)
    
    mkdir $w
    cd ${w}
    touch ${f}_testlog.txt

    foreach c ($configs)

      cp ${workdir}/$c $c

      echo "Starting test configuration: $c for atomic system: $f" >> ${f}_testlog.txt
      ($w $c --posfile ${inputdir}/$f.pdb --temperature 0 --numsteps $steps --psffile ${inputdir}/$f.psf --parfile ${inputdir}/$f.par) >>& ${f}_testlog.txt
      echo End of Run '\n\n\n\n'Start of Run >>& ${f}_testlog.txt

    end
  
  #-----------
  # Analyzes the results
  #-----------

  # Identifies Fatal Errors

  touch ${f}_fatalerrors.txt
  grep "Starting \|Fatal Error" ${f}_testlog.txt >> ${f}_fatalerrors.txt

  cd ..

  end

end


