      SUBROUTINE CLCDBV(ERSTAT) 
      IMPLICIT NONE
C
C***********************************************************************
C
C   NAME- CLCDBV
C
C   LANGUAGE- FORTRAN 77      TYPE- SUBROUTINE      COMPUTER- CRAY J916
C
C   VERSION- 1.0      DATE- 9/11/91  PROGRAMMER- CARLA NEIGH (SMSRC)
C   VERSION- 2.0      DATE-12/01/94  PROGRAMMER- SURYA JANDHYALA(SMSRC)
C     ATOVS-43  ADDED INCLUDE RETPARM. REPLACED HARD CODE WITH
C               A PARAMETER.
C   VERSION- 3.0      DATE- 2/23/96  PROGRAMMER- ALEX POZDENYAK (FDC)
C     MODIFIED TO RUN ON THE CRAY.  REPLACED I*4 WITH INT.
C   VERSION- 3.1      DATE- 01/15/97  PROGRAMMER- TIM GARDNER (HSTX)  	
C   VERSION- 3.2      DATE- 07/24/97  PROGRAMMER- LEAH WILSON (HSTX)  	
C   VERSION- 3.3      DATE- 11/18/97  PROGRAMMER- LEAH WILSON (HSTX)  	
C
C   FUNCTION- THIS SUBROUTINE GETS THE CDB VALUES USED FOR THE
C             ONLINE RADIANCE CLASSIFICATION FOR SPGS AND STORES
C             THEM IN THE COMMON BLOCK CLASIF.
C
C   VERSION 3.1- ADDED EIGVECTOR DATE THRESHOLD AND MAXIMUM NUMBER
C                OF EIGENVECTORS.
C   VERSION 3.2- REPLACE CDB UTILITIES WITH NEW 8-BYTE UTILITIES.
C   VERSION 3.3- ADD LATEST RTOVS UPGRADES.
C
C   FILES-
C     DSN OR DESCRIPTIVE TITLE  I/O  UNIT    FUNCTIONAL DECRIPTION
C     ------------------------  ---  ----    ---------------------
C     CDB                        I   CDBUNT  COEFFICIENT DATA BASE
C
C   CALLING SEQUENCE PARAMETERS-
C
C   NAME    TYPE  I/O    DESCRIPTION
C   ----    ----  ---    -----------
C   ERSTAT   INT   O     STATUS CODE RETURNED FROM ROUTINE
C                        INDICATING ERRORS IN OBTAINING
C                        CDB VALUES
C                        = 0 IF NO ERROR ENCOUNTERED,  99 IF
C                        ERROR ENCOUNTERED IN ACCESSING CDB,
C
C   COMMON AREA PARAMETERS- CLASIF, SPVAL, RETPARM, SPGUNT
C
C   SUBPROGRAMS CALLED-  REALCOEF, INTCOEF
C
C   EXIT STATES-
C     CDBST > 0   : ERROR ENCOUNTERED IN ACCESSING CDB VALUES
C     THE ERROR CODE RETURNED IS THE ERROR CODE FROM THE CDB ACCESS
C     UTILITY.
C
C   COMMENTS- THIS SUBROUTINE ASSUMES THAT THE OPERATIONS TO OPEN AND
C             CLOSE THE CDB ARE DONE ELSEWHERE IN PROCESSING.
C
C***********************************************************************
C
      INCLUDE 'RETPARM'
      INCLUDE 'CLASIF'
      INCLUDE 'SPVAL'
      INCLUDE 'SPGUNT'
C
      INTEGER   CDBST, I,J,K,L,CHAVS1(2), ERSTAT
      REAL CHAVSB(NUMCHN),CHAVSA(NUMCHN,NUMCHN)
C
C   INITIALIZE CDB STATUS
C
      ERSTAT = 0
C
C   GET EIGENVECTORS FOR PATHS 1, 2 AND 3.
C   (NOTE:  PATH 1=CLEAR/CLOUD-CLEARED, PATH 2=CLOUDY, PATH 3=NO-HIRS)
C
      CALL REALCOEF(CDBUNT,'CLASSIFY','EIGVECTR','CLEAR   ',NUMCHN,
     1              NUMCHN,0,0,CHAVSA,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
         DO J=1,NUMCHN
            P1EIGV(I,J,1) = CHAVSA(I,J)
         END DO
      END DO
      CALL REALCOEF(CDBUNT,'CLASSIFY','EIGVECTR','LCLEAR  ',NUMCHN,
     1              NUMCHN,0,0,CHAVSA,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
         DO J=1,NUMCHN
            P1EIGV(I,J,2) = CHAVSA(I,J)
         END DO
      END DO
C
      CALL REALCOEF(CDBUNT,'CLASSIFY','EIGVECTR','CLOUDY  ',NUMCHN,
     1              NUMCHN,0,0,CHAVSA,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
         DO J=1,NUMCHN
            P2EIGV(I,J,1) = CHAVSA(I,J)
         END DO
      END DO
      CALL REALCOEF(CDBUNT,'CLASSIFY','EIGVECTR','LCLOUDY ',NUMCHN,
     1              NUMCHN,0,0,CHAVSA,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
         DO J=1,NUMCHN
            P2EIGV(I,J,2) = CHAVSA(I,J)
         END DO
      END DO
C
      CALL REALCOEF(CDBUNT,'CLASSIFY','EIGVECTR','NOHIRS  ',NUMCHN,
     1              NUMCHN,0,0,CHAVSA,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
         DO J=1,NUMCHN
            P3EIGV(I,J,1) = CHAVSA(I,J)
         END DO
      END DO
      CALL REALCOEF(CDBUNT,'CLASSIFY','EIGVECTR','LNOHIRS ',NUMCHN,
     1              NUMCHN,0,0,CHAVSA,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
         DO J=1,NUMCHN
            P3EIGV(I,J,2) = CHAVSA(I,J)
         END DO
      END DO
C
C   GET EIGENVALUES FOR PATHS 1, 2 AND 3.
C
      CALL REALCOEF(CDBUNT,'CLASSIFY','EIGNVALU','CLEAR   ',NUMCHN,0,
     1              0,0,CHAVSB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
         P1EVAL(I,1) = CHAVSB(I)
      END DO
      CALL REALCOEF(CDBUNT,'CLASSIFY','EIGNVALU','LCLEAR  ',NUMCHN,0,
     1              0,0,CHAVSB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
         P1EVAL(I,2) = CHAVSB(I)
      END DO
C
      CALL REALCOEF(CDBUNT,'CLASSIFY','EIGNVALU','CLOUDY  ',NUMCHN,0,
     1              0,0,CHAVSB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
         P2EVAL(I,1) = CHAVSB(I)
      END DO
      CALL REALCOEF(CDBUNT,'CLASSIFY','EIGNVALU','LCLOUDY ',NUMCHN,0,
     1              0,0,CHAVSB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
         P2EVAL(I,2) = CHAVSB(I)
      END DO
C
      CALL REALCOEF(CDBUNT,'CLASSIFY','EIGNVALU','NOHIRS  ',NUMCHN,0,
     1              0,0,CHAVSB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
         P3EVAL(I,1) = CHAVSB(I)
      END DO
      CALL REALCOEF(CDBUNT,'CLASSIFY','EIGNVALU','LNOHIRS ',NUMCHN,0,
     1              0,0,CHAVSB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
         P3EVAL(I,2) = CHAVSB(I)
      END DO
C
C
C   GET CLASS SUBINTERVAL BOUNDS FOR PATHS 1, 2 AND 3.
C
      CALL REALCOEF(CDBUNT,'CLASSIFY','CLBOUNDS','CLEAR   ',16,4,0,
     1              0,P1CLBN,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      CALL REALCOEF(CDBUNT,'CLASSIFY','CLBOUNDS','CLOUDY  ',16,4,0,
     1              0,P2CLBN,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      CALL REALCOEF(CDBUNT,'CLASSIFY','CLBOUNDS','NOHIRS  ',16,4,0,
     1              0,P3CLBN,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
C
C   GET CLASS LOOKUP TABLES FOR PATHS 1, 2 AND 3.
C
      CALL INTCOEF(CDBUNT,'CLASSIFY','CLASSTBL','CLEAR   ',16,4,2,
     1             2,P1CLTB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      CALL INTCOEF(CDBUNT,'CLASSIFY','CLASSTBL','CLOUDY  ',16,4,2,
     1             2,P2CLTB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      CALL INTCOEF(CDBUNT,'CLASSIFY','CLASSTBL','NOHIRS  ',16,4,2,
     1             2,P3CLTB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
C
C   GET NUMBER OF CLASS INTERVALS FOR PATHS 1, 2 AND 3.
C
      CALL INTCOEF(CDBUNT,'CLASSIFY','CLINTRVL','CLEAR   ',4,0,0,
     1             0,P1NINT,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      CALL INTCOEF(CDBUNT,'CLASSIFY','CLINTRVL','CLOUDY  ',4,0,0,
     1             0,P2NINT,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      CALL INTCOEF(CDBUNT,'CLASSIFY','CLINTRVL','NOHIRS  ',4,0,0,
     1             0,P3NINT,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
C
C   GET CHANNEL AVERAGES FOR PATHS 1, 2 AND 3.
C
      CALL REALCOEF(CDBUNT,'CLASSIFY','CHANAVG ','CLEAR   ',NUMCHN,0,
     1              0,0,CHAVSB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
        P1CHAV(I,1) = CHAVSB(I)
      END DO
      CALL REALCOEF(CDBUNT,'CLASSIFY','CHANAVG ','LCLEAR  ',NUMCHN,0,
     1              0,0,CHAVSB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
        P1CHAV(I,2) = CHAVSB(I)
      END DO
C
      CALL REALCOEF(CDBUNT,'CLASSIFY','CHANAVG ','CLOUDY  ',NUMCHN,0,
     1              0,0,CHAVSB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
        P2CHAV(I,1) = CHAVSB(I)
      END DO
      CALL REALCOEF(CDBUNT,'CLASSIFY','CHANAVG ','LCLOUDY ',NUMCHN,0,
     1              0,0,CHAVSB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
        P2CHAV(I,2) = CHAVSB(I)
      END DO
C
      CALL REALCOEF(CDBUNT,'CLASSIFY','CHANAVG ','NOHIRS  ',NUMCHN,0,
     1              0,0,CHAVSB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
        P3CHAV(I,1) = CHAVSB(I)
      END DO
      CALL REALCOEF(CDBUNT,'CLASSIFY','CHANAVG ','LNOHIRS ',NUMCHN,0,
     1              0,0,CHAVSB,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      DO I=1,NUMCHN
        P3CHAV(I,2) = CHAVSB(I)
      END DO
C
C   GET AVERAGE FLAGS FOR PATHS 1, 2 AND 3.
C
      CALL INTCOEF(CDBUNT,'CLASSIFY','AVGFLAG ','CLEAR   ',2,0,0,
     1             0,P1AVFL,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      CALL INTCOEF(CDBUNT,'CLASSIFY','AVGFLAG ','CLOUDY  ',2,0,0,
     1             0,P2AVFL,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      CALL INTCOEF(CDBUNT,'CLASSIFY','AVGFLAG ','NOHIRS  ',2,0,0,
     1             0,P3AVFL,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
C
C   GET EIGENVECTOR FLAGS FOR PATHS 1, 2 AND 3.
C
      CALL INTCOEF(CDBUNT,'CLASSIFY','EIGFLAG ','CLEAR   ',2,0,0,
     1             0,CHAVS1,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      P1EGFL(1,1) = CHAVS1(1)
      P1EGFL(2,1) = CHAVS1(2)
      CALL INTCOEF(CDBUNT,'CLASSIFY','EIGFLAG ','LCLEAR  ',2,0,0,
     1             0,CHAVS1,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      P1EGFL(1,2) = CHAVS1(1)
      P1EGFL(2,2) = CHAVS1(2)
C
      CALL INTCOEF(CDBUNT,'CLASSIFY','EIGFLAG ','CLOUDY  ',2,0,0,
     1             0,CHAVS1,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      P2EGFL(1,1) = CHAVS1(1)
      P2EGFL(2,1) = CHAVS1(2)
      CALL INTCOEF(CDBUNT,'CLASSIFY','EIGFLAG ','LCLOUDY ',2,0,0,
     1             0,CHAVS1,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      P2EGFL(1,2) = CHAVS1(1)
      P2EGFL(2,2) = CHAVS1(2)
C
      CALL INTCOEF(CDBUNT,'CLASSIFY','EIGFLAG ','NOHIRS  ',2,0,0,
     1             0,CHAVS1,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      P3EGFL(1,1) = CHAVS1(1)
      P3EGFL(2,1) = CHAVS1(2)
      CALL INTCOEF(CDBUNT,'CLASSIFY','EIGFLAG ','LNOHIRS ',2,0,0,
     1             0,CHAVS1,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      P3EGFL(1,2) = CHAVS1(1)
      P3EGFL(2,2) = CHAVS1(2)
C
C   GET NUMBER OF EIGS TO USE (FOR CLEAR OR CLOUDY), DATE DELIMITER,
C   AND NUMBER OF PATHS.
C
      CALL INTCOEF(CDBUNT,'CLASSIFY','EIGNUM  ','CLEAR   ',1,0,0,
     +             0,EIGNM1,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      CALL INTCOEF(CDBUNT,'CLASSIFY','EIGNUM  ','LCLEAR  ',1,0,0,
     +             0,EIGNM3,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      CALL INTCOEF(CDBUNT,'CLASSIFY','EIGDATE ','LIMIT   ',1,0,0,
     +             0,EIGDAT,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      CALL INTCOEF(CDBUNT,'CLASSIFY','EIGNUM  ','CLOUDY  ',1,0,0,
     +             0,EIGNM2,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      CALL INTCOEF(CDBUNT,'CLASSIFY','EIGNUM  ','LCLOUDY ',1,0,0,
     +             0,EIGNM4,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      CALL INTCOEF(CDBUNT,'CLASSIFY','EIGNUM  ','NPATHS  ',1,0,0,
     +             0,NPATH,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      CALL INTCOEF(CDBUNT,'CLASSIFY','EIGNUM  ','NTERRA  ',1,0,0,
     +             0,NTERR,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 800
      GO TO 900
C
C  ERROR GETTING CDB COEFFICIENT.
C
 800  ERSTAT=99
C
 900  RETURN
      END
