[Tutor] reading Fortran unformatted files with Python

Gabriele Brambilla gb.gabrielebrambilla at gmail.com
Mon Jul 13 17:14:36 CEST 2015


Hi,

I have problems reading unformatted fortran output (binary) with python.

I have a code in fortran where I write data on a file inside a cycle:

write(11) x,y,z,BA01(i,j,k,1),BA01(i,j,k,2),1
BB01(i,j,k,1),BB01(i,j,k,2),2           BE01(i,j,k,1),3
EC01(i,j,k,1),EC01(i,j,k,2),4           ED01(i,j,k,1),ED01(i,j,k,2),5
         EF01(i,j,k,1),6           rGH01(i,j,k,1),rGH01(i,j,k,2),7
      rGI01(i,j,k,1),rGI01(i,j,k,2),8           rGJ01(i,j,k,1),1
    rGL(i,j,k,2),rGM(i,j,k,2),rGN(i,j,k,2)

How can I read this 21 real line by line in Python? How can I decode this
unit specifier 11? All the numbers are defined as REAL.

thanks

Gabriele


More information about the Tutor mailing list