IS_IOSTAT_EOR(3) - [STATE:INQUIRY] Test for end-of-record value
result = is_iostat_eor(i)
elemental integer function is_iostat_eor(i)integer(kind=KIND),intent(in) :: i
o I is integer of any kind o the return value is a default logical
IS_IOSTAT_EOR(3) tests whether a variable has the value of the I/O status "end of record". The function is equivalent to comparing the variable with the IOSTAT_EOR parameter of the intrinsic module ISO_FORTRAN_ENV.
o I : The value to test as indicating "end of record".
Returns .true. if and only if I has the value which indicates an end-of-record condition for iostat= specifiers, and is .false. otherwise.
Sample program:
program demo_is_iostat_eor use iso_fortran_env, only : iostat_eor implicit none integer :: inums(5), lun, iosResults:! create a test file to read from open(newunit=lun, form=formatted,status=scratch,action=readwrite) write(lun, (a)) & 10 20 30, & 40 50 60 70, & 80 90, & 100, & 110 120 130, & 140 rewind(lun)
do read(lun, *, iostat=ios) inums write(*,*)iostat=,ios if(is_iostat_eor(ios)) then inums=-huge(0) print *, end of record elseif(is_iostat_end(ios)) then print *,end of file inums=-huge(0) exit elseif(ios.ne.0)then print *,I/O error,ios inums=-huge(0) exit else write(*,(*(g0,1x)))inums=,inums endif enddo
close(lun,iostat=ios,status=delete)
end program demo_is_iostat_eor
> iostat= 0 > inums= 10 20 30 40 50 > iostat= 0 > inums= 80 90 100 110 120 > iostat= -1 > end of fileNote: the list-directed read starts on a new line with each read, and that the read values should not portably be used if IOSTAT is not zero.
Format descriptors, Stream I/O and non-advancing I/O and reads into strings that can then be parsed or read multiple times give full control of what is read. List-directed I/O is generally more appropriate for interactive I/O.
Fortran 2003
Fortran intrinsic descriptions
o associated(3) - Association status of a pointer or pointer/target pair o extends_type_of(3) - Determine if the dynamic type of A is an extension of the dynamic type of MOLD. o is_iostat_end(3) - Test for end-of-file value o is_iostat_eor(3) - Test for end-of-record value o present(3) - Determine whether an optional dummy argument is specified o same_type_as(3) - Query dynamic types for equality
Nemo Release 3.1 | is_iostat_eor (3fortran) | February 19, 2025 |