Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

LEN_TRIM

Elemental Intrinsic Function (Generic): Returns the length of the character argument without counting trailing blank characters.

result = LEN_TRIM (string [, kind])

string

(Input) Must be of type character.

kind

(Input; optional) Must be a scalar integer constant expression.

Results

The result is a scalar of type integer. If kind is present, the kind parameter of the result is that specified by kind; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the result value in the kind of the result, the result is undefined.

The result has a value equal to the number of characters remaining after any trailing blanks in string are removed. If the argument contains only blank characters, the result is zero.

The setting of compiler options specifying integer size can affect this function.

Example

LEN_TRIM (' C D ') has the value 4.

LEN_TRIM (' ') has the value 0.

The following shows another example:

INTEGER LEN1
LEN1 = LEN_TRIM (' GOOD DAY ') ! returns 9
LEN1 = LEN_TRIM (' ')          ! returns 0

See Also