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

ID 767251
Date 3/22/2024
Public

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

Document Table of Contents

Assumed-Length Character Arguments

An assumed-length character argument is a dummy argument that assumes the length attribute of its corresponding actual argument. An asterisk (*) specifies the length of the dummy character argument.

A character array dummy argument can also have an assumed length. The length of each element in the dummy argument is the length of the elements in the actual argument. The assumed length and the array declarator together determine the size of the assumed-length character array.

The following example shows an assumed-length character argument:

  INTEGER FUNCTION ICMAX(CVAR)
    CHARACTER*(*) CVAR
    ICMAX = 1
    DO I=2,LEN(CVAR)
      IF (CVAR(I:I) .GT. CVAR(ICMAX:ICMAX)) ICMAX=I
    END DO
    RETURN
  END

The function ICMAX finds the position of the character with the highest ASCII code value. It uses the length of the assumed-length character argument to control the iteration. Intrinsic function LEN determines the length of the argument.

The length of the dummy argument is determined each time control transfers to the function. The length of the actual argument can be the length of a character variable, array element, substring, or expression. Each of the following function references specifies a different length for the dummy argument:

  CHARACTER VAR*10, CARRAY(3,5)*20
  ...
  I1 = ICMAX(VAR)
  I2 = ICMAX(CARRAY(2,2))
  I3 = ICMAX(VAR(3:8))
  I4 = ICMAX(CARRAY(1,3)(5:15))
  I5 = ICMAX(VAR(3:4)//CARRAY(3,5))

See Also