Reading Fortran Ascii output using python

Irmen de Jong irmen.NOSPAM at xs4all.nl
Mon Oct 31 14:24:10 EDT 2016


On 31-10-2016 18:46, Heli wrote:

> Thanks Irmen, 
> 
> I tried with "rU" but that did not make a difference. The problem is a line that with one single write statement in my fortran code :
> 
> write(UNIT=9,FMT="(99g20.8)")  value
> 
> seems to be read in two python inputfile.readline(). 
> 
> Any ideas how I should be fixing this?
> 
> Thanks, 
> 

We don't speak Fortran here (at least I don't).
Please show your Python code. What is 'inputfile'?
Also, in Python, the readline method is defined as:

>>> help(io.TextIOBase.readline)
Help on method_descriptor:

readline(...)
    Read until newline or EOF.

    Returns an empty string if EOF is hit immediately.

So there must be something in that line in your file that it considers an EOF.
Have you tried opening it in a regular text editor and inspecting what the characters
are on that particular line?


Irmen




More information about the Python-list mailing list