TRIM — Remove trailing blank characters of a string#

TRIM(STRING)#

Removes trailing blank characters of a string.

Parameters:

STRING – Shall be a scalar of type CHARACTER.

Returns:

A scalar of type CHARACTER which length is that of STRING less the number of trailing blanks.

Standard:

Fortran 90 and later

Class:

Transformational function

Syntax:
RESULT = TRIM(STRING)
Example:
PROGRAM test_trim
  CHARACTER(len=10), PARAMETER :: s = "GFORTRAN  "
  WRITE(*,*) LEN(s), LEN(TRIM(s))  ! "10 8", with/without trailing blanks
END PROGRAM
See also:

ADJUSTL — Left adjust a string, ADJUSTR — Right adjust a string