module solvers

implicit none

contains

!--------------------------------------------------------------------

subroutine gauss_seidel(T,ap,ae,aw,an,as,ane,anw,ase,asw,Nv1,Nv2,Nt,itsolver)

	integer :: i, j, it
	integer :: aux1, aux2

	integer, intent(in) :: Nv1, Nv2, Nt, itsolver

	real*8,dimension(Nt), intent(in)    :: ap 
	real*8,dimension(Nt), intent(in)    :: ae 
	real*8,dimension(Nt), intent(in)    :: aw 
	real*8,dimension(Nt), intent(in)    :: an 
	real*8,dimension(Nt), intent(in)    :: as 
	real*8,dimension(Nt), intent(in)    :: ane 
	real*8,dimension(Nt), intent(in)    :: anw 
	real*8,dimension(Nt), intent(in)    :: ase 
	real*8,dimension(Nt), intent(in)    :: asw
	real*8,dimension(Nt), intent(inout) :: T

	do it = 1, itsolver
	
		do i = 2, Nv2-1
			
			aux1 = (i-1)*Nv1

			do j = 2, Nv1-1
				
				aux2 = aux1 + j

				T(aux2) = ( ae(aux2)*T(aux2+1)      + aw(aux2)*T(aux2-1)      + &
							an(aux2)*T(aux2+Nv1)	+ as(aux2)*T(aux2-Nv1)    + &
							ane(aux2)*T(aux2+Nv1+1) + anw(aux2)*T(aux2+Nv1-1) + &
							ase(aux2)*T(aux2-Nv1+1) + asw(aux2)*T(aux2-Nv1-1) ) / ap(aux2)

			end do
		
		end do
		
	end do 

end subroutine gauss_seidel

!--------------------------------------------------------------------

end module solvers