 module Coef
 
 use variaveis 
 
 implicit none

 contains

	subroutine coeficientes(N, AW, AP, AE, BP, un)

    integer                             :: N
	real*8                              :: x                ! coordenada espacial
	real*8, dimension(:), intent(inout) :: AW, AP, AE, BP  
	real*8, dimension(:), intent(inout) :: un
	
	dx = 1.0d0 / (N - 1)

    ! contorno esquerdo
    AW(1) = 0.0d0
    AE(1) = 0.0d0
    AP(1) = 1.0d0
    BP(1) = 0.0d0

    ! pontos internos
	do i = 2, N-1

       x = (i-1) * dx

	   AW(i) = 1.0d0 / (dx**2) + (Re * un(i-1)) / ( dx ) 

       AE(i) = 1.0d0 / (dx**2) 

       AP(i) = 2.0d0 / (dx**2) + (Re * un(i)) / ( dx )

       BP(i) = ((Re**2.0d0)*(dexp(x*Re))*(2.0d0*dexp(x*Re) - dexp(Re) - 1.0d0)) / &
	   ((dexp(Re) - 1.0d0 )**2.0d0) 

    end do

 	! contorno direito
    AW(N) = 0.0d0
    AE(N) = 0.0d0
    AP(N) = 1.0d0
    BP(N) = 1.0d0

  end subroutine coeficientes

! **********************************************

end module Coef
