Fortran [solved] [Fortran] Problem reading formatted text file

  • Thread starter Morridini
  • Start date
Hi all, I have a problem I'm trying to solve.

I have a code that has written a simple ascii text file like this:
write(ilun_out, '(E23.15,A,E23.15,A,E23.15,A,E23.15)' x, ' ', y, ' ', z, ' ', rho

So this provides a nice looking ascii file with four columns, separated by a small space. Now I want to read this data into another code... and nothing works. No matter how much I try to tweak the formatting, reading in the spaces into "dummy" objects etc, I get the same problem.

The problem is that the fourth column, rho, is never read. Upon checking what I had read in I see that instead of getting the FIRST value of column FOUR, rho instead has the value of the SECOND value of column THREE.

Anyone know what's going on here?


UPDATE: Ok I have no idea WHAT was going on, it might have been some problems with libraries or the compiler acting up, but after a computer reboot my original try actually worked... so there wasn't anything wrong in the code itself. Oh well.

In case anyone ever has a similar problem, the solution is the rather simple way of doing this:
open(unit=ilun_ascii,file=fileloc_ascii,form='formatted', status='old')
read(ilun_ascii,*) x, y, z, rho
Last edited:

jim mcnamara

Thanks for noting the solution, it may help future searchers.

Want to reply to this thread?

"[solved] [Fortran] Problem reading formatted text file" You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving