!
!   ARMPL version 21.0 Copyright ARM, NAG 2021
!
!   Interface blocks for Fortran sparse routines in ARMPL
!
module armpl_sparse

    use armpl_kinds
    use armpl_sparse_params

!   Sparse matrix utility subroutines

    interface armpl_spmat_create_csr

        subroutine armpl_spmat_create_csr_s(A, m, n, row_ptr, col_indx, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer, intent(in) :: m, n
            integer, intent(in) :: row_ptr(m+1)
            integer, intent(in) :: col_indx(*)
            real(kind=armpl_r32), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_csr_s

        subroutine armpl_spmat_create_csr_d(A, m, n, row_ptr, col_indx, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer, intent(in) :: m, n
            integer, intent(in) :: row_ptr(m+1)
            integer, intent(in) :: col_indx(*)
            real(kind=armpl_r64), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_csr_d

        subroutine armpl_spmat_create_csr_c(A, m, n, row_ptr, col_indx, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer, intent(in) :: m, n
            integer, intent(in) :: row_ptr(m+1)
            integer, intent(in) :: col_indx(*)
            complex(kind=armpl_r32), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_csr_c

        subroutine armpl_spmat_create_csr_z(A, m, n, row_ptr, col_indx, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer, intent(in) :: m, n
            integer, intent(in) :: row_ptr(m+1)
            integer, intent(in) :: col_indx(*)
            complex(kind=armpl_r64), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_csr_z

    end interface armpl_spmat_create_csr

    interface armpl_spmat_create_csc

        subroutine armpl_spmat_create_csc_s(A, m, n, row_indx, col_ptr, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer, intent(in) :: m, n
            integer, intent(in) :: row_indx(*)
            integer, intent(in) :: col_ptr(n+1)
            real(kind=armpl_r32), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_csc_s

        subroutine armpl_spmat_create_csc_d(A, m, n, row_indx, col_ptr, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer, intent(in) :: m, n
            integer, intent(in) :: row_indx(*)
            integer, intent(in) :: col_ptr(n+1)
            real(kind=armpl_r64), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_csc_d

        subroutine armpl_spmat_create_csc_c(A, m, n, row_indx, col_ptr, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer, intent(in) :: m, n
            integer, intent(in) :: row_indx(*)
            integer, intent(in) :: col_ptr(n+1)
            complex(kind=armpl_r32), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_csc_c

        subroutine armpl_spmat_create_csc_z(A, m, n, row_indx, col_ptr, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer, intent(in) :: m, n
            integer, intent(in) :: row_indx(*)
            integer, intent(in) :: col_ptr(n+1)
            complex(kind=armpl_r64), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_csc_z

    end interface armpl_spmat_create_csc

    interface armpl_spmat_create_coo

        subroutine armpl_spmat_create_coo_s(A, m, n, nnz, row_indx, col_indx, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer, intent(in) :: m, n, nnz
            integer, intent(in) :: row_indx(*)
            integer, intent(in) :: col_indx(*)
            real(kind=armpl_r32), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_coo_s

        subroutine armpl_spmat_create_coo_d(A, m, n, nnz, row_indx, col_indx, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer, intent(in) :: m, n, nnz
            integer, intent(in) :: row_indx(*)
            integer, intent(in) :: col_indx(*)
            real(kind=armpl_r64), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_coo_d

        subroutine armpl_spmat_create_coo_c(A, m, n, nnz, row_indx, col_indx, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer, intent(in) :: m, n, nnz
            integer, intent(in) :: row_indx(*)
            integer, intent(in) :: col_indx(*)
            complex(kind=armpl_r32), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_coo_c

        subroutine armpl_spmat_create_coo_z(A, m, n, nnz, row_indx, col_indx, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer, intent(in) :: m, n, nnz
            integer, intent(in) :: row_indx(*)
            integer, intent(in) :: col_indx(*)
            complex(kind=armpl_r64), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_coo_z

    end interface armpl_spmat_create_coo

    interface
        subroutine armpl_spmat_destroy(A, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(inout) :: A
            integer, intent(out) :: info
        end subroutine armpl_spmat_destroy
    end interface

    interface
        subroutine armpl_spmat_hint(A, sparse_hint_type, sparse_hint_value, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i4), intent(in) :: sparse_hint_type, sparse_hint_value
            integer, intent(out) :: info
        end subroutine armpl_spmat_hint
    end interface

    interface
        subroutine armpl_spmv_optimize(A, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(out) :: info
        end subroutine armpl_spmv_optimize
    end interface

    interface armpl_spmat_update

        subroutine armpl_spmat_update_s(A, n_updates, row_indx, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(in) :: n_updates
            integer, intent(in) :: row_indx(n_updates)
            integer, intent(in) :: col_indx(n_updates)
            real(kind=armpl_r32), intent(in) :: vals(n_updates)
            integer, intent(out) :: info
        end subroutine armpl_spmat_update_s

        subroutine armpl_spmat_update_d(A, n_updates, row_indx, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(in) :: n_updates
            integer, intent(in) :: row_indx(n_updates)
            integer, intent(in) :: col_indx(n_updates)
            real(kind=armpl_r64), intent(in) :: vals(n_updates)
            integer, intent(out) :: info
        end subroutine armpl_spmat_update_d

        subroutine armpl_spmat_update_c(A, n_updates, row_indx, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(in) :: n_updates
            integer, intent(in) :: row_indx(n_updates)
            integer, intent(in) :: col_indx(n_updates)
            complex(kind=armpl_r32), intent(in) :: vals(n_updates)
            integer, intent(out) :: info
        end subroutine armpl_spmat_update_c

        subroutine armpl_spmat_update_z(A, n_updates, row_indx, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(in) :: n_updates
            integer, intent(in) :: row_indx(n_updates)
            integer, intent(in) :: col_indx(n_updates)
            complex(kind=armpl_r64), intent(in) :: vals(n_updates)
            integer, intent(out) :: info
        end subroutine armpl_spmat_update_z

    end interface armpl_spmat_update

    interface armpl_spmat_create_dense

        subroutine armpl_spmat_create_dense_s(A, layout, m, n, lda, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer(kind=armpl_i4), intent(in) :: layout
            integer, intent(in) :: m
            integer, intent(in) :: n
            integer, intent(in) :: lda
            real(kind=armpl_r32), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_dense_s

        subroutine armpl_spmat_create_dense_d(A, layout, m, n, lda, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer(kind=armpl_i4), intent(in) :: layout
            integer, intent(in) :: m
            integer, intent(in) :: n
            integer, intent(in) :: lda
            real(kind=armpl_r64), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_dense_d

        subroutine armpl_spmat_create_dense_c(A, layout, m, n, lda, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer(kind=armpl_i4), intent(in) :: layout
            integer, intent(in) :: m
            integer, intent(in) :: n
            integer, intent(in) :: lda
            complex(kind=armpl_r32), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_dense_c

        subroutine armpl_spmat_create_dense_z(A, layout, m, n, lda, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer(kind=armpl_i4), intent(in) :: layout
            integer, intent(in) :: m
            integer, intent(in) :: n
            integer, intent(in) :: lda
            complex(kind=armpl_r64), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_dense_z

    end interface armpl_spmat_create_dense

    interface armpl_spmat_create_bsr

        subroutine armpl_spmat_create_bsr_s(A, block_layout, m, n, block_size, row_ptr, col_indx, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer(kind=armpl_i4), intent(in) :: block_layout
            integer, intent(in) :: m
            integer, intent(in) :: n
            integer, intent(in) :: block_size
            integer, intent(in) :: row_ptr(*)
            integer, intent(in) :: col_indx(*)
            real(kind=armpl_r32), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_bsr_s

        subroutine armpl_spmat_create_bsr_d(A, block_layout, m, n, block_size, row_ptr, col_indx, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer(kind=armpl_i4), intent(in) :: block_layout
            integer, intent(in) :: m
            integer, intent(in) :: n
            integer, intent(in) :: block_size
            integer, intent(in) :: row_ptr(*)
            integer, intent(in) :: col_indx(*)
            real(kind=armpl_r64), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_bsr_d

        subroutine armpl_spmat_create_bsr_c(A, block_layout, m, n, block_size, row_ptr, col_indx, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer(kind=armpl_i4), intent(in) :: block_layout
            integer, intent(in) :: m
            integer, intent(in) :: n
            integer, intent(in) :: block_size
            integer, intent(in) :: row_ptr(*)
            integer, intent(in) :: col_indx(*)
            complex(kind=armpl_r32), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_bsr_c

        subroutine armpl_spmat_create_bsr_z(A, block_layout, m, n, block_size, row_ptr, col_indx, vals, flags, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(out) :: A
            integer(kind=armpl_i4), intent(in) :: block_layout
            integer, intent(in) :: m
            integer, intent(in) :: n
            integer, intent(in) :: block_size
            integer, intent(in) :: row_ptr(*)
            integer, intent(in) :: col_indx(*)
            complex(kind=armpl_r64), intent(in) :: vals(*)
            integer, intent(in) :: flags
            integer, intent(out) :: info
        end subroutine armpl_spmat_create_bsr_z

    end interface armpl_spmat_create_bsr

    interface
        function armpl_spmat_create_null(m, n)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8) :: armpl_spmat_create_null
            integer, intent(in) :: m
            integer, intent(in) :: n
        end function armpl_spmat_create_null
    end interface

    interface
        function armpl_spmat_create_identity(n)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8) :: armpl_spmat_create_identity
            integer, intent(in) :: n
        end function armpl_spmat_create_identity
    end interface

    interface
        subroutine armpl_spmat_query(A, m, n, nnz, base_index, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, intent(out) :: nnz
            integer, intent(out) :: base_index
            integer, intent(out) :: info
        end subroutine armpl_spmat_query
    end interface

    interface
        subroutine armpl_spmm_optimize(transA, transB, alpha, A, B, beta, C, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i4), intent(in) :: transA
            integer(kind=armpl_i4), intent(in) :: transB
            integer(kind=armpl_i4), intent(in) :: alpha
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i8), intent(in) :: B
            integer(kind=armpl_i4), intent(in) :: beta
            integer(kind=armpl_i8), intent(out) :: C
            integer, intent(out) :: info
        end subroutine armpl_spmm_optimize
    end interface

    interface
        subroutine armpl_spadd_optimize(transA, transB, alpha, A, beta, B, C, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i4), intent(in) :: transA
            integer(kind=armpl_i4), intent(in) :: transB
            integer(kind=armpl_i4), intent(in) :: alpha
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i4), intent(in) :: beta
            integer(kind=armpl_i8), intent(in) :: B
            integer(kind=armpl_i8), intent(out) :: C
            integer, intent(out) :: info
        end subroutine armpl_spadd_optimize
    end interface

!   Sparse matrix--vector execution subroutines

    interface armpl_spmv_exec

        subroutine armpl_spmv_exec_s(trans, alpha, A, x, beta, y, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i4), intent(in) :: trans
            real(kind=armpl_r32), intent(in) :: alpha
            integer(kind=armpl_i8), intent(in) :: A
            real(kind=armpl_r32), intent(in) :: x(*)
            real(kind=armpl_r32), intent(in) :: beta
            real(kind=armpl_r32), intent(inout) :: y(*)
            integer, intent(out) :: info
        end subroutine armpl_spmv_exec_s

        subroutine armpl_spmv_exec_d(trans, alpha, A, x, beta, y, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i4), intent(in) :: trans
            real(kind=armpl_r64), intent(in) :: alpha
            integer(kind=armpl_i8), intent(in) :: A
            real(kind=armpl_r64), intent(in) :: x(*)
            real(kind=armpl_r64), intent(in) :: beta
            real(kind=armpl_r64), intent(inout) :: y(*)
            integer, intent(out) :: info
        end subroutine armpl_spmv_exec_d

        subroutine armpl_spmv_exec_c(trans, alpha, A, x, beta, y, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i4), intent(in) :: trans
            complex(kind=armpl_r32), intent(in) :: alpha
            integer(kind=armpl_i8), intent(in) :: A
            complex(kind=armpl_r32), intent(in) :: x(*)
            complex(kind=armpl_r32), intent(in) :: beta
            complex(kind=armpl_r32), intent(inout) :: y(*)
            integer, intent(out) :: info
        end subroutine armpl_spmv_exec_c

        subroutine armpl_spmv_exec_z(trans, alpha, A, x, beta, y, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i4), intent(in) :: trans
            complex(kind=armpl_r64), intent(in) :: alpha
            integer(kind=armpl_i8), intent(in) :: A
            complex(kind=armpl_r64), intent(in) :: x(*)
            complex(kind=armpl_r64), intent(in) :: beta
            complex(kind=armpl_r64), intent(inout) :: y(*)
            integer, intent(out) :: info
        end subroutine armpl_spmv_exec_z

    end interface armpl_spmv_exec

!   Sparse matrix--matrix execution subroutines

    interface armpl_spmm_exec

        subroutine armpl_spmm_exec_s(transA, transB, alpha, A, B, beta, C, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i4), intent(in) :: transA
            integer(kind=armpl_i4), intent(in) :: transB
            real(kind=armpl_r32), intent(in) :: alpha
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i8), intent(in) :: B
            real(kind=armpl_r32), intent(in) :: beta
            integer(kind=armpl_i8), intent(out) :: C
            integer, intent(out) :: info
        end subroutine armpl_spmm_exec_s

        subroutine armpl_spmm_exec_d(transA, transB, alpha, A, B, beta, C, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i4), intent(in) :: transA
            integer(kind=armpl_i4), intent(in) :: transB
            real(kind=armpl_r64), intent(in) :: alpha
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i8), intent(in) :: B
            real(kind=armpl_r64), intent(in) :: beta
            integer(kind=armpl_i8), intent(out) :: C
            integer, intent(out) :: info
        end subroutine armpl_spmm_exec_d

        subroutine armpl_spmm_exec_c(transA, transB, alpha, A, B, beta, C, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i4), intent(in) :: transA
            integer(kind=armpl_i4), intent(in) :: transB
            complex(kind=armpl_r32), intent(in) :: alpha
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i8), intent(in) :: B
            complex(kind=armpl_r32), intent(in) :: beta
            integer(kind=armpl_i8), intent(out) :: C
            integer, intent(out) :: info
        end subroutine armpl_spmm_exec_c

        subroutine armpl_spmm_exec_z(transA, transB, alpha, A, B, beta, C, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i4), intent(in) :: transA
            integer(kind=armpl_i4), intent(in) :: transB
            complex(kind=armpl_r64), intent(in) :: alpha
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i8), intent(in) :: B
            complex(kind=armpl_r64), intent(in) :: beta
            integer(kind=armpl_i8), intent(out) :: C
            integer, intent(out) :: info
        end subroutine armpl_spmm_exec_z

    end interface armpl_spmm_exec

    interface armpl_spadd_exec

        subroutine armpl_spadd_exec_s(transA, transB, alpha, A, beta, B, C, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i4), intent(in) :: transA
            integer(kind=armpl_i4), intent(in) :: transB
            real(kind=armpl_r32), intent(in) :: alpha
            integer(kind=armpl_i8), intent(in) :: A
            real(kind=armpl_r32), intent(in) :: beta
            integer(kind=armpl_i8), intent(in) :: B
            integer(kind=armpl_i8), intent(out) :: C
            integer, intent(out) :: info
        end subroutine armpl_spadd_exec_s

        subroutine armpl_spadd_exec_d(transA, transB, alpha, A, beta, B, C, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i4), intent(in) :: transA
            integer(kind=armpl_i4), intent(in) :: transB
            real(kind=armpl_r64), intent(in) :: alpha
            integer(kind=armpl_i8), intent(in) :: A
            real(kind=armpl_r64), intent(in) :: beta
            integer(kind=armpl_i8), intent(in) :: B
            integer(kind=armpl_i8), intent(out) :: C
            integer, intent(out) :: info
        end subroutine armpl_spadd_exec_d

        subroutine armpl_spadd_exec_c(transA, transB, alpha, A, beta, B, C, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i4), intent(in) :: transA
            integer(kind=armpl_i4), intent(in) :: transB
            complex(kind=armpl_r32), intent(in) :: alpha
            integer(kind=armpl_i8), intent(in) :: A
            complex(kind=armpl_r32), intent(in) :: beta
            integer(kind=armpl_i8), intent(in) :: B
            integer(kind=armpl_i8), intent(out) :: C
            integer, intent(out) :: info
        end subroutine armpl_spadd_exec_c

        subroutine armpl_spadd_exec_z(transA, transB, alpha, A, beta, B, C, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i4), intent(in) :: transA
            integer(kind=armpl_i4), intent(in) :: transB
            complex(kind=armpl_r64), intent(in) :: alpha
            integer(kind=armpl_i8), intent(in) :: A
            complex(kind=armpl_r64), intent(in) :: beta
            integer(kind=armpl_i8), intent(in) :: B
            integer(kind=armpl_i8), intent(out) :: C
            integer, intent(out) :: info
        end subroutine armpl_spadd_exec_z

    end interface armpl_spadd_exec

!   Sparse matrix export subroutines

    interface armpl_spmat_export_csr

        subroutine armpl_spmat_export_csr_s(A, index_base, m, n, row_ptr, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(in) :: index_base
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, allocatable, intent(out) :: row_ptr(:)
            integer, allocatable, intent(out) :: col_indx(:)
            real(kind=armpl_r32), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_csr_s

        subroutine armpl_spmat_export_csr_d(A, index_base, m, n, row_ptr, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(in) :: index_base
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, allocatable, intent(out) :: row_ptr(:)
            integer, allocatable, intent(out) :: col_indx(:)
            real(kind=armpl_r64), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_csr_d

        subroutine armpl_spmat_export_csr_c(A, index_base, m, n, row_ptr, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(in) :: index_base
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, allocatable, intent(out) :: row_ptr(:)
            integer, allocatable, intent(out) :: col_indx(:)
            complex(kind=armpl_r32), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_csr_c

        subroutine armpl_spmat_export_csr_z(A, index_base, m, n, row_ptr, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(in) :: index_base
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, allocatable, intent(out) :: row_ptr(:)
            integer, allocatable, intent(out) :: col_indx(:)
            complex(kind=armpl_r64), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_csr_z

    end interface armpl_spmat_export_csr

    interface armpl_spmat_export_csc

        subroutine armpl_spmat_export_csc_s(A, index_base, m, n, row_indx, col_ptr, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(in) :: index_base
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, allocatable, intent(out) :: row_indx(:)
            integer, allocatable, intent(out) :: col_ptr(:)
            real(kind=armpl_r32), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_csc_s

        subroutine armpl_spmat_export_csc_d(A, index_base, m, n, row_indx, col_ptr, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(in) :: index_base
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, allocatable, intent(out) :: row_indx(:)
            integer, allocatable, intent(out) :: col_ptr(:)
            real(kind=armpl_r64), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_csc_d

        subroutine armpl_spmat_export_csc_c(A, index_base, m, n, row_indx, col_ptr, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(in) :: index_base
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, allocatable, intent(out) :: row_indx(:)
            integer, allocatable, intent(out) :: col_ptr(:)
            complex(kind=armpl_r32), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_csc_c

        subroutine armpl_spmat_export_csc_z(A, index_base, m, n, row_indx, col_ptr, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(in) :: index_base
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, allocatable, intent(out) :: row_indx(:)
            integer, allocatable, intent(out) :: col_ptr(:)
            complex(kind=armpl_r64), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_csc_z

    end interface armpl_spmat_export_csc

    interface armpl_spmat_export_coo

        subroutine armpl_spmat_export_coo_s(A, m, n, nnz, row_indx, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, intent(out) :: nnz
            integer, allocatable, intent(out) :: row_indx(:)
            integer, allocatable, intent(out) :: col_indx(:)
            real(kind=armpl_r32), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_coo_s

        subroutine armpl_spmat_export_coo_d(A, m, n, nnz, row_indx, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, intent(out) :: nnz
            integer, allocatable, intent(out) :: row_indx(:)
            integer, allocatable, intent(out) :: col_indx(:)
            real(kind=armpl_r64), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_coo_d

        subroutine armpl_spmat_export_coo_c(A, m, n, nnz, row_indx, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, intent(out) :: nnz
            integer, allocatable, intent(out) :: row_indx(:)
            integer, allocatable, intent(out) :: col_indx(:)
            complex(kind=armpl_r32), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_coo_c

        subroutine armpl_spmat_export_coo_z(A, m, n, nnz, row_indx, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, intent(out) :: nnz
            integer, allocatable, intent(out) :: row_indx(:)
            integer, allocatable, intent(out) :: col_indx(:)
            complex(kind=armpl_r64), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_coo_z

    end interface armpl_spmat_export_coo

    interface armpl_spmat_export_dense

        subroutine armpl_spmat_export_dense_s(A, layout, m, n, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i4), intent(in) :: layout
            integer, intent(out) :: m
            integer, intent(out) :: n
            real(kind=armpl_r32), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_dense_s

        subroutine armpl_spmat_export_dense_d(A, layout, m, n, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i4), intent(in) :: layout
            integer, intent(out) :: m
            integer, intent(out) :: n
            real(kind=armpl_r64), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_dense_d

        subroutine armpl_spmat_export_dense_c(A, layout, m, n, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i4), intent(in) :: layout
            integer, intent(out) :: m
            integer, intent(out) :: n
            complex(kind=armpl_r32), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_dense_c

        subroutine armpl_spmat_export_dense_z(A, layout, m, n, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i4), intent(in) :: layout
            integer, intent(out) :: m
            integer, intent(out) :: n
            complex(kind=armpl_r64), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_dense_z

    end interface armpl_spmat_export_dense

    interface armpl_spmat_export_bsr

        subroutine armpl_spmat_export_bsr_s(A, block_layout, index_base, m, n, block_size, row_ptr, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i4), intent(in) :: block_layout
            integer, intent(in) :: index_base
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, intent(out) :: block_size
            integer, allocatable, intent(out) :: row_ptr(:)
            integer, allocatable, intent(out) :: col_indx(:)
            real(kind=armpl_r32), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_bsr_s

        subroutine armpl_spmat_export_bsr_d(A, block_layout, index_base, m, n, block_size, row_ptr, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i4), intent(in) :: block_layout
            integer, intent(in) :: index_base
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, intent(out) :: block_size
            integer, allocatable, intent(out) :: row_ptr(:)
            integer, allocatable, intent(out) :: col_indx(:)
            real(kind=armpl_r64), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_bsr_d

        subroutine armpl_spmat_export_bsr_c(A, block_layout, index_base, m, n, block_size, row_ptr, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i4), intent(in) :: block_layout
            integer, intent(in) :: index_base
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, intent(out) :: block_size
            integer, allocatable, intent(out) :: row_ptr(:)
            integer, allocatable, intent(out) :: col_indx(:)
            complex(kind=armpl_r32), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_bsr_c

        subroutine armpl_spmat_export_bsr_z(A, block_layout, index_base, m, n, block_size, row_ptr, col_indx, vals, info)
            use armpl_kinds
            implicit none
            integer(kind=armpl_i8), intent(in) :: A
            integer(kind=armpl_i4), intent(in) :: block_layout
            integer, intent(in) :: index_base
            integer, intent(out) :: m
            integer, intent(out) :: n
            integer, intent(out) :: block_size
            integer, allocatable, intent(out) :: row_ptr(:)
            integer, allocatable, intent(out) :: col_indx(:)
            complex(kind=armpl_r64), allocatable, intent(out) :: vals(:)
            integer, intent(out) :: info
        end subroutine armpl_spmat_export_bsr_z

    end interface armpl_spmat_export_bsr

end module armpl_sparse
