#!/bin/csh -f
#
# PDBDIFF
#
# Source Version: 2.0
# Software Release #92-0043
#
# include "cpyright.h"
#

set FrontEnd = ""
set DPE = `which pact-dpe`
if ("$DPE" != "") then
   if (-e "$DPE[1]") then
      source $DPE
   endif
endif

set Mode      = 0
set Bits      = 128
set Individ   = 1
set Promote   = 0
set DiffUltra = 0
set DiffPVA   = 0
set Toler     = 1.0e-8

while (1)
   if ($#argv < 2) then
       echo ""
       echo "Usage: pdbdiff [-a] [-b n] [-d] [-i] [-l] [-p f] [-s] [-t #] [-u] [-v] <pdb-file1> <pdb-file2>"
       echo ""
       echo "Options:   a - display all entries if any differ"
       echo "           b - number of mantissa bits to use in floating point comparisions"
       echo "           d - compare different floating point types"
       echo "           i - enter interactive mode"
       echo "           l - compare different fixed point types"
       echo "           p - fractional decimal precision to use in floating point comparisons"
       echo "           s - display only the entries which differ"
       echo "           t - comparison tolerance for -v option defaults to 1.0e-8"
       echo "           u - compare ULTRA files"
       echo "           v - compare PVA (Portable Visualization and Analysis) files"
       echo ""
       exit(0)
   endif
   switch ($argv[1])
      case -a:
               set Individ = 0
               breaksw
      case -b:
               shift
               set Bits = $argv[1]
               breaksw
      case -d:
               if ($Promote == 0) then
                   set Promote = 2
               else if ($Promote == 1) then
                   set Promote = 3
               endif
               breaksw
      case -i:
               set Mode = 1
               breaksw
      case -l:
               if ($Promote == 0) then
                   set Promote = 1
               else if ($Promote == 2) then
                   set Promote = 3
               endif
               breaksw
      case -p:
               shift
               set Bits = $argv[1]
               breaksw
      case -s:
               set Individ = 1
               breaksw
      case -t:
               shift
               set Toler = $1
               breaksw
      case -u:
               set DiffUltra = 1
               breaksw
      case -v:
               set DiffPVA = 1
               breaksw
      default:
               if ($DiffPVA == 1) then
                  $FrontEnd sx -i -l sxdm.scm \(compare $1 $2 $Toler\)
                  set DiffStat = $status
               else if ($DiffUltra == 1) then
                  $FrontEnd ultra -s \(compare $1 $2 $Toler\)
                  set DiffStat = $status
               else
                  if ($Mode == 1) then
                     $FrontEnd sx -l sxcomp.scm \(pdbcomp $1 $2 $Bits $Individ $Promote\)
                     set DiffStat = $status
                  else
                     $FrontEnd sx -s -l sxcomp.scm \(pdbdiff $1 $2 $Bits $Individ $Promote\)
                     set DiffStat = $status
                  endif
               endif
               exit($DiffStat)
   endsw
   shift
end

