Intel equivelent of CVF EOF function

Intel equivelent of CVF EOF function

I'm trying to convert to Intel 7.0 from CVF and noticed that Intel doesn't seem to have a function similar to CVF's EOF function. The code is looping through a number of files and checks for empty files using the following lines:

REWIND (UNIT = UNITNO (INDEX))
ENDFIL = EOF (UNITNO (INDEX))

Does Intel 7.0 have a similar function that I just haven't found, or am I going to have to try and read from each file to determine if it is empty?

Thanks
Tim Coletta

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Intel Fortran doesn't have EOF yet. You'll have to do the test READ yourself. (This would also be more portable.)

Steve

Retired 12/31/2016

So try to spot all EOF() clauses in the CVF environments and convert to test iostat.

An alternative might be to emulate this function using something like:

logical function eof(unit)
    integer :: unit

    character(len=1) :: onechar
    integer :: ierr

    read( lun, iostat = ierr, '(a)' ) onechar
    eof = ierr /= 0
end function

If there are unformatted files, you will need to extend this. And you may want to distinguish between an error and a "true" end-of-file.

Change Line-8 of the code in #4 to eof = ierr /= -1 to exclude EOR and other conditions, and note that the specific value dedicated to signify EOF is compiler-dependent, but you can USE ISO_FORTRAN_ENV and use the named constant IOSTAT_END instead. 

Leave a Comment

Please sign in to add a comment. Not a member? Join today