      program xut2carr
!
!     Exercise driver for random trials of ut2carr and carr2ut
!
!     B. Knapp, 2001-01-10
!
C
C     RCS DATA
C     
C     $Header$
C     
C     $Log$
C
C
      implicit none
!
      integer*4 iseed, i, n, itns, itnsmax
      parameter (n=1000000)
      real*8 t0, t1, c, djd, djdmax, ut2carr, carr2ut
      real*4 ran1
      external ran1, ut2carr, carr2ut
!
!     One test of ut2carr
      t0 = 2451545.d0
      c = ut2carr(t0)
      write(*,5) t0, c !, itns
 5    format(2f24.16,i8)
      stop
!
!     Generate random JD, n times
      iseed = -135676531
      itnsmax = 0
      djdmax = -1.0d0
      do i=1,n
         t0 = 2.25d6+ran1(iseed)*0.5d6
         c  = ut2carr(t0,itns)
         t1 = carr2ut(c)
         djd = t1-t0
         if (abs(djd) .gt. djdmax .or. itns .gt. itnsmax) then
            djdmax = max(djdmax, abs(djd))
            itnsmax = max(itnsmax, itns)
            write(*,10) t0, c, djd, itns
 10         format(2f24.16,1pe16.6,i8)
         endif
      enddo
      end
