[solved] [Fortran] Problem reading formatted text file

  • Fortran
  • Thread starter Morridini
  • Start date
  • #1
4
1

Main Question or Discussion Point

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?

Cheers

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:
  • Like
Likes jim mcnamara

Answers and Replies

  • #2
jim mcnamara
Mentor
3,876
2,256
Thanks for noting the solution, it may help future searchers.
 

Related Threads on [solved] [Fortran] Problem reading formatted text file

Replies
12
Views
13K
Replies
1
Views
16K
Replies
11
Views
6K
Replies
5
Views
3K
Replies
1
Views
15K
Replies
9
Views
18K
Replies
6
Views
8K
Replies
5
Views
5K
Top