Dear all,
I hope someone can shed some light on this issue I am having with unformatted binary files.
I want (for various reasons) to write a binary file with C# that can be read using Fortran as if it were an ordinary Fortran unformatted file.
I was expecting the Fortran standard to specify what the output structure is of an unformatted binary file, but I have not been able to find that. Other web pages have stated that a record in an unformatted file is surrounded by a 4byte header and footer which indicate the number of bytes in the record.
However, I have found that when using some test programs with Salford FTN95, I get only a 1 byte header and footer.
Essentially, my problem is this: using this code
program bintest
implicit none
!test the writing of binary data to a Fortran unformatted file
open(10,file='ftnbintest.out',form='unformatted')
write(10) 1
write(10) 16
write(10) 32
write(10) 10281
write(10) 305419896
close(10)
end program bintest
gives different results when compiling with FTN95 and when compiling with GNU fortran. I get a 1 byte header and footer with FTN95 and a 4 byte header and footer with GNU.
Can someone explain? What should be in the output? Can someone point me to some document where the Fortran binary file structure is defined?
Thanks,
Mark.