c-----------------------------------------------------------------------
      subroutine findformat(word, first, last, type, rtf)
c-----------------------------------------------------------------------
c
c     THIS SUBROUTINE FINDS THE FORMAT NEEDED TO READ A "WORD". THE SIZE
c     OF THIS STRING IS NOT NUMERICALLY LIMITED, BUT DETERMINED WHEN THE
c     SUBROUTINE IS CALLED. IT NEEDS AS INPUT "TYPE", A ONE-CHARACTER
c     STRING DESCRIBING THE TYPE (A, I, OR F), THE STRING ITSELF 
c     ("WORD"), AND ITS LIMITS ("FIRST" AND "LAST"). IT WILL RETURN
c     THE FORMAT ("RTF") AS A STRING.
c
      character type*1
      character lstr*2, dstr*2
      character rtf*(*)
      character word*(*)
      integer first, last, len, dec
c
      len = (last - first) + 1
c          
      write(lstr, fmt='(I2)') len
      if (type .ne. 'F') then
           if (len .ge. 10) then
                rtf = (('(' // type) // lstr(1:2)) // ')'
           else
                rtf = (('(' // type) // lstr(2:2)) // ')'
           end if
c
      end if
      if (type .eq. 'F') then
         dec = len - index(word,'.')
         if ((dec.eq.len) .and. (index(word,'E').ne.0)) dec=len- 
     &                                  index(word,'E')
         write(dstr, fmt='(I2)') dec
         if (len .ge. 10) then
              if (dec .ge. 10) then
                   rtf=(((('('//type)//lstr(1:2))//'.')//dstr(1:2))//')'
              else
                   rtf=(((('('//type)//lstr(1:2))//'.')//dstr(2:2))//')'
              end if
         else
              if (dec .ge. 10) then
                   rtf=(((('('//type)//lstr(2:2))//'.')//dstr(1:2))//')'
              else
                   rtf=(((('('//type)//lstr(2:2))//'.')//dstr(2:2))//')'
              end if
         end if
      end if
      return 
      end
