! Citeste/genereaza A si b:
subroutine Read_Ab(n, nb, A, b, general, kodInput)

real A(n,n), b(n,nb)
logical general
character(80) dummy

SELECT CASE(kodInput)
CASE(0)
! Genereaza:
!if (kodInput ==0) then
call GenAB(n, nb, a, b)

! Din fisierul de intrare: kodA ==1
! --------------------------------
!If_1: IF(kodInput ==1) THEN
CASE(1)
! Citeste A:
if(general) then
	do i =1,n
	read(1,*) (a(i,j), j= 1,n)
	enddo
else ! Simetric: triunghiul superior:
	do i =1,n
	read(1,*) ( a(i,j), j=i,n )
	enddo

	! completeaza simetric:
	do i =1,n
	do j =1,i
	a(i,j) =a(j,i)
	enddo
	enddo
endif

! Citeste: Termenii liberi "b":
	do j =1,nb
	read(1,*) (b(i,j), i= 1,n)
	enddo

CASE(2)
! Fisier extern:
! -------------
!If_2: IF(kodInput ==2) THEN
! Citeste fis.#2:
read(2,*) dummy

sim_if: &
if(general) then  ! matrice generala
! Read A:
	do i =1,n
	read(2,*) (a(i,j), j= 1,n)
	enddo

else ! matrice simetrica: triunghiul superior
	do i =1,n
	read(2,*) ( a(i,j), j=i,n )
	enddo

	! completeaza simetric:
	do i =1,n
	do j =1,i
	a(i,j) =a(j,i)
	enddo
	enddo
endif sim_if

! Read b:
	do j =1,nb
	read(2,*) (b(i,j), i= 1,n)
	enddo

	close(2)

CASE DEFAULT

END SELECT

END subroutine Read_Ab
