LEN intrinsic function
Standard: F77 F90 F95 F2003
  Example Program

STRING : scalar or array of type Character, with any kind;
KIND : scalar Integer constant expression;

Result: scalar Integer or Integer(Kind=KIND).

The LEN intrinsic function returns the character length of STRING; if STRING is an array, this is the number of characters in each element. This is an inquiry function; STRING need not have a value, and indeed except in the case of deferred character length (:) can even be an unallocated allocatable variable or a disassociated pointer.

In Fortran 2003, the KIND argument should be used when the number of characters might exceed the range of a default integer; this is only relevant to 64-bit Windows as the ABI on 32-bit platforms and 64-bit Linux limit the maximum character length to 2GB-1.

In Fortran 2003, this enquiry may also be performed on a character variable using the “%len” formulation (and this can be done even if LEN is not available for use as an intrinsic function, for example, if it is the name of another local variable).

CHARACTER type, LEN_TRIM intrinsic function.