### 6.1.1.4 Passed-Length Character Arguments

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

When control transfers to the subprogram, each dummy argument assumes the length of its corresponding actual argument.

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

Examples

The following example of a function subprogram uses a passed-length character argument. The function finds the position of the character with the highest ASCII code value. It uses the length of the passed- length character argument to control the iteration. The processor- defined function LEN determines the length of the argument.

          INTEGER FUNCTION ICMAX(CVAR)

          CHARACTER*(*) CVAR

          ICMAX = 1

          DO 10 I=2,LEN(CVAR)

    10    IF (CVAR(I:I) .GT. CVAR(ICMAX:ICMAX)) ICMAX=I

          RETURN

          END

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))

For More Information:

For details on the LEN function, see Section 6.3.2.1.

Previous Page Next Page Table of Contents