##############################################################################
## Author:      C. Rhodes
## Version:     2.0
## Date:	Wed Jan 27 14:46:19 EST 1993
## Purpose:     This shell script is designed to perform the necessary
##		formatting needed to turn pq output into CAYLEY output.
##		It first calls a compression routine that turns the sequences
##		output by pq into multiprecision integers and then neatly
##		streams the output.
##############################################################################

echo "LIBRARY " $1 ";"
echo "GPS ="
echo "SEQ("
cay_padic_compress < $1 |cayley | awk 'BEGIN { 
					 first = 0
					 l = 0 }
			    { 
			      d[NR] = $2
			      n[NR] = $4
                              p[NR] = $6
                              cc[NR] = $8             
                              long[NR] = $10 
			      l++
			      if ((first == 0 ) && ($1=="SEQ("))
				 first = l 
			    }
			    END  { for (i=first; i<NR-4; i++){
  			           printf "SEQ( %s, %s, %s, %s, %s ),\n", \
					d[i],n[i],p[i],cc[i],long[i]
				 }
  			           printf "SEQ( %s, %s, %s, %s, %s )\n", \
					d[i],n[i],p[i],cc[i],long[i]
}' 

echo ");"
echo "&Library of groups set up&"
echo "FINISH;"
