!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!  This file is AUTOMATICALLY GENERATED by:
!!  ../tools/fortran_wrappers.pl ../include/magma_z.i
!!  Do not edit.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

module magma_zfortran

use magma_param

implicit none

!---- Fortran interfaces to MAGMA subroutines ----
interface

integer function magmaf_get_zpotrf_nb( m )
    integer :: m
end function magmaf_get_zpotrf_nb

integer function magmaf_get_zgetrf_nb( m )
    integer :: m
end function magmaf_get_zgetrf_nb

integer function magmaf_get_zgetri_nb( m )
    integer :: m
end function magmaf_get_zgetri_nb

integer function magmaf_get_zgeqp3_nb( m )
    integer :: m
end function magmaf_get_zgeqp3_nb

integer function magmaf_get_zgeqrf_nb( m )
    integer :: m
end function magmaf_get_zgeqrf_nb

integer function magmaf_get_zgeqlf_nb( m )
    integer :: m
end function magmaf_get_zgeqlf_nb

integer function magmaf_get_zgehrd_nb( m )
    integer :: m
end function magmaf_get_zgehrd_nb

integer function magmaf_get_zhetrd_nb( m )
    integer :: m
end function magmaf_get_zhetrd_nb

integer function magmaf_get_zhetrf_nb( m )
    integer :: m
end function magmaf_get_zhetrf_nb

integer function magmaf_get_zhetrf_nopiv_nb( m )
    integer :: m
end function magmaf_get_zhetrf_nopiv_nb

integer function magmaf_get_zgelqf_nb( m )
    integer :: m
end function magmaf_get_zgelqf_nb

integer function magmaf_get_zgebrd_nb( m )
    integer :: m
end function magmaf_get_zgebrd_nb

integer function magmaf_get_zhegst_nb( m )
    integer :: m
end function magmaf_get_zhegst_nb

integer function magmaf_get_zgesvd_nb( m )
    integer :: m
end function magmaf_get_zgesvd_nb

integer function magmaf_get_zhegst_nb_m( m )
    integer :: m
end function magmaf_get_zhegst_nb_m

subroutine magmaf_get_zbulge_nb( m, nbthreads )
    integer          :: m
    integer          :: nbthreads
end subroutine magmaf_get_zbulge_nb

subroutine magmaf_zbulge_get_Vblksiz( m, nb, nbthreads )
    integer          :: m
    integer          :: nb
    integer          :: nbthreads
end subroutine magmaf_zbulge_get_Vblksiz

subroutine magmaf_get_zbulge_gcperf(  )
end subroutine magmaf_get_zbulge_gcperf

subroutine magmaf_zgebrd( m, n, A, lda, d, e, tauq, taup, work, lwork, info )
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    double precision :: d(*)
    double precision :: e(*)
    complex*16       :: tauq(*)
    complex*16       :: taup(*)
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zgebrd

subroutine magmaf_zgeev( jobvl, jobvr, n, A, lda, w, VL, ldvl, VR, ldvr, work, lwork,  &
        rwork, info )
    character        :: jobvl
    character        :: jobvr
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: w(*)
    complex*16       :: VL(*)
    integer          :: ldvl
    complex*16       :: VR(*)
    integer          :: ldvr
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: info
end subroutine magmaf_zgeev

subroutine magmaf_zgehrd( n, ilo, ihi, A, lda, tau, work, lwork, dT, info )
    integer          :: n
    integer          :: ilo
    integer          :: ihi
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: work(*)
    integer          :: lwork
    magma_devptr_t   :: dT
    integer          :: info
end subroutine magmaf_zgehrd

subroutine magmaf_zgehrd2( n, ilo, ihi, A, lda, tau, work, lwork, info )
    integer          :: n
    integer          :: ilo
    integer          :: ihi
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zgehrd2

subroutine magmaf_zgelqf( m, n, A, lda, tau, work, lwork, info )
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zgelqf

subroutine magmaf_zgeqlf( m, n, A, lda, tau, work, lwork, info )
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zgeqlf

subroutine magmaf_zgeqp3( m, n, A, lda, jpvt, tau, work, lwork, rwork, info )
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    integer          :: jpvt(*)
    complex*16       :: tau(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: info
end subroutine magmaf_zgeqp3

subroutine magmaf_zgeqrf( m, n, A, lda, tau, work, lwork, info )
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zgeqrf

subroutine magmaf_zgeqrf_ooc( m, n, A, lda, tau, work, lwork, info )
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zgeqrf_ooc

subroutine magmaf_zgeqrf4( ngpu, m, n, A, lda, tau, work, lwork, info )
    integer          :: ngpu
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zgeqrf4

subroutine magmaf_zgesdd( jobz, m, n, A, lda, s, U, ldu, VT, ldvt, work, lwork, rwork,  &
        iwork, info )
    character        :: jobz
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    double precision :: s(*)
    complex*16       :: U(*)
    integer          :: ldu
    complex*16       :: VT(*)
    integer          :: ldvt
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: iwork(*)
    integer          :: info
end subroutine magmaf_zgesdd

subroutine magmaf_zgesv( n, nrhs, A, lda, ipiv, B, ldb, info )
    integer          :: n
    integer          :: nrhs
    complex*16       :: A(*)
    integer          :: lda
    integer          :: ipiv(*)
    complex*16       :: B(*)
    integer          :: ldb
    integer          :: info
end subroutine magmaf_zgesv

subroutine magmaf_zgesv_rbt( ref, n, nrhs, A, lda, B, ldb, info )
    character        :: ref
    integer          :: n
    integer          :: nrhs
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: B(*)
    integer          :: ldb
    integer          :: info
end subroutine magmaf_zgesv_rbt

subroutine magmaf_zgesvd( jobu, jobvt, m, n, A, lda, s, U, ldu, VT, ldvt, work, lwork,  &
        rwork, info )
    character        :: jobu
    character        :: jobvt
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    double precision :: s(*)
    complex*16       :: U(*)
    integer          :: ldu
    complex*16       :: VT(*)
    integer          :: ldvt
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: info
end subroutine magmaf_zgesvd

subroutine magmaf_zgetf2_nopiv( m, n, A, lda, info )
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    integer          :: info
end subroutine magmaf_zgetf2_nopiv

subroutine magmaf_zgetrf( m, n, A, lda, ipiv, info )
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    integer          :: ipiv(*)
    integer          :: info
end subroutine magmaf_zgetrf

subroutine magmaf_zgetrf_nopiv( m, n, A, lda, info )
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    integer          :: info
end subroutine magmaf_zgetrf_nopiv

subroutine magmaf_zgetrf_piv( m, n, NB, A, lda, ipiv, info )
    integer          :: m
    integer          :: n
    integer          :: NB
    complex*16       :: A(*)
    integer          :: lda
    integer          :: ipiv(*)
    integer          :: info
end subroutine magmaf_zgetrf_piv

subroutine magmaf_zheevd( jobz, uplo, n, A, lda, w, work, lwork, rwork, lrwork, iwork,  &
        liwork, info )
    character        :: jobz
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    double precision :: w(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zheevd

subroutine magmaf_zheevdx( jobz, range, uplo, n, A, lda, vl, vu, il, iu, m, w, work,  &
        lwork, rwork, lrwork, iwork, liwork, info )
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    integer          :: m
    double precision :: w(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zheevdx

subroutine magmaf_zheevdx_2stage( jobz, range, uplo, n, A, lda, vl, vu, il, iu, m, w,  &
        work, lwork, rwork, lrwork, iwork, liwork, info )
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    integer          :: m
    double precision :: w(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zheevdx_2stage

subroutine magmaf_zheevr( jobz, range, uplo, n, A, lda, vl, vu, il, iu, abstol, m, w, Z,  &
        ldz, isuppz, work, lwork, rwork, lrwork, iwork, liwork, info )
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    double precision :: abstol
    integer          :: m
    double precision :: w(*)
    complex*16       :: Z(*)
    integer          :: ldz
    integer          :: isuppz(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zheevr

subroutine magmaf_zheevx( jobz, range, uplo, n, A, lda, vl, vu, il, iu, abstol, m, w, Z,  &
        ldz, work, lwork, rwork, iwork, ifail, info )
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    double precision :: abstol
    integer          :: m
    double precision :: w(*)
    complex*16       :: Z(*)
    integer          :: ldz
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: iwork(*)
    integer          :: ifail(*)
    integer          :: info
end subroutine magmaf_zheevx

subroutine magmaf_zhegst( itype, uplo, n, A, lda, B, ldb, info )
    integer          :: itype
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: B(*)
    integer          :: ldb
    integer          :: info
end subroutine magmaf_zhegst

subroutine magmaf_zhegvd( itype, jobz, uplo, n, A, lda, B, ldb, w, work, lwork, rwork,  &
        lrwork, iwork, liwork, info )
    integer          :: itype
    character        :: jobz
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: B(*)
    integer          :: ldb
    double precision :: w(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zhegvd

subroutine magmaf_zhegvdx( itype, jobz, range, uplo, n, A, lda, B, ldb, vl, vu, il, iu,  &
        m, w, work, lwork, rwork, lrwork, iwork, liwork, info )
    integer          :: itype
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: B(*)
    integer          :: ldb
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    integer          :: m
    double precision :: w(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zhegvdx

subroutine magmaf_zhegvdx_2stage( itype, jobz, range, uplo, n, A, lda, B, ldb, vl, vu,  &
        il, iu, m, w, work, lwork, rwork, lrwork, iwork, liwork, info )
    integer          :: itype
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: B(*)
    integer          :: ldb
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    integer          :: m
    double precision :: w(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zhegvdx_2stage

subroutine magmaf_zhegvr( itype, jobz, range, uplo, n, A, lda, B, ldb, vl, vu, il, iu,  &
        abstol, m, w, Z, ldz, isuppz, work, lwork, rwork, lrwork, iwork, liwork, info )
    integer          :: itype
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: B(*)
    integer          :: ldb
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    double precision :: abstol
    integer          :: m
    double precision :: w(*)
    complex*16       :: Z(*)
    integer          :: ldz
    integer          :: isuppz(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zhegvr

subroutine magmaf_zhegvx( itype, jobz, range, uplo, n, A, lda, B, ldb, vl, vu, il, iu,  &
        abstol, m, w, Z, ldz, work, lwork, rwork, iwork, ifail, info )
    integer          :: itype
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: B(*)
    integer          :: ldb
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    double precision :: abstol
    integer          :: m
    double precision :: w(*)
    complex*16       :: Z(*)
    integer          :: ldz
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: iwork(*)
    integer          :: ifail(*)
    integer          :: info
end subroutine magmaf_zhegvx

subroutine magmaf_zhesv( uplo, n, nrhs, A, lda, ipiv, B, ldb, info )
    character        :: uplo
    integer          :: n
    integer          :: nrhs
    complex*16       :: A(*)
    integer          :: lda
    integer          :: ipiv(*)
    complex*16       :: B(*)
    integer          :: ldb
    integer          :: info
end subroutine magmaf_zhesv

subroutine magmaf_zhetrd( uplo, n, A, lda, d, e, tau, work, lwork, info )
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    double precision :: d(*)
    double precision :: e(*)
    complex*16       :: tau(*)
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zhetrd

subroutine magmaf_zhetrf( uplo, n, A, lda, ipiv, info )
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    integer          :: ipiv(*)
    integer          :: info
end subroutine magmaf_zhetrf

subroutine magmaf_zhetrf_nopiv( uplo, n, a, lda, info )
    character        :: uplo
    integer          :: n
    complex*16       :: a(*)
    integer          :: lda
    integer          :: info
end subroutine magmaf_zhetrf_nopiv

subroutine magmaf_zhetrd_hb2st( uplo, n, nb, Vblksiz, A, lda, d, e, V, ldv, TAU, compT,  &
        T, ldt )
    character        :: uplo
    integer          :: n
    integer          :: nb
    integer          :: Vblksiz
    complex*16       :: A(*)
    integer          :: lda
    double precision :: d(*)
    double precision :: e(*)
    complex*16       :: V(*)
    integer          :: ldv
    complex*16       :: TAU(*)
    integer          :: compT
    complex*16       :: T(*)
    integer          :: ldt
end subroutine magmaf_zhetrd_hb2st

subroutine magmaf_zhetrd_he2hb( uplo, n, nb, A, lda, tau, work, lwork, dT, info )
    character        :: uplo
    integer          :: n
    integer          :: nb
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: work(*)
    integer          :: lwork
    magma_devptr_t   :: dT
    integer          :: info
end subroutine magmaf_zhetrd_he2hb

subroutine magmaf_zlatrsd( uplo, trans, diag, normin, n, A, lda, lambda, x, scale, cnorm,  &
        info )
    character        :: uplo
    character        :: trans
    character        :: diag
    character        :: normin
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: lambda
    complex*16       :: x(*)
    double precision :: scale(*)
    double precision :: cnorm(*)
    integer          :: info
end subroutine magmaf_zlatrsd

subroutine magmaf_zlauum( uplo, n, A, lda, info )
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    integer          :: info
end subroutine magmaf_zlauum

subroutine magmaf_zposv( uplo, n, nrhs, A, lda, B, ldb, info )
    character        :: uplo
    integer          :: n
    integer          :: nrhs
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: B(*)
    integer          :: ldb
    integer          :: info
end subroutine magmaf_zposv

subroutine magmaf_zpotrf( uplo, n, A, lda, info )
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    integer          :: info
end subroutine magmaf_zpotrf

subroutine magmaf_zpotri( uplo, n, A, lda, info )
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    integer          :: info
end subroutine magmaf_zpotri

subroutine magmaf_zstedx( range, n, vl, vu, il, iu, d, e, Z, ldz, rwork, lrwork, iwork,  &
        liwork, dwork, info )
    character        :: range
    integer          :: n
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    double precision :: d(*)
    double precision :: e(*)
    complex*16       :: Z(*)
    integer          :: ldz
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    magma_devptr_t   :: dwork
    integer          :: info
end subroutine magmaf_zstedx

subroutine magmaf_ztrevc3( side, howmany, select, n, T, ldt, VL, ldvl, VR, ldvr, mm,  &
        mout, work, lwork, rwork, info )
    character        :: side
    character        :: howmany
    integer          :: select(*)
    integer          :: n
    complex*16       :: T(*)
    integer          :: ldt
    complex*16       :: VL(*)
    integer          :: ldvl
    complex*16       :: VR(*)
    integer          :: ldvr
    integer          :: mm
    integer          :: mout(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: info
end subroutine magmaf_ztrevc3

subroutine magmaf_ztrevc3_mt( side, howmany, select, n, T, ldt, VL, ldvl, VR, ldvr, mm,  &
        mout, work, lwork, rwork, info )
    character        :: side
    character        :: howmany
    integer          :: select(*)
    integer          :: n
    complex*16       :: T(*)
    integer          :: ldt
    complex*16       :: VL(*)
    integer          :: ldvl
    complex*16       :: VR(*)
    integer          :: ldvr
    integer          :: mm
    integer          :: mout(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: info
end subroutine magmaf_ztrevc3_mt

subroutine magmaf_ztrtri( uplo, diag, n, A, lda, info )
    character        :: uplo
    character        :: diag
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    integer          :: info
end subroutine magmaf_ztrtri

subroutine magmaf_zunghr( n, ilo, ihi, A, lda, tau, dT, nb, info )
    integer          :: n
    integer          :: ilo
    integer          :: ihi
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    magma_devptr_t   :: dT
    integer          :: nb
    integer          :: info
end subroutine magmaf_zunghr

subroutine magmaf_zungqr( m, n, k, A, lda, tau, dT, nb, info )
    integer          :: m
    integer          :: n
    integer          :: k
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    magma_devptr_t   :: dT
    integer          :: nb
    integer          :: info
end subroutine magmaf_zungqr

subroutine magmaf_zungqr2( m, n, k, A, lda, tau, info )
    integer          :: m
    integer          :: n
    integer          :: k
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    integer          :: info
end subroutine magmaf_zungqr2

subroutine magmaf_zunmbr( vect, side, trans, m, n, k, A, lda, tau, C, ldc, work, lwork,  &
        info )
    character        :: vect
    character        :: side
    character        :: trans
    integer          :: m
    integer          :: n
    integer          :: k
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: C(*)
    integer          :: ldc
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zunmbr

subroutine magmaf_zunmlq( side, trans, m, n, k, A, lda, tau, C, ldc, work, lwork, info )
    character        :: side
    character        :: trans
    integer          :: m
    integer          :: n
    integer          :: k
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: C(*)
    integer          :: ldc
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zunmlq

subroutine magmaf_zunmql( side, trans, m, n, k, A, lda, tau, C, ldc, work, lwork, info )
    character        :: side
    character        :: trans
    integer          :: m
    integer          :: n
    integer          :: k
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: C(*)
    integer          :: ldc
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zunmql

subroutine magmaf_zunmqr( side, trans, m, n, k, A, lda, tau, C, ldc, work, lwork, info )
    character        :: side
    character        :: trans
    integer          :: m
    integer          :: n
    integer          :: k
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: C(*)
    integer          :: ldc
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zunmqr

subroutine magmaf_zunmtr( side, uplo, trans, m, n, A, lda, tau, C, ldc, work, lwork, info  &
        )
    character        :: side
    character        :: uplo
    character        :: trans
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: C(*)
    integer          :: ldc
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zunmtr

subroutine magmaf_zgeev_m( jobvl, jobvr, n, A, lda, w, VL, ldvl, VR, ldvr, work, lwork,  &
        rwork, info )
    character        :: jobvl
    character        :: jobvr
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: w(*)
    complex*16       :: VL(*)
    integer          :: ldvl
    complex*16       :: VR(*)
    integer          :: ldvr
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: info
end subroutine magmaf_zgeev_m

subroutine magmaf_zgehrd_m( n, ilo, ihi, A, lda, tau, work, lwork, T, info )
    integer          :: n
    integer          :: ilo
    integer          :: ihi
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: work(*)
    integer          :: lwork
    complex*16       :: T(*)
    integer          :: info
end subroutine magmaf_zgehrd_m

subroutine magmaf_zgetrf_m( ngpu, m, n, A, lda, ipiv, info )
    integer          :: ngpu
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    integer          :: ipiv(*)
    integer          :: info
end subroutine magmaf_zgetrf_m

subroutine magmaf_zheevd_m( ngpu, jobz, uplo, n, A, lda, w, work, lwork, rwork, lrwork,  &
        iwork, liwork, info )
    integer          :: ngpu
    character        :: jobz
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    double precision :: w(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zheevd_m

subroutine magmaf_zheevdx_2stage_m( ngpu, jobz, range, uplo, n, A, lda, vl, vu, il, iu,  &
        m, w, work, lwork, rwork, lrwork, iwork, liwork, info )
    integer          :: ngpu
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    integer          :: m
    double precision :: w(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zheevdx_2stage_m

subroutine magmaf_zheevdx_m( ngpu, jobz, range, uplo, n, A, lda, vl, vu, il, iu, m, w,  &
        work, lwork, rwork, lrwork, iwork, liwork, info )
    integer          :: ngpu
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    integer          :: m
    double precision :: w(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zheevdx_m

subroutine magmaf_zhegst_m( ngpu, itype, uplo, n, A, lda, B, ldb, info )
    integer          :: ngpu
    integer          :: itype
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: B(*)
    integer          :: ldb
    integer          :: info
end subroutine magmaf_zhegst_m

subroutine magmaf_zhegvd_m( ngpu, itype, jobz, uplo, n, A, lda, B, ldb, w, work, lwork,  &
        rwork, lrwork, iwork, liwork, info )
    integer          :: ngpu
    integer          :: itype
    character        :: jobz
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: B(*)
    integer          :: ldb
    double precision :: w(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zhegvd_m

subroutine magmaf_zhegvdx_2stage_m( ngpu, itype, jobz, range, uplo, n, A, lda, B, ldb,  &
        vl, vu, il, iu, m, w, work, lwork, rwork, lrwork, iwork, liwork, info )
    integer          :: ngpu
    integer          :: itype
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: B(*)
    integer          :: ldb
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    integer          :: m
    double precision :: w(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zhegvdx_2stage_m

subroutine magmaf_zhegvdx_m( ngpu, itype, jobz, range, uplo, n, A, lda, B, ldb, vl, vu,  &
        il, iu, m, w, work, lwork, rwork, lrwork, iwork, liwork, info )
    integer          :: ngpu
    integer          :: itype
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: B(*)
    integer          :: ldb
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    integer          :: m
    double precision :: w(*)
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zhegvdx_m

subroutine magmaf_zpotrf_m( ngpu, uplo, n, A, lda, info )
    integer          :: ngpu
    character        :: uplo
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    integer          :: info
end subroutine magmaf_zpotrf_m

subroutine magmaf_zstedx_m( ngpu, range, n, vl, vu, il, iu, d, e, Z, ldz, rwork, lrwork,  &
        iwork, liwork, info )
    integer          :: ngpu
    character        :: range
    integer          :: n
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    double precision :: d(*)
    double precision :: e(*)
    complex*16       :: Z(*)
    integer          :: ldz
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zstedx_m

subroutine magmaf_ztrsm_m( ngpu, side, uplo, transa, diag, m, n, alpha, A, lda, B, ldb )
    integer          :: ngpu
    character        :: side
    character        :: uplo
    character        :: transa
    character        :: diag
    integer          :: m
    integer          :: n
    complex*16       :: alpha
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: B(*)
    integer          :: ldb
end subroutine magmaf_ztrsm_m

subroutine magmaf_zunghr_m( n, ilo, ihi, A, lda, tau, T, nb, info )
    integer          :: n
    integer          :: ilo
    integer          :: ihi
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: T(*)
    integer          :: nb
    integer          :: info
end subroutine magmaf_zunghr_m

subroutine magmaf_zungqr_m( m, n, k, A, lda, tau, T, nb, info )
    integer          :: m
    integer          :: n
    integer          :: k
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: T(*)
    integer          :: nb
    integer          :: info
end subroutine magmaf_zungqr_m

subroutine magmaf_zunmqr_m( ngpu, side, trans, m, n, k, A, lda, tau, C, ldc, work, lwork,  &
        info )
    integer          :: ngpu
    character        :: side
    character        :: trans
    integer          :: m
    integer          :: n
    integer          :: k
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: C(*)
    integer          :: ldc
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zunmqr_m

subroutine magmaf_zunmtr_m( ngpu, side, uplo, trans, m, n, A, lda, tau, C, ldc, work,  &
        lwork, info )
    integer          :: ngpu
    character        :: side
    character        :: uplo
    character        :: trans
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    complex*16       :: tau(*)
    complex*16       :: C(*)
    integer          :: ldc
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zunmtr_m

subroutine magmaf_zgegqr_gpu( ikind, m, n, dA, ldda, dwork, work, info )
    integer          :: ikind
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    magma_devptr_t   :: dwork
    complex*16       :: work(*)
    integer          :: info
end subroutine magmaf_zgegqr_gpu

subroutine magmaf_zgelqf_gpu( m, n, dA, ldda, tau, work, lwork, info )
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    complex*16       :: tau(*)
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zgelqf_gpu

subroutine magmaf_zgels_gpu( trans, m, n, nrhs, dA, ldda, dB, lddb, hwork, lwork, info )
    character        :: trans
    integer          :: m
    integer          :: n
    integer          :: nrhs
    magma_devptr_t   :: dA
    integer          :: ldda
    magma_devptr_t   :: dB
    integer          :: lddb
    complex*16       :: hwork(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zgels_gpu

subroutine magmaf_zgels3_gpu( trans, m, n, nrhs, dA, ldda, dB, lddb, hwork, lwork, info )
    character        :: trans
    integer          :: m
    integer          :: n
    integer          :: nrhs
    magma_devptr_t   :: dA
    integer          :: ldda
    magma_devptr_t   :: dB
    integer          :: lddb
    complex*16       :: hwork(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zgels3_gpu

subroutine magmaf_zgeqp3_gpu( m, n, dA, ldda, jpvt, tau, dwork, lwork, rwork, info )
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    integer          :: jpvt(*)
    complex*16       :: tau(*)
    magma_devptr_t   :: dwork
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: info
end subroutine magmaf_zgeqp3_gpu

subroutine magmaf_zgeqr2x_gpu( m, n, dA, ldda, dtau, dT, ddA, dwork, info )
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    magma_devptr_t   :: dtau
    magma_devptr_t   :: dT
    magma_devptr_t   :: ddA
    magma_devptr_t   :: dwork
    integer          :: info
end subroutine magmaf_zgeqr2x_gpu

subroutine magmaf_zgeqr2x2_gpu( m, n, dA, ldda, dtau, dT, ddA, dwork, info )
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    magma_devptr_t   :: dtau
    magma_devptr_t   :: dT
    magma_devptr_t   :: ddA
    magma_devptr_t   :: dwork
    integer          :: info
end subroutine magmaf_zgeqr2x2_gpu

subroutine magmaf_zgeqr2x3_gpu( m, n, dA, ldda, dtau, dT, ddA, dwork, info )
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    magma_devptr_t   :: dtau
    magma_devptr_t   :: dT
    magma_devptr_t   :: ddA
    magma_devptr_t   :: dwork
    integer          :: info
end subroutine magmaf_zgeqr2x3_gpu

subroutine magmaf_zgeqr2x4_gpu( m, n, dA, ldda, dtau, dT, ddA, dwork, queue, info )
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    magma_devptr_t   :: dtau
    magma_devptr_t   :: dT
    magma_devptr_t   :: ddA
    magma_devptr_t   :: dwork
    integer          :: queue
    integer          :: info
end subroutine magmaf_zgeqr2x4_gpu

subroutine magmaf_zgeqrf_gpu( m, n, dA, ldda, tau, dT, info )
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    complex*16       :: tau(*)
    magma_devptr_t   :: dT
    integer          :: info
end subroutine magmaf_zgeqrf_gpu

subroutine magmaf_zgeqrf2_gpu( m, n, dA, ldda, tau, info )
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    complex*16       :: tau(*)
    integer          :: info
end subroutine magmaf_zgeqrf2_gpu

subroutine magmaf_zgeqrf3_gpu( m, n, dA, ldda, tau, dT, info )
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    complex*16       :: tau(*)
    magma_devptr_t   :: dT
    integer          :: info
end subroutine magmaf_zgeqrf3_gpu

subroutine magmaf_zgeqrs_gpu( m, n, nrhs, dA, ldda, tau, dT, dB, lddb, hwork, lwork, info  &
        )
    integer          :: m
    integer          :: n
    integer          :: nrhs
    magma_devptr_t   :: dA
    integer          :: ldda
    complex*16       :: tau(*)
    magma_devptr_t   :: dT
    magma_devptr_t   :: dB
    integer          :: lddb
    complex*16       :: hwork(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zgeqrs_gpu

subroutine magmaf_zgeqrs3_gpu( m, n, nrhs, dA, ldda, tau, dT, dB, lddb, hwork, lwork,  &
        info )
    integer          :: m
    integer          :: n
    integer          :: nrhs
    magma_devptr_t   :: dA
    integer          :: ldda
    complex*16       :: tau(*)
    magma_devptr_t   :: dT
    magma_devptr_t   :: dB
    integer          :: lddb
    complex*16       :: hwork(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zgeqrs3_gpu

subroutine magmaf_zgerbt_gpu( gen, n, nrhs, dA, ldda, dB, lddb, U, V, info )
    character        :: gen
    integer          :: n
    integer          :: nrhs
    magma_devptr_t   :: dA
    integer          :: ldda
    magma_devptr_t   :: dB
    integer          :: lddb
    complex*16       :: U(*)
    complex*16       :: V(*)
    integer          :: info
end subroutine magmaf_zgerbt_gpu

subroutine magmaf_zgessm_gpu( order, m, n, k, ib, ipiv, dL1, lddl1, dL, lddl, dA, ldda,  &
        info )
    character        :: order
    integer          :: m
    integer          :: n
    integer          :: k
    integer          :: ib
    integer          :: ipiv(*)
    magma_devptr_t   :: dL1
    integer          :: lddl1
    magma_devptr_t   :: dL
    integer          :: lddl
    magma_devptr_t   :: dA
    integer          :: ldda
    integer          :: info
end subroutine magmaf_zgessm_gpu

subroutine magmaf_zgesv_gpu( n, nrhs, dA, ldda, ipiv, dB, lddb, info )
    integer          :: n
    integer          :: nrhs
    magma_devptr_t   :: dA
    integer          :: ldda
    integer          :: ipiv(*)
    magma_devptr_t   :: dB
    integer          :: lddb
    integer          :: info
end subroutine magmaf_zgesv_gpu

subroutine magmaf_zgesv_nopiv_gpu( n, nrhs, dA, ldda, dB, lddb, info )
    integer          :: n
    integer          :: nrhs
    magma_devptr_t   :: dA
    integer          :: ldda
    magma_devptr_t   :: dB
    integer          :: lddb
    integer          :: info
end subroutine magmaf_zgesv_nopiv_gpu

subroutine magmaf_zgetf2_gpu( m, n, dA, ldda, ipiv, info )
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    integer          :: ipiv(*)
    integer          :: info
end subroutine magmaf_zgetf2_gpu

subroutine magmaf_zgetrf_gpu( m, n, dA, ldda, ipiv, info )
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    integer          :: ipiv(*)
    integer          :: info
end subroutine magmaf_zgetrf_gpu

subroutine magmaf_zgetrf_nopiv_gpu( m, n, dA, ldda, info )
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    integer          :: info
end subroutine magmaf_zgetrf_nopiv_gpu

subroutine magmaf_zgetri_gpu( n, dA, ldda, ipiv, dwork, lwork, info )
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    integer          :: ipiv(*)
    magma_devptr_t   :: dwork
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zgetri_gpu

subroutine magmaf_zgetrs_gpu( trans, n, nrhs, dA, ldda, ipiv, dB, lddb, info )
    character        :: trans
    integer          :: n
    integer          :: nrhs
    magma_devptr_t   :: dA
    integer          :: ldda
    integer          :: ipiv(*)
    magma_devptr_t   :: dB
    integer          :: lddb
    integer          :: info
end subroutine magmaf_zgetrs_gpu

subroutine magmaf_zgetrs_nopiv_gpu( trans, n, nrhs, dA, ldda, dB, lddb, info )
    character        :: trans
    integer          :: n
    integer          :: nrhs
    magma_devptr_t   :: dA
    integer          :: ldda
    magma_devptr_t   :: dB
    integer          :: lddb
    integer          :: info
end subroutine magmaf_zgetrs_nopiv_gpu

subroutine magmaf_zheevd_gpu( jobz, uplo, n, dA, ldda, w, wA, ldwa, work, lwork, rwork,  &
        lrwork, iwork, liwork, info )
    character        :: jobz
    character        :: uplo
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    double precision :: w(*)
    complex*16       :: wA(*)
    integer          :: ldwa
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zheevd_gpu

subroutine magmaf_zheevdx_gpu( jobz, range, uplo, n, dA, ldda, vl, vu, il, iu, m, w, wA,  &
        ldwa, work, lwork, rwork, lrwork, iwork, liwork, info )
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    integer          :: m
    double precision :: w(*)
    complex*16       :: wA(*)
    integer          :: ldwa
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zheevdx_gpu

subroutine magmaf_zheevr_gpu( jobz, range, uplo, n, dA, ldda, vl, vu, il, iu, abstol, m,  &
        w, dZ, lddz, isuppz, wA, ldwa, wZ, ldwz, work, lwork, rwork, lrwork, iwork,  &
        liwork, info )
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    double precision :: abstol
    integer          :: m
    double precision :: w(*)
    magma_devptr_t   :: dZ
    integer          :: lddz
    integer          :: isuppz(*)
    complex*16       :: wA(*)
    integer          :: ldwa
    complex*16       :: wZ(*)
    integer          :: ldwz
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: lrwork
    integer          :: iwork(*)
    integer          :: liwork
    integer          :: info
end subroutine magmaf_zheevr_gpu

subroutine magmaf_zheevx_gpu( jobz, range, uplo, n, dA, ldda, vl, vu, il, iu, abstol, m,  &
        w, dZ, lddz, wA, ldwa, wZ, ldwz, work, lwork, rwork, iwork, ifail, info )
    character        :: jobz
    character        :: range
    character        :: uplo
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    double precision :: vl
    double precision :: vu
    integer          :: il
    integer          :: iu
    double precision :: abstol
    integer          :: m
    double precision :: w(*)
    magma_devptr_t   :: dZ
    integer          :: lddz
    complex*16       :: wA(*)
    integer          :: ldwa
    complex*16       :: wZ(*)
    integer          :: ldwz
    complex*16       :: work(*)
    integer          :: lwork
    double precision :: rwork(*)
    integer          :: iwork(*)
    integer          :: ifail(*)
    integer          :: info
end subroutine magmaf_zheevx_gpu

subroutine magmaf_zhegst_gpu( itype, uplo, n, dA, ldda, dB, lddb, info )
    integer          :: itype
    character        :: uplo
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    magma_devptr_t   :: dB
    integer          :: lddb
    integer          :: info
end subroutine magmaf_zhegst_gpu

subroutine magmaf_zhetrd_gpu( uplo, n, dA, ldda, d, e, tau, wA, ldwa, work, lwork, info )
    character        :: uplo
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    double precision :: d(*)
    double precision :: e(*)
    complex*16       :: tau(*)
    complex*16       :: wA(*)
    integer          :: ldwa
    complex*16       :: work(*)
    integer          :: lwork
    integer          :: info
end subroutine magmaf_zhetrd_gpu

subroutine magmaf_zhetrd2_gpu( uplo, n, dA, ldda, d, e, tau, wA, ldwa, work, lwork,  &
        dwork, ldwork, info )
    character        :: uplo
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    double precision :: d(*)
    double precision :: e(*)
    complex*16       :: tau(*)
    complex*16       :: wA(*)
    integer          :: ldwa
    complex*16       :: work(*)
    integer          :: lwork
    magma_devptr_t   :: dwork
    integer          :: ldwork
    integer          :: info
end subroutine magmaf_zhetrd2_gpu

subroutine magmaf_zhetrf_nopiv_gpu( uplo, n, da, ldda, info )
    character        :: uplo
    integer          :: n
    magma_devptr_t   :: da
    integer          :: ldda
    integer          :: info
end subroutine magmaf_zhetrf_nopiv_gpu

subroutine magmaf_zlarf_gpu( m, n, dv, dtau, dC, lddc )
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dv
    magma_devptr_t   :: dtau
    magma_devptr_t   :: dC
    integer          :: lddc
end subroutine magmaf_zlarf_gpu

subroutine magmaf_zlarfb_gpu( side, trans, direct, storev, m, n, k, dV, lddv, dT, lddt,  &
        dC, lddc, dwork, ldwork )
    character        :: side
    character        :: trans
    character        :: direct
    character        :: storev
    integer          :: m
    integer          :: n
    integer          :: k
    magma_devptr_t   :: dV
    integer          :: lddv
    magma_devptr_t   :: dT
    integer          :: lddt
    magma_devptr_t   :: dC
    integer          :: lddc
    magma_devptr_t   :: dwork
    integer          :: ldwork
end subroutine magmaf_zlarfb_gpu

subroutine magmaf_zlarfb_gpu_gemm( side, trans, direct, storev, m, n, k, dV, lddv, dT,  &
        lddt, dC, lddc, dwork, ldwork, dworkvt, ldworkvt )
    character        :: side
    character        :: trans
    character        :: direct
    character        :: storev
    integer          :: m
    integer          :: n
    integer          :: k
    magma_devptr_t   :: dV
    integer          :: lddv
    magma_devptr_t   :: dT
    integer          :: lddt
    magma_devptr_t   :: dC
    integer          :: lddc
    magma_devptr_t   :: dwork
    integer          :: ldwork
    magma_devptr_t   :: dworkvt
    integer          :: ldworkvt
end subroutine magmaf_zlarfb_gpu_gemm

subroutine magmaf_zlarfb2_gpu( m, n, k, dV, lddv, dT, lddt, dC, lddc, dwork, ldwork )
    integer          :: m
    integer          :: n
    integer          :: k
    magma_devptr_t   :: dV
    integer          :: lddv
    magma_devptr_t   :: dT
    integer          :: lddt
    magma_devptr_t   :: dC
    integer          :: lddc
    magma_devptr_t   :: dwork
    integer          :: ldwork
end subroutine magmaf_zlarfb2_gpu

subroutine magmaf_zlauum_gpu( uplo, n, dA, ldda, info )
    character        :: uplo
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    integer          :: info
end subroutine magmaf_zlauum_gpu

subroutine magmaf_zposv_gpu( uplo, n, nrhs, dA, ldda, dB, lddb, info )
    character        :: uplo
    integer          :: n
    integer          :: nrhs
    magma_devptr_t   :: dA
    integer          :: ldda
    magma_devptr_t   :: dB
    integer          :: lddb
    integer          :: info
end subroutine magmaf_zposv_gpu

subroutine magmaf_zpotf2_gpu( uplo, n, dA, ldda, info )
    character        :: uplo
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    integer          :: info
end subroutine magmaf_zpotf2_gpu

subroutine magmaf_zpotrf_gpu( uplo, n, dA, ldda, info )
    character        :: uplo
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    integer          :: info
end subroutine magmaf_zpotrf_gpu

subroutine magmaf_zpotri_gpu( uplo, n, dA, ldda, info )
    character        :: uplo
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    integer          :: info
end subroutine magmaf_zpotri_gpu

subroutine magmaf_zpotrs_gpu( uplo, n, nrhs, dA, ldda, dB, lddb, info )
    character        :: uplo
    integer          :: n
    integer          :: nrhs
    magma_devptr_t   :: dA
    integer          :: ldda
    magma_devptr_t   :: dB
    integer          :: lddb
    integer          :: info
end subroutine magmaf_zpotrs_gpu

subroutine magmaf_zssssm_gpu( order, m1, n1, m2, n2, k, ib, dA1, ldda1, dA2, ldda2, dL1,  &
        lddl1, dL2, lddl2, ipiv, info )
    character        :: order
    integer          :: m1
    integer          :: n1
    integer          :: m2
    integer          :: n2
    integer          :: k
    integer          :: ib
    magma_devptr_t   :: dA1
    integer          :: ldda1
    magma_devptr_t   :: dA2
    integer          :: ldda2
    magma_devptr_t   :: dL1
    integer          :: lddl1
    magma_devptr_t   :: dL2
    integer          :: lddl2
    integer          :: ipiv(*)
    integer          :: info
end subroutine magmaf_zssssm_gpu

subroutine magmaf_ztrtri_gpu( uplo, diag, n, dA, ldda, info )
    character        :: uplo
    character        :: diag
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    integer          :: info
end subroutine magmaf_ztrtri_gpu

subroutine magmaf_zungqr_gpu( m, n, k, dA, ldda, tau, dT, nb, info )
    integer          :: m
    integer          :: n
    integer          :: k
    magma_devptr_t   :: dA
    integer          :: ldda
    complex*16       :: tau(*)
    magma_devptr_t   :: dT
    integer          :: nb
    integer          :: info
end subroutine magmaf_zungqr_gpu

subroutine magmaf_zunmql2_gpu( side, trans, m, n, k, dA, ldda, tau, dC, lddc, wA, ldwa,  &
        info )
    character        :: side
    character        :: trans
    integer          :: m
    integer          :: n
    integer          :: k
    magma_devptr_t   :: dA
    integer          :: ldda
    complex*16       :: tau(*)
    magma_devptr_t   :: dC
    integer          :: lddc
    complex*16       :: wA(*)
    integer          :: ldwa
    integer          :: info
end subroutine magmaf_zunmql2_gpu

subroutine magmaf_zunmqr_gpu( side, trans, m, n, k, dA, ldda, tau, dC, lddc, hwork,  &
        lwork, dT, nb, info )
    character        :: side
    character        :: trans
    integer          :: m
    integer          :: n
    integer          :: k
    magma_devptr_t   :: dA
    integer          :: ldda
    complex*16       :: tau(*)
    magma_devptr_t   :: dC
    integer          :: lddc
    complex*16       :: hwork(*)
    integer          :: lwork
    magma_devptr_t   :: dT
    integer          :: nb
    integer          :: info
end subroutine magmaf_zunmqr_gpu

subroutine magmaf_zunmqr2_gpu( side, trans, m, n, k, dA, ldda, tau, dC, lddc, wA, ldwa,  &
        info )
    character        :: side
    character        :: trans
    integer          :: m
    integer          :: n
    integer          :: k
    magma_devptr_t   :: dA
    integer          :: ldda
    complex*16       :: tau(*)
    magma_devptr_t   :: dC
    integer          :: lddc
    complex*16       :: wA(*)
    integer          :: ldwa
    integer          :: info
end subroutine magmaf_zunmqr2_gpu

subroutine magmaf_zunmtr_gpu( side, uplo, trans, m, n, dA, ldda, tau, dC, lddc, wA, ldwa,  &
        info )
    character        :: side
    character        :: uplo
    character        :: trans
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    complex*16       :: tau(*)
    magma_devptr_t   :: dC
    integer          :: lddc
    complex*16       :: wA(*)
    integer          :: ldwa
    integer          :: info
end subroutine magmaf_zunmtr_gpu

subroutine magmaf_znan_inf( uplo, m, n, A, lda, cnt_nan, cnt_inf )
    character        :: uplo
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
    integer          :: cnt_nan(*)
    integer          :: cnt_inf(*)
end subroutine magmaf_znan_inf

subroutine magmaf_znan_inf_gpu( uplo, m, n, dA, ldda, cnt_nan, cnt_inf )
    character        :: uplo
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
    integer          :: cnt_nan(*)
    integer          :: cnt_inf(*)
end subroutine magmaf_znan_inf_gpu

subroutine magmaf_zprint( m, n, A, lda )
    integer          :: m
    integer          :: n
    complex*16       :: A(*)
    integer          :: lda
end subroutine magmaf_zprint

subroutine magmaf_zprint_gpu( m, n, dA, ldda )
    integer          :: m
    integer          :: n
    magma_devptr_t   :: dA
    integer          :: ldda
end subroutine magmaf_zprint_gpu

end interface

!---- Fortran-only subroutines (see ../tools/fortran_wrappers.pl to edit) ----
contains

subroutine magmaf_zoff1d( ptrNew, ptrOld, inc, i)
    magma_devptr_t   :: ptrNew
    magma_devptr_t   :: ptrOld
    integer          :: inc, i

    ptrNew = ptrOld + (i-1) * inc * sizeof_complex_16
end subroutine magmaf_zoff1d

subroutine magmaf_zoff2d( ptrNew, ptrOld, lda, i, j)
    magma_devptr_t   :: ptrNew
    magma_devptr_t   :: ptrOld
    integer          :: lda, i, j

    ptrNew = ptrOld + ((j-1) * lda + (i-1)) * sizeof_complex_16
end subroutine magmaf_zoff2d

end module magma_zfortran


        SUBROUTINE UMD2OF (W, N, RPERM, CPERM, NZOFF,
     $          OFFP, OFFI, OFFX, PR,
     $          ICNTL, MP, MI, MX, MN, MNZ, PRESRV, NBLKS, BLKP,
     $          ONZ, WHO, INFO, NBELOW)
        INTEGER N, NZOFF, W (N+1), RPERM (N), CPERM (N), ONZ,
     $          OFFP (N+1), OFFI (ONZ), PR (N), ICNTL (20), MN, MNZ,
     $          MP (MN+1), MI (MNZ), NBLKS, BLKP (NBLKS+1), WHO, NBELOW,
     $          INFO (40)
        LOGICAL PRESRV
        DOUBLE PRECISION
     $          OFFX (ONZ), MX (MNZ)

C=== UMD2OF ============================================================
C
C  Unsymmetric-pattern MultiFrontal Package (UMFPACK). Version 2.2d
C  Copyright (C) 1997, Timothy A. Davis, University of Florida, USA.
C  ALL RIGHTS RESERVED.
C  Joint work with Iain S. Duff, Rutherford Appleton Laboratory, UK.
C  July 7, 1997. Work supported by the National Science Foundation
C  (DMS-9223088 and DMS-9504974) and the State of Florida; and by CRAY
C  Research Inc. through the allocation of supercomputing resources.

C***********************************************************************
C* NOTICE:  "The UMFPACK Package may be used SOLELY for educational,   *
C* research, and benchmarking purposes by non-profit organizations and *
C* the U.S. government.  Commercial and other organizations may make   *
C* use of UMFPACK SOLELY for benchmarking purposes only.  UMFPACK may  *
C* be modified by or on behalf of the User for such use but at no time *
C* shall UMFPACK or any such modified version of UMFPACK become the    *
C* property of the User.  UMFPACK is provided without warranty of any  *
C* kind, either expressed or implied.  Neither the Authors nor their   *
C* employers shall be liable for any direct or consequential loss or   *
C* damage whatsoever arising out of the use or misuse of UMFPACK by    *
C* the User.  UMFPACK must not be sold.  You may make copies of        *
C* UMFPACK, but this NOTICE and the Copyright notice must appear in    *
C* all copies.  Any other use of UMFPACK requires written permission.  *
C* Your use of UMFPACK is an implicit agreement to these conditions."  *
C*                                                                     *
C* The MA38 Package in Release 12 of the Harwell Subroutine Library    *
C* (HSL) has equivalent functionality (and identical calling interface)*
C* as UMFPACK (the HSL has single and double precision versions only,  *
C* however).  It is available for commercial use.   Technical reports, *
C* information on HSL, and matrices are available via the World Wide   *
C* Web at http://www.cis.rl.ac.uk/struct/ARCD/NUM.html, or by          *
C* anonymous ftp at seamus.cc.rl.ac.uk/pub.  Also contact Dr. Scott    *
C* Roberts, Harwell Subroutine Library, B 552, AEA Technology,         *
C* Harwell, Didcot, Oxon OX11 0RA, England.                            *
C* telephone (44) 1235 434988, fax (44) 1235 434136                    *
C* email Scott.Roberts@aeat.co.uk, who will provide details of price   *
C* and conditions of use.                                              *
C***********************************************************************

C=======================================================================
C  NOT USER-CALLABLE.

C=======================================================================
C  DESCRIPTION:
C=======================================================================
C
C  Permute the off-diagonal blocks according to final pivot permutation.
C  This routine is called only if the block-triangular-form (BTF) is
C  used.

C=======================================================================
C  INPUT:
C=======================================================================
C
C       n:              order of matrix
C       Rperm (1..n):   the final row permutations, including BTF
C                       If i is the k-th pivot row, then Rperm (k) = i
C       Cperm (1..n):   the final column permutations, including BTF
C                       If j is the k-th pivot col, then Cperm (k) = j
C       Icntl:          integer control parameters, see UMD21I
C       Info:           integer informational parameters
C       who:            who called (1: UMD2FA, 2: UMD2RF)
C
C       if presrv is true then
C           mn:                 order of preserved matrix
C           mnz:                number of entries in preserved matrix
C           Mp (1..mn+1):       column pointers of preserved matrix
C           Mi (1..mnz):        row indices of preserved matrix
C           Mx (1..mnz):        values of preserved matrix
C           Blkp (1..nblks+1):  the index range of the blocks
C           nblks:              the number of diagonal blocks
C       else
C           mn:                 0
C           mnz:                nzoff
C           Mp:                 unaccessed
C           Offp (1..n+1):      column pointers for off-diagonal entries
C                               in original order
C           Mi (1..mnz):        the row indices of off-diagonal entries,
C                               in original order
C           Mx (1..mnz):        the values of off-diagonal entries,
C                               in original order
C           nblks:              0
C           Blkp (1..nblks+1):  unaccessed
C           nzoff:              number of entries in off-diagonal blocks

C=======================================================================
C  WORKSPACE:
C=======================================================================
C
C       W (1..n)

C=======================================================================
C  OUTPUT:
C=======================================================================
C
C       Offp (1..n+1):          row pointers for off-diagonal part
C       Offi (1..nzoff):        column indices in off-diagonal part
C       Offx (1..nzoff):        values in off-diagonal part
C       nzoff:                  number of entries in off-diagonal blocks
C       Pr (1..n):              inverse row permutation
C       nbelow:                 entries that are below the diagonal
C                               blocks (can only occur if who = 2)

C=======================================================================
C  SUBROUTINES AND FUNCTIONS CALLED / CALLED BY:
C=======================================================================
C
C       called by subroutine:   UMD2F0, UMD2RA, UMD2R0
C       subroutines called:     UMD2P2

C=======================================================================
C  LOCAL SCALARS:
C=======================================================================

        INTEGER ROW, COL, P, BLK, K, K1, K2, IO, PRL
        LOGICAL PR3

C  row:     row index
C  col:     column index
C  p:       pointer
C  blk:     current diagonal block
C  k:       kth pivot
C  k1,k2:   current diaogonal block is A (k1..k2, k1..k2)
C  io:      I/O unit for diagnostic messages
C  prl:     printing level
C  pr3:     true if printing entries below diagonal blocks (UMD2RF)

C=======================================================================
C  EXECUTABLE STATMENTS:
C=======================================================================

        IO = ICNTL (2)
        PRL = ICNTL (3)
        PR3 = PRL .GE. 3 .AND. IO .GE. 0

C-----------------------------------------------------------------------
C  compute inverse row permutation
C-----------------------------------------------------------------------

C       if original row i is the kth pivot row, then
C               Rperm (k) = i
C               Pr (i) = k
C       if original col j is the kth pivot col, then
C               Cperm (k) = j
CFPP$ NODEPCHK L
        DO 10 K = 1, N
           PR (RPERM (K)) = K
10      CONTINUE

C-----------------------------------------------------------------------
C  construct row-oriented pointers for permuted row-form
C-----------------------------------------------------------------------

        W (1) = 1
        DO 20 ROW = 2, N
           W (ROW) = 0
20      CONTINUE
        NBELOW = 0
        IF (PRESRV) THEN
           DO 50 BLK = 1, NBLKS
              K1 = BLKP (BLK)
              K2 = BLKP (BLK+1) - 1
              DO 40 COL = K1, K2
CFPP$ NODEPCHK L
                 DO 30 P = MP (CPERM (COL)), MP (CPERM (COL)+1)-1
                    ROW = PR (MI (P))
                    IF (ROW .LT. K1) THEN
C                      offdiagonal entry
                       W (ROW) = W (ROW) + 1
                    ELSE IF (ROW .GT. K2 .AND. WHO .EQ. 2) THEN
C                      This entry is below the diagonal block - invalid.
C                      This can only occur if who = 2 (UMD2RF).
                       IF (PR3) THEN
C                         print the original row and column indices:
                          CALL UMD2P2 (2, 96, MI (P), COL, MX (P), IO)
                       ENDIF
                       NBELOW = NBELOW + 1
                    ENDIF
30               CONTINUE
40            CONTINUE
50         CONTINUE
        ELSE
           DO 70 COL = 1, N
CFPP$ NODEPCHK L
              DO 60 P = OFFP (COL), OFFP (COL+1) - 1
                 ROW = PR (MI (P))
                 W (ROW) = W (ROW) + 1
60            CONTINUE
70         CONTINUE
        ENDIF
        DO 80 ROW = 2, N
           W (ROW) = W (ROW) + W (ROW-1)
80      CONTINUE
        W (N+1) = W (N)
C       W (row) now points just past end of row in Offi/x

C-----------------------------------------------------------------------
C  construct the row-oriented form of the off-diagonal values,
C  in the final pivot order.  The column indices in each row
C  are placed in ascending order (the access of Offi/Offx later on
C  does not require this, but it makes access more efficient).
C-----------------------------------------------------------------------

        IF (PRESRV) THEN
           DO 110 BLK = NBLKS, 1, -1
              K1 = BLKP (BLK)
              K2 = BLKP (BLK+1) - 1
              DO 100 COL = K2, K1, - 1
CFPP$ NODEPCHK L
                 DO 90 P = MP (CPERM (COL)), MP (CPERM (COL)+1)-1
                    ROW = PR (MI (P))
                    IF (ROW .LT. K1) THEN
C                      offdiagonal entry
                       W (ROW) = W (ROW) - 1
                       OFFI (W (ROW)) = COL
                       OFFX (W (ROW)) = MX (P)
                    ENDIF
90               CONTINUE
100           CONTINUE
110        CONTINUE
        ELSE
           DO 130 COL = N, 1, -1
CFPP$ NODEPCHK L
              DO 120 P = OFFP (CPERM (COL)), OFFP (CPERM (COL) + 1) - 1
                 ROW = PR (MI (P))
                 W (ROW) = W (ROW) - 1
                 OFFI (W (ROW)) = COL
                 OFFX (W (ROW)) = MX (P)
120           CONTINUE
130        CONTINUE
        ENDIF

C-----------------------------------------------------------------------
C  save the new row pointers
C-----------------------------------------------------------------------

        DO 140 ROW = 1, N+1
           OFFP (ROW) = W (ROW)
140     CONTINUE

        NZOFF = OFFP (N+1) - 1

        RETURN
        END