LEN(STRING, KIND)

Purpose

Returns the length of a character entity. The argument to this function need not be defined.

Class

Inquiry function

Argument type and attributes

STRING
must be of type character. It may be scalar or array valued. If it is an unallocated allocatable or a pointer that is not associated, its length type parameter must not be deferred.
Fortran 2003 begins KIND (optional)
must be a scalar integer constant expression. Fortran 2003 ends

Result type and attributes

Result value

The result has a value equal to the number of characters in STRING if it is scalar or in an element of STRING if it is array valued.

Examples

If C is declared by the statement
 CHARACTER (11) C(100)

LEN (C) has the value 11.

Specific Name Argument Type Result Type Pass As Arg?
LEN default character default integer yes  1 
Note:
  •  1  IBM Extension: the ability to pass the name as an argument.