length
- Date:
10-12-2011
NAME
LENGTH - Returns the number of words transferred
SYNOPSIS
LENGTH ([I=]i)
IMPLEMENTATION
Cray Linux Environment (CLE)
STANDARDS
Fortran extension
DESCRIPTION
LENGTH returns the length (in words) of a BUFFER IN or BUFFER OUT statement transfer.
LENGTH is an elemental function. The name of this intrinsic cannot be passed as an argument.
RETURN VALUES
The value returned is of type default integer.
If the LENGTH function is called during the execution of asynchronous I/O with BUFFER IN or BUFFER OUT, the execution sequence is delayed until the transfer is complete. LENGTH then returns the number of words successfully transferred.
Programs that transfer characters or data from a medium that supports partial-word I/O cannot detect partial-word transfers. The return value is rounded up to a word count in these cases.
The return value is 0 under the following two conditions:
An end-of-file or error occurs
It is following a read or write of a zero-length record.
The unit(3i) function should be used prior to LENGTH to properly distinguish these previous two cases.
EXAMPLES
PROGRAM PGM
DIMENSION V(16384)
10 BUFFER IN (32,-1) (V(1),V(16384))
X= UNIT(32)
K= LENGTH(32)
IF (X .GE. 0.0) GOTO 14
11 DO 12 I=1,K,1
12 IF (V(I) .EQ. 'KEY') GOTO 13
IF (X .EQ. -1.0) GOTO 10
STOP
13 ...
...
14 CONTINUE
END
SEE ALSO
unit(3i)