      INTEGER FUNCTION LENGTH(TEXT)
      CHARACTER*(*) TEXT
C
C Subroutine to determine the length of a string without trailing
C blanks.
C
C Input:
C     TEXT... Character string.
C
C Output:
C     LENGTH..Length of the string without trailing blanks.
C             LENGTH=1 for a blank string.
C
C No subroutines and external functions required.
C
C Date: 1995, August 18
C Coded by Ludek Klimes
C
C-----------------------------------------------------------------------
C
      INTEGER I
C
C.......................................................................
C
      DO 1 I=LEN(TEXT),1,-1
        IF(TEXT(I:I).NE.' ') THEN
          GO TO 2
        END IF
    1 CONTINUE
      I=1
    2 CONTINUE
      LENGTH=I
C
      RETURN
      END
C
C=======================================================================
C
