INTEGER FUNCTION iecf_len (y_char)
!
!  Calculate the 'length' of a character string.
!  The 'length' is the character-position of the last character in the
!  string which is neither 'BLANK', nor 'NULL'.
IMPLICIT NONE

CHARACTER (LEN=*),INTENT(IN) :: y_char
CHARACTER (LEN=1) :: null
INTEGER :: i, lgth

null = char (0)
lgth = len (y_char)

DO i = lgth, 1, - 1
   IF ( (y_char (i:i) .NE.' ') .AND. (y_char (i:i) .NE. null) ) goto 20
ENDDO
i = 0

20 CONTINUE
iecf_len = i

RETURN
END FUNCTION iecf_len
