      subroutine prompt_read_user(round_aper,ra,dec,rahalf,
     $     dechalf,radius,error)
C
C Description:
C 
C This routine prompts the user and reads/processes user responses. It
C is used in the interactive mode of astronet to define search regions. 
C
C Programming Interface:
C 
C Name        In/out  Type     Structure  Description
C
C round_aper  in      logical  scalar     TRUE if the viewing aperture is
C                                         circular. FALSE if rectangular
C ra          out     real*8   scalar     The RA of the aperture center
C dec         out     real*8   scalar     The Decl. of the aperture center
C rahalf      out     real*8   scalar     The half-width of the aperture
C dechalf     out     real*8   scalar     The half-height of the aperture
C radius      out     real*8   scalar     The radius of the aperture
C                                         Note that radius is defined only
C                                         if 'round_aper' is TRUE. 'rahalf'
C                                         and 'dechalf' are defined only if
C                                         'round_aper' is FALSE
C error       out     logical  scalar     TRUE if an error occurs
C
C User interface:
C
C See other documentation for details.
C
C Errors:
C
C As a user interface program, this routine is supposed to detect any
C errors in the values supplied by the user. Errors probably exist
C that this routine does not detect. If an error is detected, the
C routine sends and error message, sets 'error' TRUE and immediately
C returns.
C
C Routines accessed
C
C str2r8
C err_msg
C dms2rad
C hms2rad
C
      implicit none
      include 'std_io.for'
      include 'include_.for'
      real*8 ra,dec,rahalf,dechalf,radius
      logical error,round_aper
      character*256 buf
      write(stdout,12,err=401)
 12   format(' ')
      write(stdout,11,err=401)
 11   format(' Astronet - Star Catalog Access')
      write(stdout,12,err=401)
      if (round_aper) then
         write(stdout,1,err=401)
 1       format(' Circular aperture radius (arcsec) (0 to quit): ',$)
         read(stdin,2,err=402) buf
 2       format(a256)
         call str2r8(buf,radius,error)
         if (error) goto 400
         radius=pio180*radius/3600.0d0
         if ((radius .lt. 0.0d0) .or.
     $        (radius .gt. pio180/12.0d0)) then
            error=.true.
            call err_msg('prompt_read_user',
     $           'The aperture radius must lie '//
     $           'between 0 and 300 arcsec.')
         end if
      else
         write(stdout,3,err=401)
 3       format(' Rectangular aperture width (arcsec) (0 to quit): ',$)
         read(stdin,2,err=402) buf
         call str2r8(buf,rahalf,error)
         if (error) goto 400
         rahalf=pio180*rahalf/3600.0d0
         if ((rahalf .lt. 0.0d0) .or.
     $        (rahalf .gt. pi/4.0d0)) then
            error=.true.
            call err_msg('prompt_read_user',
     $           'The aperture width must lie '//
     $           'between 0 and 162000 arcsec.')
         elseif (rahalf .gt. 0.0d0) then
            write(stdout,5,err=401)
 5          format(' Rectangular aperture height (arcsec): ',$)
            read(stdin,2,err=402) buf
            call str2r8(buf,dechalf,error)
            if (error) goto 400
            dechalf=pio180*dechalf/3600.0d0
            if ((dechalf .lt. 0.0d0) .or.
     $           (dechalf .gt. pi/4.0d0)) then
               error=.true.
               call err_msg('prompt_read_user',
     $              'The aperture height must lie '//
     $              'between 0 and 162000 arcsec.')
            end if
         end if
      end if
      if (.not. error) then
         if (((.not. round_aper) .and. (rahalf .ne. 0.0d0)) .or.
     $       ((round_aper) .and. (radius  .ne. 0.0d0))) then
            write(stdout,7,err=401)
 7          format(' RA aperture center (hr min sec): ',$)
            read(stdin,2,err=402) buf
            call hms2rad(buf,ra,error)
            if (error) then 
               goto 400
            else
               if ((ra .lt. 0.0d0) .or. (ra .gt. twopi)) then
                  error=.true.
                  call err_msg('prompt_read_user',
     $                 'RA must lie between 0 and 24 hours')
               else
                  write(stdout,9,err=401)
 9                format(' Decl. aperture center (deg min sec): ',$)
                  read(stdin,2,err=402) buf
                  call dms2rad(buf,dec,error)
                  if (error) goto 400
                  if ((dec .lt. 0.0d0) .or. (dec .gt. pi)) then
                  error=.true.
                  call err_msg('prompt_read_user',
     $                 'Decl. must lie between -90 and 90 deg.')
                  end if
               end if
            end if
         end if
      end if
      goto 400
 401  error=.true.
      call err_msg('prompt_read_user',
     $     'Error writing a prompt message.')
      goto 400
 402  error=.true.
      call err_msg('prompt_read_user',
     $     'Error reading a users response.')
 400  continue
      if (error) then
         call err_msg('prompt_read_user','Traceback')
      end if
      return
      end
