LAPACK 3.3.1
Linear Algebra PACKage

BLAS/SRC/lsame.f

Go to the documentation of this file.
00001       LOGICAL FUNCTION LSAME(CA,CB)
00002 *
00003 *  -- LAPACK auxiliary routine (version 3.1) --
00004 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00005 *     November 2006
00006 *
00007 *     .. Scalar Arguments ..
00008       CHARACTER CA,CB
00009 *     ..
00010 *
00011 *  Purpose
00012 *  =======
00013 *
00014 *  LSAME returns .TRUE. if CA is the same letter as CB regardless of
00015 *  case.
00016 *
00017 *  Arguments
00018 *  =========
00019 *
00020 *  CA      (input) CHARACTER*1
00021 *
00022 *  CB      (input) CHARACTER*1
00023 *          CA and CB specify the single characters to be compared.
00024 *
00025 * =====================================================================
00026 *
00027 *     .. Intrinsic Functions ..
00028       INTRINSIC ICHAR
00029 *     ..
00030 *     .. Local Scalars ..
00031       INTEGER INTA,INTB,ZCODE
00032 *     ..
00033 *
00034 *     Test if the characters are equal
00035 *
00036       LSAME = CA .EQ. CB
00037       IF (LSAME) RETURN
00038 *
00039 *     Now test for equivalence if both characters are alphabetic.
00040 *
00041       ZCODE = ICHAR('Z')
00042 *
00043 *     Use 'Z' rather than 'A' so that ASCII can be detected on Prime
00044 *     machines, on which ICHAR returns a value with bit 8 set.
00045 *     ICHAR('A') on Prime machines returns 193 which is the same as
00046 *     ICHAR('A') on an EBCDIC machine.
00047 *
00048       INTA = ICHAR(CA)
00049       INTB = ICHAR(CB)
00050 *
00051       IF (ZCODE.EQ.90 .OR. ZCODE.EQ.122) THEN
00052 *
00053 *        ASCII is assumed - ZCODE is the ASCII code of either lower or
00054 *        upper case 'Z'.
00055 *
00056           IF (INTA.GE.97 .AND. INTA.LE.122) INTA = INTA - 32
00057           IF (INTB.GE.97 .AND. INTB.LE.122) INTB = INTB - 32
00058 *
00059       ELSE IF (ZCODE.EQ.233 .OR. ZCODE.EQ.169) THEN
00060 *
00061 *        EBCDIC is assumed - ZCODE is the EBCDIC code of either lower or
00062 *        upper case 'Z'.
00063 *
00064           IF (INTA.GE.129 .AND. INTA.LE.137 .OR.
00065      +        INTA.GE.145 .AND. INTA.LE.153 .OR.
00066      +        INTA.GE.162 .AND. INTA.LE.169) INTA = INTA + 64
00067           IF (INTB.GE.129 .AND. INTB.LE.137 .OR.
00068      +        INTB.GE.145 .AND. INTB.LE.153 .OR.
00069      +        INTB.GE.162 .AND. INTB.LE.169) INTB = INTB + 64
00070 *
00071       ELSE IF (ZCODE.EQ.218 .OR. ZCODE.EQ.250) THEN
00072 *
00073 *        ASCII is assumed, on Prime machines - ZCODE is the ASCII code
00074 *        plus 128 of either lower or upper case 'Z'.
00075 *
00076           IF (INTA.GE.225 .AND. INTA.LE.250) INTA = INTA - 32
00077           IF (INTB.GE.225 .AND. INTB.LE.250) INTB = INTB - 32
00078       END IF
00079       LSAME = INTA .EQ. INTB
00080 *
00081 *     RETURN
00082 *
00083 *     End of LSAME
00084 *
00085       END
 All Files Functions