unit(3I)

UNIT - Returns the status of a BUFFER IN or BUFFER OUT statement

As shipped in IRIX 6.5.22. Last changed in IRIX 6.5.19.

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.

     The BUFFER IN and BUFFER OUT statements are used for synchronous I/O.
     Asynchronous I/O is not available through BUFFER I/O.

RETURN VALUES
     When the transfer is complete, UNIT returns a value of type real.  The
     value is of type REAL(KIND=4) on IRIX systems.  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 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)