      program xrise_set
!
!     Exercise driver for subroutine rise_set
!
!     B. Knapp, 1998-06-24, 2001-04-20 (new ephem interface)
!
C
C     RCS DATA
C     
C     $Header$
C     
C     $Log$
C
C
      implicit none
!
      integer*4 y, m, p, status, rh, rm, th, tm, sh, sm
      real*8 d, lat, lon, jd, rise, transit, set,
     &   rise_yd, transit_yd, set_yd,
     &   rise_h, transit_h, set_h, rs, ts, ss
!
 1    write(*,'(/a$)')
     &' Object (-1=quit, 0=Sun, 1=Mer, 2=Ven, 4=Mars, ..., 10=Moon)? '
      read(*,*) p
      if (p .ge. 0 .and. p .le. 10 .and. p .ne. 3) then
         write(*,'(a$)') ' Latitude (N > 0), Longitude (W > 0) (deg)? '
         read(*,*) lat, lon
         write(*,'(a$)') ' Year, month, day (& fraction) (UT)? '
         read(*,*) y,m,d
      
         call ymd2jd( y, m, d, jd )
!
         call rise_set( jd, p, lat, lon, rise, transit, set, status )
         write(*,10) status
 10      format( ' Status: ',i4/)
!
         call jd2yd( rise, rise_yd )
         rise_h = mod( rise_yd, 1.d0 )*24.d0
         call deg2dms( rise_h, rh, rm, rs )
         write(*,20) '    Rise:',rh,rm,nint(rs)
 20      format(a8,i4,':',i2.2,':',i2.2)
!
         call jd2yd( transit, transit_yd )
         transit_h = mod( transit_yd, 1.d0 )*24.d0
         call deg2dms( transit_h, th, tm, ts )
         write(*,20) ' Transit:',th,tm,nint(ts)
!
         call jd2yd( set, set_yd )
         set_h = mod( set_yd, 1.d0 )*24.d0
         call deg2dms( set_h, sh, sm, ss )
         write(*,20) '     Set:',sh,sm,nint(ss)
!
         goto 1
      else
         write(*,*) ' '
      endif
      end
