anchor.diff:    CALL MATRIX_PRINT(E)
   !----------------------------------------------------------------------------------------------------------------------------------+
     WRITE(6,900)
  -  WRITE(6,980)'RUNNING GAUSS-JORDAN ELIMINATION ON [D]'
  -  WRITE(6,900)
  -  CALL MATRIX_GAUSS_JORDAN_ELIMINATION(D)
  +  WRITE(6,980)'RUNNING NEW GAUSS ELIMINATION ON [D]'
  +  WRITE(6,900)
  +  CALL MATRIX_IDENTITY(D2)
  +  CALL MATRIX_RANDOMIZE(D1,0)
  +  CALL GAUSS_ELIMINATION(D,.FALSE.)
  +  CALL BACK_SUBSTITUTION(D)
  +  CALL MATRIX_PRINT(D)
  +!----------------------------------------------------------------------------------------------------------------------------------+
  +  WRITE(6,900)
  +  WRITE(6,980)'RUNNING NEW GAUSS ELIMINATION WITH JORDAN=.TRUE. ON [D]'
  +  WRITE(6,900)
  +  CALL MATRIX_IDENTITY(D2)
  +  CALL MATRIX_RANDOMIZE(D1,0)
  +  CALL GAUSS_ELIMINATION(D,.TRUE.)
     CALL MATRIX_PRINT(D)
   !----------------------------------------------------------------------------------------------------------------------------------+
     WRITE(6,900)
  
positive.code:   ELSE
      MATRIX(ROW,COL) = 0D0
    END IF
  END SUBROUTINE MATRIX_GAUSS_ELIMINATE_ROW
  !----------------------------------------------------------------------------------------------------------------------------------+
  SUBROUTINE MATRIX_GAUSS_ELIMINATION_BACK_SUBSTITUTION(MATRIX)
  !----------------------------------------------------------------------------------------------------------------------------------+
  ! Performs Gauss Elimination and back substitution.
  !----------------------------------------------------------------------------------------------------------------------------------+
    IMPLICIT NONE
    REAL(KIND=8),INTENT(INOUT),DIMENSION(:,:) :: MATRIX     ! The matrix on which solution is performed
    INTEGER(KIND=4)                           :: ROWS,COLS  ! Row and column count of matrix for error checking
  !----------------------------------------------------------------------------------------------------------------------------------+
  ! Consider the matrix below representing the system of equations:
  !
  !                                                           [A]*[x] = B
  !
  !                                                 | A11 A12 A13 A14 A15 B16 B17 |
  !                                                 | A21 A22 A23 A24 A25 B26 B27 |
  !                                                 | A31 A32 A33 A34 A35 B36 B37 |
  !                                                 | A41 A42 A43 A44 A45 B46 B47 |
  !                                                 | A51 A52 A53 A54 A55 B56 B57 |
  !
  ! This procedure performs Gauss elimination with repeated calls to MATRIX_GAUSS_ELIMINATE_COLUMN leave an upper triangle matrix.
  ! Junk values are left in place below the diagonal to save operations.  This results in the following:
  !
  !                                                 | A11 A12 A13 A14 A15 B16 B17 |
  !                                                 | JNK A22 A23 A24 A25 B26 B27 |
  !                                                 | JNK JNK A33 A34 A35 B36 B37 |
  !                                                 | JNK JNK JNK A44 A45 B46 B47 |
  !                                                 | JNK JNK JNK JNK A55 B56 B57 |
  !
  ! The final step is to perform back substitution callin MBSUB resulting in the following:
  !
  !                                                 | A11 A12 A13 A14 A15 X16 X17 |
  !                                                 | JNK A22 A23 A24 A25 X26 X27 |
  !                                                 | JNK JNK A33 A34 A35 X36 X37 |
  !                                                 | JNK JNK JNK A44 A45 X46 X47 |
  !                                                 | JNK JNK JNK JNK A55 X56 X57 |
  !
  ! X values are where the solution matrix is stored.
  !
  !----------------------------------------------------------------------------------------------------------------------------------+
    ROWS = SIZE(MATRIX,1)
    COLS = SIZE(MATRIX,2)
    IF (ROWS.GT.COLS) THEN
      WRITE(0,910), ROWS, COLS
      STOP
    END IF
  !----------------------------------------------------------------------------------------------------------------------------------+
    CALL MATRIX_GAUSS_ELIMINATION(MATRIX)
    CALL MATRIX_BACK_SUBSTITUTION(MATRIX)
  910 FORMAT('*** FATAL ERRROR: MATRIX_GAUSS_ELIMINATION_BACK_SUBSTITUTION: MATRIX ROWS LARGER THAN COLUMNS',/,18X,I8, ' .GT. ',I8)
  END SUBROUTINE MATRIX_GAUSS_ELIMINATION_BACK_SUBSTITUTION
  !----------------------------------------------------------------------------------------------------------------------------------+
  SUBROUTINE MATRIX_GAUSS_ELIMINATION(MATRIX)
  !----------------------------------------------------------------------------------------------------------------------------------+
  ! Performs Gauss elimination on the matrix.
  !----------------------------------------------------------------------------------------------------------------------------------+
    IMPLICIT NONE
    REAL(KIND=8),INTENT(INOUT),DIMENSION(:,:) :: MATRIX        ! Matrix on which Gauss elimination is performed
    INTEGER(KIND=4)                           :: I,ROWS, COLS  ! Index and counter variables.
  !----------------------------------------------------------------------------------------------------------------------------------+
  ! Consider the matrix below representing the system of equations:
  !
  !                                                          [A]*[x] = B
  !                                          
  !                                                | A11 A12 A13 A14 A15 B16 B17 |
  !                                                | A21 A22 A23 A24 A25 B26 B27 |
  !                                                | A31 A32 A33 A34 A35 B36 B37 |
  !                                                | A41 A42 A43 A44 A45 B46 B47 |
  !                                                | A51 A52 A53 A54 A55 B56 B57 |
  !
  ! This procedure performs Gauss elimination with repeated calls to MATRIX_GAUSS_ELIMINATE_COLUMN leaveing an upper triangle matrix.
  ! Junk values are left in place below the diagonal to save operations.  This results in the following:
  !
  !                                               | A11 A12 A13 A14 A15 B16 B17 |
  !                                               | JNK A22 A23 A24 A25 B26 B27 |
  !                                               | JNK JNK A33 A34 A35 B36 B37 |
  !                                               | JNK JNK JNK A44 A45 B46 B47 |
  !                                               | JNK JNK JNK JNK A55 B56 B57 |
  !
  !----------------------------------------------------------------------------------------------------------------------------------+
    ROWS = SIZE(MATRIX,1)
    COLS = SIZE(MATRIX,2)
    IF (ROWS.GT.COLS) THEN
      WRITE(0,910), ROWS, COLS
      STOP
    END IF
  !----------------------------------------------------------------------------------------------------------------------------------+
    DO I = 1, ROWS
      CALL MATRIX_PARTIAL_PIVOT(MATRIX,I)
      CALL MATRIX_GAUSS_ELIMINATE_COLUMN(MATRIX,I)
    END DO
  910 FORMAT('*** FATAL ERRROR: MATRIX_GAUSS_ELIMINATION: MATRIX ROWS LARGER THAN COLUMNS',/,18X,I8, '   .GT.   ',I8)
  !----------------------------------------------------------------------------------------------------------------------------------+
  END SUBROUTINE MATRIX_GAUSS_ELIMINATION
  !----------------------------------------------------------------------------------------------------------------------------------+
  SUBROUTINE MATRIX_GAUSS_ELIMINATE_COLUMN(MATRIX,COL)
  !----------------------------------------------------------------------------------------------------------------------------------+
  ! Performs gauss elimination on a particular column.
  !----------------------------------------------------------------------------------------------------------------------------------+
    IMPLICIT NONE
    REAL(KIND=8),INTENT(INOUT),DIMENSION(:,:) :: MATRIX  ! Matrix on which the column is zeroed.
    INTEGER(KIND=4),INTENT(IN)                :: COL     ! Associated column to be zeroed for elimination.
    INTEGER(KIND=4)                           :: J
  !----------------------------------------------------------------------------------------------------------------------------------+
  ! Performs Gauss elimination on a particular column.  This procedure is called multiple times to columns for Gauss-Jordan
  ! elimination.  Consider the following matrix:
  !   
  !                                              | A11 A12 A13 A14 A15 A16 A17 |
  !                                              | JNK A22 A23 A24 A25 A26 A27 |
  !                                              | JNK A32 A33 A34 A35 A36 A37 |
  !                                              | JNK A42 A43 A44 A45 A46 A47 |
  !                                              | JNK A52 A53 A54 A55 A56 A57 |
  !
  !
  ! Column 2 is the next to be 'zeroed'.  This is done by repeated calls  to MATRIX_GAUSS_ELIMINATE_ROW with SCOL=COL+1.  The
  ! result is the following:
  !
  !                                              | A11 A12 A13 A14 A15 A16 A17 |
  !                                              | JNK A22 A23 A24 A25 A26 A27 |
  !                                              | JNK JNK A33 A34 A35 A36 A37 |
  !                                              | JNK JNK A43 A44 A45 A46 A47 |
  !                                              | JNK JNK A53 A54 A55 A56 A57 |
  !
  !   Note:  This procedure calls MATRIX_GAUSS_ELIMINATE_ROW for rows below the diagonal at the particular column in the matrix. 
  !
  !   Repeated calls, result in a matrix with junk (JNK) values below the diagonal and actuals values on and above the diagonal.  The
  !   junk values are left in place to save operations for large systems.
  !
  !----------------------------------------------------------------------------------------------------------------------------------+
    DO J = COL+1, SIZE(MATRIX,1)
      CALL MATRIX_GAUSS_ELIMINATE_ROW(MATRIX,J,COL,COL+1)
    END DO
  !----------------------------------------------------------------------------------------------------------------------------------+
  END SUBROUTINE MATRIX_GAUSS_ELIMINATE_COLUMN
  !----------------------------------------------------------------------------------------------------------------------------------+
  SUBROUTINE MATRIX_BACK_SUBSTITUTION(MATRIX)
  !----------------------------------------------------------------------------------------------------------------------------------+
  ! Performs on a matrix representing a system of equations.
  !----------------------------------------------------------------------------------------------------------------------------------+
  
negative.code: USE MODLINALG
    IMPLICIT NONE
    CALL TEST_MODLINALG
  !  REAL(KIND=8),DIMENSION(3,3) :: A, B
  !  REAL(KIND=8),DIMENSION(3,3) :: C
  !
  !  CALL MATRIX_RANDOMIZE(A)
  !  CALL MATRIX_RANDOMIZE(B)
  !
  !  CALL MATRIX_PRINT(A)
  !  WRITE(6,*)
  !  CALL MATRIX_PRINT(B)
  !  WRITE(6,*)
  !  C = A + B
  !  CALL MATRIX_PRINT(C)
  !  WRITE(6,*)
  !  C = A * B
  !  CALL MATRIX_PRINT(C)
  END PROGRAM LINAGLTEST
  