!      program gen_data
!	Gera arquivo de entrada para projeto 3.6 do livro Calculo Numerico

      implicit real *8 (a-h,o-z)
	parameter (np=10)
	dimension a(np,np)
	dimension b(np),eps(np),temp(np)
      open(unit=1,file='input_rad.txt',status='old')
      open(unit=2,file='output.txt',status='unknown')        
      open(unit=3,file='input.txt',status='unknown')        
!
!	Leitura de dados
!
      read(1,*)n,dl
      write(*,*)'n= ',n,' dl= ',dl
      read(1,*)sigma
      write(*,*)'sigma= ',sigma
      read(1,*)area
      write(*,*)'area= ',area
!
	write(*,*)'o vetor eps(i) eh:'
	write(2,*)'o vetor eps(i) eh:'
	read (1,*) (eps(i),i=1,n)
      write(*,*)'eps(i)=', (eps(i),i=1,n)
	write(2,*)'eps(i)=', (eps(i),i=1,n)

	write(*,*)'o vetor temp(i) eh:'
	write(2,*)'o vetor temp(i) eh:'
	read (1,*) (temp(i),i=1,n)
      write(*,*)'temp(i)=', (temp(i),i=1,n)
	write(2,*)'temp(i)=', (temp(i),i=1,n)

	  ! calculo da matriz associada a(i,j)

	a(1,1)=1.d0
	aux1=-(1.d0-eps(1))/4.d0

	a(1,2)=aux1
	a(1,3)=aux1
	a(1,4)=aux1
	a(1,5)=aux1

	a(2,2)=1.d0
	aux2=-(1.d0-eps(2))/4.d0

	a(2,1)=aux2
	a(2,3)=aux2
	a(2,4)=aux2
	a(2,5)=aux2

	a(3,3)=1.d0
	aux3=-(1.d0-eps(3))/4.d0

	a(3,1)=aux3
	a(3,2)=aux3
	a(3,4)=aux3
	a(3,5)=aux3

	a(4,4)=1.d0
	aux4=-(1.d0-eps(4))/4.d0

	a(4,1)=aux4
	a(4,2)=aux4
	a(4,3)=aux4
	a(4,5)=aux4

	a(5,5)=1.d0
	aux5=-(1.d0-eps(5))/4.d0

	a(5,1)=aux5
	a(5,2)=aux5
	a(5,3)=aux5
	a(5,4)=aux5

!=============Write input file for solver============================
    write(3,*)n,dl

!----------

!	imprima a matriz a(i,j)
	write(*,*)'a matriz a(i,j) eh'
	write(2,*)'a matriz a(i,j) eh'
	do i=1,n
		write(*,*)'linha ',i
		write(2,*)'linha ',i
		write(2,*)(a(i,j),j=1,n)
		write(*,*)(a(i,j),j=1,n)
		write(3,*)(a(i,j),j=1,n)
	enddo

!	calcule o vetor b(i)
	write(*,*)'o vetor b(i) eh'
	write(2,*)'o vetor b(i) eh'
	do i=1,n
		b(i)=eps(i)*sigma*temp(i)**4
		write(2,*)b(i)
		write(*,*)b(i)
	enddo

	write(3,*) (b(i),i=1,n)


 close (1)
 close (2)
 close (3)

 stop

 end

