#!/bin/csh -f
# countncond counts the number of non-null conditions in a 
# list of paradigm files.
#
# $Id: countncond,v 1.1 2004/02/17 22:02:17 greve Exp $

if($#argv == 0) then
  echo "USAGE: countncond parfile1 <parfile2 ...>"
  exit 1;
endif

set parfilelist = ($argv);

set condlist = ();
foreach par ($parfilelist)
  if(! -e $par) then
    echo "ERROR: cannot find $par"
    exit 1; 
  endif

  set tmp = `cat $par | awk '{if($2 != "") print $2}' | sort | uniq `
  set condlist = ($condlist $tmp);
end

set TF = /tmp/countncond.$$
rm -f $TF

foreach c ($condlist)
  if($c == 0) continue;
  echo $c >> $TF
end

set ucondlist = `cat $TF | sort | uniq`;
echo $#ucondlist

rm -f $TF


exit 0;
