Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

[solved] [Fortran] Problem reading formatted text file

  1. Oct 9, 2013 #1
    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: Oct 9, 2013
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: [solved] [Fortran] Problem reading formatted text file
Loading...