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

stream access problems

Izaak_Beekman
New Contributor II
561 Views
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
0 Kudos
4 Replies
mecej4
Honored Contributor III
561 Views
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.

0 Kudos
Ron_Green
Moderator
561 Views

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

0 Kudos
Izaak_Beekman
New Contributor II
561 Views
11.1.046 on x86_64 RHEL and 32 bit Ubuntu.
0 Kudos
Izaak_Beekman
New Contributor II
561 Views
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.
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:
[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.
0 Kudos
Reply