!.......................................................
! lenchr - find index of last non-blank,null
!.......................................................

      function lenchr (ch)

!        Returns position of last non-blank,null character in ch, &
!        or 1 if ch is all blanks.

      integer lenchr
      character*(*) ch

      do i = len(ch), 1, -1
         if (ch(i:i).ne.' '.and.ch(i:i).ne.char(0)) then
            lenchr = i
            return
         endif
      enddo

      lenchr = 1
      return
      end
