      SUBROUTINE OLRDVR2000(DSDR1T,ISSPOT,OLR1ST,HIROBS,ECOFSZ,ECOF37,
     +                  OLR,LC1,LC2,LC3,LC4,CCOLR,LIMTER,THEIGHT,ERSTAT)
      IMPLICIT NONE
C
C**********************************************************************
C
C   NAME- OLRDVR2000
C
C   LANGUAGE- VS FORTRAN       TYPE- SUBROUTINE   COMPUTER- CEMSCS
C
C   VERSION- 1.0   DATE- 09/07/95   PROGRAMMER- LEAH WILSON (HSTX)
C   VERSION- 1.1   DATE- 09/05/96   PROGRAMMER- LEAH WILSON (HSTX)
C   VERSION- 1.2   DATE- 02/24/97   PROGRAMMER- LEAH WILSON (HSTX)
C   VERSION- 3.0   DATE- 11/13/97   PROGRAMMER- BRIAN BARIL (HSTX)
C   VERSION- 3.1   DATE- 01/23/98   PROGRAMMER- BRIAN BARIL (RSTX)
C   VERSION- 3.2   DATE- 03/05/98   PROGRAMMER- LEAH WILSON (RSTX)
C   VERSION- 3.3   DATE- 07/14/00   PROGRAMMER- LEAH WILSON (RSTX)
C   VERSION- 3.4   DATE- 08/24/00   PROGRAMMER- LEAH WILSON (RSTX)
C   VERSION- 3.5   DATE- 09/13/00   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 3.6   DATE- 05/30/02   PORGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 1.3   DATE- 03/06/02   PROGRAMMER- RICKEY ROLLINS (CSC)
C   VERSION- 4.0    DATE- 02/27/03   PROGRAMMER- Rickey Rollins (CSC)
C   VERSION- 4.1   DATE- 12/29/04   PROGRAMMER- FRANK TILLEY (RAYTHEON)
C   VERSION- 4.2   DATE- 03/16/05   PROGRAMMER- FRANK TILLEY (RAYTHEON)
C   VERSION- 5.0   DATE- 02/24/05   PROGRAMMER- FRANK TILLEY (ERT)
C   VERSION- 5.1   DATE- 03/04/08   PROGRAMMER- FRANK TILLEY (IMSG)
C 
C   FUNCTION-*$LWILSO* DRIVER FOR COMPUTING THE OLR/LAYER COOLING
C                      RATE PARAMETERS FOR OUTPUT TO THE RTOVS DSDR1T.
C   VERSION- 1.1 REMOVE CALL TO OLRCOE, WHICH IS NOW CALLED IN SPGDVR.
C   VERSION- 1.2 ADD OLR,LC1-4 TO SUBROUTINE CALL, DUE TO REMOVAL FROM
C                /CLIMATE/.
C   VERSION- 3.0 MODIFICATIONS FOR INCLUSION INTO ATOVS.
C   VERSION- 3.1 COMMENTED OUT CLOUD CLEARED CALCULATIONS FOR OLR
C                SINCE THE SAME VALUES ARE OBTAINED IN NON CLOUD-
C                CLEARD.  
C   VERSION- 3.2 ADD ERSTAT TO OLRDVR AND RADCOL CALLS.
C   VERSION- 3.3 DO NOT COMPUTE LC1-3 FOR TERRAIN HEIGHTS GREATER 
C                THAN LIMITS SPECIFIED IN LIMTER.
C   VERSION- 3.4 LIMTER WAS EXPANDED TO 5 ELEMENTS, CHANGE IT TO 5
C                HERE FOR CONSISTENCY WITH CLDTOP.F AND WRTR1T.F.
C   VERSION- 3.5 CHANGED THE HIGH TERRAIN VALUE FOR LAYER COOLING RATES FROM
C                1000 TO 10000 SO THAT ACTUAL VALUES OF 1.0 ARE NOT
C                MISTAKEN FOR HIGH TERRAIN FOR LAYER COOLING RATES 1 - 3.
C                (WR#170)
C   VERSION- 3.6 INCREASED THE DIMENSION OF THE DSDR1T ARRAY FROM 284
C                TO 370 (WR #186/187).
C   VERSION- 1.3 DECLARED DSDR1T as I*2
C   VERSION- 4.0    DATE- 02/27/03   PROGRAMMER- Rickey Rollins (CSC)
C        Replace R4SPV equivalence test with ISR4SPV function   
C   VERSION- 4.1 ADDED LOGIC TO SKIP OVER SPOTS WHERE THE CLOUD AMOUNT
C                IS SET TO -777 (MISSING).
C   VERSION- 4.2 ADDED CALLING ARGUMENTS 'HIROBS' AND 'ECOFSZ' AND 
C                PASSED THEM INTO SUBROUTINE 'RADCOL' (WR #265).
C   VERSION- 5.0 CHANGED SUBROUTINE NAME TO REFLECT DSDR1T RECORD
C                LENGTH AND CHANGED INTERNALLY TO HANDLE A 1248-BYTE
C                DSDR1T RECORD LENGTH (WR #296)
C   VERSION- 5.1 CHANGED SUBROUTINE NAME TO REFLECT DSDR1T RECORD
C                LENGTH AND CHANGED INTERNALLY TO HANDLE A 2000-BYTE
C                DSDR1T RECORD LENGTH.
C
C   CALLING ARGUMENTS-
C   VARIABLE              TYPE    I/O    DESCRIPTION
C   --------              ----    ---    -----------
C   DSDR1T                 INT    I/O    ARRAY CONTAINING ONE
C                                        DSDR1T RECORD.
C   ISSPOT                 INT     I     SPOT NUMBER (1-9) BEING
C                                        PROCESSED.
C   OLR1ST                 LOG    I/O    SET TO TRUE IF THIS IS THE
C                                        FIRST CALL TO OLRDVR2000.
C   HIROBS                 REAL    I     NON LIMB-CORRECTED HIRS
C                                        BRIGHTNESS TEMPERATURES FOR
C                                        CHANNELS 1-19.
C   ECOFSZ                 REAL    I     VECTOR OF 5 ELLINGSON
C                                        COEFFICIENTS FOR USE WITH
C                                        NON LIMB-CORRECTED HIRS
C                                        BRIGHTNESS TEMPERATURES.
C   ECOF37                 REAL    I     VECTOR OF 5 ELLINGSON
C                                        COEFFICIENTS FOR USE WITH
C                                        LIMB-CORRECTED CLOUD-CLEARED HIRS
C                                        BRIGHTNESS TEMPERATURES.
C   OLR,LC1-4              REAL    O     STORES OUTGOING LONGWAVE
C                                        RADIATION AND 4 LAYER COOLING
C                                        RATES.
C   LIMTER                 REAL    I     STORES TERRAIN HEIGHT LIMITS
C                                        FOR LC1-4.  (DIM 5, ELEMENTS
C                                        4 AND 5 NOT USED IN THIS ROUTINE.)
C   THEIGHT                REAL    I     TERRAIN HEIGHT FOR INPUT SPOT.
C
C   LOCAL VARIABLES-
C      VARIABLE              TYPE      DESCRIPTION
C      --------              ----      -----------
C      IMISSC                 LOG      TRUE IF ANY REQUIRED CHANNEL IS
C                                      MISSING.
C      ICH                    INT      LOOP CONTROL VARIABLE.
C      OLRBT                  REAL      ARRAY (DIM 19) STORING BRIGHT-
C                                      NESS TEMPERATURES TO BE USED
C                                      BY SUBROUTINE RADCOL.
C
C   SUBPROGRAMS CALLED- RADCOL
C
C   COMMON AREAS- R1TDAT2000 CLIMATE SPVAL
C
C**********************************************************************
C
      INCLUDE 'R1TDAT2000'
      INCLUDE 'CLIMATE'
      INCLUDE 'SPVAL'
C
      INTEGER   R1TLEN
      PARAMETER (R1TLEN=2000)
      INTEGER*2   DSDR1T(R1TLEN/2)
      INTEGER   ISSPOT, ICH, ERSTAT, IWRD
      REAL   OLRBT(19),OLR, LC1, LC2, LC3, LC4, LIMTER(5), THEIGHT
      REAL   HIROBS(19), ECOFSZ(5), ECOF37(5),DLR, CCOLR, CCHIRBT(19)
      LOGICAL   OLR1ST, IMISSC
      LOGICAL   ISR4SPV
C
C   INITIALIZE OLR/LC VARIABLES FOR THE NON-CLOUD CLEARED CASE
C
      DO 50 IWRD = 1,19
         OLRBT(IWRD) = R4SPV
   50 CONTINUE
      OLR = R4SPV
      CCOLR = R4SPV
      LC1 = R4SPV
      LC2 = R4SPV
      LC3 = R4SPV
      LC4 = R4SPV
C
C   LOAD BRIGHTNESS TEMPERATURES INTO OLRBT ARRAY THEN CALL
C   RADCOL TO COMPUTE OLR/LC FOR THE NON-CLOUD CLEARED CASE
C
      IF(DSDR1T(CH1WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(1) = DSDR1T(CH1WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CH2WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(2) = DSDR1T(CH2WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CH3WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(3) = DSDR1T(CH3WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CH4WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(4) = DSDR1T(CH4WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CH5WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(5) = DSDR1T(CH5WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CH6WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(6) = DSDR1T(CH6WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CH7WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(7) = DSDR1T(CH7WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CH8WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(8) = DSDR1T(CH8WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CH9WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(9) = DSDR1T(CH9WRD(ISSPOT)) / 64.0
      IF(DSDR1T(C10WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(10) = DSDR1T(C10WRD(ISSPOT)) / 64.0
      IF(DSDR1T(C11WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(11) = DSDR1T(C11WRD(ISSPOT)) / 64.0
      IF(DSDR1T(C12WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(12) = DSDR1T(C12WRD(ISSPOT)) / 64.0
      IF(DSDR1T(C13WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(13) = DSDR1T(C13WRD(ISSPOT)) / 64.0
      IF(DSDR1T(C14WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(14) = DSDR1T(C14WRD(ISSPOT)) / 64.0
      IF(DSDR1T(C15WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(15) = DSDR1T(C15WRD(ISSPOT)) / 64.0
      IF(DSDR1T(C16WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(16) = DSDR1T(C16WRD(ISSPOT)) / 64.0
      IF(DSDR1T(C17WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(17) = DSDR1T(C17WRD(ISSPOT)) / 64.0
      IF(DSDR1T(C18WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(18) = DSDR1T(C18WRD(ISSPOT)) / 64.0
      IF(DSDR1T(C19WRD(ISSPOT)).NE.I2SPV)
     1   OLRBT(19) = DSDR1T(C19WRD(ISSPOT)) / 64.0

      IF(DSDR1T(CCH1WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(1) = DSDR1T(CCH1WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH2WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(2) = DSDR1T(CCH2WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH3WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(3) = DSDR1T(CCH3WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH4WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(4) = DSDR1T(CCH4WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH5WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(5) = DSDR1T(CCH5WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH6WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(6) = DSDR1T(CCH6WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH7WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(7) = DSDR1T(CCH7WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH8WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(8) = DSDR1T(CCH8WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH9WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(9) = DSDR1T(CCH9WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH10WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(10) = DSDR1T(CCH10WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH11WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(11) = DSDR1T(CCH11WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH12WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(12) = DSDR1T(CCH12WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH13WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(13) = DSDR1T(CCH13WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH14WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(14) = DSDR1T(CCH14WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH15WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(15) = DSDR1T(CCH15WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH16WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(16) = DSDR1T(CCH16WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH17WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(17) = DSDR1T(CCH17WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH18WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(18) = DSDR1T(CCH18WRD(ISSPOT)) / 64.0
      IF(DSDR1T(CCH19WRD(ISSPOT)).NE.I2SPV)
     +   CCHIRBT(19) = DSDR1T(CCH19WRD(ISSPOT)) / 64.0
C
C   IF THERE ARE ANY MISSING BRIGHTNESS TEMPERATURES, DO NOT CALCULATE
C   THE OLR/LC PARAMETERS
C
      IMISSC = .FALSE.
      DO 100 ICH=1,19
         IF(ISR4SPV(OLRBT(ICH))) IMISSC = .TRUE.
  100 CONTINUE
C
C   IF THE CLOUD AMOUNT IS SET TO MISSING, DO NOT CALCULATE THE
C   OLR/LC PARAMETERS.
C
      IF (DSDR1T(CLAWRD(ISSPOT)) .EQ. I2SPV) IMISSC = .TRUE.

      IF(.NOT.IMISSC) CALL RADCOL(OLRBT,HIROBS,CCHIRBT,ECOFSZ,ECOF37,OLR1ST,
     +                            OLR,LC1,LC2,LC3,LC4,CCOLR,ERSTAT)
C
C   STORE OLR AND LC1-4 AT EACH SPOT
C
      IF(.NOT. ISR4SPV(OLR)) DSDR1T(NOLWRD(ISSPOT)) = NINT(OLR*10.0)

C
C   DO NOT COMPUTE LC1-3 IF TERRAIN HEIGHT EXCEEDS LIMITS
C
C   CHANGED THE HIGH TERRAIN VALUE FROM 1000 TO 10000 ASA (9/13/01)
C
      IF(.NOT. ISR4SPV(LC1)) THEN
         IF(THEIGHT.GT.LIMTER(1)) THEN
            DSDR1T(CL1WRD(ISSPOT)) = 10000
            LC1 = 10000.0
         ELSE
            DSDR1T(CL1WRD(ISSPOT)) = NINT(LC1*1000.0)
         ENDIF
      ENDIF
      IF(.NOT. ISR4SPV(LC2)) THEN
         IF(THEIGHT.GT.LIMTER(2)) THEN
            DSDR1T(CL2WRD(ISSPOT)) = 10000
            LC2 = 10000.0
         ELSE
            DSDR1T(CL2WRD(ISSPOT)) = NINT(LC2*1000.0)
         ENDIF
      ENDIF
      IF(.NOT. ISR4SPV(LC3)) THEN
         IF(THEIGHT.GT.LIMTER(3)) THEN
            DSDR1T(CL3WRD(ISSPOT)) = 10000
            LC3 = 10000.0
         ELSE
            DSDR1T(CL3WRD(ISSPOT)) = NINT(LC3*1000.0)
         ENDIF
      ENDIF
      IF(.NOT. ISR4SPV(LC4)) DSDR1T(CL4WRD(ISSPOT)) = NINT(LC4*1000.0)
C
      RETURN
      END
