SUBROUTINE SYSTEMQ ( MXN, MXW, NNODE, NBW, A, B )
      IMPLICIT REAL*8 ( A-H , O-Z )
      DIMENSION A(MXN,MXW) , B(MXN)
C---------- ELIMINATION ------------------
      DO N = 1 , NNODE 
      DO L = 2 , NBW 
      C = A(N,L) / A(N,1) 
      I = N + L - 1 
      IF ( I .LE. NNODE ) THEN
      J = 0 
      DO K = L , NBW 
      J = J + 1 
      A(I,J) = A(I,J) - C * A(N,K)
      END DO
      A(N,L) = C
      B(I) = B(I) - A(N,L) * B(N)
      ENDIF
      END DO
      B(N) = B(N) / A(N,1)
      END DO
C---------- BACKSUBSTITUTION -------------
      N = NNODE
      DO WHILE ( N .GT. 0 )
      DO K = 2 , NBW
      L = N + K - 1 
      IF ( L .LE. NNODE ) B(N) = B(N)-A(N,K)*B(L) 
      END DO
      N = N - 1 
      END DO
      RETURN
      END