You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
program test_convert
implicit noneinteger, parameter:: n =4integer, parameter:: fid =20real:: arr(n)
real:: buf(n)
integer:: i
arr = (/1.0, 2.0, 3.0, 4.0/)
open(fid, file="test.txt", form='UNFORMATTED', status='new')
write(fid) arr
close(fid)
open(fid, file="test.txt", form='UNFORMATTED', status='old')
read(fid) buf
close(fid)
end program
When building with flang and running with the command FORT_CONVERT='SWAP' ./a.out, I see the following error:
fatal Fortran runtime error(./test.f90:15): Unformatted variable-length sequential file input failed at record #1 (file offset 0): hit EOF reading record with length 268435456 bytesAborted
When building with gfortran and running with the command GFORTRAN_CONVERT_UNIT='SWAP' ./a.out, the program executes as expected.
I think the fix is to make sure that the header and footer lengths here (and potentially other places) are also byte-swapped as appropriate, but I need to investigate further (and assuming I'm not doing something incorrect in the Fortran source).