unit
- Date:
06-19-2023
NAME
UNIT - Returns the status of a BUFFER IN or BUFFER OUT statement
SYNOPSIS
UNIT ([I=]i)
STANDARDS
Fortran extension
DESCRIPTION
After execution of asynchronous I/O with a BUFFER IN or BUFFER OUT statement, the execution sequence continues concurrently with the data transfer. If UNIT is called in this execution sequence, the sequence is delayed until the transfer is complete. After the BUFFER IN operation, use UNIT or length(3i) before using memory locations where the data is stored. UNIT accepts the following argument:
- i
Must be an integer or Boolean value. Represents a unit number.
UNIT is an elemental function. The name of this intrinsic cannot be passed as an argument.
RETURN VALUES
When the transfer is complete, UNIT returns a value of type real. The returned value has one of the following meanings:
- Value
Meaning
- -2.0
A partial-record read terminated after delivering the requested number of words or characters, but more data remains in the record. This status can be received only after a BUFFER IN in partial-record mode.
- -1.0
Operation was completed (indicates one of the following):
A full- or partial-record BUFFER OUT operation completed.
A full-record BUFFER IN completed, transferring as much of the record as would fit in the space provided.
A partial-record BUFFER IN completed, transferring as much data as was left in the record (no more data remains in the record).
UNIT was called for an unconnected unit or for a unit on which no BUFFER IN or BUFFER OUT operations have been performed.
- 0.0
An end-of-file was encountered on the previous BUFFER IN operation. No data was transferred.
- 1.0
A partially recovered error occurred on the previous BUFFER IN operation. Use the length(3i) function to determine how much data was transferred.
- 2.0
An unrecovered error occurred on the last BUFFER IN or BUFFER OUT operation.
EXAMPLES
PROGRAM TESTUNIT
DIMENSION M(200,5)
BUFFER IN(32,0) (M(1,1),M(200,5))
IF (UNIT(32) .EQ. -1.0) THEN
DO J = 1,5
DO I = 1,200
M(I,J) = M(I,J)*2
END DO
END DO
BUFFER OUT (22,0) (M(1,1),M(200,5))
IF (UNIT(22) .NE. -1.0) CALL ABORT
ELSE
CALL ABORT
ENDIF
END
SEE ALSO
length(3i)