      SUBROUTINE MAXOFN(INSTIM,N,ICOUNT)
C**********************************************************************
C
C   NAME- MAXOFN
C
C   LANGUAGE- VS FORTRAN  TYPE- SUBROUTINE COMPUTER- HDS-9000
C
C   VERSION- 1.0    DATE- 01/09/91   PROGRAMMER- JEFF MANNING,SMSRC
C   VERSION- 3.0    DATE- 05/29/96   PROGRAMMER- ALEX POZDNYAK, FDC
C      MODIFIED TO RUN ON THE CRAY.  REPLACED I*4 WITH INT.
C  
C   FUNCTION- FIND THE MAXIMUM VALUE OF N NUMBER OF INPUT VALUES.
C               RETURN THE INDEX OF THAT VALUE.
C
C   CALLING SEQUENCE PARAMETERS-
C     VARIABLE            TYPE       I/O      FUNCTION
C     --------            ----       ---      --------
C      INSTIM             INT         I       2-D ARRAY CONTAINING THE
C                                             INPUT VALUES.
C      N                  INT         I       NUMBER OF VALUES OF INPUT
C      ICOUNT             INT         O       HOLDS THE INDEX OF THE
C                                             MAXIMUM VALUE.
C
C   LOCAL PARAMETERS-
C     VARIABLE            TYPE       FUNCTION
C     --------            ----       --------
C
C      MSEC1              INT        HOLDS MILLISECONDS OF
C                                    MAXIMUM VALUE.
C      NCEN1              INT        HOLDS THE CENTURY DAY OF
C                                    THE MAXIMUM VALUE.
C      K                  INT        DO LOOP COUNTER
C
C   EXIT STATES- NONE
C
C   COMMENTS- TIMES ARE NEVER SENT IN TERMS OF MISSING VALUES
C             AND AT LEAST TWO OR MORE INPUTS ARE SENT TO THE
C             ROUTINE.
C
C********************************************************************
C
      INTEGER ICOUNT,N,MSEC1,NCEN1
      INTEGER INSTIM(2,N),K
C
      MSEC1=0
      ICOUNT=0
      NCEN1=0
C
C     LOOP THROUGH THE INSTRUMENTS
C
      DO 30 K=1,N
C
C     CHECK THE INSTRUMENT TIME AGAINST THE HELD MAXIMUM TIME.
C     COMPARE THE CENTURY DAYS.
C
          IF (NCEN1 .LT. 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 THE MILLISECONDS.
C
              IF (MSEC1 .LT. INSTIM(2,K)) THEN
                  MSEC1=INSTIM(2,K)
                  ICOUNT=K
C
              END IF
          ELSE
          END IF
 30   CONTINUE
C
      RETURN
      END
