      logical function is_valid_switch_arg(ndx)
C
C Description:
C
C This function returns TRUE if the command line argument ndx is a valid
C argument to the preceeding switch.
C
C Programming interface:
C
C Name                 In/out   Type     Structure   Meaning
C
C ndx                  in       integer  scalar      The index of the selected
C                                                    command line argument
C is_valid_switch_arg  out      logical  scalar      TRUE if the selected
C                                                    argument is valid for
C                                                    the preceeding switch.
C
C Errors
C 
C No errors should occur. No errors are trapped.
C
C Subroutines accessed
C
C getarg
C
C Portability Issues:
C
C getarg is provided by Sun's FORTRAN. It returns the ith argument in
C the command line. If your compiler or OS does not support getarg
C you will have to write a substitute or build a new user interface
C for the astorb program.
C

      implicit none
      include 'std_io.for'
      include 'include_.for'
      integer ndx,switch_count,i,lnblnk
      integer*2 n,status
      parameter (switch_count=14)
      logical done,is_int_num,is_fp_num
      character*3 switch
      character*16 local_switch,arg
      dimension switch(switch_count)
      data switch/'-ap','-dn','-fl',
     $     '-in','-mh','-ml','-mt','-os',
     $     '-ot','-pr','-ps','-so','-st','-cm'/
      n=ndx-1
      call getarg(n,local_switch,status)
      i=1
      done=.false.
      do while ((i .le. switch_count) .and. (.not. done))
         done=(local_switch .eq. switch(i))
         i=i+1
      end do
      i=i-1
      n=ndx
      call getarg(n,arg,status)
      if     (i .eq. 1) then
         is_valid_switch_arg=((arg .eq. 'c') .or. (arg .eq. 'r'))
      elseif ((i .eq. 2) .or. (i .eq. 3) .or. (i .eq. 5) .or.
     $        (i .eq. 6) .or. (i .eq. 11)) then
         is_valid_switch_arg=(is_int_num(arg) .or. is_fp_num(arg))
      elseif ((i .eq. 4)  .or. (i .eq. 9) .or. (i .eq. 14)) then
         is_valid_switch_arg=((arg(1:1) .ne. '-') .and.
     $        (lnblnk(arg) .ne. 0))
      elseif (i .eq. 7) then
         is_valid_switch_arg=((arg .eq.'r') .or.
     $        (arg .eq. 'b') .or. (arg .eq. 'rb'))
      elseif (i .eq. 8) then
         is_valid_switch_arg=((arg .eq.'ascii') .or.
     $        (arg .eq. 'cat') .or. (arg .eq. 'iraf'))
      elseif (i .eq. 10) then
         is_valid_switch_arg=((arg .eq.'i') .or. (arg .eq. 'b'))
      elseif (i .eq. 12) then
         is_valid_switch_arg=((arg .eq.'a') .or. (arg .eq. 'd'))
      elseif (i .eq. 13) then
         is_valid_switch_arg=((arg .eq. 'RA') .or. (arg .eq. 'D') .or.
     $        (arg .eq. 'rad') .or. (arg .eq. 'r') .or.
     $        (arg .eq. 'b') .or. (arg .eq. 'i').or.
     $        (arg .eq. 'a'))
      end if
      return
      end
