Silverfrost Forums

Welcome to our forums

Continued: UNFORMATTED READ

8 Aug 2007 7:29 #2157

Dear Andrew,

thank you very much for your answer. I had found the SUBROUTINE READF@ in the documentation of FTN95 myself before, but in order to further process the data read by that routine, I think I have to struggle with things like sign bits, mantissa and exponent position and lengths, exponent biases, inter-record bits or bytes, and so on. I really hoped I could avoid this by some way or other.

I reall cannot quite imagine that this problem should not have been encountered (and probably solved) by hundreds or even thousands of Fortran enthusiasts who have changed from the IBM/Microsoft world to Silverfrost/Salford Fortran.

With thanks in advance for any help,

Yours sincerely,

Wolfgang Höppner.

9 Aug 2007 12:54 #2159

Wolfgang,

If I assume you are reading old binary files, from another computer and compiler, then you have the problem of understanding both the unformatted file structure ( bytes in header of the record ) and also the structure of the variables ( big and little indians !!! )

If you have access to the original program on the old computer, then by far the best would be to create a more system independent file structure. I would try to create a formatted file and read the text. There are all the problems of precision of the text format and others, but by far the biggest advantage is you can see the numbers in the dump file, using notepad or some other file viewer.

If you need to read these files as binary, then you need something like readf@ to read both the file structure ( 2 or 4 byte header, record and possibly trailer, if backspace is supported) and what the header means, as length can refer to characters, 2 byte integers or 4-byte reals. This is a common problem when mixing files from pre F77, F77 or F90+ compilers. There are a lot of variation on record header formats. There are also transparent or fixed length file formats in fortran that can be useful.

You also need to know the structure of the data in the record, with mixing of integers, reals and their precision. I assume this is the case, or it just gets too hard. If the file came from a pc, then probably the mixing of real number formats between compilers will not be a problem.

Solve the header problem and hope for the best !

regards john

Please login to reply.