      SUBROUTINE OLRCOE(ERSTAT)
      IMPLICIT NONE
C
C***********************************************************************
C
C   NAME- OLRCOE
C
C   LANGUAGE- VS FORTRAN      TYPE- SUBROUTINE      COMPUTER- CEMSCS
C
C   VERSION- 1.0      DATE- 09/05/96   PROGRAMMER- LEAH WILSON (HSTX)
C   VERSION- 3.0      DATE- 01/30/98   PROGRAMMER- BRIAN BARIL (RSTX)
C   VERSION- 3.1      DATE- 03/05/98   PROGRAMMER- LEAH WILSON (RSTX)
C
C   FUNCTION- THIS SUBROUTINE GETS THE CDB VALUES USED FOR OLR, DLR
C             AND LAYER COOLING RATES AND STORES THEM IN COMMON
C             BLOCK /CLIMATE/.
C
C   VERSION- 3.0 REPLACED CALLS TO RGTCDB WITH REALCOEF. REMOVED 
C            INT *4. REMOVED ERROR MESSAGES WHICH ARE NOW HANDLED 
C            IN THE CDB
C   VERSION- 3.1 CHANGED BANDCORR.HIRS CALL DUE TO CDB MODS.  ADD
C                KIDS MESSAGING TO EXPLAIN THAT MISSING OLR COEFFS
C                ARE NOT FATAL TO SPGDVR, BUT THAT NO OLR,LC1-4  CAN
C                BE CALCULATED.
C
C   FILES-
C     DSN OR DESCRIPTIVE TITLE  I/O  UNIT  FUNCTIONAL DECRIPTION
C     ------------------------  ---  ----  ---------------------
C     NSS. ... . ... .CDB        I  CDBUNT COEFFICIENT DATA BASE
C
C   CALLING SEQUENCE PARAMETERS-
C
C   NAME    TYPE  I/O    DESCRIPTION
C   ----    ----  ---    -----------
C   CDBST   I      O     STATUS CODE RETURNED FROM ROUTINE
C                        INDICATING ERRORS IN OBTAINING AND
C                        CHECKING CDB VALUES
C                        = 0 IF NO ERROR ENCOUNTERED, <> 0 IF
C                        ERROR ENCOUNTERED
C
C   LOCAL PARAMETERS-
C   NAME          TYPE     DESCRIPTION
C   ----          ----     -----------
C   KMSG          CH*100   KIDS MESSAGE BUFFER
C
C   COMMON AREAS - SPGUNT, CLIMATE
C
C   SUBPROGRAMS CALLED- REALCOEF, KIDS
C
C   EXIT STATES-
C      CDBST <> 0 : ERROR ENCOUNTERED IN PROCESSING OR CHECKING
C                   CDB VALUES
C
C   COMMENTS- THIS SUBROUTINE ASSUMES THAT THE OPERATIONS SETCDB AND
C             CLOCDB ARE DONE ELSEWHERE IN PROCESSING
C
C***********************************************************************
C
      REAL      DUMMY1(20),DUMMY2(20) 
      INTEGER   CDBST, ERSTAT, IDUM
      CHARACTER*100 KMSG
C
      INCLUDE 'SPGUNT'
      INCLUDE 'CLIMATE'
C
C   INITIALIZE CDB STATUS
C
      CDBST = 0
C
C   GET HIRS CENTRAL FREQUENCIES
C
      CALL REALCOEF(CDBUNT,'INSTRMNT','BANDCENT','HIRS    ',20,0,0,0,
     1              WVNO,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
C   GET HIRS BAND CORRECTION COEFFICIENTS
C
      CALL REALCOEF(CDBUNT,'INSTRMNT','BANDCORR','HIRCORRB',20,0,0,0,
     1              DUMMY1,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
      CALL REALCOEF(CDBUNT,'INSTRMNT','BANDCORR','HIRCORRC',20,0,0,0,
     1              DUMMY2,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
      DO IDUM=1,20
         BNDCOR(1,IDUM) = DUMMY1(IDUM)
         BNDCOR(2,IDUM) = DUMMY2(IDUM)
      ENDDO
C
C   GET INTERCEPTS FOR OLR, DLR, AND 4 LAYER COOLING RATES
C
      CALL REALCOEF(CDBUNT,'RETRIEVE','CLIMATE ','INTRCEPT',6,0,0,0,
     1              LWRINT,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
C   GET REGRESSION COEFFICIENTS FOR OLR, DLR, AND 4 LAYER COOLING RATES
C
      CALL REALCOEF(CDBUNT,'RETRIEVE','CLIMATE ','REGRESSC',6,19,0,0,
     1              LWRREG,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
C   GET BRIGHTNESS TEMPERATURE CORRECTION INTERCEPTS
C
      CALL REALCOEF(CDBUNT,'RETRIEVE','CLIMATE ','BTCORRIN',6,19,0,0,
     1              LWRBTI,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
C   GET BRIGHTNESS TEMPERATURE CORRECTION SLOPES
C
      CALL REALCOEF(CDBUNT,'RETRIEVE','CLIMATE ','BTCORRSL',6,19,0,0,
     1              LWRBTS,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
C   GET CHANNEL USAGE FLAGS FOR EACH PARAMETER
C
      CALL INTCOEF(CDBUNT,'RETRIEVE','CLIMATE ','CHUSAGE ',6,19,0,0,
     1              LWRCHN,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
      GO TO 999
C
  990 KMSG(1:50)='NOTE: Missing OLR CDB coefficients - not fatal to '
      KMSG(51:100)='SPGDVR, but no OLR & LC1-4 values will be made. '
      print *,KMSG
c     CALL KIDS(KUNIT,SUBNAM,0,KMSG,0)
c     ERSTAT = CDBST
C
  999 RETURN
      END
