Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

IOSTAT=67

sgibby
Beginner
921 Views
I am getting IOSTAT=67 reading an unformattted sequential binary file whose records contain character strings of varying lenghth. For example, the first 2 records may be 80 characters long, but the 3rd record is only 15 characters long. And I don't know what's coming. I want to read the record into a character string line*200, but I get IOSTAT=67. If I make line*60, it reads the 1st 2 records, but IOSTAT=67 on the third.

I tried PAD='YES', but incompatible with FORM='UNFORMATTTED' on the OPEN statement.

How can I read character strings of varying, unknown lenghth from unformatted binary file?

Thanks,
Shawn

Example coding:
Character*200
OPEN(NL,FILE=FILL,STATUS='OLD',FORM='UNFORMATTED', IOSTAT=IOS,ERR=908, CONVERT='BIG_ENDIAN')
READ(NL,IOSTAT=IOS,ERR=909,END=210) LINE

If the record contains a string less than 200, I get IOSTAT=67. This does not happen (i.e., the code works) on my IBM RS/6000.
0 Kudos
2 Replies
sgibby
Beginner
921 Views
For now, I have removed the ERR= branch and added an IF statement below the read to allow IOSTAT=67.

original coding
READ(NL,IOSTAT=IOS,ERR=909,END=210) LINE

new coding
READ(NL,IOSTAT=IOS,END=210) LINE !NO ERR=909
If (IOS .NE. 0 .AND. IOS .NE. 67) GOTO 909

Perhaps it's just the convention the VSF compiler uses; but it ought to allow one character string to be read like the XLF compiler on RS/6000. Any other thoughts or help would be appreciated.

Shawn
0 Kudos
james1
Beginner
921 Views
I don't believe that there is a standard for how compilers are supposed to handle an unformatted variable length file. Try changing this formatted file (format (a)) and see what you get.

James
0 Kudos
Reply