subroutine Gauss_Seidel(Nx,Ny,Nxy,it_interna,AS,AW,AP,AE,AN,BP,TNum)
	
	implicit none
	integer,intent(in)                   :: Nx,Ny,Nxy,it_interna
	integer                              :: np
	real*8,dimension(Nxy),intent(in)     :: AS,AW,AP,AE,AN,BP
	real*8,dimension(Nxy),intent(inout)  :: TNum
	integer::i,j,k

do k=1,it_interna

	!Canto inferior-esquerdo (Sudoeste) 
    TNum(1) = (BP(1)-AE(1)*TNum(2)-AN(1)*TNum(1+Nx))/AP(1)

    !Sul
    !j = 1
    do i = 2, Nx
       	   
	   np = i
       
	   TNum(np) = (BP(np)-AW(np)*TNum(np-1)-AE(np)*TNum(np+1)- &
       AN(np)*TNum(np+Nx))/AP(np)
    
	end do

	!Interior e Leste e Oeste
	do i = 2,Nx-1

		do j = 2,Ny-1
		
			np = (j-1)*Nx + i
			
			TNum(np)=(BP(np)-AS(np)*TNum(np-Nx)-AW(np)*TNum(np-1)- &
			AE(np)*TNum(np+1)-AN(np)*TNum(np+Nx))/AP(np)

		end do

	end do

	!Norte
    j = ny
    do i = 1, Nx-1
    
	   np = (j-1)*nx + i
       
	   TNum(np) = (BP(np)-AS(np)*TNum(np-Nx)-AW(np)*TNum(np-1)- &
       AE(np)*TNum(np+1))/AP(np)
    
	end do

    !Canto superior-direito (Nordeste)
    np = nxy
    TNum(Nxy) =(BP(Nxy)-AS(np)*TNum(np-Nx)-AW(np)*TNum(np-1))/AP(np)

end do 

end subroutine Gauss_Seidel

