- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone !
In the process of writing a code, i have a subroutine that reads a binary data file. the snippet of the code is...
---------
open(unit=11,file=fname,status="old",form='binary',iostat=nerr,access="direct",recl=1)
do 5 i=1,i_tn
read(11,rec=i,iostat=nerr) tmpchar
if(nerr .gt. 0) then
write(*,*) 'End of file reached'
write(*,*) 'total elements read -->',icount
goto 100
elseif(nerr .lt. 0) then
write(*,*) 'unusual bad read'
write(*,*) 'total elements read -->',icount
goto 100
elseif(nerr .eq. 0) then
icount=icount+1;
itissueid=ichar(tmpchar)+1;
endif
5 end do
100 close(unit=11)
-----------------------------------
This snippets works great on the win32 platform, however, the moment I transferred the code and the data file to the Linux platform, it went bonkers. It reaches the end of the file immediately and in short...had me screwed !
Help ! ! !
-A
In the process of writing a code, i have a subroutine that reads a binary data file. the snippet of the code is...
---------
open(unit=11,file=fname,status="old",form='binary',iostat=nerr,access="direct",recl=1)
do 5 i=1,i_tn
read(11,rec=i,iostat=nerr) tmpchar
if(nerr .gt. 0) then
write(*,*) 'End of file reached'
write(*,*) 'total elements read -->',icount
goto 100
elseif(nerr .lt. 0) then
write(*,*) 'unusual bad read'
write(*,*) 'total elements read -->',icount
goto 100
elseif(nerr .eq. 0) then
icount=icount+1;
itissueid=ichar(tmpchar)+1;
endif
5 end do
100 close(unit=11)
-----------------------------------
This snippets works great on the win32 platform, however, the moment I transferred the code and the data file to the Linux platform, it went bonkers. It reaches the end of the file immediately and in short...had me screwed !
Help ! ! !
-A
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know of any difference between the platforms for code such as this. You should do a binary dump of the file (od) to make sure it got transferred the way you wanted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there...thanks for the response. I did think that may be a point to consider and did look at the data file. It's identical.
Just to give some more info.
The raw data file (binary contains) N 1 byte values. They can be read as characters and then converted.
There doesn't seem to be any header info/record indicating that the data was not written by FORTRAN (in all probability).
Will await some more input...
Cheers
Just to give some more info.
The raw data file (binary contains) N 1 byte values. They can be read as characters and then converted.
There doesn't seem to be any header info/record indicating that the data was not written by FORTRAN (in all probability).
Will await some more input...
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try adding STATUS="OLD" to the OPEN. I'm guessing that will give you a clue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would add some debugging code to see if it reads any bytes at all. Also make sure that the filename being specified is correct, noting that Linux is case-sensitive, and that there isn't an empty file of the exact name being referenced (which could happen if you had run the program without status='old' at one time.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello again...
Sorry for the delayed response (i was busy slapping myself silly) as the problem was that for some wierd reason, the filename as being passed to the subroutine was being duplicated in the character string.
Works great now !
Cheers..
Sorry for the delayed response (i was busy slapping myself silly) as the problem was that for some wierd reason, the filename as being passed to the subroutine was being duplicated in the character string.
Works great now !
Cheers..
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