Recordtype='fixed'

I’m trying to run old code on the PGI Fortran compiler and it does not like the option recordtype in this statement:

open(12,file=‘blah.dat’,form=‘unformatted’, status=‘old’,recl=239, recordtype=‘fixed’, readonly)

I’m trying to read sequentially from a binary file. When I remove the recordtype=‘fixed’ option and try to specify the record length using recl=52 I get a runtime error from the read statement.

Does anyone know the equivalent syntax for recordtype=fixed in the PGFortran compiler?

We need to know about the system where the data file was written and any other available information about the OS, compiler used, etc.

Secondly, you mention two different record sizes, and that puzzles me. Where did you get information regarding the record size? What was the unit used in stating record size (remember, some old systems had no concept of “byte”) ?

I’m having the same problem. So, same question:
Does anyone know the equivalent syntax for recordtype=‘fixed’ in the PGFortran compiler.

I should have added that my dataset was written under Microsoft Visual Fortran (Visual F#)

Try:

open(unit=10,file='foo',recl=8,form='unformatted',access='direct')

and then read/write sequentially, i.e., without a rec= specifier

  • Mat

Thanks for the suggestion, but that did not work.

open(unit=47,file=‘foo’,form=‘unformatted’, status=‘old’, access=‘direct’, recl=5, readonly, iostat=ierr, err=99, iomsg=message)

read(47,iostat=jerr, err=99, iomsg=message2) k1, k2, k3, k4, k5

My open statement worked fine. But on the first read, I get an iostat error code = 219, iomessage = ‘attempt to read/write past end of record’

Here is what I suspect is happening. The open statement is defaulting to a variable length record. (The old equivalent of recordtype=‘variable’). As such, the read statement is expecting the first word in the record to be the record length. But since the file was created as a true fixed length record, no such information is obtained. (Or, more precisely, the read statement picks up an erroneous record length obtained from the first variable in the read.)

I must say, reading and writing fixed length records should be pretty standard stuff.

Any help will be appreciated.

I think I found it. Recl needs to be number of bytes, not number of long-words.

With this change, my code now seems to work.

Thanks to all who tried to help.