      SUBROUTINE MINOFN(INSTIM,N,ICOUNT)
C***********************************************************************
C
C   NAME- MINOFN
C
C   LANGUAGE- FORTRAN 77    TYPE- SUBROUTINE    COMPUTER- CRAY     
C
C   VERSION-1.0     DATE- 01/09/91   PROGRAMMER- JEFF MANNING, SMSRC
C   VERSION-3.0     DATE- 05/28/96   PROGRAMMER- ALEX POZDNYAK, FDC 
C      MODIFIED TO RUN ON THE CRAY.  REPLACED I*4 WITH INT.
C 
C   FUNCTION- THIS ROUTINE GIVES THE ARRAY INDEX VALUE OF THE SMALLEST
C             INPUT VALUE. COMPARISIONS ARE MADE BETWEEN INPUT VALUES
C             AND THE SMALLEST VALUE IS HELD FOR THE NEXT COMPARISION.
C             INPUT VALUES INCLUDE THE CENTURY DAY AND THE MILLISECOND
C             OF THE DAY.
C
C   CALLING SEQUENCE PARAMETERS-
C     VARIABLE-           TYPE       I/O      FUNCTION
C     --------            ----       ---      --------
C      INSTIM              INT        I       2-D ARRAY CONTAINING THE
C                                             INPUT VALUES.UNITS ARE
C                                             CENTURY DAY, MILLISECOND
C                                             OF THE DAY.
C      N                   INT        I       NUMBER OF INPUT VALUES.
C      ICOUNT              INT        O       HOLDS THE INDEX OF THE
C                                              MINIMUM VALUE.
C
C   LOCAL PARAMETERS-
C    VARIABLE             TYPE       FUNCTION
C    --------             ----       --------
C     MSEC1                INT       HOLDS THE MILLISECONDS
C                                    OF THE MINIMUM VALUE.
C     NCEN1                INT       HOLDS THE CENTURY DAY
C                                    OF THE MINIMUM VALUE.
C     K                    INT       DO LOOP COUNTER
C
C   EXIT STATES: NONE
C
C   COMMENTS- TIMES ARE NOT SENT IN TERMS OF MISSING VALUES
C             AND AT LEAST TWO INPUTS ARE SENT TO THE ROUTINE.
C
C**********************************************************************
C
      INTEGER ICOUNT,N,MSEC1,NCEN1,K
      INTEGER INSTIM(2,N)
C
C     SET THE CENTURY DAY TO AN UNREACHABLE NUMBER ( A DAY MORE THAN
C     100 YEARS FROM 1990). SET THE MILLISECOND OF DAY TO A NUMBER
C     GREATER THAN THE NUMBER OF MILLISECONDS IN A DAY.
C
      MSEC1=90000000
      ICOUNT=0
      NCEN1=500000
C
C     LOOP THROUGH THE INSTRUMENTS
C
      DO 30 K=1,N
C
C     CHECK THE INSTRUMENT TIME TO SEE IF IT IS GREATER THAN THE
C     HELD TIME. COMPARE CENTURY DAYS.
C
          IF (NCEN1 .GT. INSTIM(1,K)) THEN
              NCEN1=INSTIM(1,K)
              MSEC1=INSTIM(2,K)
              ICOUNT=K
C
          ELSE IF (NCEN1 .EQ. INSTIM(1,K)) THEN
C
C      COMPARE MILLISECONDS.
C
              IF (MSEC1 .GT. INSTIM(2,K)) THEN
                  MSEC1=INSTIM(2,K)
                  ICOUNT=K
C
              END IF
          ELSE
          END IF
 30   CONTINUE
C
      RETURN
      END
