      FUNCTION ANRSCN(SCNTIM, PRVTIM)
      IMPLICIT NONE
C***********************************************************************
C
C   NAME- ANRSCN
C
C   LANGUAGE- VS FORTRAN  TYPE- INTEGER FUNCTION  COMPUTER- AIX
C
C   VERSION- 1.0   DATE-  9/24/03    PROGRAMMER- FRANK TILLEY (RAYTHEON)
C   VERSION- 1.1   DATE- 11/13/06    PROGRAMMER- FRANK TILLEY (IMSG)
C      UNDER WR #300 THE VALUE OF 'SCANMS' FOR CALCULATING SCAN LINE
C      DIFFERENCES WAS CHANGED FROM 8000 TO 7990 TO COMPENSATE FOR
C      ROUNDING FROM MICROSECONDS TO MILLISECONDS IN METOP-2 SATELLITE
C      DATA.
C
C   FUNCTION- THIS FUNCTION COMPUTES THE SCAN LINE DIFFERENCE BETWEEN
C             TWO AMSU-A SCAN LINE START TIMES.
C
C   CALLING SEQUENCE PARAMETERS-
C   NAME      TYPE   I/O   DESCRIPTION
C   ----      ----   ---   -----------
C   SCNTIM(2) INT     I    SCAN LINE START TIME (CENTURY DAY, MILLISECOND
C                          OF DAY) OF CURRENT AMSU-A SCAN LINE.
C   PRVTIM(2) INT     I    SCAN LINE START TIME OF PREVIOUS SCAN LINE. 
C
C   COMMON AREA PARAMETERS- NONE
C
C   LOCAL PARAMETERS-
C   NAME    TYPE   DESCRIPTION
C   ----    ----   -----------
C   DAYDIF  INT    DIFFERENCE IN CENTURY DAYS.
C   DYMSEC  INT    NUMBER OF MILLISECONDS IN A DAY.
C   SCANMS  INT    NUMBER OF MILLISECONDS BETWEEN AMSU-A SCAN LINES
C                  (WITH A FUDGE FACTOR).
C   TMPTIM  INT    CURRENT SCAN LINE TIME IN MILLISECONDS, ADJUSTED IF
C                  NECESSARY FOR DIFFERENCES IN CENTURY DAY.
C
C   SUBROUTINES CALLED- NONE
C
C   FUNCTIONS USED- NONE
C
C   EXIT STATES - IF THE DIFFERENCE IN CENTURY DAYS IS NEGATIVE OR
C                 EXCEEDS 1, THE VALUE OF ANRSCN IS RETURNED AS -999.
C
C               - IF THE SCAN LINE START TIMES ARE IDENTICAL THE VALUE
C                 OF ANRSCN IS RETURNED AS -999.
C
C***********************************************************************
C
      INTEGER ANRSCN, SCNTIM(2), PRVTIM(2)
C
      INTEGER DYMSEC, SCANMS, DAYDIF, TMPTIM

      PARAMETER(DYMSEC=(24*60*60*1000), SCANMS=7990)
C
C CHECK TO SEE IF CENTURY DAYS HAVE CHANGED BETWEEN SCANS.
C
      DAYDIF = SCNTIM(1) - PRVTIM(1)
C     
C IF THE DIFFERENCE IS NEGATIVE OR EXCEEDS 1, RETURN A VALUE OF -999.
C
      IF (DAYDIF.LT.0.OR.DAYDIF.GT.1) THEN
         ANRSCN = -999
         GO TO 1000
      END IF
C
C MAKE ANY NECESSARY ADJUSTMENTS TO THE CURRENT LINE START TIME IF
C THE PREVIOUS SCAN TIME IS FROM THE PREVIOUS DAY.
C
      IF (DAYDIF.EQ.1) THEN
         TMPTIM = SCNTIM(2) + DYMSEC
      ELSE
         TMPTIM = SCNTIM(2)
      END IF
C
C IF THE SCAN LINE START TIMES ARE IDENTICAL, RETURN A VALUE OF -999.
C
      IF (TMPTIM .EQ. PRVTIM(2)) THEN
         ANRSCN = -999
         GO TO 1000
      END IF
C
C CALCULATE THE NUMBER OF AMSU-A SCANS BETWEEN THE SCAN TIMES.
C
      ANRSCN = (TMPTIM-PRVTIM(2)) / SCANMS
C
C IF THE CALCULATION RESULTS IN THE NUMBER OF SCANS BEING ZERO,
C INCREMENT THE NUMBER OF SCANS BY 1 IF THE CURRENT SCAN LINE
C START TIME IS GREATER THAN THE START TIME OF THE PREVIOUS
C SCAN.

      IF (ANRSCN.EQ.0) THEN
         IF (TMPTIM .GT. PRVTIM(2)) ANRSCN = ANRSCN + 1
      END IF
C
 1000 CONTINUE
      RETURN
      END
