      SUBROUTINE CNFRNG(ANCBUF,NSPOTS,NLINES,NELEM,NOVLP,CLIM,
     1                  INSNUM,RANGE)
      IMPLICIT NONE
C***********************************************************************
C
C   NAME-  CNFRNG
C
C   LANGUAGE- FORTRAN  TYPE- SUBROUTINE       COMPUTER- RS/6000
C
C   VERSION- 2.0    DATE- 11/27/95   PROGRAMMER- CARLA NEIGH, SMSRC
C   VERSION- 2.1    DATE- 03/20/96   PROGRAMMER- DAVE MOREL, SMSRC
C      ATOVS-379   ADDED ARGUMENT CLIM, TO USE AS THE SPOT CONFIDENCE
C                  LIMIT IN DETERMINING IF A FOV FOR AN INSTRUMENT
C                  WAS CONSIDERED PROCESSED OR NOT FOR THE STATS FILE.
C   VERSION-3.0      DATE- 05/13/96        PROGRAMMER- A. POZDNYAK (FDC)
C      MODIFIED TO RUN ON THE CRAY.  REPLACED I*4 WITH INT AND
C      R*4 WITH REAL.
C
C   FUNCTION-  THIS ROUTINE IS USED TO ACCUMULATE THE NUMBER OF 
C              FIELDS OF VIEW WITH A SPOT CONFIDENCE IN EACH OF 
C              THE FOLLOWING RANGE VALUES:  91 - 100, 71 - 90, 
C              41 - 70, AND 0 - 40. IT ALSO TOTALS THE NUMBER OF FOV'S
C              PROCESSED AND NOT PROCESSED, PER INSTRUMENT.
C
C   CALLING SEQUENCE PARAMETERS-
C   NAME    TYPE   I/O   DESCRIPTION
C   ----    ----   ---   -----------
C   ANCBUF  REAL    I    3D ARRAY (DIM NSPOTS X NLINES X NELEM)
C                        CONTAINING AN INSTRUMENTS ANCILLARY
C                        DATA BUFFER.
C   NSPOTS  INT     I    NUMBER OF SPOTS IN A SCAN LINE FOR 
C                        THE INSTRUMENT.
C   NLINES  INT     I    NUMBER OF SCAN LINES IN AN EXTENDED DATA 
C                        FRAME.
C   NELEM   INT     I    NUMBER OF DATA ELEMENTS PER SPOT IN THE
C                        ANCILLARY BUFFER.
C   NOVLP   INT     I    NUMBER OF SCAN LINES IN THE INSTRUMENT'S
C                        OVERLAP BUFFER.
C   CLIM    INT     I    SPOT CONFIDENCE LIMIT
C   INSNUM  INT     I    INSTRUMENT NUMBER, WHERE 1 = HIRS, 2 = 
C                        AMSU-A AND 3 = AMSU-B.
C   RANGE   INT    I/O   ARRAY (DIM 4) CONTAINING THE NUMBER OF
C                        FIELDS OF VIEW WITH A SPOT CONFIDENCE IN
C                        EACH OF THE FOLLOWING RANGE VALUES:
C                        91 - 100, 71 - 90, 41 - 70, AND 0 - 40.
C
C   COMMON AREA PARAMETERS- MONSTA
C
      INCLUDE 'MONSTA'
C
C   LOCAL PARAMETERS-
C   NAME    TYPE   DESCRIPTION
C   ----    ----   -----------
C   I,J     INT    DO LOOP INDICES.
C   CNFIDX  INT    INDEX FOR ELEMENT NUMBER OF SPOT CONFIDENCE
C                  IN INSTRUMENT ANCILLARY BUFFER.
C   STLINE  INT    STARTING LINE OF 256 SECOND PORTION OF THE FRAME.
C   ENLINE  INT    ENDING LINE OF 256 SECOND PORTION OF THE FRAME.
C 
C   EXIT STATES-  NONE
C
C***********************************************************************
C
      INTEGER  NSPOTS, NLINES, NELEM, NOVLP, INSNUM, RANGE(4)
      REAL     ANCBUF(NSPOTS,NLINES,NELEM)
C
      INTEGER  I, J, CNFIDX, STLINE, ENLINE, CLIM 
C
C   SPOT CONFIDENCE IS IN THE 6TH ELEMENT OF THE ANCILLARY BUFFER FOR
C   THE HIRS INSTRUMENT, AND IN THE 5TH FOR ALL OTHERS.
C
      IF (INSNUM .EQ. 1) THEN
         CNFIDX = 6
      ELSE
         CNFIDX = 5
      ENDIF
C
      STLINE = NOVLP/2 + 1
      ENLINE = NLINES - NOVLP/2
C
      DO 30 J =  STLINE, ENLINE 
         DO 20 I = 1, NSPOTS
C
            IF (ANCBUF(I,J,CNFIDX) .GE. 91.0) THEN
               RANGE(1) = RANGE(1) + 1
            ELSEIF (ANCBUF(I,J,CNFIDX) .GE. 71.0) THEN
               RANGE(2) = RANGE(2) + 1
            ELSEIF (ANCBUF(I,J,CNFIDX) .GE. 41.0) THEN
               RANGE(3) = RANGE(3) + 1
            ELSE
               RANGE(4) = RANGE(4) + 1
            ENDIF
C
C           TOTAL, FOR THE STATISTICS FILE, THE NUMBER OF FIELD OF VIEWS
C           PER INSTRUMENT, THAT ARE CONSIDERED PROCESSED AND NOT PROCESSED.
C
            IF (ANCBUF(I,J,CNFIDX) .GE. CLIM) THEN
               IF(INSNUM .EQ. 1) HFOVPR = HFOVPR + 1
               IF(INSNUM .EQ. 2) AFOVPR = AFOVPR + 1
               IF(INSNUM .EQ. 3) BFOVPR = BFOVPR + 1
            ELSE
               IF(INSNUM .EQ. 1) HFOVNP = HFOVNP + 1
               IF(INSNUM .EQ. 2) AFOVNP = AFOVNP + 1
               IF(INSNUM .EQ. 3) BFOVNP = BFOVNP + 1
            ENDIF
C
   20    CONTINUE
   30 CONTINUE 
C
      RETURN
      END
