      SUBROUTINE dattau(nymd,nhms,tau)
C  CONVERT A DATE/TIME TO A TAU
C  NOTE: THIS PROGRAM IS SET UP TO CONVERT DATES TO TAUS WITHIN THE
C        THE YEARS 1972-1999. A STOP WILL BE ISSUED FOR DATES NOT
C        WITHIN THIS RANGE.
      INTEGER DATE (4)
      INTEGER I
      INTEGER ILPNDX
      INTEGER IYEAR
      INTEGER IYRNDX
      INTEGER LEAPYR (7)
      DATA LEAPYR / 75, 79, 83, 87, 91, 95, 99 /
C                     - THE LAST YEAR IN EACH OF THE FOUR YEAR PERIODS
      INTEGER montau (12)
      DATA montau / 744, 672, 744, 720, 744, 720, 744, 744, 720, 744, 72
     &0, 744 /
C                     - NUMBER OF TAUS IN EACH MONTH OF THE YEAR
      INTEGER NHMS
      DATA NTAU4Y / 35064 /
C                     - NUMBER OF HOURS IN ANY GIVEN FOUR YEAR PERIOD
      INTEGER NYMD
      REAL TAU
      INTEGER taubis
      DATA taubis / 7248 /
C                     - TAU BIAS (THE 0 TAU IS NOT ON A YEAR BOUNDARY)
      INTEGER tauend (5)
      DATA tauend / 0, 8784, 17544, 26304, 35064 /
C                     - TAUS AT THE END OF THE 1ST TO 4TH YEARS
C  UNPACK DATE PARAMETERS FROM MODEL FORM FOR PROCESSING
      date(3) = nymd / 10000
      date(1) = (nymd - date(3) * 10000) / 100
      date(2) = nymd - date(3) * 10000 - date(1) * 100
      date(4) = nhms / 10000
C  CHECK IF YEAR IS WITHIN THE RANGE OF YEARS FOR WHICH THERE ARE TAUS
      iyear = date(3)
      IF ((iyear .LT. leapyr(1)) .OR. (iyear .GT. leapyr(7))) THEN
        WRITE( 6,900 ) date
        PRINT *, ' FATAL: DATTAU>> Date out of range.'
        STOP 'fatal.'
      ENDIF
C  DETERMINE WHICH LEAP YEAR GROUP IYEAR IS IN
      ilpndx = 0
  100 CONTINUE
      ilpndx = ilpndx + 1
      IF ((ilpndx .LT. 7) .AND. (iyear .GT. leapyr(ilpndx))) THEN
        GOTO 100
      ENDIF
C  DETERMINE WHICH YEAR IN THE LEAP YEAR GROUP IYEAR IS (1-4)
      iyrndx = 4 - leapyr(ilpndx) + iyear
C  CALCULATE THE TAU AT THE END OF THE YEAR BEFORE IYEAR
      tau = ((ilpndx * ntau4y) - ntau4y) + tauend(iyrndx)
C  SET THE NUMBER OF HOURS IN FEBRUARY
      montau(2) = 672
      IF (iyrndx .EQ. 1) THEN
        montau(2) = 696
      ENDIF
C  INCREMENT NUMBER OF TAUS UP TO THE GIVEN MONTH
      IF (date(1) .GT. 1) THEN
        tau = tau + sum(montau(:date(1) - 1))
      ENDIF
C  INCREMENT TAU BY THE DAYS AND HOURS INTO THE MONTH
      tau = tau + date(2) * 24.0 - 24.0 + date(4)
C  GET FINAL TAU BY SUBTRACTING THE TAU BIAS AND ADDING A WIGGLE
      tau = tau - taubis + 0.000001
      tau = ifix(tau + 0.1)
      RETURN
900   FORMAT (' DATTAU: DATE OUT OF RANGE '/' DATTAU: INPUT WAS: MONTH='
     &,I2,'  DAY=',I2,'  YEAR=',I3,'  HOUR=',I2)
      END
