c *********************************************************************** subroutine invdiag(a,b,n) c inverse of a diagonal matrix c jul 2011 malv c *********************************************************************** implicit none integer n,i,j,k real*8 a(n,n),b(n,n) do 1,i=2,n-1 do 2,j=2,n-1 if (i.eq.j) then a(i,j) = 1.d0/b(i,i) else a(i,j)=0.0d0 end if 2 continue 1 continue do k=1,n a(n,k) = 0.0d0 a(1,k) = 0.0d0 a(k,1) = 0.0d0 a(k,n) = 0.0d0 end do return end