Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

Intel equivelent of CVF EOF function

tim_coletta
Beginner
911 Views
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
0 Kudos
4 Replies
Steven_L_Intel1
Employee
911 Views
Intel Fortran doesn't have EOF yet. You'll have to do the test READ yourself. (This would also be more portable.)

Steve
0 Kudos
Xj_Kong
Novice
911 Views

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

0 Kudos
Arjen_Markus
Honored Contributor II
911 Views

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.

0 Kudos
mecej4
Honored Contributor III
911 Views

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. 

0 Kudos
Reply