
      SUBROUTINE CNVTI2R(MSGUN,TIME,ITIME)
C          This subroutine converts ITIME to TIME, where
C            MSGUN = Fortran unit for daignostic messages
C            TIME  = floating point version of time:  yyddd.fraction
C            ITIME = integer version of time: (1) = year 4-digit
C                                             (2) = month/day
C                                             (3) = hour/minute
C                                             (4) = centisecond
      PARAMETER (MISS=-32767 , RMISS=-32767.)
C          MISS = Missing data value
      DIMENSION ITIME(4) , JDAZ(12) , LENM(12)
      SAVE JDAZ , LENM
      DATA JDAZ/ 0,31,28,31,30,31,30,31,31,30,31,30/
      DATA LENM/31,28,31,30,31,30,31,31,30,31,30,31/

      TIME = RMISS
      IF(ITIME(1) .EQ. MISS)RETURN

      YY = FLOAT( ITIME(1)-1900 )
      IF(YY .LT. 0.)GO TO 9100

      JDAZ(3) = 28
      LENM(2) = 28
      LENYR   = 365
      IF(MOD(ITIME(1),4) .EQ. 0)THEN
        JDAZ(3) = 29
        LENM(2) = 29
        LENYR   = 366
      ENDIF

      NMON = ITIME(2)/100
      NDAY = ITIME(2) - NMON*100
      IF( NMON .LT. 0 .OR. NMON .GT. 12)GO TO 9100
      IF( NDAY .GT. LENM(NMON) )GO TO 9100
      DDD = 0.
      DO 100 I=1,NMON
  100 DDD = DDD + FLOAT(JDAZ(I))
      DDD = DDD + FLOAT(NDAY)
      IF(DDD .LT. 0. .OR. DDD .GT. 366.)GO TO 9100

      HR = FLOAT(ITIME(3)/100 )
      RM = FLOAT(ITIME(3)) - HR*100.
      SS = FLOAT(ITIME(4)) / 100.
      IF(HR .LT. 0. .OR. HR .GT.  24.)GO TO 9100
      IF(RM .LT. 0. .OR. RM .GT.  60.)GO TO 9100
      IF(SS .LT. 0. .OR. SS .GT.  60.)GO TO 9100
      FRACT = (HR + (RM+SS/60.)/60. )/24.

      IF(IFIX(FRACT+1.E-10) .EQ. 1 .AND. IFIX(DDD) .EQ. LENYR)THEN
        YY    = YY + 1
        DDD   = 1.
        FRACT = 0.
      ENDIF
      TIME = YY*1000. + DDD + FRACT

      RETURN

C          Error trap messages
 9100 WRITE(MSGUN,'('' Goofy date input:'',4I7)')(ITIME(I),I=1,4)
      STOP 'in err'
      END
