How can I read Fortran90 binary files in MATLAB?

2 次查看(过去 30 天)
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!

回答(1 个)

Qu Cao
Qu Cao 2016-8-24
编辑:Qu Cao 2016-8-24
You can try using 'fread' to read Fortran binary files into MATLAB. The following link should be useful for you:

类别

Help CenterFile Exchange 中查找有关 Fortran with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by