      LOGICAL          FUNCTION LSAME( CA, CB )
*
*  -- LAPACK auxiliary routine (preliminary version) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     August 6, 1991
*
*     .. Scalar Arguments ..
      CHARACTER          CA, CB
*     ..
*
*  Purpose
*  =======
*
*  LSAME returns .TRUE. if CA is the same letter as CB regardless of
*  case.
*
*  Arguments
*  =========
*
*  CA      (input) CHARACTER*1
*  CB      (input) CHARACTER*1
*          CA and CB specify the single characters to be compared.
*
*  Further Details
*  ===============
*
*  This version of the routine is only correct for ASCII code.
*  Installers must modify the routine for other character-codes.
*
*  For EBCDIC systems the constant IOFF must be changed to -64.
*  IOFF is computed as
*     IOFF = ICHAR( 'a' ) - ICHAR( 'A' )
*
*  For CDC systems using 6-12 bit representations, the system-
*  specific code in comments must be activated.
*
*  Important!:  The statement function definition for UCASE must use
*  upper case letters A and Z, and the definition for LCASE must use
*  lower case letters a and z.  It is assumed that the characters A-Z
*  are consecutive in the collating sequence, both in upper case and
*  in lower case.
*
*     .. Parameters ..
      INTEGER            IOFF
      PARAMETER          ( IOFF = 32 )
*     ..
*     .. Intrinsic Functions ..
      INTRINSIC          ICHAR
*     ..
*     .. Local Scalars ..
      INTEGER            IC, INTA, INTB
*     ..
*     .. Statement Functions ..
      LOGICAL            LCASE, UCASE
*     ..
*     .. Statement Function definitions ..
      UCASE( IC ) = IC.GE.ICHAR( 'A' ) .AND. IC.LE.ICHAR( 'Z' )
      LCASE( IC ) = IC.GE.ICHAR( 'a' ) .AND. IC.LE.ICHAR( 'z' )
*     ..
*     .. Executable Statements ..
*
*     Test if the characters are equal
*
      LSAME = CA.EQ.CB
      IF( LSAME )
     $   RETURN
*
*     Now test for equivalence if both characters are alphabetic.
*
      INTA = ICHAR( CA )
      INTB = ICHAR( CB )
*
      IF( UCASE( INTA ) ) THEN
*
*        A is upper case
*
         IF( UCASE( INTB ) ) THEN
*
*           B is upper case -- test already done
*
            LSAME = .FALSE.
*
         ELSE IF( LCASE( INTB ) ) THEN
*
*           B is lower case
*
            LSAME = INTA.EQ.INTB - IOFF
         END IF
*
      ELSE IF( LCASE( INTA ) ) THEN
*
*        A is lower case
*
         IF( LCASE( INTB ) ) THEN
*
*           B is lower case -- test already done
*
            LSAME = .FALSE.
*
         ELSE IF( UCASE( INTB ) ) THEN
*
*           B is upper case
*
            LSAME = INTA - IOFF.EQ.INTB
         END IF
      END IF
*
      RETURN
*
*  The following comments contain code for CDC systems using 6-12 bit
*  representations.
*
*     .. Parameters ..
*     INTEGER            ICIRFX
*     PARAMETER        ( ICIRFX=62 )
*     .. Scalar arguments ..
*     CHARACTER*1        CB
*     .. Array arguments ..
*     CHARACTER*1        CA(*)
*     .. Local scalars ..
*     INTEGER            IVAL
*     .. Intrinsic functions ..
*     INTRINSIC          ICHAR, CHAR
*     .. Executable statements ..
*
*     See if the first character in string CA equals string CB.
*
*     LSAME = CA(1) .EQ. CB .AND. CA(1) .NE. CHAR(ICIRFX)
*
*     IF (LSAME) RETURN
*
*     The characters are not identical. Now check them for equivalence.
*     Look for the 'escape' character, circumflex, followed by the
*     letter.
*
*     IVAL = ICHAR(CA(2))
*     IF (IVAL.GE.ICHAR('A') .AND. IVAL.LE.ICHAR('Z')) THEN
*        LSAME = CA(1) .EQ. CHAR(ICIRFX) .AND. CA(2) .EQ. CB
*     END IF
*
*     RETURN
*
*     End of LSAME
*
      END
