9.3.43 EOF (A)

Description:  Checks whether a file is at or beyond the end-of-file record.[1] 
Class:  Inquiry function 
Arguments:  A must be of type integer. It represents a unit specifier corresponding to an open file. It cannot be zero unless you have reconnected unit zero to a unit other than the screen or keyboard. 
Results:  The value of the result is .TRUE. if the file connected to A is at or beyond the end-of-file record; otherwise, .FALSE.. 

[1] This specific function cannot be passed as an actual argument.

Examples

Consider the following:

!  Creates a file of random numbers, reads them back
      REAL  x, total
      INTEGER  count
      OPEN (1, FILE = 'TEST.DAT')
      DO I = 1, 20
         CALL RANDOM(x)
         WRITE (1, *) x * 100.0
      END DO
      CLOSE(1)
      total = 0
      count = 0
      OPEN (1, FILE = 'TEST.DAT')
      DO WHILE (.NOT. EOF(1))
         count = count + 1
         READ (1, *) value
         total = total + value
      END DO
      IF ( count .GT. 0) THEN
        WRITE (*,*) 'Average is: ', total / count
      ELSE
        WRITE (*,*) 'Input file is empty '
      END IF
      END


Previous Page Next Page Table of Contents