- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
James

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page