
      include 'householder.f'

      subroutine subhmain(n)
c     PODPROGRAM GLOWNY DO HOUSEHOLDERA
c     ROZWIAZUJE UKLAD Ax=b METODDA HOUSEHOLDERA
      implicit none
      real*8 A,b,x,AAT,BBT
      integer k1,k2,j,k,n,pyt
      dimension A(n,n),b(n),x(n),AAT(n*n),BBT(n)
c     DATA
      open(unit=10,file='A')
      open(unit=11,file='b')
      write(*,*)'HOUSEHOLDER'
      write(*,*)' 0 - CZYTANIE DANYCH Z KONSOLI'
      write(*,*)' 1 - CZYTANIE DANYCH Z PLIKOW AAT I BBT'
      read (*,*) pyt
      if(pyt.eq.0)then 
      goto 30
      else
      goto 40
      endif
      
c     CZYTANIE Z KONSOLI 
   30 write(*,*)'PODAWAJ A KOLUMNAMI'
      do 1,k2=1,n,1
      do 2,k1=1,n,1
      read (*,*)  A(k1,k2)
      write(10,*) A(k1,k2)
      if(mod(k1,n).eq.0)then
      write(*,*) 'KONIEC KOLUMNY', k2
      else
      continue
      endif
    2 continue
    1 continue
      write(*,*)'PODAWAJ KOLUMNE b'
      do 3,k=1,n,1
      read (*,*) b(k)
      write(11,*)b(k)
      if(mod(k,n).eq.0)then
      write(*,*)'KONIEC b'
      else
      continue
      endif
    3 continue
      goto 50
   40 open(unit=20,file='AAT')
      rewind(20)
      do 41,k2=1,n,1
      do 42,k1=1,n,1
      j=n*(k2-1)+k1
      read (20,*) AAT(j)
   42 continue
   41 continue
      rewind(10)
      do 43,k2=1,n,1
      do 44,k1=1,n,1
      j=n*(k2-1)+k1
      A(k1,k2)=AAT(j)
      write(10,*) AAT(j)
   44 continue
   43 continue
      open(unit=21,file='BBT')
      rewind(21)
      do 45,k1=1,n,1
      read (21,*) BBT(k1)
   45 continue
      rewind(11)
      do 46,k1=1,n,1
      b(k1)=BBT(k1)
      write(11,*) BBT(k1)
   46 continue
   50 write(*,*)'<ENTER>'
      read (*,*)
      call householder(n)
      return
      end
