SUBROUTINE LA_TEST_ZHPGVD( ITYPE, JOBZ, UPLO, N, AP, BP, W, Z, LDZ,&
     &  WORK,LWORK, RWORK, LRWORK, IWORK, LIWORK, INFO )
!
!  -- LAPACK95 interface driver routine (version 1.1) --
!     UNI-C, Denmark;
!     August 13, 1999
!
!  .. Use Statements ..
   USE LA_PRECISION, ONLY: WP => DP
   USE F95_LAPACK, ONLY: LA_HPGVD
!  .. Implicit Statement ..
   IMPLICIT NONE
!  .. Scalar Arguments ..
   INTEGER, INTENT(IN) :: ITYPE, N, LDZ, LWORK, LRWORK, LIWORK
   INTEGER, INTENT(INOUT) :: INFO
   CHARACTER*1, INTENT(IN) :: JOBZ, UPLO
!  .. Array Arguments ..
   COMPLEX(WP), INTENT(INOUT) :: AP(1:N*(N+1)/2), BP( 1:N*(N+1)/2)
   REAL(WP), INTENT(OUT)::  W(1:N)
   COMPLEX(WP), INTENT(OUT) ::   WORK(1:LWORK), Z(1:LDZ, 1:N)
      INTEGER, INTENT(OUT) :: IWORK(1:LIWORK)
      REAL(WP), INTENT(OUT) :: RWORK(1: LRWORK)
!  .. Parameters ..
   CHARACTER(LEN=8),  PARAMETER :: SRNAME = 'LA_HPGVD'
   CHARACTER(LEN=14), PARAMETER :: SRNAMT = 'LA_TEST_ZHPGVD'
!  .. Common blocks ..
   INTEGER :: INFOTC
   COMMON /LINFO95/ INFOTC
!  .. Local Scalars ..
   INTEGER :: I, J, IAP, IW, IBP, IITYPE, IZ1, IZ2
   CHARACTER*1 :: IUPLO, IJOBZ   
!  .. Local Arrays ..
   LOGICAL, SAVE :: CTEST = .TRUE., ETEST = .TRUE.
   LOGICAL LSAME
!  .. Executable Statements ..

   IAP = N *(N+1)/2; IUPLO = UPLO; IW = N; IJOBZ = JOBZ
   IBP = N*(N+1)/2; IITYPE = ITYPE; IZ1 = MAX(1, N); IZ2 = N
   I = INFO / 100; J = INFO - I*100
   SELECT CASE(I)
     CASE (1)
      IAP = IAP - 1
     CASE (2)
       IBP = IAP - 1
     CASE (3)
       IW = IW - 1
     CASE (4)
       IITYPE = 22   
     CASE (5)
       IUPLO = 'T' 
     CASE (6)
       IZ2 = IZ2 - 1
       IJOBZ = 'V'
     CASE(:-1,7:)
       CALL UESTOP(SRNAMT)
   END SELECT
   IF (LSAME(IJOBZ, 'V')) THEN
     CALL LA_HPGVD( AP(1:IAP), BP(1:IBP), W(1 :IW), &
     &  IITYPE, IUPLO, Z(1:IZ1, 1: IZ2), INFO )
      ELSE
        CALL LA_HPGVD( AP(1:IAP), BP(1:IBP), W(1 :IW), &
     &    IITYPE, IUPLO, INFO = INFO )
      END IF
      
      CALL LA_AUX_AA01( I, CTEST, ETEST, SRNAMT )
 END SUBROUTINE LA_TEST_ZHPGVD
      
      
