      PROGRAM DECRET
C
C     Function : Demonstrates use of decoding routines.
C
C     Input    : Data file attached as unit 11
C
C     Output   : Prints section 1 and 2 of decoded fields.
C
C     -----------------------------------------------------------------
C
      PARAMETER (JPACK=54000)
      PARAMETER (JPUNP=210000)
C
      DIMENSION ISEC0(2)
      DIMENSION ISEC1(32)
      DIMENSION ISEC2(512)
      DIMENSION ISEC3(2)
      DIMENSION ISEC4(64)
C
      DIMENSION ZSEC2(128)
      DIMENSION ZSEC3(2)
C
      DIMENSION INBUFF(JPACK)
      DIMENSION ZSEC4(JPUNP)
C
      CHARACTER*1 YOPER
C
      NUMERR = 0
C
   50 CONTINUE
C
#ifdef CRAY
      BUFFER IN (11,1) (INBUFF(1),INBUFF(JPACK))
      IF (UNIT(11)) 100,200,300
#else
      READ(UNIT=11,ERR=200) INBUFF
#endif
C
  100 CONTINUE
C
      ILREC = LENGTH(11)
      WRITE (*,9000)
      WRITE (*,9000)
      WRITE (*,9001) ILREC
      WRITE (*,9000)
      WRITE (*,9000)
C
      YOPER = 'D'
c--      CALL GRSDBG (1)
      IERR = 1
      CALL GRIBEX (ISEC0,ISEC1,ISEC2,ZSEC2,ISEC3,ZSEC3,ISEC4,
     C             ZSEC4,JPUNP,INBUFF,JPACK,IWORD,YOPER,IERR)
C
      WRITE (*,9000)
      WRITE (*,9005) YOPER
      WRITE (*,9004) IERR
      WRITE (*,9003) ISEC4(1)
C
      IF (IERR.NE.0)
     C   THEN
             NUMERR = NUMERR + 1
         ENDIF
C
C     Print section 0 .
C
      CALL GRPRS0 (ISEC0)
C
C     Print section 1 , product definition section.
C
      CALL GRPRS1 (ISEC0,ISEC1)
C
C     Print section 2 , grid definition section.
C
      CALL GRPRS2 (ISEC0,ISEC2,ZSEC2)
C
      GO TO 50
C
C
  200 CONTINUE
      WRITE (*,9002) NUMERR
      STOP
C
  300 STOP 'Read error'
C
 9000 FORMAT (1H )
 9001 FORMAT (1H ,'Record length (words) = 'I6)
 9002 FORMAT (1H ,'Number of decoding errors = ',I9)
 9003 FORMAT (1H ,'Number of values decoded = ',I9)
 9004 FORMAT (1H ,'Error return code = ',I4)
 9005 FORMAT (1H ,'Function code = ',A)
C
      END
