      SUBROUTINE TIMER(T)
C   ==================================================================
C   ===                                                            ===
C   ===    This subroutine returns the elapsed time since its      ===
C   ===    first CALL                                              ===
C   ===                                                            ===
C   ===    ATTENTION - uses gettimer posix routine on AIX          ===
C   ===                                                            ===
C   ===               Matthew Peters - Aug, 92                     ===
C   ==================================================================

      DOUBLE PRECISION T
      INTEGER TP(2) , TP1_FIRST_TIME
      INTEGER TOD
      LOGICAL FIRST_TIME
      STATIC FIRST_TIME
      DATA FIRST_TIME / .TRUE. /

C     Call GETTIMER to obtain the time of day.
C     GETTIMER returns time since Jan 1 some year with seconds in
C     TP(1) and nanoseconds in TP(2).
      TOD = 9
      CALL GETTIMER(%VAL(TOD),TP(1))

C     Alter the seconds field to make them start counting from zero
      IF (FIRST_TIME) THEN
         TP1_FIRST_TIME = TP(1)
         TP(1) = 0
         FIRST_TIME = .FALSE.
      ELSE
         TP(1) = TP(1) - TP1_FIRST_TIME
      END IF

C     Calculate and return the time in seconds
      T = (TP(2) / 1.0E9) + (TP(1))

      END
