LF Fortran 95

LEN_TRIM Function

Description

The LEN_TRIM function returns the length of a CHARACTER string, not counting any trailing blanks.

Syntax

LEN_TRIM (string)

Arguments

string is an INTENT(IN) scalar or array of type CHARACTER.

Result

If string is scalar, the result is a scalar default INTEGER. Its value is the number of characters in string, not counting any trailing blanks.

If string is an array, the result is a conformable type default INTEGER array. Each element of the result contains the number of characters in each element of string, not counting any trailing blanks.

Example

character(len=10) :: c3="Yow!" character(len=*),parameter :: c6="Howdy " character(len=3),dimension(2) :: ca2=(/"Fol","ks "/) write(*,*) len_trim(c3),len_trim(c6) ! writes 4 5 write(*,*) len_trim(ca2) ! writes 3 2