SUBROUTINE LA_TEST_SGGEVX(BALANC, JOBVL, JOBVR, SENSE, N, A, LDA, B, LDB,&
     &  ALPHAR, ALPHAI, BETA, VL, LDVL, VR, LDVR, ILO, IHI, LSCALE, RSCALE,&
     &  ABNRM, BBNRM, RCONDE, RCONDV, WORK, LWORK, IWORK, BWORK, INFO)
!
!  -- LAPACK95 interface driver routine (version 1.1) --
!     UNI-C, Denmark;
!     SEPTEMBER 5, 1999
!
!  .. Use Statements ..
      USE LA_PRECISION, ONLY: WP => SP
      USE F95_LAPACK, ONLY: LA_GGEVX
!  .. Implicit Statement ..
      IMPLICIT NONE
!  .. Scalar Arguments ..
      INTEGER, INTENT(IN) :: N, LDA, LDB, LDVL, LDVR, LWORK
      INTEGER, INTENT(INOUT) :: INFO
      INTEGER, INTENT(OUT):: ILO, IHI
      CHARACTER*1, INTENT(IN) :: BALANC, JOBVL, JOBVR, SENSE
      REAL(WP), INTENT(OUT) :: ABNRM, BBNRM
!  .. Array Arguments ..
      REAL(WP), INTENT(INOUT) :: A(1:LDA,1:N), B(1:LDB, 1:N)
      REAL(WP), INTENT(OUT):: WORK(1:LWORK)
      REAL(WP), INTENT(OUT) :: ALPHAR(1:N), ALPHAI(1:N), BETA(1:N), &
     &  VL(1: LDVL, 1:N), VR(1: LDVR, 1:N), LSCALE(1:N), RSCALE(1:N), &
     &  RCONDE(1:N), RCONDV(1:N)
      INTEGER :: IWORK(1: N+6)
      LOGICAL :: BWORK(1:N)
!  .. Parameters ..
      CHARACTER(LEN=8),  PARAMETER :: SRNAME = 'LA_GGEVX'
      CHARACTER(LEN=14), PARAMETER :: SRNAMT = 'LA_TEST_SGGEVX'
!  .. Common blocks ..
      INTEGER :: INFOTC
      COMMON /LINFO95/ INFOTC
!  .. Local Scalars ..
      INTEGER :: I, J, IA1, IA2, IB1, IB2, IALPHAI, IALPHAR, IBETA, IVL1, &
     &  IVL2, IVR1, IVR2, ILSCALE, IRSCALE, IRCONDE, IRCONDV
      CHARACTER*1 :: IJOBVL, IJOBVR, IBALANC
!  .. Local Arrays ..
      LOGICAL, SAVE :: CTEST = .TRUE., ETEST = .TRUE.
      LOGICAL LSAME
!  .. Executable Statements ..
      IA1 = N; IA2 = N; IJOBVL = JOBVL; IJOBVR = JOBVR; IBALANC = BALANC
      IB1 = N; IB2 = N; IALPHAR = N; IALPHAI = N; IBETA = N
      IVL1 = N; IVL2 = N; IVR1 = N; IVR2 = N; ILSCALE = N; IRSCALE = N
      IRCONDE = N; IRCONDV = N
      I = INFO / 100; J = INFO - I*100
      SELECT CASE(I)
      CASE (1)
      IA2 = IA1 - 1
      CASE (2)
      IB1 = IA1 - 1
      CASE (3)
      IALPHAR = IA1 - 1
      CASE (4)
      IALPHAI = IA1 - 1
      CASE (5)
      IBETA  = IA1 - 1
      CASE (6)
      IJOBVL = 'V'
      IVL1 = IA1 - 1
      CASE (7)
      IJOBVR = 'V'
      IVR1 = IA1 - 1
      CASE (8)
      IBALANC = 'T'
      CASE (11)
      ILSCALE = IA2 - 1
      CASE (12)
      IRSCALE = IA2 - 1
      CASE (15)
      IRCONDE = IA2 - 1
      CASE (16)
      IRCONDV = IA2 - 1
      CASE(:-1,9,10,13, 14, 17:)
      CALL UESTOP(SRNAMT)
      END SELECT
      IF (LSAME(IJOBVL,'V')) THEN
        IF (LSAME (IJOBVR, 'V')) THEN
          CALL LA_GGEVX( A(1:IA1,1:IA2), B(1:IB1, 1:IB2), ALPHAR(1: IALPHAR), &
     &      ALPHAI(1:IALPHAI), BETA(1: IBETA), VL(1:IVL1,1:IVL2), &
     &      VR(1:IVR1,1:IVR2), IBALANC, ILO, IHI, LSCALE(1:ILSCALE), RSCALE(1: IRSCALE), &
     &      ABNRM, BBNRM, RCONDE(1: IRCONDE), RCONDV(1: IRCONDV), INFO)    
        ELSE
          CALL LA_GGEVX( A(1:IA1,1:IA2), B(1:IB1, 1:IB2), ALPHAR(1: IALPHAR), &
     &      ALPHAI(1:IALPHAI), BETA(1: IBETA), VL(1:IVL1,1:IVL2), BALANC=IBALANC, &
     &      ILO=ILO, IHI=IHI, LSCALE=LSCALE(1:ILSCALE), RSCALE=RSCALE(1 : IRSCALE), &
     &      ABNRM=ABNRM, BBNRM=BBNRM, RCONDE=RCONDE(1: IRCONDE), &
     &      RCONDV=RCONDV(1 : IRCONDV), INFO = INFO)
        END IF
      ELSE
        IF (LSAME (IJOBVR, 'V')) THEN
          CALL LA_GGEVX( A(1:IA1,1:IA2), B(1:IB1, 1:IB2), ALPHAR(1: IALPHAR), &
     &      ALPHAI(1:IALPHAI), BETA(1: IBETA), VR = VR(1:IVR1,1:IVR2), ILO=ILO, IHI=IHI, &
     &      BALANC=IBALANC, LSCALE=LSCALE(1 :ILSCALE), &
     &      RSCALE=RSCALE(1: IRSCALE), ABNRM=ABNRM, BBNRM=BBNRM, RCONDE=RCONDE(1 : IRCONDE), &
     &      RCONDV=RCONDV(1 : IRCONDV), INFO = INFO)
        ELSE
          CALL LA_GGEVX( A(1:IA1,1:IA2), B(1:IB1, 1:IB2), ALPHAR(1: IALPHAR), &
     &      ALPHAI(1:IALPHAI), BETA(1: IBETA), BALANC=IBALANC, ILO=ILO, IHI=IHI, &
     &      LSCALE=LSCALE(1  :ILSCALE), RSCALE=RSCALE(1: IRSCALE), ABNRM=ABNRM, &
     &      BBNRM=BBNRM,  RCONDE=RCONDE(1 : IRCONDE), &
     &      RCONDV=RCONDV(1 : IRCONDV), INFO = INFO)
        END IF
      END IF
      CALL LA_AUX_AA01( I, CTEST, ETEST, SRNAMT )
      END SUBROUTINE LA_TEST_SGGEVX
      
