LF Fortran 95

LEN Function

Description

The LEN function returns the total length of a CHARACTER data object.

Syntax

LEN (string)

Arguments

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

Result

The result is a scalar default INTEGER.

Its value is the length of the character object string.

Example

character :: c1 character(len=4) :: c3="Yow!" character(len=*), parameter :: c6=" Howdy" character(len=3),dimension(2) :: ca2=(/" Fo","lks"/) character :: ca4*4(2)=(/" So ","long"/) write(*,*) len(c1),len(c3),len(c6) ! writes 1 4 6 write(*,*) len(ca2),len(ca4) ! writes 3 4