      LOGICAL FUNCTION ISAEROSOL(MHSCH3,MHSCH5,AMSU6,PCLOUD,HEIGHT,
     +                           HIR8OBS,SFCTYP,CLTTMP,NIGHT)
      IMPLICIT NONE
C
C**********************************************************************
C
C   NAME- ISAEROSOL
C
C   LANGUAGE- FORTRAN      TYPE- LOGICAL FUNCTION  COMPUTER- IBM SP
C
C   VERSION- 1.0    DATE-  3/17/06    PROGRAMMER- FRANK TILLEY (ERT)
C   VERSION- 2.0    DATE- 12/27/07    PROGRAMMER- FRANK TILLEY (IMSG)
C      SIMPLIFIED THE FUNCTION AND REMOVED UNNEEDED CALLING ARGUMENTS.
C   VERSION- 2.1    DATE-  5/29/08    PROGRAMMER- FRANK TILLEY (IMSG)
C      ADDED MHS CHANNEL 3 AND TERRAIN HEIGHT TO THE CALLING ARGUMENTS
C      AND ADDED CODE TO DETECT AEROSOLS OVER HIGH TERRAIN.
C
C   FUNCTION - THIS FUNCTION EVALUATES TO TRUE IF THE INPUT PARAMETERS
C              INDICATE THE PRESENCE OF AEROSOLS AT A HIRS FOV.
C
C   CALLING ARGUMENTS-
C      VARIABLE          TYPE I/O FUNCTION
C      --------          ---- --- --------
C      MHSCH3            REAL  I  MHS CHANNEL 3 BRIGHTNESS TEMPERATURE
C      MHSCH5            REAL  I  MHS CHANNEL 5 BRIGHTNESS TEMPERATURE
C      AMSU6             REAL  I  LIMB-CORRECTED AMSU-A CHANNEL 6
C                                 BRIGHTNESS TEMPERATURE.
C      PCLOUD            REAL  I  CLOUD TOP PRESSURE.
C      HEIGHT            INT   I  TERRAIN HEIGHT IN METERS.
C      HIR8OBS           REAL  I  OBSERVED HIRS CHANNEL 8 TEMPERATURE.
C      CLTTMP            REAL  I  CLOUD TOP TEMPERATURE (K).
C      NIGHT             LOG   I  FLAG SET TO .TRUE. FOR NIGHT TIME.
C
C   SUBPROGRAMS CALLED- NONE
C
C   COMMON AREAS-
C
C**********************************************************************
C
      INCLUDE 'SPVAL'
      INCLUDE 'RETPARM'

      REAL MHSCH3, MHSCH5, AMSU6, PCLOUD, HIR8OBS, CLTTMP

      LOGICAL NIGHT

      INTEGER HEIGHT, SFCTYP
C
      REAL HIRSTHRS, THRESH

C
C-- INITIALIZE ISAEROSOL TO FALSE.
C
      ISAEROSOL = .FALSE.

C
C-- IF THE CLOUD TOP TEMPERATURE IS GREATER THAN 304.0 K SET THE ISAEROSOL FLAG
C   TO TRUE
C
      IF (CLTTMP.GT.304.0) THEN
         ISAEROSOL = .TRUE.
         GO TO 1000
      END IF
C
C-- TEST FOR AEROSOLS OVER HIGH TERRAIN.
C
      IF (HEIGHT.GT.1200) THEN
         IF (PCLOUD.LE.400.0) THEN
C        -- HIGH CLOUDS
            THRESH = 15.5
            IF (SFCTYP.GE.10) THRESH = 15.5
            IF ((MHSCH3 - AMSU6).GT.THRESH) THEN
               IF (AMSU6 .GT. 238.0) THEN
                  IF (NIGHT) THEN
                     HIRSTHRS = 270.0
                  ELSE
                     HIRSTHRS = 279.5
                  END IF
                  IF (HIR8OBS .GT. HIRSTHRS) THEN
                     ISAEROSOL = .TRUE.
                     GO TO 1000
                  END IF
               ELSE
                  IF (NIGHT) THEN
                     HIRSTHRS = 280.0
                  ELSE
                     HIRSTHRS = 280.0
                  END IF
                  IF (HIR8OBS .GT. HIRSTHRS) THEN
                     ISAEROSOL = .TRUE.
                     GO TO 1000
                  END IF
               END IF
            END IF
         ELSE
C        -- LOW CLOUDS
            THRESH = 32.0
            IF (SFCTYP.GE.10) THRESH = 33.0
            IF ((MHSCH5-AMSU6).GT.THRESH) THEN
               IF (AMSU6.GT.238.0) THEN
                  IF (NIGHT) THEN
                     HIRSTHRS = 272.0
                  ELSE
                     HIRSTHRS = 283.0
                  END IF
                  IF (HIR8OBS.GT.HIRSTHRS) THEN
                     ISAEROSOL = .TRUE.
                     GO TO 1000
                  END IF
               ELSE
                  IF (NIGHT) THEN
                     HIRSTHRS = 278.0
                  ELSE
                     HIRSTHRS = 278.0
                  END IF
                  IF (HIR8OBS.GT.HIRSTHRS) THEN
                     ISAEROSOL = .TRUE.
                     GO TO 1000
                  END IF
               END IF
            END IF
         END IF
      ELSE
C
C-- TEST OVER LOWER TERRAIN, FOR HIGH AND LOW CLOUD TOP PRESSURES
C

         IF (PCLOUD.LE.400.0) THEN
C  HIGH CLOUDS LOW TERRAIN
            THRESH = 14.0
            IF (SFCTYP.GE.10) THRESH = 14.0
            IF ((MHSCH3 - AMSU6).GT.THRESH) THEN
C     TROPICS
               IF (AMSU6 .GT. 238.0) THEN
                  IF (NIGHT) THEN
                     HIRSTHRS = 265.0
                     IF (SFCTYP.EQ.0) HIRSTHRS = 283.0
                  ELSE
                     HIRSTHRS = 288.0
                     IF (SFCTYP.EQ.0) HIRSTHRS = 283.0
                  END IF
                  IF (HIR8OBS .GT. HIRSTHRS) THEN
                     ISAEROSOL = .TRUE.
                     GO TO 1000
                  END IF
               ELSE
C     POLAR
                  IF (NIGHT) THEN
                     HIRSTHRS = 283.0
                     IF (SFCTYP.EQ.0) HIRSTHRS = 283.0
                  ELSE
                     HIRSTHRS = 283.0
                     IF (SFCTYP.EQ.0) HIRSTHRS = 283.0
                  END IF
                  IF (HIR8OBS .GT. HIRSTHRS) THEN
                     ISAEROSOL = .TRUE.
                     GO TO 1000
                  END IF
               END IF
            END IF
         ELSE
C LOW CLOUDS
            THRESH = 26.5
            IF (SFCTYP.GE.10) THRESH = 34.8
            IF (SFCTYP.EQ.1.OR.SFCTYP.EQ.2) THRESH = 35.0
            IF ((MHSCH5-AMSU6).GT.THRESH) THEN
               IF (AMSU6.GT.238.0) THEN
C              TROPICS
                  IF (NIGHT) THEN
                     HIRSTHRS = 265.0
                     IF (SFCTYP.EQ.0) HIRSTHRS = 290.0
                  ELSE
                     HIRSTHRS = 288.0
                     IF (SFCTYP.EQ.0) HIRSTHRS = 290.0
                  END IF
                  IF (HIR8OBS.GT.HIRSTHRS) THEN
                     ISAEROSOL = .TRUE.
                     GO TO 1000
                  END IF 
               ELSE
C              NON-TROPICS
                  IF (NIGHT) THEN
                     HIRSTHRS = 265.0
                  ELSE
                     HIRSTHRS = 278.0
                  END IF
                  IF (HIR8OBS.GT.HIRSTHRS) THEN
                     ISAEROSOL = .TRUE.
                     GO TO 1000
                  END IF
               END IF
            END IF
         END IF
      END IF

C
 1000 CONTINUE


      RETURN
 
      END
