Effacer les filtres
Effacer les filtres

How can I read Fortran90 binary files in MATLAB?

2 vues (au cours des 30 derniers jours)
dawaske
dawaske le 12 Août 2016
Modifié(e) : Qu Cao le 24 Août 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!

Réponses (1)

Qu Cao
Qu Cao le 24 Août 2016
Modifié(e) : Qu Cao le 24 Août 2016
You can try using 'fread' to read Fortran binary files into MATLAB. The following link should be useful for you:

Catégories

En savoir plus sur Fortran with MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by