c	file inv6.f
c	Solves the inverse resistor problem.
c	Takes lambda, produces gamma.

	implicit double precision (a-h,o-z)
	dimension glam(80,80)
	dimension alph(20),c(20,20),work(20),iwork(20)
	dimension tarray(2)

	lda=20
	read(3,*)n
	n2=2*n
	n3=3*n
	n4=4*n
	do 5 j=1,n4
	  do 6 i=1,n4
	    read(3,*)glam(i,j)
6	  continue
5	continue
	tm=dtime(tarray)
	print *, 'read time  =  ',tm
	do 100 kk=1,n
	do 10 j=1,kk
	  do 11 i=1,kk
	    c(i,j)=glam(n4-kk+i,n+j)
	    write(8,*)c(i,j)
11	  continue
10	continue
	do 12 i=1,kk
	 alph(i)=-glam(n4-kk+i,n-kk+1)
12	continue
	itask=1
	ii=kk
	call dgefs(c,lda,ii,alph,itask,ind,work,iwork)
	write(9,*)ind
	do 15 i=1,kk
	  write(9,*)alph(i)
15	continue
	write(9,*)
	do 20 i=1,kk
	  a=glam(n-kk+i,n-kk+1)
	  do 19 j=1,kk
	    a=a+glam(n-kk+i,n+j)*alph(j)
19	  continue
	  write(10,*)a
20	continue
	write(10,*)
100	continue
	tm=dtime(tarray)
	print *, 'compute and write time  =  ',tm
	stop
	end
