- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Has anyone had any success, or experience using stream access? I am trying to read binary data in and out of matlab. I have relatively extensively unit tested my fortran data conversion program, and it appears to work, or at least be consistent in how it writes out and then reads stream data. I have tripple checked my code for errors too. However, when i try to read the data with matlab I can read the three integers at the beginning of the file, followed by the 5 scalar double precision reals, and then all of the elements where dim=1 of a double precision 3-d array. Ass soon as the second and third indeces are incremented matlab reads all zeros. I have used the unix od program to check that indeed my fortran conversion program wrote a whole boatload of zeros where there is data. I suspect this might be a compiler bug, but it will take a while before I can produce some simple reproducer code. Has any one else had success or failure using stream access to read binary data in and out of matlab?
Thanks,
-Z
Thanks,
-Z
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Given the finding "..my fortran conversion program wrote a whole boatload of zeros where there is data", it is obvious that there is no point in bringing Matlab into the picture until one gets the Fortran program to write a correct file.
One possibility is that you declared multidimensional arrays that are larger than needed, and improperly wrote a subarray to the file. This is just speculation, however, and little progress is possible without your showing a small example.
One possibility is that you declared multidimensional arrays that are larger than needed, and improperly wrote a subarray to the file. This is just speculation, however, and little progress is possible without your showing a small example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What version of the compiler are you using? I seem to remember a bug with binary files some time in the past. I can check but would need to know your compiler version.
ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11.1.046 on x86_64 RHEL and 32 bit Ubuntu.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've triple checked the code both visually, and it passes the tests I have created for it. I write the entire array which is an allocatable component of a derived type. The file is opened as unformatted with stream access then I just do something like:Given the finding "..my fortran conversion program wrote a whole boatload of zeros where there is data", it is obvious that there is no point in bringing Matlab into the picture until one gets the Fortran program to write a correct file.One possibility is that you declared multidimensional arrays that are larger than needed, and improperly wrote a subarray to the file. This is just speculation, however, and little progress is possible without your showing a small example.
[fortran]write(unit) object%array1 object%array2 ....[/fortran]I bring up Matlab because it would appear that Fortran is writing out the correct information, just in a non-transparent form, or incorrect order. Also if anyone else has had this problem, or has a work around or alternative suggestion for getting binary data in and out of Matlab I would greatly appreciate any advice or suggestions.

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