      logical function is_valid_switch(ndx)
C
C Description:
C
C This function returns TRUE if the command line argument ndx is a valid
C switch.
C
C Programming interface:
C
C Name             In/out  Type     Structure  Meaning
C
C ndx              in      integer  scalar     The position index of a command
C                                              line argument
C is_valid_switch  out     logical  scalar     TRUE if the argument is a
C                                              valid switch.
C
C Subroutine accessed
C
C getarg
C
C Portability issues:
C
C getarg is specific to the UNIX operating system. It is provided by
C Sun's FORTRAN compiler but it may not be provided by others. UNIX
C users may be able to devise a functionally equivalent function. DOS
C uses need to find a way to access the ith command line argument from
C a FORTRAN program.
C
      implicit none
      include 'std_io.for'
      include 'include_.for'
      integer ndx,switch_count,i
      integer*2 n,status
      parameter (switch_count=14)
      logical done
      character*3 switch
      character*16 local_switch
      dimension switch(switch_count)
      data switch/'-ap','-dn','-fl',
     $     '-in','-mh','-ml','-mt','-os',
     $     '-ot','-pr','-ps','-so','-st','-cm'/
      n=ndx
      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
      is_valid_switch=done
      return
      end
