Hi,
I have encountered the exact same behavior.
W11, gcc 15.2 with mingw64 13.0.0
Reading and closing a formatted file is fine
Reading and closing an unformatted file is fine
After an unformatted file has been read (even for only one value) though, fractional parts of any future formatted reads are being dropped (eg : ‘31649.08’ will be read as ‘31649.00’)
(If the unformatted file is only opened, but immediately closed without reading any value, then the problem does not appear)
Adding DECIMAL=’POINT’ to the formatted OPEN statement and/or the READ statement does not solve the issue.
Specifying the format (eg (F15.8)) in the READ statement does not solve the issue.
If the content of the formatted file is written in exponential form, then there is no issue.
Additionally, the issue only manifests itself when executing directly on Windows. If the exact same executable is launched by gdb (on Windows), then the issue is not present.
Here is a minimum example to reproduce ![]()
subroutine readtxt
t=0.0
open(newunit=kf,file=“toto.txt”,form=‘FORMATTED’,
& status=‘OLD’,action=‘READ’,iostat=IPB)
print*,‘IPB=’,IPB
if (IPB==0) then
read(kf,*) t
print*,‘t=’,t
endif
close(kf)
return
endsubroutine readbin
OPEN(newunit=io,FILE=“toto.bin”,ACCESS=‘STREAM’,
& FORM=‘UNFORMATTED’,STATUS=‘OLD’,IOSTAT=IPB)
read(io) x
close(io)
return
endprogram toto
call readtxt
call readtxt
call readbin
call readtxt
call readtxt
return
end
With toto.txt being a simple one line ASCII file with eg 123.456 written in it, and toto.bin any non-empty binary file.
The end result produces the following output on Windows :
PS D:\Work\toto> .\a.exe
IPB= 0
t= 123.456001
IPB= 0
t= 123.456001
IPB= 0
t= 123.000000
IPB= 0
t= 123.000000