      SUBROUTINE CHKTYP(DTYPE,INSTR,NUMOFI,ERSTAT)
      IMPLICIT NONE
C
C********************************************************************
C
C   NAME- CHKTYP
C
C   LANGUAGE- FORTRAN 77     TYPE- SUBROUTINE      COMPUTER- CRAY    
C   VERSION- 1.0    DATE- 01/15/91   PROGRAMMER- JEFF MANNING (SMSRC)
C   VERSION- 2.0    DATE- 11/01/94   PROGRAMMER- ALEX POZDNYAK(SMSRC)
C       XATOV-62:   COMMENTS FOR NUMBERING CONVENTION CHANGED.
C                   LOCAL ARRAY WAS ADDED CONTAINING 1B DATA TYPES
C                   CORRESPONDING TO INSTRUMENT NUMBER INDICES. THE
C                   INSTR ELEMENT OF THE ARRAY IS CHECKED AGAINST
C                   DTYPE(INSTR). DTYPE WAS CHANGED TO DIMENSION
C                   NUMOFI.
C   VERSION- 3.0    DATE- 04/17/96   PROGRAMMER- ALEX POZDNYAK(FDC)  
C       MODIFIED TO RUN ON THE CRAY.  REPLACED I*4 WITH INT.
C 
C   FUNCTION- THIS ROUTINE CHECKS THE INSTRUMENT DATA TYPE AND COMPARE
C             IT TO THE INSTRUMENT NUMBER. IF THEY DO NOT MATCH UP
C             THEN AN ERROR MESSAGE IS OUTPUT.
C
C   CALLING SEQUENCE PARAMETERS-
C     VARIABLE  TYPE  I/O  DEFINITION
C     --------  ----  ---  --------------------------------------------
C     DTYPE      INT  I    ARRAY CONTAINING THE DATA TYPE OF THE
C                          INSTRUMENT. DIMENSION NUMOFI.
C     INSTR      INT  I    INSTRUMENT NUMBER.
C     NUMOFI     INT  I    NUMBER OF INSTRUMENTS.
C     ERSTAT     INT  O    ERROR CODE.
C
C
C   LOCAL PARAMETERS-
C     VARIABLE  TYPE  FUNCTION
C     --------  ----  -----------------------------------------------
C     LTYPE      INT  ARRAY CONTAINING 1B DATA TYPES CORRESPONDING TO
C                     INSTRUMENT NUMBER INDICES.
C
C
C   SUBROUTINE CALLED- CHKTY$
C
C********************************************************************
C
      INTEGER   DTYPE(NUMOFI)
      INTEGER   NUMOFI,INSTR,ERSTAT
      INTEGER   LTYPE(3)
C
      DATA LTYPE(1),LTYPE(2),LTYPE(3)/5,10,11/
C
C     INITIALIZE VARIABLES
C
      ERSTAT=0
C
C     THE INSTRUMENT NUMBERS WHICH CORRESPOND TO THE DATA TYPES ARE:
C
C     HIRS=1, AMSU-A=2,  AMSU-B=3:   INSTRUMENT NUMBERING CONVENTION.
C     HIRS=5, AMSU-A=10, AMSU-B=11:  THE DATA TYPES FROM 1B DATA.
C
C     COMPARE INSTRUMENT NUMBER TO SEE IF IT CORRESPONDS TO THE
C     CORRECT DATA TYPE.
C
      IF (INSTR.LE.2) THEN
         IF(LTYPE(INSTR).NE.DTYPE(INSTR)) THEN
            CALL CHKTY$(310,DTYPE(INSTR),INSTR,ERSTAT)
         END IF
      END IF
      IF (INSTR.EQ.3) THEN
         IF (DTYPE(INSTR).NE.11.AND.DTYPE(INSTR).NE.12) THEN
            CALL CHKTY$(310,DTYPE(INSTR),INSTR,ERSTAT)
         END IF
      END IF
C
      RETURN
      END
C*********************************************************************
      SUBROUTINE CHKTY$(MSGCOD,TYPE,INSTRU,ERSTAT)
      IMPLICIT NONE
C
C*********************************************************************
C   NAME- CHKTY$
C
C   LANGUAGE- VS FORTRAN   TYPE- SUBROUTINE
C
C   VERSION- 1.0    DATE- 03/27/91    PROGRAMMER- JEFF MANNING (SMSRC)
C   VERSION- 3.0    DATE- 08/04/97    PROGRAMMER- LEAH WILSON (HSTX)
C
C   FILES-
C     DSN                       I/O  UNIT  FUNCTIONAL DESCRIPTION
C     ---                       ---  ----  -----------------------
C     .../KIDS                   O   KUNIT KRAY I/A DOCUMENTATION SYSTEM.
C
C   FUNCTION- THIS SUBROUTINE IS THE ERROR HANDLING ROUTINE FOR
C             ROUTINE CHKTYP
C   VERSION- 3.0  CONVERT FROM MMLF TO KIDS CONVENTION.
C
C   CALLING SEQUENCE PARAMETERS-
C     VARIABLE               TYPE  I/O  FUNCTION
C     --------               ----  ---  --------
C     MSGCOD                  INT   I   MESSAGE CODE USED TO
C                                       IDENTIFY THE ERROR PATTERN
C     TYPE                    INT   I   INSTRUMENT DATA TYPE
C     INSTRU                  INT   I   INSTRUMENT NUMBER
C     ERSTAT                  INT   O   STATUS CODE IF AN ERROR
C                                       OCCURS DURING I/O
C
      INTEGER  MSGCOD,ERSTAT,TYPE,INSTRU
C
C   COMMON AREA PARAMETERS-
C
      INCLUDE  'ERPARM'
      INCLUDE  'ERINFO'
      INCLUDE  'SPGUNT'
C
C   LOCAL PARAMETERS-
C     VARIABLE                TYPE    FUNCTION
C     --------                ----    --------
C     STAT                     INT    STATUS CODE IF AN ERROR
C                                     OCCURS DURING I/O
C     I                        INT    LOOP COUNTER
C     KMSG                    CH*100  KIDS MESSAGE BUFFER.
C     C4TEMP                   CH*4   TEMPORARY FOR WRITING INTO KMSG.
C
C   SUBPROGRAMS CALLED- KIDS
C
C   EXIT STATES-
C       ERSTAT =  0;INDICATING NO OR NON-FATAL ERRORS FOUND
C       ERSTAT = 99;INDICATING A FATAL ERROR WAS DETECTED
C
C*********************************************************************
C
      INTEGER  STAT,I
      CHARACTER*4 C4TEMP
      CHARACTER*6 INSNAM(3)
      CHARACTER*100 KMSG
      DATA INSNAM / 'HIRS  ', 'AMSU-A','AMSU-B' /
C
C  SET ERINFO:SUBNAM TO MAIN MODULE SINCE KIDS FILLS IN SUBROUTINE NAME
C
      SUBNAM = 'SPGDVR'
C
C  INITIALIZE VARIABLES
C
      ERSTAT=0
      STAT=0
C
C  CHECK FOR VALID MSGCOD VALUES
C
      IF(MSGCOD.EQ.310) THEN
        KMSG(1:50)= '* WARNING * Header data type does not correspond'
        KMSG(51:100)='to instr. - data type:      (      )            '
        WRITE(C4TEMP,'(I4)') TYPE
        KMSG(74:77) = C4TEMP
        KMSG(80:85) = INSNAM(INSTRU)
        CALL KIDS(KUNIT,SUBNAM,0,KMSG,0)
      ELSE
C
C NOT A VALID MSGCOD
C
        STAT=0
        KMSG = 'Invalid message code      '
        WRITE(C4TEMP,'(I4)') MSGCOD
        KMSG(22:25) = C4TEMP
        CALL KIDS(KUNIT,SUBNAM,0,KMSG,0)
      ENDIF
C
      RETURN
      END
