* Last processed by NICE on 12-Jun-2000 15:53:00
* Customized for :  IEEE, LINUX, UNIX, MOTIF, F77
      SUBROUTINE GAUSS(MATJU,RESOL,LVAR)
C----------------------------------------------------------------------
C POINT
C	Gauss pivot inversion for a matrix
C----------------------------------------------------------------------
      INCLUDE 'size.inc'
      INTEGER LVAR
      REAL*8 MATJU(MVAR,MVAR+1),RESOL(MVAR)
*
      REAL*8 A(MVAR,MVAR+1),CK(MVAR)
      INTEGER LOC(MVAR),J,L,K,JI
      REAL*8  AMAX,F
*
      DO J=1,MVAR
         CK(J)=0.0D0
      ENDDO
      DO J=1,MVAR
         DO L=1,MVAR+1
            A(J,L)=MATJU(J,L)
         ENDDO
      ENDDO
*
      DO JI=1,LVAR
         AMAX=0.0D0
         DO K=1,LVAR
            IF (AMAX.LT.ABS(A(K,JI))) THEN
               IF (CK(K).LE.0.D0) THEN
                  LOC(JI) = K
                  AMAX = ABS(A(K,JI))
               ENDIF
            ENDIF
         ENDDO
*
         IF (AMAX.LE.1.0D-15) THEN
            WRITE(6,1000)
            DO J=1,LVAR
               WRITE(6,1001) (MATJU(J,K),K=1,LVAR+1)
            ENDDO
            STOP 'E-POINTING,  No solution'
         ENDIF
*
         L=LOC(JI)
         CK(L)=1.0D0
         DO J=1,LVAR
            IF (L.NE.J) THEN
               F=-A(J,JI)/A(L,JI)
               DO K=JI+1,LVAR+1
                  A(J,K)=A(J,K)+F*A(L,K)
               ENDDO
            ENDIF
         ENDDO
      ENDDO
*
      DO JI=1,LVAR
         L=LOC(JI)
         RESOL(JI)=A(L,LVAR+1)/A(L,JI)
      ENDDO
*
1000  FORMAT(/,'E-GAUSS,  Dependant equations',//)
1001  FORMAT(7(1X,1PG10.2))
      END
