1       LOGICAL          FUNCTION LSAME( CA, CB )
 2 *
 3 *  -- LAPACK auxiliary routine (version 3.2) --
 4 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
 5 *     November 2006
 6 *
 7 *     .. Scalar Arguments ..
 8       CHARACTER          CA, CB
 9 *     ..
10 *
11 *  Purpose
12 *  =======
13 *
14 *  LSAME returns .TRUE. if CA is the same letter as CB regardless of
15 *  case.
16 *
17 *  Arguments
18 *  =========
19 *
20 *  CA      (input) CHARACTER*1
21 *  CB      (input) CHARACTER*1
22 *          CA and CB specify the single characters to be compared.
23 *
24 * =====================================================================
25 *
26 *     .. Intrinsic Functions ..
27       INTRINSIC          ICHAR
28 *     ..
29 *     .. Local Scalars ..
30       INTEGER            INTA, INTB, ZCODE
31 *     ..
32 *     .. Executable Statements ..
33 *
34 *     Test if the characters are equal
35 *
36       LSAME = CA.EQ.CB
37       IF( LSAME )
38      $   RETURN
39 *
40 *     Now test for equivalence if both characters are alphabetic.
41 *
42       ZCODE = ICHAR'Z' )
43 *
44 *     Use 'Z' rather than 'A' so that ASCII can be detected on Prime
45 *     machines, on which ICHAR returns a value with bit 8 set.
46 *     ICHAR('A') on Prime machines returns 193 which is the same as
47 *     ICHAR('A') on an EBCDIC machine.
48 *
49       INTA = ICHAR( CA )
50       INTB = ICHAR( CB )
51 *
52       IF( ZCODE.EQ.90 .OR. ZCODE.EQ.122 ) THEN
53 *
54 *        ASCII is assumed - ZCODE is the ASCII code of either lower or
55 *        upper case 'Z'.
56 *
57          IF( INTA.GE.97 .AND. INTA.LE.122 ) INTA = INTA - 32
58          IF( INTB.GE.97 .AND. INTB.LE.122 ) INTB = INTB - 32
59 *
60       ELSE IF( ZCODE.EQ.233 .OR. ZCODE.EQ.169 ) THEN
61 *
62 *        EBCDIC is assumed - ZCODE is the EBCDIC code of either lower or
63 *        upper case 'Z'.
64 *
65          IF( INTA.GE.129 .AND. INTA.LE.137 .OR.
66      $       INTA.GE.145 .AND. INTA.LE.153 .OR.
67      $       INTA.GE.162 .AND. INTA.LE.169 ) INTA = INTA + 64
68          IF( INTB.GE.129 .AND. INTB.LE.137 .OR.
69      $       INTB.GE.145 .AND. INTB.LE.153 .OR.
70      $       INTB.GE.162 .AND. INTB.LE.169 ) INTB = INTB + 64
71 *
72       ELSE IF( ZCODE.EQ.218 .OR. ZCODE.EQ.250 ) THEN
73 *
74 *        ASCII is assumed, on Prime machines - ZCODE is the ASCII code
75 *        plus 128 of either lower or upper case 'Z'.
76 *
77          IF( INTA.GE.225 .AND. INTA.LE.250 ) INTA = INTA - 32
78          IF( INTB.GE.225 .AND. INTB.LE.250 ) INTB = INTB - 32
79       END IF
80       LSAME = INTA.EQ.INTB
81 *
82 *     RETURN
83 *
84 *     End of LSAME
85 *
86       END