	parameter  (nt=2000)
	character*70  t
	character*80 fil1,fil2,fil3
	dimension   ang1(3,nt),ang2(3,nt),grp(nt)
c
	print *,'original angles file?'
	read 53,fil1
53	format(a80)
	open(21,file=fil1,status='old',readonly)
	read(21,101)  t
101	format(a70)
	write(22,101)  t
	n1=0
1	n1=n1+1	
	read(21,201,end=22)  (ang1(k,n1),k=1,3)
201	format(5x,2x,3f12.5)
	goto  1
22	close(21)
	n1=n1-1
c
	print *,'rotated angles file?'
	read 53,fil2
c
	open(21,file=fil2,status='old',readonly)
	read(21,101)  t
	n2=0
2	n2=n2+1
	read(21,201,end=23)  (ang2(k,n2),k=1,3)
	goto  2
23	close(21)
	n2=n2-1
c
	print *,'selection doc file?'
	read 53,fil3

	open(21,file=fil3,status='old',readonly)
	read(21,101)  t
	do  3  i=1,n2
	read(21,201,end=24)  grp(i)
3	continue
24	close(21)
c
	print  *,n1,n2
	kkk=0
	mm=3
	do  5  i=1,n1
	do  6  j=1,n2
	if(grp(j).ne.float(i))  goto  6
	lj=grp(j)
	do  7  l=1,3
7	ang1(l,i)=ang2(l,lj)
	kkk=kkk+1
	goto  8
6	continue
8	write(22,205)  i,mm,(ang1(k,i),k=1,3)
205	format(i5,i2,3g12.5)
5	continue
	print *,kkk
	stop
	end


