Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Integer edit descriptor with float list item

$
0
0

Dear Intel support team,

when I try to read an integer value with the I integer descriptor into a real variable, ifort returns an incorrect value and no error status. You will find below my ifort version and the demonstration program.

Quoting the Fortran standard 2008 (section 10.7.2.2): "Integer editing: Iw [...] The specified input/output list item shall be of type integer". Obviously, I violate this rule, so I would expect an error status. Or if you want to extend the standard, you could implicitly convert the integer value to the real variable. Anyway, my worry is that an incorrect value is returned with no detection possible.

May be I should add that in my real use case, the string to be read and the format used are NOT known at compilation time. Only the list items (type real) are known.

Sebastien

$ ifort --version
ifort (IFORT) 14.0.2 20140120
Copyright (C) 1985-2014 Intel Corporation. All rights reserved.

$ cat read_inte_into_real.f90
program test
implicit none
real(kind=8) :: work(2)
integer(kind=4) :: ier
character(len=32) :: string
!
string = "1 48216 0.10763 0.12938 0.05432 "
read(string,'(I1,1X,I5)',iostat=ier) work
if (ier.ne.0) then
print *,"Error"
else
print *,work
endif
end program test

$ ifort read_inte_into_real.f90 -o test && ./test
4.940656458412465E-324 2.382186917988154E-319


Viewing all articles
Browse latest Browse all 3270

Latest Images

Trending Articles

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>