Filter löschen
Filter löschen

How can I read Fortran90 binary files in MATLAB?

2 Ansichten (letzte 30 Tage)
dawaske
dawaske am 12 Aug. 2016
Bearbeitet: Qu Cao am 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!

Antworten (1)

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

Kategorien

Mehr zu Fortran with MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by