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

Reading formatted input in fortran

  1. Jul 15, 2009 #1
    format statement to read input in fortran

    hello everyone,
    I've to read this following line in fortran,
    I dont know to read the exponential form
    please help me

    3.49E+03 2.73E+01 2.01E-01 9.16E-02 5.94E-02 5.11E-02 3.27E+04 3.27E+04

    can somebody help me to write the format statement to read the whole line
    or can please tell me how should I read the exponential data eg 3.49E+01 and 9.44E-09

    thank you,
    Last edited: Jul 16, 2009
  2. jcsd
  3. Dec 25, 2010 #2
    Taken from this site: http://elsa.berkeley.edu/sst/fmttop.html

    Try also this site, for more details: http://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/chap05/format.html
  4. Dec 26, 2010 #3


    User Avatar

    Staff: Mentor

    If the data is separated by spaces as you have here, you can use the default format (*):

    Code (Text):

          real a, b, c, d, e, f, g, h
          open (unit=10, file='agalya.txt')
          read (10, *) a, b, c, d, e, f, g, h
          write (*, *) a, b, c, d, e, f, g, h
    This "write" statement doesn't give you the numbers in the same format in which you read them; it uses its own default format. You can of course specify your own output format as needed.
    Last edited: Dec 26, 2010
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?