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

Creating 2-d array from a text file in fortran

  1. Jun 21, 2012 #1
    I have a text file of the format

    x1 y1
    x2 y2
    . .
    . .
    . .

    I need to read this into an array. How is this done in Fortran?
  2. jcsd
  3. Jun 21, 2012 #2
    you start by declaring a couple of array variables long enough to accommodate your values.
    then, you open the file
    write a do-loop
    read values into array with the loop variable as the index

    If I tell you more, I will be writing more than what it takes to simply write the code and give it to you.

    with those hints, go ahead and take a shot at it, don't be shy, write some code and see what happens....you are not going to break anything nor set the room on fire or anything...that's what so wonderful about software!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook