I am using Fortran Compiler 17.0.2.187.
I think I have come across a bug in the compiler. The following test program writes out data to an unformatted file. It then reads it back in, and compares with the original data to make sure the IO was done correctly. If I use the default options, the test passes. However, if I enable buffering with /assume:buffered_io , the test fails.
Roman
module unformattedIO_mod integer,parameter,private:: mcell=150000 integer(kind=8),allocatable,private:: wtz(:), gdiag(:) integer(kind=8),allocatable,private:: wtz2(:), gdiag2(:) character(len=*),parameter:: testfilename='testIO.dat' contains !--------------------------------------------------------------------------------- subroutine writefile() implicit none integer i allocate(wtz(mcell), gdiag(mcell) ) do i = 1, mcell wtz(i) = i gdiag(i) = 100 * i end do open(unit=8, file=testfilename, form='unformatted', action='write') write(8) wtz write(8) gdiag close(8) return end subroutine writefile !---------------------------------------------------------------- subroutine readfile() implicit none allocate(wtz2(mcell), gdiag2(mcell) ) open(unit=9, file=testfilename, form='unformatted', action='read') read(9) wtz2 read(9) gdiag2 close(9) if ( all(gdiag == gdiag2) .and. all(wtz == wtz2) ) then write(*,*) 'Test passed.' else write(*,*) 'Test failed.' end if return end subroutine readfile end module unformattedIO_mod !============================================================= program testUnformattedIO use unformattedIO_mod, only: writefile, readfile implicit none call writefile() call readfile() stop end program testUnformattedIO