How can I read Fortran90 binary files in MATLAB?

3 views (last 30 days)
dawaske
dawaske on 12 Aug 2016
Edited: Qu Cao on 24 Aug 2016
Hey guys!
I have a Fortan90 based simulation (compiled with the Linux PGI compiler in case this is important) that stores its results in 2D matrices, which are then exported as binary files. In order to comfortably plot the output from the simulations I need to read those binary files into MATLAB, which is just not happening despite searching Google for several hours and trying all kinds of things :( This is the Fortran code responsible for saving the matrices:
subroutine save_data (x,y,z)
integer, intent(in):: x,y,z
integer::i
real, dimension(x,y):: temp
character(20):: filename = ''
do i=1, z
write(filename,'(a,i3.3,a)') 'output_matrix',i,'.dat'
temp=output(1:x,1:y,i)
open(unit=13, file=filename, action="write", status="replace", form="unformatted")
write(13) temp
close(unit=13)
end do
end subroutine save_data
with x=16, y=26 and z=31 for example. Is it even possible to read those output_matrix.dat-files into MATLAB or do I need to store them differently?
I hope you can help me!

Answers (1)

Qu Cao
Qu Cao on 24 Aug 2016
Edited: Qu Cao on 24 Aug 2016
You can try using 'fread' to read Fortran binary files into MATLAB. The following link should be useful for you:

Categories

Find more on Fortran with MATLAB in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!