    INCLUDE 'mkl_dss.f90' ! Include the standard DSS "header file."
    PROGRAM solver_dense_test
    use mkl_dss
    IMPLICIT NONE
    INTEGER, PARAMETER :: dp = KIND(1.0D0)
    INTEGER :: error
    INTEGER :: i
    INTEGER, PARAMETER :: bufLen = 20
    ! Define the data arrays and the solution and rhs vectors.
    INTEGER, ALLOCATABLE :: columns( : )
    INTEGER :: nCols
    INTEGER :: nNonZeros
    INTEGER :: nRhs
    INTEGER :: nRows
    REAL(KIND=DP), ALLOCATABLE :: rhs( : )
    INTEGER, ALLOCATABLE :: rowIndex( : )
    REAL(KIND=DP), ALLOCATABLE :: solution( : )
    REAL(KIND=DP), ALLOCATABLE :: values( : )
    TYPE(MKL_DSS_HANDLE) :: handle ! Allocate storage for the solver handle.
    REAL(KIND=DP),ALLOCATABLE::statOUt( : )
    CHARACTER*15 statIn
    INTEGER perm(1)
    INTEGER buff(bufLen)

    ! Set the problem to be solved.
    nRows = 15
    nCols = 15
    nNonZeros = 225
    nRhs = 1
    perm(1) = 0
    ALLOCATE( rowIndex(nRows + 1 ) )
    rowIndex = (/ 1, 16, 31, 46, 61, 76, 91, 106, 121, 136, 151, 166, 181, 196, 211, 226 /)
    
    ALLOCATE( columns(nNonZeros ) )
    columns = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, &
    & 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, &
    & 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, &
    & 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, &
    & 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, &
    & 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, &
    & 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, &
    & 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, &
    & 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, &
    & 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, &
    & 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, &
    & 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, &
    & 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, &
    & 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, &
    & 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 /)
    
    ALLOCATE( values( nNonZeros ) )
    values = (/ 282443.02_DP, -77580.13_DP, 103440.17_DP, -89868.23_DP, 1650.64_DP, -2200.85_DP, 108680.30_DP, &
    & -1650.64_DP, 94636.75_DP, -116383.29_DP, 77580.13_DP, 41816.24_DP, 0.0_DP, 0.0_DP, 0.0_DP, &
    & -77580.13_DP, 260483.60_DP, -90510.15_DP, -1650.64_DP, 67856.41_DP, -82807.16_DP, 1650.64_DP, -46686.29_DP, &
    & 1925.75_DP, 77580.13_DP, -96781.93_DP, -36589.21_DP, 0.0_DP, 0.0_DP, 0.0_DP, &
    & 103440.17_DP, -90510.15_DP, 316276.79_DP, 2200.85_DP, -82807.16_DP, 117658.39_DP, 94636.75_DP, -1925.75_DP, & 
    & 138880.92_DP, -41816.24_DP, 36589.21_DP, 74235.18_DP, 0.0_DP, 0.0_DP, 0.0_DP, &
    & -89868.23_DP, -1650.64_DP, 2200.85_DP, 282443.02_DP, 77580.13_DP, -103440.17_DP, -116383.29_DP, -77580.13_DP, &
    & -41816.24_DP, 108680.30_DP, 1650.64_DP, -94636.75_DP, 0.0_DP, 0.0_DP, 0.0_DP, &
    & 1650.64_DP, 67856.41_DP, -82807.16_DP, 77580.13_DP, 260483.60_DP, -90510.15_DP, -77580.13_DP, -96781.93_DP, &
    & -36589.21_DP, -1650.64_DP, -46686.29_DP, 1925.75_DP, 0.0_DP, 0.0_DP, 0.0_DP, &
    & -2200.85_DP, -82807.16_DP, 117658.39_DP, -103440.17_DP, -90510.15_DP, 316276.79_DP, 41816.24_DP, 36589.21_DP, &
    & 74235.18_DP, -94636.75_DP, -1925.75_DP, 138880.92_DP, 0.0_DP, 0.0_DP, 0.0_DP, &
    & 108680.30_DP, 1650.64_DP, 94636.75_DP, -116383.29_DP, -77580.13_DP, 41816.24_DP, 295318.02_DP, 77580.13_DP, &
    & 116315.17_DP, -89868.23_DP, -1650.64_DP, -2200.85_DP, 0.625_DP, 0.0_DP, 0.625_DP, &
    & -1650.64_DP, -46686.29_DP, -1925.75_DP, -77580.13_DP, -96781.93_DP, 36589.21_DP, 77580.13_DP, 265633.60_DP, &
    & 90510.15_DP, 1650.65_DP, 67856.41_DP, 82807.16_DP, 0.0_DP, 0.250_DP, 0.0_DP, &
    & 94636.75_DP, 1925.75_DP, 138880.92_DP, -41816.24_DP, -36589.21_DP, 74235.18_DP, 111165.17_DP, 90510.15_DP, &
    & 324001.79_DP, 2200.85_DP, 82807.16_DP, 117658.39_DP, 0.375_DP, 0.0_DP, 0.375_DP, &
    & -116383.29_DP, 77580.13_DP, -41816.24_DP, 108680.30_DP, -1650.64_DP, -94636.75_DP, -89868.23_DP, 1650.64_DP, &
    & 2200.85_DP, 282443.02_DP, -77580.13_DP, -103440.17_DP, 0.0_DP, 0.0_DP, 0.0_DP, &
    & 77580.13_DP, -96781.93_DP, 36589.21_DP, 1650.64_DP, -46686.29_DP, -1925.75_DP, -1650.64_DP, 67856.41_DP, &
    & 82807.16_DP, -77580.13_DP, 260483.60_DP, 90510.15_DP, 0.0_DP, 0.0_DP, 0.0_DP, &
    & 41816.24_DP, -36589.21_DP, 74235.18_DP, -94636.75_DP, 1925.75_DP, 138880.92_DP, -2200.85_DP, 82807.16_DP, &
    & 117658.39_DP, -103440.17_DP, 90510.15_DP, 316276.79_DP, 0.0_DP, 0.0_DP, 0.0_DP, &
    & 0.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, 12875.0_DP, 0.0_DP, 12875.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, &
    & -0.3750_DP, 0.0_DP, 0.6250_DP, &
    & 0.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, 5150.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, &
    & 0.0_DP, -0.7500_DP, 0.0_DP, &
    & 0.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, 7725.0_DP, 0.0_DP, 7725.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, &
    & 0.3750_DP, 0.0_DP, -0.6250_DP/)

    ALLOCATE( rhs( nRows ) )
    rhs = (/ 0.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, 0.0_DP, -643.75_DP, 0.0_DP, -386.25_DP, &
    & 0.0_DP, 0.0_DP, 0.0_DP, -643.75_DP, 0.0_DP, -386.25_DP/)
    
    ! Initialize the solver.
    error = dss_create( handle, MKL_DSS_DEFAULTS )
    IF (error /= MKL_DSS_SUCCESS) GOTO 999
    ! Define the non-zero structure of the matrix.
    error = dss_define_structure( handle, MKL_DSS_SYMMETRIC_STRUCTURE, rowIndex, nRows, &
    & nCols, columns, nNonZeros )
    IF (error /= MKL_DSS_SUCCESS) GOTO 999
    ! Reorder the matrix.
    error = dss_reorder( handle, MKL_DSS_DEFAULTS, perm )
    IF (error /= MKL_DSS_SUCCESS) GOTO 999
    ! Factor the matrix.
    error = dss_factor_real( handle, MKL_DSS_INDEFINITE, values )
    IF (error /= MKL_DSS_SUCCESS) GOTO 999
    ! Allocate the solution vector and solve the problem.
    ALLOCATE( solution( nRows ) )
    error = dss_solve_real(handle, MKL_DSS_DEFAULTS, rhs, nRhs, solution )
    IF (error /= MKL_DSS_SUCCESS) GOTO 999
    
    
    ! Print Out the determinant of the matrix
    !ALLOCATE(statOut( 5 ) )    
    !statIn = 'determinant'
    !call mkl_cvt_to_null_terminated_str(buff,bufLen,statIn);
    !error = dss_statistics(handle, MKL_DSS_DEFAULTS, buff, statOut )
    !IF (error /= MKL_DSS_SUCCESS) GOTO 999
    !WRITE(*,"('pow of determinant is '(5F10.3))") ( statOut(1) )
    !WRITE(*,"('base of determinant is '(5F10.3))") ( statOut(2) )
    !WRITE(*,"('Determinant is '(5F10.3))") ( (10**statOut(1))*statOut(2) )
    ! Deallocate solver storage and various local arrays.
    error = dss_delete( handle, MKL_DSS_DEFAULTS )
    IF (error /= MKL_DSS_SUCCESS ) GOTO 999
    IF ( ALLOCATED( rowIndex) ) DEALLOCATE( rowIndex )
    IF ( ALLOCATED( columns ) ) DEALLOCATE( columns )
    IF ( ALLOCATED( values ) ) DEALLOCATE( values )
    IF ( ALLOCATED( rhs ) ) DEALLOCATE( rhs )
    IF ( ALLOCATED( statOut ) ) DEALLOCATE( statOut )
    ! Print the solution vector, deallocate it and exit
    WRITE(*,"('Solution Array: '(5F12.5))") ( solution(i), i = 1, nCols )
    IF ( ALLOCATED( solution ) ) DEALLOCATE( solution )
    GOTO 1000
    ! Print an error message and exit
999 WRITE(*,*) "Solver returned error code ", error
1000 CONTINUE
    PAUSE
END PROGRAM