program Prova_D

	use portlib

	integer :: itmax, N, dos
	real    :: x, tol

	real,dimension(:,:),allocatable :: A, B, C

	write(*,*) "Informe o valor de x"
	read(*,*) x

	write(*,*) "Informe o valor de itmax"
	read(*,*) itmax

	write(*,*) "Informe o valor de tol"
	read(*,*) tol

	write(*,*) "Informe a ordem das matrizes"
	read(*,*) N

	allocate ( A(N,N), B(N,N), C(N,N) )

	call matriz_A (N, A)

	call matriz_B (N, B)

	C = matmul(A,B)

	call zero_funcao (itmax,x,tol)

	open(1,file = 'saida.txt')

	write(1,1)

	do i = 1, N

		write(1,2) ( A(i,j), j = 1, N) 

	end do

	write(1,3)

	do i = 1, N

		write(1,2) ( B(i,j), j = 1, N ) 

	end do

	write(1,4)

	do i = 1, N

		write(1,2) ( C(i,j), j = 1, N ) 

	end do

	write(1,5) x

	close(1)

	dos = system('notepad saida.txt')

	1 format (/, "Matriz A")
	2 format ( <N>(1pe15.6) )
	3 format (/, "Matriz B")
	4 format (/, "Matriz C")
	5 format (/, "O valor de x encontrado é:", 1pe15.6)

end program Prova_D