Hi, sorry for the confusion I understood that the Real(8) I'm using correspond to dtype float64 in Python. With the second method it seems to work but I get a wrong number of elements.
They should be grouped by 21 float64 but I don't find a number of data = 21*m where m is an integer number. I think the problem is that Fortran write 4bytes at the beginning and at the end of each file. I found a way to remove the first 4 bytes but not the last. Do you have any suggestion? Thanks On Mon, Jul 13, 2015 at 2:08 PM, Gabriele Brambilla < gb.gabrielebrambi...@gmail.com> wrote: > The second method seem to work. > But how can I know which dtype in Python corresponds to REAL in fortran? > > Thanks > > > > On Mon, Jul 13, 2015 at 11:29 AM, Laura Creighton <l...@openend.se> wrote: > >> In a message of Mon, 13 Jul 2015 11:14:36 -0400, Gabriele Brambilla >> writes: >> >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 >> >_______________________________________________ >> >Tutor maillist - Tutor@python.org >> >To unsubscribe or change subscription options: >> >https://mail.python.org/mailman/listinfo/tutor >> >> You want to use this package: >> https://pypi.python.org/pypi/fortranfile >> >> You need to also load numpy for this to work. >> >> Some people cannot get this to work, and like this way of doing >> things better: >> >> https://physics.ucf.edu/~dle/blog.php?id=1 >> >> Again, needs numpy. Write back if you need a numpy-free solution (i.e. >> you are on Jython). >> >> Laura >> > > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor