SUBROUTINE lu_fact_3(a,ipiv,info)
USE class_psblas, ONLY : psb_dpk_
REAL(psb_dpk_), INTENT(INOUT) :: A(3,3)
INTEGER, INTENT(OUT) :: ipiv(3)
INTEGER, INTENT(OUT) :: info
!
REAL(psb_dpk_) ::tmp, swp(3)
INTEGER :: j, k, jp
REAL(psb_dpk_), PARAMETER :: tol = 1.d-20
info = 0
IF (.FALSE.) THEN
DO j = 1, 3
jp = j - 1 + MAXLOC(ABS(a(j:,j)),dim=1)
ipiv(j) = jp
IF (jp /= j) THEN
DO k=1,3
tmp = a(j,k)
a(j,k) = a(jp,k)
a(jp,k) = tmp
END DO
END IF
IF(ABS(a(j,j)) < tol) THEN
info = j
ELSE
a(j+1:,j) = a(j+1:,j) * (1.d0/a(j,j))
END IF
DO k = j + 1, 3
a(j+1:,k) = a(j+1:,k) - a(j,k) * a(j+1:,j)
END DO
END DO
ELSE
jp = 1 - 1 + MAXLOC(ABS(a(1:,1)),dim=1)
ipiv(1) = jp
IF (jp /= 1) THEN
swp(1:3) = a(1,1:3)
a(1,1:3) = a(jp,1:3)
a(jp,1:3) = swp(1:3)
END IF
IF(ABS(a(1,1)) < tol) THEN
info = 1
ELSE
a(1+1:,1) = a(1+1:,1) * (1.d0/a(1,1))
END IF
DO k = 1 + 1, 3
a(1+1:,k) = a(1+1:,k) - a(1,k) * a(1+1:,1)
END DO
jp = 2 - 1 + MAXLOC(ABS(a(2:,2)),dim=1)
ipiv(2) = jp
IF (jp /= 2) THEN
swp(1:3) = a(2,1:3)
a(2,1:3) = a(jp,1:3)
a(jp,1:3) = swp(1:3)
END IF
IF(ABS(a(2,2)) < tol) THEN
info = 2
ELSE
a(2+1:,2) = a(2+1:,2) * (1.d0/a(2,2))
END IF
DO k = 2 + 1, 3
a(2+1:,k) = a(2+1:,k) - a(2,k) * a(2+1:,2)
END DO
ipiv(3) = 3
IF(ABS(a(3,3)) < tol) THEN
info = 3
END IF
END IF
END SUBROUTINE lu_fact_3