      IMPLICIT REAL*8 (A-H,O-Z)
      PARAMETER(IMAX=76,KMAXP=29,JMAX=36,NVR=697)
      DIMENSION G(IMAX,NVR,JMAX)
      CHARACTER*80 ANS
      REAL*4 IHEAD(108)                                                    START.14
      LOGICAL FOUND
      FOUND=.FALSE.                                                       START.43
      IHIST=3
      WRITE(6,"(' Please enter TIGXM HISTORY filename: ',$)")
      READ(5,"(a)")ANS
      OPEN(IHIST,FILE=ANS,FORM='UNFORMATTED')
C     ****
C     ****    READ IN DESIRED HISTORY TIME
C     ****
      WRITE(6,"('*** Please INPUT Model Day ***')")
      WRITE(6,"('---Model Day:',$)")
      READ(5,"(a)") ANS
      READ(ANS,*)MDAY
      WRITE(6,*)MDAY
      WRITE(6,"('---Model Hour:',$)")
      READ(5,"(a)") ANS
      READ(ANS,*)MHOR
      WRITE(6,*)MHOR
      WRITE(6,"('---Model Minute:',$)")
      READ(5,"(a)") ANS
      READ(ANS,*)MMIN
      WRITE(6,*)MMIN
C     ****                                                                START.44
C     ****    UNBLOCK THE HEADER                                          START.45
C     ****                                                                START.46
1000  CONTINUE                                                            START.47
      READ(IHIST,END=900)(IHEAD(I),I=1,108)                               START.48
C     ****                                                                START.49
C     ****    CONVERT HISTORY FILE HEADER TO COMPUTATION TIME             START.50
C     ****                                                                START.51
      NDAY=IFIX(IHEAD(2))                                                 START.52
      NHOR=IFIX(IHEAD(3))                                                 START.53
      NMIN=IFIX(IHEAD(4))                                                 START.54
C     ****                                                                START.55
C     ****    CHECK FOR DESIRED TIME                                      START.56
C     ****                                                                START.57
      IF(NDAY.EQ.MDAY.AND.NHOR.EQ.MHOR.AND.NMIN.EQ.MMIN)FOUND=.TRUE.
      IF(.NOT.FOUND)THEN
       WRITE(6,"(' Searching for history ',i2,':',i2,':',i2,
     1   ' Found history ',i2,':',i2,':',i2,' -- still searching')")
     2   MDAY,MHOR,MMIN,NDAY,NHOR,NMIN
c      *****                                                              START.64
c      *****     UNBLOCK THE DATA                                         START.65
c      *****                                                              START.66
       DO J=1,JMAX                                                        START.67
        READ(IHIST,END=900)((G(I,K,J),I=1,IMAX),K=1,NVR)                  START.68
       ENDDO                                                              START.69
       GOTO 1000                                                          START.70
      ELSE                                                                START.71
       WRITE(6,"(' Searching for ut ',i2,':',i2,':',i2,
     1   ' Found history ',i2,':',i2,':',i2,' -- Success! ')")
     2   MDAY,MHOR,MMIN,NDAY,NHOR,NMIN
c      *****                                                              START.75
c      *****     READ IN THE DATA                                         START.76
c      *****                                                              START.77
       DO J=1,JMAX                                                        START.78
        READ(IHIST)((G(I,K,J),I=1,IMAX),K=1,NVR)                            START.79
       ENDDO                                                              START.95
      ENDIF                                             
      CLOSE(IHIST)
      OPEN(IHIST,FILE='hist.dat',FORM='UNFORMATTED')
      DO J=1,JMAX
       WRITE(IHIST)((REAL(G(I,K,J)),I=1,IMAX),K=1,NVR)
      ENDDO         
900   WRITE(6,*)'DESIRED TIME OUT OF THE RANGE OF HISTORY FILE, PLEASE     START.132
     1TRY ANOTHER HISTORY FILE'                                            START.133
      STOP
      END
