IS_IOSTAT_END(3) - [STATE:INQUIRY] Test for end-of-file value
result = is_iostat_end(i)
elemental logical function is_iostat_end(i)integer,intent(in) :: i
o I is integer of any kind o the return value is a default logical
IS_IOSTAT_END(3) tests whether a variable (assumed returned as a status from an I/O statement) has the "end of file" I/O status value.
The function is equivalent to comparing the variable with the IOSTAT_END parameter of the intrinsic module ISO_FORTRAN_ENV.
o I : An integer status value to test if indicating end of file.
returns .true. if and only ifI has the value which indicates an end of file condition for IOSTAT= specifiers, and is .false. otherwise.
Sample program:
program demo_iostat implicit none integer,parameter :: wp=kind(0.0d0) real(kind=wp) :: value integer :: ios integer :: lun character(len=256) :: message ! make a scratch input file for demonstration purposes call makefile(lun) write(*,*)Begin entering numeric values, one per line do read(lun,*,iostat=ios,iomsg=message)value if(ios.eq.0)then write(*,*)VALUE=,value elseif( is_iostat_end(ios) ) then stop end of file. Goodbye! else write(*,*)ERROR:,ios,trim(message) exit endif ! enddo contains subroutine makefile(lun) ! make a scratch file just for demonstration purposes integer :: iostat,lun integer :: i character(len=80),parameter :: fakefile(*)=[character(len=80) :: &Results:3.141592653589793238462643383279502884197169399375105820974944592307 & &/ pi, &
0.577215664901532860606512090082402431042 & &/ The Euler-Mascheroni constant (Gamma), &
2.71828182845904523536028747135266249775724709369995 & &/ Napiers constant "e"& & is the base of the natural logarithm system,& & named in honor of Euler , &
1.6180339887498948482045868 & &/ Golden_Ratio, &
1 / unity]
open(newunit=lun,status=scratch) write(lun,(a))(trim(fakefile(i)),i=1,size(fakefile)) rewind(lun) end subroutine makefile end program demo_iostat
STOP end of file. Goodbye! > Begin entering numeric values, one per line > VALUE= 3.1415926535897931 > VALUE= 0.57721566490153287 > VALUE= 2.7182818284590451 > VALUE= 1.6180339887498949 > VALUE= 1.0000000000000000
Fortran 2003
Fortran intrinsic descriptions (license: MIT) @urbanjost
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_end (3fortran) | November 02, 2024 |