      SUBROUTINE RETCLS(LAT,TERAIN,SOLZEN,OPCLS)
      IMPLICIT NONE
C***********************************************************************
C
C   NAME- RETCLS
C
C   LANGUAGE- VS FORTRAN   TYPE- SUBROUTINE      COMPUTER- HDS 9000
C
C   VERSION- 1.0    DATE- 7/19/93    PROGRAMMER-  CARLA A. NEIGH, SMSRC
C   VERSION- 2.0    DATE- 5/06/96    PROGRAMMER-  FRANK TILLEY,   SMSRC
C     FOR REHOSTING TO THE CRAY, CHANGED ALL R*4 DECLARATIONS TO REAL
C     AND ALL I*4 DECLARATIONS TO INTEGER.
C   VERSION- 2.1    DATE-10/25/01    PROGRAMMER-  M.P. FERGUSON, RITSS
C     BIN DESIGNATIONS MODIFIED SO THAT ICE AND COAST FOV WILL BE CORRECTLY
C     CATEGORIZED AS LAND, NOT SEA.
C
C   FUNCTION-  THIS SUBROUTINE RETURNS THE RETRIEVAL CLASS NUMBER FOR
C              A RETRIEVAL DATA POINT BASED ON THE LATITUDE, LAND/SEA,
C              AND DAY/NIGHT.
C
C   CALLING SEQUENCE PARAMETERS-
C   NAME    TYPE   I/O   DESCRIPTION
C   ----    ----   ---   -----------
C   LAT     REAL    I    LATITUDE OF THE RETRIEVAL DATA POINT.
C   TERAIN  INT     I    TERRAIN FLAG FOR THE RETRIEVAL DATA POINT.
C   SOLZEN  REAL    I    SOLAR ZENITH ANGLE FOR THE RETRIEVAL DATA
C                        POINT.
C   OPCLS   INT     O    THE RETRIEVAL OPERATOR CLASS NUMBER.
C
C   LOCAL PARAMETERS-
C   NAME    TYPE   DESCRIPTION
C   ----    ----   -----------
C   OVRSEA  L*4    LOGICAL FLAG INDICATING WHETHER DATA POINT IS
C                  OVER LAND OR SEA (TRUE = OVER SEA, FALSE = OVER
C                  LAND).
C   DAYTIM  L*4    LOGICAL FLAG INDICATING WHETHER DATA POINT IS
C                  IN DAYTIME OR NIGHTTIME (TRUE = DAYTIME, FALSE =
C                  NIGHTTIME).
C
C***********************************************************************
C
      INTEGER   TERAIN, OPCLS, ISEA, IDAY
      REAL   LAT, SOLZEN
C
      LOGICAL*4 OVRSEA, DAYTIM
C
C   SET THE LOGICAL FLAGS FOR LAND/SEA AND DAY/NIGHT.
C
      IF (TERAIN .NE. 0) THEN
         OVRSEA = .FALSE.
         ISEA = 1
      ELSE
         OVRSEA = .TRUE.
         ISEA = 0
      ENDIF
C
      IF (SOLZEN .GT. 90.5) THEN
         DAYTIM = .FALSE.
         IDAY = 1
      ELSE
         DAYTIM = .TRUE.
         IDAY = 0
      ENDIF
C
C   DETERMINE THE RETRIEVAL OPERATOR CLASS NUMBER.  THE CLASS NUMBERS
C   ARE AS FOLLOWS:
C
C   LAT ZONE           SEA        LAND-DAY          LAND-NIGHT
C   --------           ---        --------          ----------
C   60 N - 90 N         1            10                 17
C   45 N - 60 N         2            11                 18
C   30 N - 45 N         3            12                 19
C   15 N - 30 N         4            13                 20
C   15 N - 15 S         5             5                  5
C   15 S - 30 S         6            14                 21
C   30 S - 45 S         7            15                 22
C   45 S - 60 S         8             8                  8
C   60 S - 90 S         9            16                 23
C
C
      IF ((LAT .LE. 90.0) .AND. (LAT .GT. 60.0)) THEN
         IF (OVRSEA) THEN
            OPCLS = 1
         ELSE
            IF (DAYTIM) THEN
               OPCLS = 10
            ELSE
               OPCLS = 17
            ENDIF
         ENDIF
      ELSEIF ((LAT .LE. 60.0) .AND. (LAT .GT. 45.0)) THEN
         IF (OVRSEA) THEN
            OPCLS = 2
         ELSE
            IF (DAYTIM) THEN
               OPCLS = 11
            ELSE
               OPCLS = 18
            ENDIF
         ENDIF
      ELSEIF ((LAT .LE. 45.0) .AND. (LAT .GT. 30.0)) THEN
         IF (OVRSEA) THEN
            OPCLS = 3
         ELSE
            IF (DAYTIM) THEN
               OPCLS = 12
            ELSE
               OPCLS = 19
            ENDIF
         ENDIF
      ELSEIF ((LAT .LE. 30.0) .AND. (LAT .GT. 15.0)) THEN
         IF (OVRSEA) THEN
            OPCLS = 4
         ELSE
            IF (DAYTIM) THEN
               OPCLS = 13
            ELSE
               OPCLS = 20
            ENDIF
         ENDIF
      ELSEIF ((LAT .LE. 15.0) .AND. (LAT .GT. -15.0)) THEN
         OPCLS = 5
      ELSEIF ((LAT .LE. -15.0) .AND. (LAT .GT. -30.0)) THEN
         IF (OVRSEA) THEN
            OPCLS = 6
         ELSE
            IF (DAYTIM) THEN
               OPCLS = 14
            ELSE
               OPCLS = 21
            ENDIF
         ENDIF
      ELSEIF ((LAT .LE. -30.0) .AND. (LAT .GT. -45.0)) THEN
         IF (OVRSEA) THEN
            OPCLS = 7
         ELSE
            IF (DAYTIM) THEN
               OPCLS = 15
            ELSE
               OPCLS = 22
            ENDIF
         ENDIF
      ELSEIF ((LAT .LE. -45.0) .AND. (LAT .GT. -60.0)) THEN
         OPCLS = 8
      ELSEIF ((LAT .LE. -60.0) .AND. (LAT .GT. -90.0)) THEN
         IF (OVRSEA) THEN
            OPCLS = 9
         ELSE
            IF (DAYTIM) THEN
               OPCLS = 16
            ELSE
               OPCLS = 23
            ENDIF
         ENDIF
      ENDIF

      RETURN
      END


