      SUBROUTINE INV3X3(A,B,IERR)
C
C Inversion matrice 3 x 3 
C
      DIMENSION A(3,3),B(3,3)
C
      DET = A(1,1)*A(2,2)*A(3,3) + A(1,2)*A(2,3)*A(3,1)
     1    + A(1,3)*A(3,2)*A(2,1) - A(1,3)*A(2,2)*A(3,1)
     2    - A(1,2)*A(2,1)*A(3,3) - A(1,1)*A(2,3)*A(3,2)
      IF (DET.EQ.0.) THEN
cc        PRINT*,'MATRICE NON INVERSIBLE'
cc        STOP
        IERR = 1
        RETURN
      ELSE
        IF (ABS(DET).LT.1.E-05) THEN
          IERR = -1
        ELSE
          IERR = 0
        ENDIF
        USDET = 1./DET
      ENDIF
C
      B(1,1) = ( A(2,2)*A(3,3) - A(2,3)*A(3,2) ) * USDET
      B(1,2) = ( A(1,3)*A(3,2) - A(1,2)*A(3,3) ) * USDET
      B(1,3) = ( A(1,2)*A(2,3) - A(2,2)*A(1,3) ) * USDET
      B(2,1) =-( A(2,1)*A(3,3) - A(2,3)*A(3,1) ) * USDET
      B(2,2) = ( A(1,1)*A(3,3) - A(1,3)*A(3,1) ) * USDET
      B(2,3) =-( A(1,1)*A(2,3) - A(1,3)*A(2,1) ) * USDET
      B(3,1) = ( A(2,1)*A(3,2) - A(2,2)*A(3,1) ) * USDET
      B(3,2) =-( A(1,1)*A(3,2) - A(1,2)*A(3,1) ) * USDET
      B(3,3) = ( A(2,2)*A(1,1) - A(2,1)*A(1,2) ) * USDET
C
      END

