      SUBROUTINE INCDBV(CDBUNT,CDBST)
      IMPLICIT NONE
C
C***********************************************************************
C
C   NAME- INCDBV
C
C   LANGUAGE- VS FORTRAN      TYPE- SUBROUTINE      COMPUTER- CRAY J916
C
C   VERSION- 1.0    DATE- 03/19/91   PROGRAMMER- CARLA NEIGH(SMSRC)
C   VERSION- 2.0    DATE- 09/15/91   PROGRAMMER- SURYA JANDHYALA(SMSRC)
C     XATOV-46  REPLACED MSU AND SSU VALUES WITH AMSU-A AND AMSU-B
C               VALUES. ADDED INCLUDE FILE INPARM.
C   VERSION- 2.1    DATE- 04/11/95   PROGRAMMER- LI LU (SMSRC)
C     ATOVS-82: CALLS TO CHARCOEF ARE ADDED FOR GETTING 1B* QUALITY
C               FLAGS OF HIRS, AMSU-A, AMSU-B, AND AVHRR. NUMBER
C               OF NON-BLANK VALUES FOR EACH FLAG ARE COMPUTED.
C   VERSION- 2.2    DATE- 08/24/95   PROGRAMMER- LI LU (SMSRC)
C     ATOVS-175: A CALL TO INTCOEF IS ADDED FOR COEFFICIENT
C		 'INPUT   .INSTRMNT.INITCNFG'. THE COEFFICIENT VALUE
C		 IS PLACED IN /INPCDB/:INTCFG. REMOVE FTLHIR, FTLAMA,
C		 FTLAMB, FTLGAC, SPSHIR, SPSAMA, SPSAMB, AND SPSGAC.
C		 CALLS TO INTCOEF ARE ALSO ADDED FOR ARRAYS CONTAINING
C		 ORDERS IN WHICH THE QC FLAG NAMES ARE TO BE USED,
C		 FOR TOTAL NUMBER OF FATAL AND SUSPECT QC FLAGS, AND
C		 FOR THE NUMBER OF FATAL FLAGS, FOR EACH INSTRUMENT.
C   VERSION- 3.0    DATE- 06/03/96   PROGRAMMER- TIM GARDNER (HSTX)
C   VERSION- 3.1    DATE- 07/25/97   PROGRAMMER- LEAH WILSON (HSTX)
C   VERSION- 3.2    DATE- 03/10/00   PROGRAMMER- LEAH WILSON (RAYTHEON)
C   VERSION- 3.3    DATE- 01/26/04   PROGRAMMER- FRANK TILLEY (RAYTHEON)
C   VERSION- 3.4    DATE- 05/25/06   PROGRAMMER- FRANK TILLEY (IMSG)
C
C   FUNCTION- THIS SUBROUTINE GETS THE CDB VALUES USED FOR 1B DATA
C             INPUT FOR SPGS AND STORES THEM IN COMMON INPCDB.
C
C   VERSION 3.0- DOCUMENTATION AND SYNTAX CHANGES FOR ATOVS BASELINE
C                ON THE CRAY.
C   VERSION 3.1- REPLACE CDB UTILITIES WITH NEW 8-BYTE UTILITIES. REMOVE
C                INCDB$. COMMENT OUT CDB CALLS FOR AMSU-B.  ADD CALLS
C                FOR HRSHAPE AND GAPMAX.
C   VERSION 3.2- REMOVE HRFLAG, HRSHAPE, GAPMAX, MAFLAG, HFGSEQ, AFGSEQ, 
C                NHRFLG, NMAFLG, HFTFLG, AFTFLG
C   VERSION 3.3- ADDED CALLS FOR AMSU-B DATA.
C   VERSION 3.4- REMOVED GCFLAG, HSCNTL, ASCNTL, GSCNTL, BSCNTL, AND IDSAT,
C                ALL OF WHICH WERE UNUSED.
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   CDBUNT  INT    I     CDB UNIT NUMBER
C   CDBST   INT    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 IN ACCESSING CDB,
C
C   COMMON AREA PARAMETERS- INPCDB, INPARM
C
C   LOCAL VARIABLES
C   NAME    TYPE  DESCRIPTION
C   ----    ----  -----------
C   I       INT   DO LOOP VARIABLE.
C
C   SUBPROGRAMS CALLED-  REALCOEF, INTCOEF, CHARCOEF
C
C   FUNCTIONS USED- PLKRAD
C
C   EXIT STATES-
C     CDBST = 99  : ERROR ENCOUNTERED IN ACCESSING CDB VALUES.
C                   THE CALLING ROUTINE CONTROLS ERROR HANDLING BASED
C                   ON THE VALUE OF CDBST.
C
C   COMMENTS- THIS SUBROUTINE ASSUMES THAT THE OPERATIONS TO OPEN/CLOSE
C             A CDB ARE DONE ELSEWHERE IN PROCESSING.
C
C***********************************************************************
C
C
      INTEGER CDBUNT, CDBST, I
      REAL PLKRAD
C
      INCLUDE 'INPARM'
      INCLUDE 'INPCDB'
C
C   INITIALIZE VARIABLES.
C
      CDBST = 0
C
C   GET SPACECRAFT ID.
C
      CALL INTCOEF(CDBUNT,'GOODIES ','SPCECRFT','ID      ',1,0,0,0,
     1             SPCRID,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
C   GET FLEMING'S C1 AND C2 RADIANCE ADJUSTMENT VALUES FOR HIRS.
C
      CALL REALCOEF(CDBUNT,'INSTRMNT','RADADJ  ','HIRS    ',2,HNCHAN,
     1              0,0,HIRADJ,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
C   GET SCAN BIAS CORRECTION COEFFICIENTS FOR AMSU-A.
C
      CALL REALCOEF(CDBUNT,'CALIBR8 ','AMSUA   ','SCANBIAS',30,ANCHAN,
     1              0,0,ASBCOR,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
C   GET HIRS CHANNEL 1 COUNT BIAS CORRECTION.
C
      CALL INTCOEF(CDBUNT,'CALIBR8 ','HIRS    ','CNTBIAS ',1,0,0,0,
     1             HCNTBS,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
C   GET LIMIT OF ADJACENT GOOD LINES IN A DATA FRAME FOR HIRS, AMSU-A
C   AND AMSU-B.
C
      CALL INTCOEF(CDBUNT,'INPUT   ','SCANLINE','LIMGDHIR',1,0,0,
     1            0,HLINLM,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
      CALL INTCOEF(CDBUNT,'INPUT   ','SCANLINE','LIMGDAMA',1,0,0,
     1            0,ALINLM,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
C   GET UPPER LIMITS AND LOWER LIMITS FOR COUNTS VALUES FOR HIRS, AMSU-A
C   AMSU-B, AND AVHRR.
C
      CALL REALCOEF(CDBUNT,'INPUT   ','UPPERLIM','HIRSBT  ',HNCHAN,
     1              0,0,0,HMAXBT,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
      CALL REALCOEF(CDBUNT,'INPUT   ','UPPERLIM','AMSUABT ',ANCHAN,
     1              0,0,0,AMAXBT,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
      CALL REALCOEF(CDBUNT,'INPUT   ','UPPERLIM','AMSUBBT ',BNCHAN,
     1              0,0,0,BMAXBT,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
      CALL REALCOEF(CDBUNT,'INPUT   ','UPPERLIM','AVHRRBT ',6,0,0,
     1              0,GMAXBT,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
      CALL REALCOEF(CDBUNT,'INPUT   ','LOWERLIM','HIRSBT  ',HNCHAN,
     1              0,0,0,HMINBT, 'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
      CALL REALCOEF(CDBUNT,'INPUT   ','LOWERLIM','AMSUABT ',ANCHAN,
     1              0,0,0,AMINBT, 'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
      CALL REALCOEF(CDBUNT,'INPUT   ','LOWERLIM','AMSUBBT ',BNCHAN,
     1              0,0,0,BMINBT, 'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
      CALL REALCOEF(CDBUNT,'INPUT   ','LOWERLIM','AVHRRBT ',6,0,0,
     1              0,GMINBT,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
C   CONVERT BRIGHTNESS TEMPERATURE LIMITS FOR HIRS, AMSU-A AND AMSU-B
C    INTO RADIANCES AND PUT INTO COMMON BLOCK VARIABLES.
C
      DO 10 I=1,HNCHAN-1
         HMAXRD(I)=PLKRAD(HMAXBT(I),I)
         HMINRD(I)=PLKRAD(HMINBT(I),I)
   10 CONTINUE
         HMAXRD(HNCHAN)=HMAXBT(HNCHAN)
         HMINRD(HNCHAN)=HMINBT(HNCHAN)
C
      DO 20 I=1,ANCHAN
         AMAXRD(I)=PLKRAD(AMAXBT(I),HNCHAN+I)
         AMINRD(I)=PLKRAD(AMINBT(I),HNCHAN+I)
   20 CONTINUE
C
      DO I=1,BNCHAN
         BMAXRD(I)=PLKRAD(BMAXBT(I),HNCHAN+ANCHAN+I)
         BMINRD(I)=PLKRAD(BMINBT(I),HNCHAN+ANCHAN+I)
      END DO
C
C   GET CONFIDENCE FACTOR FOR HIRS, AMSU-A, AMSU-B.
C
      CALL REALCOEF(CDBUNT,'INPUT   ','CNFDFCTR','HIRS    ',HNCHAN,
     1              0,0,0,HCONFC, 'GET', CDBST)
      IF(CDBST.NE.0) GO TO 990
      CALL REALCOEF(CDBUNT,'INPUT   ','CNFDFCTR','AMSUA   ',ANCHAN,
     1              0,0,0,ACONFC, 'GET', CDBST)
      IF(CDBST.NE.0) GO TO 990
      CALL REALCOEF(CDBUNT,'INPUT   ','CNFDFCTR','AMSUB   ',BNCHAN,
     1              0,0,0,BCONFC, 'GET', CDBST)
      IF(CDBST.NE.0) GO TO 990
C
C   GET INITIAL INSTRUMENT CONFIGURATIONS.
C
      CALL INTCOEF(CDBUNT,'INPUT   ','INSTRMNT','INITCNFG',1,0,0,
     1             0,INTCFG,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
ccft SET INTITIAL CONFIGURATION TO HABG (ALL INSTRUMENTS)
      INTCFG = -268435455
C
C   GET ALLOWABLE CONFIGURATIONS FOR INSTRUMENTS.
C
ccft  CALL INTCOEF(CDBUNT,'INPUT   ','INSTRMNT','CONFIGS ',5,0,0,
c    1             0,CDBCFG,'GET',CDBST)
c     IF(CDBST.NE.0) GO TO 990
ccft  SET ALLOWABLE INSTRUMENT CONFIGURATIONS
C       HABG
      CDBCFG(1) = -268435455
C       HAB
      CDBCFG(2) = -536870911
C       HA G
      CDBCFG(3) = -805306367
C       HA
      CDBCFG(4) = -1073741823
C        A
      CDBCFG(5) = -3221225471
C        AB
      CDBCFG(6) = -2684354559
C
C   GET AGE LIMIT FOR PROCESSING DATA.
C
      CALL INTCOEF(CDBUNT,'INPUT   ','DATA    ','AGELIMIT',1,0,0,
     1             0,AGELIM,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
C   GET LEAST COMMON MULTIPLE FOR INSTRUMENT SCAN-TO-SCAN TIMES.
C
      CALL INTCOEF(CDBUNT,'SYNCH   ','INSTR   ','LCM     ',1,0,0,
     1             0,LSCMTL,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
      CALL REALCOEF(CDBUNT,'INPUT   ','DATA    ','HIRANGFV',1,0,0,
     1              0,HANGFV,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
      CALL REALCOEF(CDBUNT,'INPUT   ','DATA    ','HIRFVDST',1,0,0,
     1              0,HFVDST,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
      CALL REALCOEF(CDBUNT,'INPUT   ','DATA    ','HIRSLOOK',1,0,0,
     1              0,HLOOK,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
      CALL INTCOEF(CDBUNT,'GOODIES ','SAT     ','HEIGHT  ',1,0,0,
     1             0,HTSAT,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
      CALL REALCOEF(CDBUNT,'INPUT   ','DATA    ','ERTHRTIO',1,0,0,
     1              0,ERATIO,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
C   GET THE PERCENTAGE LIMIT FOR AMSU-A SPOT EARTH LOCATION ERRORS IN A
C   DATA FRAME.
C
      CALL REALCOEF(CDBUNT,'INPUT   ','DATA    ','RTHERLIM',1,0,
     1              0,0,PCTMAX,'GET',CDBST)
      IF(CDBST.NE.0) GO TO 990
C
      RETURN
C
C  IN THE CASE OF A FATAL CDB ERROR, SET A FATAL ERROR CODE RETURN.
C
  990 CDBST = 99
      RETURN
      END
